Prevent the semicolon handler from adding indexes to message options."
This patch works around a bug in the protobuf grammar that causes the
parser to misclassify message options as message fields if they contain
syntax errors or unresolved symbols.
Change-Id: Ieee07fe51e9120f8952be839acf8b2b8803630b8
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/commands/semicolon/SmartSemicolonHandler.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/commands/semicolon/SmartSemicolonHandler.java
index 005cca6..f250c08 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/commands/semicolon/SmartSemicolonHandler.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/commands/semicolon/SmartSemicolonHandler.java
@@ -149,7 +149,16 @@
model = model.eContainer();
}
- if (model instanceof MessageField || model instanceof Group || model instanceof Literal) {
+ if (model instanceof MessageField) {
+ // If a non-indexed MessageElement, such as an Option, contains syntax errors or
+ // unresolved symbols, the Protobuf Parser may mistakenly classify it as a MessageField.
+ // Invalid MessageFields can be filtered out by verifying the presence of the field "name".
+ if (((MessageField) model).getName() != null) {
+ return model;
+ }
+ }
+
+ if (model instanceof Group || model instanceof Literal) {
return model;
}
}