In progress: [ Issue 48 ] Validate duplicated tag numbers in a message https://code.google.com/p/protobuf-dt/issues/detail?id=48 Deprecated groups are supported in the grammar. Fixed outline view as well.
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/Messages.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/Messages.java new file mode 100644 index 0000000..1b729fe --- /dev/null +++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/Messages.java
@@ -0,0 +1,27 @@ +/* + * Copyright (c) 2011 Google Inc. + * + * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse + * Public License v1.0 which accompanies this distribution, and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + */ +package com.google.eclipse.protobuf.ui.outline; + +import org.eclipse.osgi.util.NLS; + +/** + * @author alruiz@google.com (Alex Ruiz) + */ +public class Messages extends NLS { + + public static String importDeclarations; + public static String optionDeclarations; + + static { + Class<Messages> targetType = Messages.class; + NLS.initializeMessages(targetType.getName(), targetType); + } + + private Messages() {} +}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/Messages.properties b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/Messages.properties new file mode 100644 index 0000000..fbd7d57 --- /dev/null +++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/Messages.properties
@@ -0,0 +1,2 @@ +importDeclarations=import declarations +optionDeclarations=option declarations
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 6d1ed58..2c63379 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
@@ -9,6 +9,10 @@ package com.google.eclipse.protobuf.ui.outline; import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.*; +import static com.google.eclipse.protobuf.ui.outline.Messages.*; + +import java.util.ArrayList; +import java.util.List; import org.eclipse.emf.ecore.EObject; import org.eclipse.xtext.ui.editor.outline.IOutlineNode; @@ -25,6 +29,13 @@ */ public class ProtobufOutlineTreeProvider extends DefaultOutlineTreeProvider { + 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(MessageReference.class); + } + boolean _isLeaf(Option o) { return true; } @@ -40,11 +51,11 @@ } if (!protobuf.getImports().isEmpty()) { createEStructuralFeatureNode(parentNode, protobuf, PROTOBUF__IMPORTS, - labelProvider.getImage("imports"), "import declarations", false); + labelProvider.getImage("imports"), importDeclarations, false); } if (!protobuf.getOptions().isEmpty()) { createEStructuralFeatureNode(parentNode, protobuf, PROTOBUF__OPTIONS, - labelProvider.getImage("options"), "option declarations", false); + labelProvider.getImage("options"), optionDeclarations, false); } for (ProtobufElement e : protobuf.getElements()) { createNode(parentNode, e); @@ -52,7 +63,13 @@ } @Override protected void createNode(IOutlineNode parent, EObject modelElement) { - if (modelElement instanceof MessageReference) return; + if (isIgnored(modelElement)) return; super.createNode(parent, modelElement); } + + private boolean isIgnored(EObject modelElement) { + for (Class<? extends EObject> ignoredType : IGNORED_ELEMENT_TYPES) + if (ignoredType.isInstance(modelElement)) return true; + return false; + } }
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 5a320c3..d72264c 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
@@ -50,7 +50,7 @@ Type | Property | Group | ExtendMessage; Group: - modifier=Modifier 'group' name=ID '=' index=INT '{' + modifier=Modifier 'group' name=ID '=' index=INT ('[' 'deprecated' '=' deprecated=BooleanRef ']')? '{' elements+=Property* '}'(';')?;