Merge branch 'master' of https://code.google.com/p/protobuf-dt/ into
option-ref
Conflicts:
com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/FLOATValueConverter_toValue_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/DOUBLEValueConverter_toValue_Test.java
similarity index 67%
rename from com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/FLOATValueConverter_toValue_Test.java
rename to com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/DOUBLEValueConverter_toValue_Test.java
index 03e58d8..6804161 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/FLOATValueConverter_toValue_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/DOUBLEValueConverter_toValue_Test.java
@@ -8,6 +8,7 @@
*/
package com.google.eclipse.protobuf.conversion;
+import static java.lang.Double.*;
import static java.util.Arrays.asList;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
@@ -24,45 +25,47 @@
import com.google.eclipse.protobuf.junit.core.XtextRule;
/**
- * Tests for <code>{@link FLOATValueConverter#toValue(String, INode)}</code>.
+ * Tests for <code>{@link DOUBLEValueConverter#toValue(String, INode)}</code>.
*
* @author alruiz@google.com (Alex Ruiz)
*/
@RunWith(Parameterized.class)
-public class FLOATValueConverter_toValue_Test {
+public class DOUBLEValueConverter_toValue_Test {
@Rule public XtextRule xtext = new XtextRule();
private final String input;
- private final Float expected;
+ private final Double expected;
@Parameters
public static Collection<Object[]> parameters() {
return asList(new Object[][] {
- { "52e3", 52e3F },
- { "52E3", 52e3F },
- { "6e-3", 0.006F },
- { "6.8", 6.8F },
- { "-3.1", -3.1F },
- { ".3", 0.3F }
+ { "52e3", 52e3D },
+ { "52E3", 52e3D },
+ { "6e-3", 0.006D },
+ { "6.8", 6.8D },
+ { "-3.1", -3.1D },
+ { ".3", 0.3D },
+ { "nan", NaN },
+ { "inf", POSITIVE_INFINITY }
});
}
- public FLOATValueConverter_toValue_Test(String input, Float expected) {
+ public DOUBLEValueConverter_toValue_Test(String input, Double expected) {
this.input = input;
this.expected = expected;
}
- private FLOATValueConverter converter;
+ private DOUBLEValueConverter converter;
private INode node;
@Before public void setUp() {
node = mock(INode.class);
- converter = xtext.injector().getInstance(FLOATValueConverter.class);
+ converter = xtext.injector().getInstance(DOUBLEValueConverter.class);
}
@Test public void should_parse_hexadecimal_number() {
- Float value = converter.toValue(input, node);
+ Double value = converter.toValue(input, node);
assertThat(value, equalTo(expected));
}
}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/FLOATValueConverter_toValue_withInvalidInput_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/FLOATValueConverter_toValue_withInvalidInput_Test.java
index a2957f4..7dc34e3 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/FLOATValueConverter_toValue_withInvalidInput_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/FLOATValueConverter_toValue_withInvalidInput_Test.java
@@ -22,7 +22,7 @@
import com.google.eclipse.protobuf.junit.core.XtextRule;
/**
- * Tests for <code>{@link FLOATValueConverter#toValue(String, INode)}</code>.
+ * Tests for <code>{@link DOUBLEValueConverter#toValue(String, INode)}</code>.
*
* @author alruiz@google.com (Alex Ruiz)
*/
@@ -31,12 +31,12 @@
@Rule public XtextRule xtext = new XtextRule();
@Rule public ExpectedException thrown = none();
- private FLOATValueConverter converter;
+ private DOUBLEValueConverter converter;
private INode node;
@Before public void setUp() {
node = mock(INode.class);
- converter = xtext.injector().getInstance(FLOATValueConverter.class);
+ converter = xtext.injector().getInstance(DOUBLEValueConverter.class);
}
@Test public void should_throw_error_if_input_is_null() {
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/Descriptor_fileOptions_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/Descriptor_availableOptionPropertiesFor_Test.java
similarity index 81%
rename from com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/Descriptor_fileOptions_Test.java
rename to com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/Descriptor_availableOptionPropertiesFor_Test.java
index 72b65ed..7ee78d2 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/Descriptor_fileOptions_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/Descriptor_availableOptionPropertiesFor_Test.java
@@ -11,32 +11,35 @@
import static com.google.eclipse.protobuf.junit.matchers.PropertyHasType.hasType;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
import java.util.*;
+import org.eclipse.emf.ecore.EObject;
import org.junit.*;
import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.Property;
+import com.google.eclipse.protobuf.protobuf.*;
/**
- * Tests for <code>{@link ProtoDescriptor#fileOptions()}</code>.
+ * Tests for <code>{@link ProtoDescriptor#availableOptionPropertiesFor(EObject)}</code>.
*
* @author alruiz@google.com (Alex Ruiz)
*/
@Ignore("This test requires to be executed as a 'JUnit plug-in test'. I haven't found a way to register PlatformURLHandler with the JVM")
-public class Descriptor_fileOptions_Test {
+public class Descriptor_availableOptionPropertiesFor_Test {
@Rule public XtextRule xtext = new XtextRule();
private ProtoDescriptor descriptor;
-
+
@Before public void setUp() {
descriptor = xtext.getInstanceOf(ProtoDescriptorProvider.class).get();
}
@Test public void should_return_all_file_options() {
- Map<String, Property> fileOptions = mapByName(descriptor.fileOptions());
+ Protobuf optionContainer = mock(Protobuf.class);
+ Map<String, Property> fileOptions = mapByName(descriptor.availableOptionPropertiesFor(optionContainer));
assertThat(fileOptions.get("java_package"), hasType("string"));
assertThat(fileOptions.get("java_outer_classname"), hasType("string"));
assertThat(fileOptions.get("java_multiple_files"), hasType("bool"));
diff --git a/com.google.eclipse.protobuf.ui/META-INF/MANIFEST.MF b/com.google.eclipse.protobuf.ui/META-INF/MANIFEST.MF
index fd2b236..da7e2d6 100644
--- a/com.google.eclipse.protobuf.ui/META-INF/MANIFEST.MF
+++ b/com.google.eclipse.protobuf.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 1.0.8.qualifier
+Bundle-Version: 1.0.9.qualifier
Bundle-SymbolicName: com.google.eclipse.protobuf.ui; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: com.google.eclipse.protobuf;visibility:=reexport,
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/quickfix/Messages.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/quickfix/Messages.java
new file mode 100644
index 0000000..03ea039
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/quickfix/Messages.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.quickfix;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class Messages extends NLS {
+
+ public static String changeToProto2;
+ public static String changeToProto2Label;
+
+ static {
+ Class<Messages> targetType = Messages.class;
+ NLS.initializeMessages(targetType.getName(), targetType);
+ }
+
+ private Messages() {}
+}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/quickfix/Messages.properties b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/quickfix/Messages.properties
new file mode 100644
index 0000000..54e5126
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/quickfix/Messages.properties
@@ -0,0 +1,2 @@
+changeToProto2=Change syntax to "proto2".
+changeToProto2Label=Change syntax to "proto2"
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/quickfix/ProtobufQuickAssistProcessor.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/quickfix/ProtobufQuickAssistProcessor.java
index 15aa610..a5dc287 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/quickfix/ProtobufQuickAssistProcessor.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/quickfix/ProtobufQuickAssistProcessor.java
@@ -10,6 +10,7 @@
package com.google.eclipse.protobuf.ui.quickfix;
import static java.util.Arrays.asList;
+import static java.util.Collections.emptyList;
import com.google.inject.Inject;
@@ -27,10 +28,21 @@
@Inject private SpellingCorrectionProcessor spellingCorrectionProcessor;
- @Override public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
+ @Override public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext context) {
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
- proposals.addAll(asList(spellingCorrectionProcessor.computeQuickAssistProposals(invocationContext)));
- proposals.addAll(asList(super.computeQuickAssistProposals(invocationContext)));
+ proposals.addAll(spellingFixes(context));
+ proposals.addAll(asList(super.computeQuickAssistProposals(context)));
return proposals.toArray(new ICompletionProposal[proposals.size()]);
}
+
+ private List<ICompletionProposal> spellingFixes(IQuickAssistInvocationContext context) {
+ ICompletionProposal[] spellingFixes = spellingCorrectionProcessor.computeQuickAssistProposals(context);
+ if (spellingFixes.length == 0) return emptyList();
+ if (spellingFixes.length == 1 && isNoCompletionsProposal(spellingFixes[0])) return emptyList();
+ return asList(spellingFixes);
+ }
+
+ private boolean isNoCompletionsProposal(ICompletionProposal p) {
+ return p.getClass().getSimpleName().equals("NoCompletionsProposal");
+ }
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/quickfix/ProtobufQuickfixProvider.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/quickfix/ProtobufQuickfixProvider.java
index 59fc306..04f7973 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/quickfix/ProtobufQuickfixProvider.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/quickfix/ProtobufQuickfixProvider.java
@@ -1,29 +1,42 @@
/*
* Copyright (c) 2011 Google Inc.
- *
- * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
- * Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.ui.quickfix;
-import org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider;
+import static com.google.eclipse.protobuf.ui.quickfix.Messages.*;
+import static com.google.eclipse.protobuf.validation.ProtobufJavaValidator.SYNTAX_IS_NOT_PROTO2_ERROR_CODE;
+
+import com.google.eclipse.protobuf.protobuf.Syntax;
+import com.google.eclipse.protobuf.ui.labeling.Images;
+import com.google.inject.Inject;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.ui.editor.model.edit.*;
+import org.eclipse.xtext.ui.editor.quickfix.*;
+import org.eclipse.xtext.validation.Issue;
/**
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufQuickfixProvider extends DefaultQuickfixProvider {
-// @Fix(MyJavaValidator.INVALID_NAME)
-// public void capitalizeName(final Issue issue, IssueResolutionAcceptor acceptor) {
-// acceptor.accept(issue, "Capitalize name", "Capitalize the name.", "upcase.png", new IModification() {
-// public void apply(IModificationContext context) throws BadLocationException {
-// IXtextDocument xtextDocument = context.getXtextDocument();
-// String firstLetter = xtextDocument.get(issue.getOffset(), 1);
-// xtextDocument.replace(issue.getOffset(), 1, firstLetter.toUpperCase());
-// }
-// });
-// }
-
+ @Inject private Images images;
+
+ @Fix(SYNTAX_IS_NOT_PROTO2_ERROR_CODE)
+ public void makeSyntaxProto2(final Issue issue, IssueResolutionAcceptor acceptor) {
+ String image = images.imageFor(Syntax.class);
+ acceptor.accept(issue, changeToProto2Label, changeToProto2, image, new ISemanticModification() {
+ public void apply(EObject element, IModificationContext context) throws Exception {
+ if (!(element instanceof Syntax)) return;
+ Syntax syntax = (Syntax) element;
+ syntax.setName("proto2");
+ }
+ });
+ }
}
diff --git a/com.google.eclipse.protobuf/META-INF/MANIFEST.MF b/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
index 06792c5..21189b7 100644
--- a/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
+++ b/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Eclipse-ExtensibleAPI: true
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 1.0.8.qualifier
+Bundle-Version: 1.0.9.qualifier
Bundle-SymbolicName: com.google.eclipse.protobuf; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.xtext,
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/Protobuf.xtext b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/Protobuf.xtext
index 84ba83c..6c6c4d3 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/Protobuf.xtext
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/Protobuf.xtext
@@ -106,7 +106,7 @@
name=Name ':' value=SimpleRef;
SimpleRef:
- LiteralRef | BooleanRef | NumberRef | StringRef | Nan;
+ LiteralRef | BooleanRef | NumberRef | StringRef;
LiteralRef:
literal=[Literal];
@@ -119,7 +119,7 @@
| false;
NumberRef:
- HexRef | LongRef | FloatRef;
+ HexRef | LongRef | DoubleRef;
HexRef:
hex=HEX;
@@ -130,11 +130,11 @@
terminal LONG returns ecore::ELong:
('-')? (NUMBER)+;
-FloatRef:
- float=FLOAT;
+DoubleRef:
+ double=DOUBLE;
-terminal FLOAT returns ecore::EFloat:
- ('-')? (NUMBER)* ('.' (NUMBER)+)? (('e'|'E')('-')? (NUMBER)+)?;
+terminal DOUBLE returns ecore::EDouble:
+ (('-')? (NUMBER)* ('.' (NUMBER)+)? (('e'|'E')('-')? (NUMBER)+)?) | 'nan' | 'inf';
StringRef:
string=STRING;
@@ -143,13 +143,11 @@
SL_STRING (SL_STRING)*;
terminal SL_STRING:
- '"' ('\\' ('b' | 't' | 'n' | 'f' | 'r' | 'u' | '"' | "'" | '\\' | UNICODE_OCTAL) | !('\\' | '"'))* '"' (WS)*;
+ '"' ('\\' ('b' | 't' | 'n' | 'f' | 'r' | 'u' | '"' | "'" | '\\' | UNICODE_OCTAL) | !('\\' | '"'))* '"' (WS)* |
+ "'" ('\\' ('b' | 't' | 'n' | 'f' | 'r' | 'u' | '"' | "'" | '\\' | UNICODE_OCTAL) | !('\\' | "'"))* "'" (WS)*;
terminal UNICODE_OCTAL:
('0'..'3')('0'..'7')('0'..'7');
-
-Nan:
- number='nan';
Enum:
'enum' name=Name '{'
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/FLOATValueConverter.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/DOUBLEValueConverter.java
similarity index 72%
rename from com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/FLOATValueConverter.java
rename to com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/DOUBLEValueConverter.java
index 930b070..cec6067 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/FLOATValueConverter.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/DOUBLEValueConverter.java
@@ -8,6 +8,8 @@
*/
package com.google.eclipse.protobuf.conversion;
+import static java.lang.Double.*;
+import static java.lang.Double.NaN;
import static org.eclipse.xtext.util.Strings.isEmpty;
import org.eclipse.xtext.conversion.ValueConverterException;
@@ -15,11 +17,11 @@
import org.eclipse.xtext.nodemodel.INode;
/**
- * Converts floating-point numbers to {@code float}s.
+ * Converts floating-point numbers to {@code double}s.
*
* @author alruiz@google.com (Alex Ruiz)
*/
-public class FLOATValueConverter extends AbstractLexerBasedConverter<Float> {
+public class DOUBLEValueConverter extends AbstractLexerBasedConverter<Double> {
/**
* Creates an {@code float} from the given input, if the given input represents a floating-point number.
@@ -29,16 +31,18 @@
* @throws ValueConverterException if the given input is {@code null}, empty or does not represent a floating-point
* number.
*/
- public Float toValue(String string, INode node) throws ValueConverterException {
- if (isEmpty(string)) throw new ValueConverterException("Couldn't convert empty string to float.", node, null);
+ public Double toValue(String string, INode node) throws ValueConverterException {
+ if (isEmpty(string)) throw new ValueConverterException("Couldn't convert empty string to double.", node, null);
+ if ("nan".equals(string)) return NaN;
+ if ("inf".equals(string)) return POSITIVE_INFINITY;
try {
- return Float.parseFloat(string);
+ return Double.parseDouble(string);
} catch (NumberFormatException e) {
throw parsingError(string, node, e);
}
}
private ValueConverterException parsingError(String string, INode node, Exception cause) {
- return new ValueConverterException("Couldn't convert '" + string + "' to float.", node, cause);
+ return new ValueConverterException("Couldn't convert '" + string + "' to double.", node, cause);
}
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/ProtobufTerminalConverters.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/ProtobufTerminalConverters.java
index e4ac026..d778e94 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/ProtobufTerminalConverters.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/ProtobufTerminalConverters.java
@@ -18,14 +18,14 @@
*/
public class ProtobufTerminalConverters extends DefaultTerminalConverters {
- @Inject private FLOATValueConverter floatValueConverter;
+ @Inject private DOUBLEValueConverter doubleValueConverter;
@Inject private HEXValueConverter hexValueConverter;
@Inject private LONGValueConverter longValueConverter;
@Inject private STRINGValueConverter stringValueConverter;
- @ValueConverter(rule = "FLOAT")
- public IValueConverter<Float> FLOAT() {
- return floatValueConverter;
+ @ValueConverter(rule = "DOUBLE")
+ public IValueConverter<Double> DOUBLE() {
+ return doubleValueConverter;
}
@ValueConverter(rule = "HEX")
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/STRINGValueConverter.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/STRINGValueConverter.java
index 63c5f96..ae23a29 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/STRINGValueConverter.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/STRINGValueConverter.java
@@ -41,7 +41,7 @@
public String toValue(String string, INode node) throws ValueConverterException {
if (string == null) return null;
try {
- String clean = removeLineBreaksFrom(string);
+ String clean = removeLineBreaksFrom(string).trim();
return convertToJavaString(clean.substring(1, clean.length() - 1), true);
} catch (IllegalArgumentException e) {
throw parsingError(string, node, e);
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/OptionType.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/OptionType.java
index ce32976..2c75f54 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/OptionType.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/OptionType.java
@@ -21,7 +21,7 @@
*/
enum OptionType {
FILE("FileOptions"), MESSAGE("MessageOptions"), FIELD("FieldOptions"), ENUM("EnumOptions"),
- ENUM_LITERAL("EnumValueOptions"), SERVICE("ServiceOptions"), RPC("MethodOptions");
+ LITERAL("EnumValueOptions"), SERVICE("ServiceOptions"), RPC("MethodOptions");
private static final Map<Class<?>, OptionType> OPTION_TYPES_BY_CONTAINER = new HashMap<Class<?>, OptionType>();
@@ -48,4 +48,4 @@
}
return null;
}
-}
\ No newline at end of file
+}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
index 984b28f..af6225f 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
@@ -133,11 +133,12 @@
}
/**
- * Returns the options available for the given option or option container. For example, if the given object is an
- * <code>{@link Enum}</code>, this method will return <code>{@link #enumOptions()}</code>.
- * @param o an option or an option container.
+ * Returns the options available for the given option or option container. The returned options are defined in
+ * {@code google/protobuf/descriptor.proto} (more details can be found
+ * <a href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
+ * @param o the given option or option container.
* @return the options available for the given option or option container, or an empty collection if the are not any
- * options available for the given option container.
+ * options available.
*/
public Collection<Property> availableOptionPropertiesFor(EObject o) {
EObject target = o;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Properties.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Properties.java
index 625ca65..df6ed1c 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Properties.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Properties.java
@@ -55,6 +55,11 @@
return isScalarType(p, BOOL);
}
+ /**
+ * Indicates whether the given property can accept "nan" as its default value.
+ * @param p the given property.
+ * @return {@code true} if the given property can accept "nan" as its default value, {@code false} otherwise.
+ */
public boolean mayBeNan(Property p) {
String typeName = typeNameOf(p);
return FLOAT.hasValue(typeName) || DOUBLE.hasValue(typeName);
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java
index 9de1574..1ede6e7 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java
@@ -30,6 +30,9 @@
*/
public class ProtobufJavaValidator extends AbstractProtobufJavaValidator {
+ public static final String SYNTAX_IS_NOT_PROTO2_ERROR_CODE = "syntaxIsNotProto2";
+ public static final String TAG_NUMBER_IS_NOT_UNIQUE_ERROR_CODE = "tagNumberIsNotUnique";
+
@Inject private FieldOptions fieldOptions;
@Inject private ImportUriResolver uriResolver;
@Inject private IQualifiedNameProvider qualifiedNameProvider;
@@ -71,7 +74,7 @@
String name = syntax.getName();
if ("proto2".equals(name)) return;
String msg = (name == null) ? expectedSyntaxIdentifier : format(unrecognizedSyntaxIdentifier, name);
- error(msg, SYNTAX__NAME);
+ error(msg, syntax, SYNTAX__NAME, SYNTAX_IS_NOT_PROTO2_ERROR_CODE);
}
@Check public void checkTagNumberIsUnique(Field field) {
@@ -87,7 +90,7 @@
if (other.getIndex() != index) continue;
QualifiedName messageName = qualifiedNameProvider.getFullyQualifiedName(message);
String msg = format(fieldNumberAlreadyUsed, index, messageName.toString(), other.getName());
- error(msg, FIELD__INDEX);
+ error(msg, field, FIELD__INDEX, TAG_NUMBER_IS_NOT_UNIQUE_ERROR_CODE);
break;
}
}