Fixed: [Issue 97] Extensions do not show properly in outline view.
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 898e21d..85bc753 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
@@ -42,6 +42,7 @@
static {
IMAGES_BY_TYPE.put(Enum.class, "enum.gif");
IMAGES_BY_TYPE.put(ExtendMessage.class, "extend.gif");
+ IMAGES_BY_TYPE.put(Extensions.class, "extensions.gif");
IMAGES_BY_TYPE.put(Group.class, "group.gif");
IMAGES_BY_TYPE.put(Import.class, "import.gif");
IMAGES_BY_TYPE.put(Literal.class, "literal.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 9fe9161..e486599 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
@@ -1,9 +1,10 @@
/*
* 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
- *
+ *
+ * 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.labeling;
@@ -16,16 +17,16 @@
import com.google.eclipse.protobuf.util.Properties;
import com.google.inject.*;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.xtext.nodemodel.INode;
/**
* Registry of commonly used text in the 'Protocol Buffer' editor.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton
-public class Labels {
+@Singleton public class Labels {
@Inject private ModelNodes nodes;
@Inject private Properties properties;
@@ -35,6 +36,10 @@
ExtendMessage extend = (ExtendMessage) o;
return labelFor(extend);
}
+ if (o instanceof Extensions) {
+ Extensions extensions = (Extensions) o;
+ return labelFor(extensions);
+ }
if (o instanceof Import) {
Import i = (Import) o;
return labelFor(i);
@@ -58,6 +63,22 @@
return messageName(extend.getMessage());
}
+ private Object labelFor(Extensions extensions) {
+ StringBuilder builder = new StringBuilder();
+ EList<Range> ranges = extensions.getRanges();
+ int rangeCount = ranges.size();
+ for (int i = 0; i < rangeCount; i++) {
+ if (i > 0) builder.append(", ");
+ Range range = ranges.get(i);
+ builder.append(range.getFrom());
+ String to = range.getTo();
+ if (to != null) {
+ builder.append(" > ").append(to);
+ }
+ }
+ return builder.toString();
+ }
+
private Object labelFor(Import i) {
INode node = nodes.firstNodeForFeature(i, IMPORT__IMPORT_URI);
if (node == null) return i.getImportURI();
@@ -74,7 +95,9 @@
private Object labelFor(Property p) {
StyledString text = new StyledString(p.getName());
String typeName = properties.typeNameOf(p);
- if (typeName == null) typeName = "<unresolved reference>"; // TODO move to properties file
+ if (typeName == null) typeName = "<unresolved reference>"; // TODO move to
+ // properties
+ // file
String indexAndType = String.format(" [%d] : %s", p.getIndex(), typeName);
text.append(indexAndType, DECORATIONS_STYLER);
return text;
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 7821e1c..ec63990 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
@@ -32,6 +32,10 @@
IGNORED_ELEMENT_TYPES.add(FieldOption.class);
IGNORED_ELEMENT_TYPES.add(MessageRef.class);
}
+
+ boolean _isLeaf(Extensions e) {
+ return true;
+ }
boolean _isLeaf(Option o) {
return true;