List of usage examples for org.eclipse.jdt.core ITypeHierarchy getAllTypes
IType[] getAllTypes();
From source file:com.sabre.buildergenerator.eclipsejavamodel.ModelHelper.java
License:Open Source License
public boolean hasSuperType(IType type, String superTypeName) throws JavaModelException { ITypeHierarchy supertypeHierarchy = type.newSupertypeHierarchy(null); IType[] superTypes = supertypeHierarchy.getAllTypes(); for (IType superType : superTypes) { if (superType.getFullyQualifiedName().equals(superTypeName)) { return true; }// w ww . java 2 s.c om } return false; }
From source file:edu.brown.cs.bubbles.bedrock.BedrockUtil.java
License:Open Source License
/********************************************************************************/ static void outputTypeHierarchy(ITypeHierarchy th, IvyXmlWriter xw) { xw.begin("HIERARCHY"); IType[] typs = th.getAllTypes(); for (IType typ : typs) { xw.begin("TYPE"); try {/*from ww w . j a v a 2 s . c o m*/ xw.field("NAME", typ.getFullyQualifiedName()); xw.field("QNAME", typ.getTypeQualifiedName()); xw.field("PNAME", typ.getFullyQualifiedParameterizedName()); if (typ.isClass()) xw.field("KIND", "CLASS"); else if (typ.isEnum()) xw.field("KIND", "ENUM"); else if (typ.isInterface()) xw.field("KIND", "INTERFACE"); xw.field("LOCAL", typ.isLocal()); xw.field("MEMBER", typ.isMember()); xw.field("KEY", typ.getKey()); IType[] subs = th.getAllSubtypes(typ); for (IType styp : subs) { xw.begin("SUBTYPE"); xw.field("NAME", styp.getFullyQualifiedName()); xw.field("KEY", styp.getKey()); xw.end("SUBTYPE"); } IType[] sups = th.getAllSuperclasses(typ); for (IType styp : sups) { xw.begin("SUPERCLASS"); xw.field("NAME", styp.getFullyQualifiedName()); xw.field("KEY", styp.getKey()); xw.end("SUPERCLASS"); } sups = th.getAllSuperInterfaces(typ); for (IType styp : sups) { xw.begin("SUPERIFACE"); xw.field("NAME", styp.getFullyQualifiedName()); xw.field("KEY", styp.getKey()); xw.end("SUPERIFACE"); } sups = th.getAllSupertypes(typ); for (IType styp : sups) { xw.begin("SUPERTYPE"); xw.field("NAME", styp.getFullyQualifiedName()); xw.field("KEY", styp.getKey()); xw.end("SUPERTYPE"); } sups = th.getExtendingInterfaces(typ); for (IType styp : sups) { xw.begin("EXTENDIFACE"); xw.field("NAME", styp.getFullyQualifiedName()); xw.field("KEY", styp.getKey()); xw.end("EXTENDIFACE"); } sups = th.getImplementingClasses(typ); for (IType styp : sups) { xw.begin("IMPLEMENTOR"); xw.field("NAME", styp.getFullyQualifiedName()); xw.field("KEY", styp.getKey()); xw.end("IMPLEMENTOR"); } } catch (JavaModelException e) { } xw.end("TYPE"); } xw.end("HIERARCHY"); }
From source file:org.codehaus.groovy.eclipse.codeassist.proposals.GroovyExtendedCompletionContext.java
License:Apache License
private IJavaElement[] computeVisibleElements(String typeSignature) { ClassNode superType = toClassNode(typeSignature); boolean isInterface = superType.isInterface(); // look at all local variables in scope Map<String, IJavaElement> nameElementMap = new LinkedHashMap<String, IJavaElement>(); Iterator<Entry<String, VariableInfo>> variablesIter = currentScope.variablesIterator(); while (variablesIter.hasNext()) { Entry<String, VariableInfo> entry = variablesIter.next(); // don't put elements in a second time since we are moving from // inner scope to outer scope String varName = entry.getKey(); if (!varName.equals("super") && !nameElementMap.containsKey(varName)) { ClassNode type = entry.getValue().type; if (isAssignableTo(type, superType, isInterface)) { // note that parent, start location, and typeSignature are // not important here nameElementMap.put(varName, ReflectionUtils.createLocalVariable(enclosingElement, varName, 0, typeSignature)); }/*from w w w.j av a2 s . c o m*/ } } // now check fields IType enclosingType = (IType) enclosingElement.getAncestor(IJavaElement.TYPE); if (enclosingType != null) { try { ITypeHierarchy typeHierarchy = enclosingType.newSupertypeHierarchy(null); IType[] allTypes = typeHierarchy.getAllTypes(); for (IType type : allTypes) { IField[] fields = type.getFields(); for (IField field : fields) { ClassNode fieldTypeClassNode = toClassNode(field.getTypeSignature()); if (isAssignableTo(fieldTypeClassNode, superType, isInterface)) { nameElementMap.put(field.getElementName(), field); } } } } catch (JavaModelException e) { GroovyCore.logException("", e); } } return nameElementMap.values().toArray(NO_ELEMENTS); }
From source file:org.eclipse.wb.internal.core.utils.jdt.core.CodeUtils.java
License:Open Source License
/** * @return <code>true</code> if given <code>type</code> is successor of * <code>superTypeToCheck</code>. *//*w w w. j ava2s. c om*/ public static boolean isSuccessorOf(IType type, String superTypeName) throws JavaModelException { ITypeHierarchy supertypeHierarchy = type.newSupertypeHierarchy(null); for (IType superType : supertypeHierarchy.getAllTypes()) { if (superType.getFullyQualifiedName().equals(superTypeName)) { return true; } } return false; }