Fixed: [ Issue 53 ] Add content-assist for field options https://code.google.com/p/protobuf-dt/issues/detail?id=53 Fixed content assist for packed field option.
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 f0ca40c..072435b 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
@@ -8,7 +8,7 @@ */ package com.google.eclipse.protobuf.ui.contentassist; -import static com.google.eclipse.protobuf.protobuf.Modifier.OPTIONAL; +import static com.google.eclipse.protobuf.protobuf.Modifier.*; import static com.google.eclipse.protobuf.protobuf.ScalarType.STRING; import static com.google.eclipse.protobuf.ui.grammar.CommonKeyword.*; import static com.google.eclipse.protobuf.ui.grammar.CompoundElement.*; @@ -338,11 +338,10 @@ private void proposeCommonFieldOptions(Property property, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { - boolean isPrimitive = properties.isPrimitive(property); List<String> options = existingFieldOptionNames(property); for (Property fieldOption : descriptorProvider.get().fieldOptions()) { String optionName = fieldOption.getName(); - if (options.contains(optionName) || ("packed".equals(optionName) && !isPrimitive)) continue; + if (options.contains(optionName) || ("packed".equals(optionName) && !canBePacked(property))) continue; String proposalText = optionName + SPACE + EQUAL + SPACE; boolean isBooleanOption = properties.isBool(fieldOption); if (isBooleanOption) proposalText = proposalText + TRUE; @@ -359,6 +358,10 @@ return optionNames; } + private boolean canBePacked(Property property) { + return properties.isPrimitive(property) && REPEATED.equals(property.getModifier()); + } + @Override public void completeFieldOption_Value(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { FieldOption option = (FieldOption) model;