Renamed elements in the grammar.
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/syntaxcoloring/ProtobufSemanticHighlightingCalculator.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/syntaxcoloring/ProtobufSemanticHighlightingCalculator.java
index bff0655..907f555 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/syntaxcoloring/ProtobufSemanticHighlightingCalculator.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/syntaxcoloring/ProtobufSemanticHighlightingCalculator.java
@@ -123,12 +123,12 @@
private void highlightOptions(IndexedElement element, IHighlightedPositionAcceptor acceptor) {
for (FieldOption option : indexedElements.fieldOptionsOf(element)) {
- ValueRef ref = option.getValue();
- if (ref instanceof LiteralRef) {
+ ValueLink link = option.getValue();
+ if (link instanceof LiteralRef) {
highlightFirstFeature(option, FIELD_OPTION__VALUE, acceptor, ENUM_LITERAL_ID);
return;
}
- if (ref instanceof NumberRef) {
+ if (link instanceof NumberLink) {
highlightFirstFeature(option, FIELD_OPTION__VALUE, acceptor, NUMBER_ID);
}
}
@@ -209,12 +209,12 @@
if (element != null) {
highlightFirstFeature(option, OPTION__SOURCE, acceptor, DEFAULT_ID);
}
- ValueRef ref = option.getValue();
- if (ref instanceof LiteralRef) {
+ ValueLink link = option.getValue();
+ if (link instanceof LiteralRef) {
highlightFirstFeature(option, OPTION__VALUE, acceptor, ENUM_LITERAL_ID);
return;
}
- if (ref instanceof NumberRef) {
+ if (link instanceof NumberLink) {
highlightFirstFeature(option, OPTION__VALUE, acceptor, NUMBER_ID);
}
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlineTreeProvider.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlineTreeProvider.java
index 5a77117..6096449 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlineTreeProvider.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlineTreeProvider.java
@@ -28,7 +28,7 @@
private static final List<Class<? extends EObject>> IGNORED_ELEMENT_TYPES = new ArrayList<Class<? extends EObject>>();
static {
- IGNORED_ELEMENT_TYPES.add(BooleanRef.class);
+ IGNORED_ELEMENT_TYPES.add(BooleanLink.class);
IGNORED_ELEMENT_TYPES.add(FieldOption.class);
IGNORED_ELEMENT_TYPES.add(MessageLink.class);
}
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 0f11301..27b5ed2 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
@@ -89,75 +89,6 @@
ComplexTypeLink:
target=[ComplexType|QualifiedName];
-ValueRef:
- MessageNotation | SimpleRef;
-
-// { foo: 1, bar: 2 }
-MessageNotation:
- '{'
- fields+=FieldNotation ((',')? fields+=FieldNotation)*
- '}'
-;
-
-FieldNotation:
- SimpleFieldNotation | ComplexFieldNotation;
-
-SimpleFieldNotation:
- name=FieldNotationNameSource ':' value=SimpleRef;
-
-ComplexFieldNotation:
- name=FieldNotationNameSource ':'? values=MessageNotation;
-
-FieldNotationNameSource:
- NormalFieldNotationNameSource | ExtensionFieldNotationNameSource;
-
-NormalFieldNotationNameSource:
- property=[MessageField];
-
-ExtensionFieldNotationNameSource:
- '[' extension=[MessageField|QualifiedName] ']';
-
-SimpleRef:
- LiteralRef | BooleanRef | NumberRef | StringRef;
-
-LiteralRef:
- literal=[Literal];
-
-BooleanRef:
- boolean=BOOL;
-
-enum BOOL:
- true
- | false;
-
-NumberRef:
- HexRef | LongRef | DoubleRef;
-
-HexRef:
- hex=HEX;
-
-LongRef:
- long=LONG;
-
-terminal LONG returns ecore::ELong:
- ('-')? (NUMBER)+;
-
-DoubleRef:
- double=DOUBLE;
-
-terminal DOUBLE returns ecore::EDouble:
- (('-')? (NUMBER)* ('.' (NUMBER)+)? (('e'|'E')('-')? (NUMBER)+)?) | 'nan' | 'inf' | '-inf';
-
-StringRef:
- string=STRING;
-
-terminal STRING:
- SL_STRING (SL_STRING)*;
-
-terminal SL_STRING:
- '"' ('\\' ('"' | "'" | '\\' | !('\\' | '"')) | !('\\' | '"'))* '"' (WS)* |
- "'" ('\\' ('"' | "'" | '\\' | !('\\' | "'")) | !('\\' | "'"))* "'" (WS)*;
-
Enum:
'enum' name=Name '{'
elements+=EnumElement*
@@ -173,9 +104,6 @@
terminal HEX returns ecore::ELong:
('-')? '0x' (NUMBER | 'a'..'f' | 'A'..'F')+;
-terminal NUMBER:
- '0'..'9';
-
MessageExtension:
'extend' message=MessageLink '{'
elements+=MessageElement*
@@ -206,24 +134,24 @@
NativeOption | CustomOption;
NativeOption:
- 'option' source=OptionSource '=' value=ValueRef ';';
+ 'option' source=OptionSource '=' value=ValueLink ';';
CustomOption:
'option' '(' source=OptionSource ')'
- ('.' optionFields+=OptionFieldSource ('.' optionFields+=OptionFieldSource)*)? '=' value=ValueRef ';';
+ ('.' optionFields+=OptionFieldSource ('.' optionFields+=OptionFieldSource)*)? '=' value=ValueLink ';';
FieldOption:
DefaultValueFieldOption | NativeFieldOption | CustomFieldOption;
DefaultValueFieldOption:
- 'default' '=' value=ValueRef;
+ 'default' '=' value=ValueLink;
NativeFieldOption:
- source=OptionSource '=' value=ValueRef;
+ source=OptionSource '=' value=ValueLink;
CustomFieldOption:
'(' source=OptionSource ')'
- ('.' optionFields+=OptionFieldSource ('.' optionFields+=OptionFieldSource)*)? '=' value=ValueRef;
+ ('.' optionFields+=OptionFieldSource ('.' optionFields+=OptionFieldSource)*)? '=' value=ValueLink;
OptionSource:
optionField=[IndexedElement|QualifiedName];
@@ -240,6 +168,77 @@
IndexedElement:
MessageField | Group;
+ValueLink:
+ MessageNotation | SimpleValueLink;
+
+// { foo: 1, bar: 2 }
+MessageNotation:
+ '{'
+ fields+=FieldNotation ((',')? fields+=FieldNotation)*
+ '}';
+
+FieldNotation:
+ SimpleFieldNotation | ComplexFieldNotation;
+
+SimpleFieldNotation:
+ name=FieldNotationNameSource ':' value=SimpleValueLink;
+
+ComplexFieldNotation:
+ name=FieldNotationNameSource ':'? values=MessageNotation;
+
+FieldNotationNameSource:
+ NormalFieldNotationNameSource | ExtensionFieldNotationNameSource;
+
+NormalFieldNotationNameSource:
+ property=[MessageField];
+
+ExtensionFieldNotationNameSource:
+ '[' extension=[MessageField|QualifiedName] ']';
+
+SimpleValueLink:
+ LiteralRef | BooleanLink | NumberLink | StringLink;
+
+LiteralRef:
+ literal=[Literal];
+
+BooleanLink:
+ target=BOOL;
+
+enum BOOL:
+ true
+ | false;
+
+NumberLink:
+ HexNumberLink | LongLink | DoubleLink;
+
+HexNumberLink:
+ target=HEX;
+
+LongLink:
+ target=LONG;
+
+terminal LONG returns ecore::ELong:
+ ('-')? (NUMBER)+;
+
+DoubleLink:
+ target=DOUBLE;
+
+terminal DOUBLE returns ecore::EDouble:
+ (('-')? (NUMBER)* ('.' (NUMBER)+)? (('e'|'E')('-')? (NUMBER)+)?) | 'nan' | 'inf' | '-inf';
+
+terminal NUMBER:
+ '0'..'9';
+
+StringLink:
+ target=STRING;
+
+terminal STRING:
+ SL_STRING (SL_STRING)*;
+
+terminal SL_STRING:
+ '"' ('\\' ('"' | "'" | '\\' | !('\\' | '"')) | !('\\' | '"'))* '"' (WS)* |
+ "'" ('\\' ('"' | "'" | '\\' | !('\\' | "'")) | !('\\' | "'"))* "'" (WS)*;
+
terminal ID: '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
terminal ML_COMMENT: '/*' -> '*/';
terminal SL_COMMENT: '//' !('\n'|'\r')* ('\r'? '\n')?;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/ModelFinder.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/ModelFinder.java
index 6acbfc8..81aeed8 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/ModelFinder.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/ModelFinder.java
@@ -56,8 +56,8 @@
* @return the message from the given extension, or {@code null} if the extension is not referring to a message.
*/
public Message messageFrom(MessageExtension extension) {
- MessageLink ref = extension.getMessage();
- return ref == null ? null : ref.getTarget();
+ MessageLink link = extension.getMessage();
+ return link == null ? null : link.getTarget();
}
/**
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 36647a4..c9f0265 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
@@ -50,13 +50,13 @@
@Check public void checkDefaultValueType(FieldOption option) {
if (!fieldOptions.isDefaultValueOption(option)) return;
MessageField field = (MessageField) option.eContainer();
- ValueRef defaultValue = option.getValue();
+ ValueLink defaultValue = option.getValue();
if (properties.isString(field)) {
- if (defaultValue instanceof StringRef) return;
+ if (defaultValue instanceof StringLink) return;
error(expectedString, FIELD_OPTION__VALUE);
}
if (properties.isBool(field)) {
- if (defaultValue instanceof BooleanRef) return;
+ if (defaultValue instanceof BooleanLink) return;
error(expectedTrueOrFalse, FIELD_OPTION__VALUE);
}
}