In progress: [Issue 125] Support for custom options.
Fixed content assist of built-in options.
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 853b1c0..3e88b60 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
@@ -261,11 +261,6 @@
proposeAndAccept(name, context, acceptor);
}
- private ICompletionProposal createCompletionProposal(String proposal, String displayString,
- ContentAssistContext context) {
- return createCompletionProposal(proposal, displayString, defaultImage(), context);
- }
-
private void proposeAndAccept(String proposalText, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
acceptor.accept(createCompletionProposal(proposalText, context));
}
@@ -337,7 +332,8 @@
} else if (properties.isBool(option)) {
proposalText = proposalText + TRUE;
}
- ICompletionProposal proposal = createCompletionProposal(proposalText, displayString, context);
+ Image image = imageHelper.getImage(images.imageFor(Option.class));
+ ICompletionProposal proposal = createCompletionProposal(proposalText, displayString, image, context);
if (isStringOption && proposal instanceof ConfigurableCompletionProposal) {
// set cursor between the proposal's quotes
ConfigurableCompletionProposal configurable = (ConfigurableCompletionProposal) proposal;
@@ -417,4 +413,9 @@
String previousWord = styledText.getTextRange(start, valueLength);
return word.equals(previousWord);
}
+
+ /** {@inheritDoc} */
+ @Override public void completePropertyRef_Property(EObject model, Assignment assignment,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ }
}
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 fc0ca3e..984b28f 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,16 +133,18 @@
}
/**
- * Returns the options available for the given option container. For example, if the given object is an
+ * 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 optionContainer the given container of an option.
- * @return the options available for the given option container, or an empty collection if the are not any
+ * @param o an option or an 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.
*/
- public Collection<Property> availableOptionPropertiesFor(EObject optionContainer) {
- if (optionContainer instanceof Protobuf) return fileOptions();
- if (optionContainer instanceof Enum) return enumOptions();
- if (optionContainer instanceof Message) return messageOptions();
+ public Collection<Property> availableOptionPropertiesFor(EObject o) {
+ EObject target = o;
+ if (target instanceof BuiltInOption) target = target.eContainer();
+ if (target instanceof Protobuf) return fileOptions();
+ if (target instanceof Enum) return enumOptions();
+ if (target instanceof Message) return messageOptions();
return emptyList();
}