Fixed: [ Issue 34 ] Finish outline view for proto files https://code.google.com/p/protobuf-dt/issues/detail?id=34
diff --git a/com.google.eclipse.protobuf.ui/icons/rpc.gif b/com.google.eclipse.protobuf.ui/icons/rpc.gif new file mode 100644 index 0000000..b5dd4ec --- /dev/null +++ b/com.google.eclipse.protobuf.ui/icons/rpc.gif Binary files differ
diff --git a/com.google.eclipse.protobuf.ui/icons/syntax.gif b/com.google.eclipse.protobuf.ui/icons/syntax.gif new file mode 100644 index 0000000..c71de32 --- /dev/null +++ b/com.google.eclipse.protobuf.ui/icons/syntax.gif Binary files differ
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Images.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Images.java index 0534220..7fe0ced 100644 --- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Images.java +++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Images.java
@@ -48,7 +48,9 @@ IMAGES_BY_TYPE.put(Option.class, "option.gif"); IMAGES_BY_TYPE.put(Package.class, "package.gif"); IMAGES_BY_TYPE.put(Protobuf.class, "protobuf.gif"); + IMAGES_BY_TYPE.put(Rpc.class, "rpc.gif"); IMAGES_BY_TYPE.put(Service.class, "service.gif"); + IMAGES_BY_TYPE.put(Syntax.class, "syntax.gif"); } private static final List<String> STANDALONE_IMAGES = asList("extensions.gif");
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Labels.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Labels.java index db89fd2..09f8cc2 100644 --- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Labels.java +++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Labels.java
@@ -28,6 +28,10 @@ @Inject private Properties properties; public Object labelFor(Object o) { + if (o instanceof ExtendMessage) { + ExtendMessage extend = (ExtendMessage) o; + return labelFor(extend); + } if (o instanceof Import) { Import i = (Import) o; return labelFor(i); @@ -44,9 +48,17 @@ Protobuf p = (Protobuf) o; return labelFor(p); } + if (o instanceof Rpc) { + Rpc r = (Rpc) o; + return labelFor(r); + } return null; } + private Object labelFor(ExtendMessage extend) { + return messageName(extend.getMessage()); + } + private Object labelFor(Import i) { String uri = i.getImportURI(); if (uri == null || !uri.startsWith(URI_PREFIX)) return uri; @@ -71,4 +83,15 @@ // TODO show this text till I figure out how to hide 'Protobuf' node in outline view return "Protocol Buffer"; } + + private Object labelFor(Rpc r) { + StyledString text = new StyledString(r.getName()); + String types = String.format(" : %s > %s", messageName(r.getArgType()), messageName(r.getReturnType())); + text.append(types, DECORATIONS_STYLER); + return text; + } + + private String messageName(MessageReference r) { + return r.getType().getName(); + } }
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 02334ba..412134b 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
@@ -8,12 +8,14 @@ */ package com.google.eclipse.protobuf.ui.outline; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.ui.editor.outline.IOutlineNode; import org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider; import com.google.eclipse.protobuf.protobuf.*; /** - * Customization of the default outline structure + * Customization of the default outline structure. * * @author alruiz@google.com (Alex Ruiz) */ @@ -27,7 +29,8 @@ return true; } - boolean _isLeaf(Service s) { - return true; + @Override protected void createNode(IOutlineNode parent, EObject modelElement) { + if (modelElement instanceof MessageReference) return; + super.createNode(parent, modelElement); } }