diff options
author | Markus Schorn | 2008-12-01 09:18:50 +0000 |
---|---|---|
committer | Markus Schorn | 2008-12-01 09:18:50 +0000 |
commit | 14e574420decdee0ba2921c4c3f4aa1b1baec631 (patch) | |
tree | f27e67e0ae023cedd26410501855f54f6956adeb /core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt | |
parent | 0581a953b43cfc72b84ceb62d68d01a865ce23cb (diff) | |
download | org.eclipse.cdt-14e574420decdee0ba2921c4c3f4aa1b1baec631.tar.gz org.eclipse.cdt-14e574420decdee0ba2921c4c3f4aa1b1baec631.tar.xz org.eclipse.cdt-14e574420decdee0ba2921c4c3f4aa1b1baec631.zip |
Improve labels in DOMASTViewer.
Diffstat (limited to 'core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt')
-rw-r--r-- | core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMASTNodeLeaf.java | 64 |
1 files changed, 40 insertions, 24 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMASTNodeLeaf.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMASTNodeLeaf.java index 3c8cfa5c329..69c7c622c08 100644 --- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMASTNodeLeaf.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMASTNodeLeaf.java @@ -12,6 +12,11 @@ package org.eclipse.cdt.ui.tests.DOMAST; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.ui.views.properties.IPropertyDescriptor; @@ -82,11 +87,16 @@ public class DOMASTNodeLeaf implements IAdaptable { // used for applying filters to the tree, since it is lazily populated // all parents of the desired tree object to display need to have a flag as well - private int filterFlag = 0; + private int filterFlag = 0; + private static Set<String> ignoreInterfaces= new HashSet<String>(); public static final int FLAG_PROBLEM = 1<<0; public static final int FLAG_PREPROCESSOR = 1<<1; public static final int FLAG_INCLUDE_STATEMENTS = 1<<2; - + static { + ignoreInterfaces.addAll(Arrays.asList(new String[] { + "IASTCompletionContext", "IASTNode" + })); + } public DOMASTNodeLeaf(IASTNode node) { this.node = node; } @@ -106,9 +116,11 @@ public class DOMASTNodeLeaf implements IAdaptable { string.startsWith(ICPPAST_PREFIX) || string.startsWith(IGPPAST_PREFIX) || string.startsWith(IGNUAST_PREFIX) || - string.startsWith(IGCCAST_PREFIX)) - return true; - + string.startsWith(IGCCAST_PREFIX)) { + if (!ignoreInterfaces.contains(string)) { + return true; + } + } return false; } @@ -116,26 +128,30 @@ public class DOMASTNodeLeaf implements IAdaptable { public String toString() { if( node == null ) return BLANK_STRING; StringBuffer buffer = new StringBuffer(); + List<Class<?>> search= new LinkedList<Class<?>>(); + boolean done= false; - Class<?> clazz= node.getClass(); - Class<?>[] classes = clazz.getInterfaces(); - while (classes.length == 0) { - clazz= clazz.getSuperclass(); - if (clazz == null) - break; - classes= clazz.getInterfaces(); - } - for(int i=0; i<classes.length; i++) { - if (classes[i].getPackage().toString().indexOf(INTERNAL) >= 0) - continue; - - String interfaceName = classes[i].getName().substring(classes[i].getName().lastIndexOf(PERIOD) + 1); - if (hasProperPrefix(interfaceName)) { - buffer.append(interfaceName); - if (i+1 < classes.length && - hasProperPrefix(classes[i+1].getName().substring(classes[i+1].getName().lastIndexOf(PERIOD) + 1)) && - classes[i+1].getPackage().toString().indexOf(INTERNAL) < 0) - buffer.append(LIST_SEPARATOR); + for (search.add(node.getClass()); !search.isEmpty(); ) { + Class<?> clazz= search.remove(0); + boolean needComma= false; + if (clazz.isInterface()) { + if (clazz.getPackage().toString().indexOf(INTERNAL) < 0) { + String interfaceName= clazz.getName(); + interfaceName= interfaceName.substring(interfaceName.lastIndexOf(PERIOD) + 1); + if (hasProperPrefix(interfaceName)) { + if (needComma) + buffer.append(LIST_SEPARATOR); + buffer.append(interfaceName); + needComma= true; + done= true; + } + } + } + if (!done) { + search.addAll(Arrays.asList((Class<?>[])clazz.getInterfaces())); + final Class<?> superclass = clazz.getSuperclass(); + if (superclass != null) + search.add(superclass); } } |