Fixed: [Issue 155] Editor does not support complex custom options.
Working on content assist.
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/contentassist/ProtobufProposalProvider.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/contentassist/ProtobufProposalProvider.java
index 3ad7e96..9174060 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/contentassist/ProtobufProposalProvider.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/contentassist/ProtobufProposalProvider.java
@@ -149,9 +149,12 @@
}
return true;
}
- if (OPENING_BRACKET.hasValue(keyword)) return proposeOpeningBracket(context, acceptor);
+ if (OPENING_BRACKET.hasValue(keyword)) {
+ return proposeOpeningBracket(context, acceptor);
+ }
if (OPENING_CURLY_BRACKET.hasValue(keyword)) {
- return context.getCurrentModel() instanceof Option;
+ EObject model = context.getCurrentModel();
+ return model instanceof Option || model instanceof ComplexValue;
}
if (TRUE.hasValue(keyword) || FALSE.hasValue(keyword)) {
if (isBoolProposalValid(context)) {
@@ -220,19 +223,22 @@
private boolean proposeOpeningBracket(ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
EObject model = context.getCurrentModel();
- if (!(model instanceof MessageField)) return false;
- MessageField field = (MessageField) model;
- Modifier modifier = field.getModifier();
- if (OPTIONAL.equals(modifier)) {
- CompoundElement display = DEFAULT_EQUAL_IN_BRACKETS;
- int cursorPosition = display.indexOf(CLOSING_BRACKET);
- if (properties.isString(field)) {
- display = DEFAULT_EQUAL_STRING_IN_BRACKETS;
- cursorPosition++;
+ if (model instanceof ComplexValue) return true;
+ if (model instanceof MessageField) {
+ MessageField field = (MessageField) model;
+ Modifier modifier = field.getModifier();
+ if (OPTIONAL.equals(modifier)) {
+ CompoundElement display = DEFAULT_EQUAL_IN_BRACKETS;
+ int cursorPosition = display.indexOf(CLOSING_BRACKET);
+ if (properties.isString(field)) {
+ display = DEFAULT_EQUAL_STRING_IN_BRACKETS;
+ cursorPosition++;
+ }
+ createAndAccept(display, cursorPosition, context, acceptor);
}
- createAndAccept(display, cursorPosition, context, acceptor);
+ return true;
}
- return true;
+ return false;
}
private <T> T extractElementFromContext(ContentAssistContext context, Class<T> type) {
@@ -564,6 +570,16 @@
ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
}
+ @Override public void completeSimpleValueField_Value(EObject model, Assignment assignment,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ if (!(model instanceof SimpleValueField)) return;
+ SimpleValueField field = (SimpleValueField) model;
+ FieldName name = field.getName();
+ if (name != null) {
+ proposeFieldValue(name.getTarget(), context, acceptor);
+ }
+ }
+
@Override public void completeSimpleValueField_Name(EObject model, Assignment assignment,
ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
if (!(model instanceof ComplexValue)) return;