List of usage examples for org.eclipse.jdt.core.dom Type isParameterizedType
public final boolean isParameterizedType()
From source file:boa.datagen.util.Java7Visitor.java
License:Apache License
protected String typeName(final org.eclipse.jdt.core.dom.Type t) { if (t.isArrayType()) return typeName((ArrayType) t); if (t.isParameterizedType()) return typeName((ParameterizedType) t); if (t.isPrimitiveType()) return typeName((PrimitiveType) t); if (t.isQualifiedType()) return typeName((QualifiedType) t); if (t.isIntersectionType()) return typeName((IntersectionType) t); if (t.isUnionType()) return typeName((UnionType) t); if (t.isWildcardType()) return typeName((WildcardType) t); return typeName((SimpleType) t); }
From source file:boa.datagen.util.JavaVisitor.java
License:Apache License
private String typeName(org.eclipse.jdt.core.dom.Type t) { if (t.isArrayType()) return typeName(((ArrayType) t).getComponentType()) + "[]"; if (t.isParameterizedType()) { String name = ""; for (Object o : ((ParameterizedType) t).typeArguments()) { if (name.length() > 0) name += ", "; name += typeName((org.eclipse.jdt.core.dom.Type) o); }/*from ww w . j ava 2 s.c o m*/ return typeName(((ParameterizedType) t).getType()) + "<" + name + ">"; } if (t.isPrimitiveType()) return ((PrimitiveType) t).getPrimitiveTypeCode().toString(); if (t.isQualifiedType()) return typeName(((QualifiedType) t).getQualifier()) + "." + ((QualifiedType) t).getName().getFullyQualifiedName(); if (t.isUnionType()) { String name = ""; for (Object o : ((UnionType) t).types()) { if (name.length() > 0) name += " | "; name += typeName((org.eclipse.jdt.core.dom.Type) o); } return name; } if (t.isWildcardType()) { String name = "?"; if (((WildcardType) t).getBound() != null) { name += " " + (((WildcardType) t).isUpperBound() ? "extends" : "super"); name += " " + typeName(((WildcardType) t).getBound()); } return name; } return ((SimpleType) t).getName().getFullyQualifiedName(); }
From source file:com.facebook.buck.jvm.java.JavaFileParser.java
License:Apache License
public JavaFileFeatures extractFeaturesFromJavaCode(String code) { // For now, we will harcode this. Ultimately, we probably want to make this configurable via // .buckconfig. For example, the Buck project itself is diligent about disallowing wildcard // imports, but the one exception is the Java code generated via Thrift in src-gen. boolean shouldThrowForUnsupportedWildcardImport = false; AtomicBoolean isPoisonedByUnsupportedWildcardImport = new AtomicBoolean(false); CompilationUnit compilationUnit = makeCompilationUnitFromSource(code); ImmutableSortedSet.Builder<String> providedSymbols = ImmutableSortedSet.naturalOrder(); ImmutableSortedSet.Builder<String> requiredSymbols = ImmutableSortedSet.naturalOrder(); ImmutableSortedSet.Builder<String> exportedSymbols = ImmutableSortedSet.naturalOrder(); ImmutableSortedSet.Builder<String> requiredSymbolsFromExplicitImports = ImmutableSortedSet.naturalOrder(); compilationUnit.accept(new ASTVisitor() { @Nullable// www . j a va 2s .c o m private String packageName; /** Maps simple name to fully-qualified name. */ private Map<String, String> simpleImportedTypes = new HashMap<>(); /** * Maps wildcard import prefixes, such as {@code "java.util"} to the types in the * respective package if a wildcard import such as {@code import java.util.*} is used. */ private Map<String, ImmutableSet<String>> wildcardImports = new HashMap<>(); @Override public boolean visit(PackageDeclaration node) { Preconditions.checkState(packageName == null, "There should be at most one package declaration"); packageName = node.getName().getFullyQualifiedName(); return false; } // providedSymbols @Override public boolean visit(TypeDeclaration node) { // Local classes can be declared inside of methods. Skip over these. if (node.getParent() instanceof TypeDeclarationStatement) { return true; } String fullyQualifiedName = getFullyQualifiedTypeName(node); if (fullyQualifiedName != null) { providedSymbols.add(fullyQualifiedName); } @SuppressWarnings("unchecked") List<Type> interfaceTypes = node.superInterfaceTypes(); for (Type interfaceType : interfaceTypes) { tryAddType(interfaceType, DependencyType.EXPORTED); } Type superclassType = node.getSuperclassType(); if (superclassType != null) { tryAddType(superclassType, DependencyType.EXPORTED); } return true; } @Override public boolean visit(EnumDeclaration node) { String fullyQualifiedName = getFullyQualifiedTypeName(node); if (fullyQualifiedName != null) { providedSymbols.add(fullyQualifiedName); } return true; } @Override public boolean visit(AnnotationTypeDeclaration node) { String fullyQualifiedName = getFullyQualifiedTypeName(node); if (fullyQualifiedName != null) { providedSymbols.add(fullyQualifiedName); } return true; } // requiredSymbols /** * Uses heuristics to try to figure out what type of QualifiedName this is. Returns a * non-null value if this is believed to be a reference that qualifies as a "required * symbol" relationship. */ @Override public boolean visit(QualifiedName node) { QualifiedName ancestor = findMostQualifiedAncestor(node); ASTNode parent = ancestor.getParent(); if (!(parent instanceof PackageDeclaration) && !(parent instanceof ImportDeclaration)) { String symbol = ancestor.getFullyQualifiedName(); // If it does not start with an uppercase letter, it is probably because it is a // property lookup. if (CharMatcher.javaUpperCase().matches(symbol.charAt(0))) { addTypeFromDotDelimitedSequence(symbol, DependencyType.REQUIRED); } } return false; } /** * @param expr could be "Example", "Example.field", "com.example.Example". Note it could * also be a built-in type, such as "java.lang.Integer", in which case it will not be * added to the set of required symbols. */ private void addTypeFromDotDelimitedSequence(String expr, DependencyType dependencyType) { // At this point, symbol could be `System.out`. We want to reduce it to `System` and // then check it against JAVA_LANG_TYPES. if (startsWithUppercaseChar(expr)) { int index = expr.indexOf('.'); if (index >= 0) { String leftmostComponent = expr.substring(0, index); if (JAVA_LANG_TYPES.contains(leftmostComponent)) { return; } } } expr = qualifyWithPackageNameIfNecessary(expr); addSymbol(expr, dependencyType); } @Override public boolean visit(ImportDeclaration node) { String fullyQualifiedName = node.getName().getFullyQualifiedName(); // Apparently, "on demand" means "uses a wildcard," such as "import java.util.*". // Although we can choose to prohibit these in our own code, it is much harder to // enforce for third-party code. As such, we will tolerate these for some of the common // cases. if (node.isOnDemand()) { ImmutableSet<String> value = SUPPORTED_WILDCARD_IMPORTS.get(fullyQualifiedName); if (value != null) { wildcardImports.put(fullyQualifiedName, value); return false; } else if (shouldThrowForUnsupportedWildcardImport) { throw new RuntimeException(String.format( "Use of wildcard 'import %s.*' makes it impossible to statically determine " + "required symbols in this file. Please enumerate explicit imports.", fullyQualifiedName)); } else { isPoisonedByUnsupportedWildcardImport.set(true); return false; } } // Only worry about the dependency on the enclosing type. Optional<String> simpleName = getSimpleNameFromFullyQualifiedName(fullyQualifiedName); if (simpleName.isPresent()) { String name = simpleName.get(); int index = fullyQualifiedName.indexOf("." + name); String enclosingType = fullyQualifiedName.substring(0, index + name.length() + 1); requiredSymbolsFromExplicitImports.add(enclosingType); simpleImportedTypes.put(name, enclosingType); } else { LOG.warn("Suspicious import lacks obvious enclosing type: %s", fullyQualifiedName); // The one example we have seen of this in the wild is // "org.whispersystems.curve25519.java.curve_sigs". In practice, we still need to add // it as a required symbol in this case. requiredSymbols.add(fullyQualifiedName); } return false; } @Override public boolean visit(MethodInvocation node) { if (node.getExpression() == null) { return true; } String receiver = node.getExpression().toString(); if (looksLikeAType(receiver)) { addTypeFromDotDelimitedSequence(receiver, DependencyType.REQUIRED); } return true; } /** An annotation on a member with zero arguments. */ @Override public boolean visit(MarkerAnnotation node) { DependencyType dependencyType = findDependencyTypeForAnnotation(node); addSimpleTypeName(node.getTypeName(), dependencyType); return true; } /** An annotation on a member with named arguments. */ @Override public boolean visit(NormalAnnotation node) { DependencyType dependencyType = findDependencyTypeForAnnotation(node); addSimpleTypeName(node.getTypeName(), dependencyType); return true; } /** An annotation on a member with a single, unnamed argument. */ @Override public boolean visit(SingleMemberAnnotation node) { DependencyType dependencyType = findDependencyTypeForAnnotation(node); addSimpleTypeName(node.getTypeName(), dependencyType); return true; } private DependencyType findDependencyTypeForAnnotation(Annotation annotation) { ASTNode parentNode = annotation.getParent(); if (parentNode == null) { return DependencyType.REQUIRED; } if (parentNode instanceof BodyDeclaration) { // Note that BodyDeclaration is an abstract class. Its subclasses are things like // FieldDeclaration and MethodDeclaration. We want to be sure that an annotation on // any non-private declaration is considered an exported symbol. BodyDeclaration declaration = (BodyDeclaration) parentNode; int modifiers = declaration.getModifiers(); if ((modifiers & Modifier.PRIVATE) == 0) { return DependencyType.EXPORTED; } } return DependencyType.REQUIRED; } @Override public boolean visit(SimpleType node) { // This method is responsible for finding the overwhelming majority of the required // symbols in the AST. tryAddType(node, DependencyType.REQUIRED); return true; } // exportedSymbols @Override public boolean visit(MethodDeclaration node) { // Types from private method signatures need not be exported. if ((node.getModifiers() & Modifier.PRIVATE) != 0) { return true; } Type returnType = node.getReturnType2(); if (returnType != null) { tryAddType(returnType, DependencyType.EXPORTED); } @SuppressWarnings("unchecked") List<SingleVariableDeclaration> params = node.parameters(); for (SingleVariableDeclaration decl : params) { tryAddType(decl.getType(), DependencyType.EXPORTED); } @SuppressWarnings("unchecked") List<Type> exceptions = node.thrownExceptionTypes(); for (Type exception : exceptions) { tryAddType(exception, DependencyType.EXPORTED); } return true; } @Override public boolean visit(FieldDeclaration node) { // Types from private fields need not be exported. if ((node.getModifiers() & Modifier.PRIVATE) == 0) { tryAddType(node.getType(), DependencyType.EXPORTED); } return true; } private void tryAddType(Type type, DependencyType dependencyType) { if (type.isSimpleType()) { SimpleType simpleType = (SimpleType) type; Name simpleTypeName = simpleType.getName(); String simpleName = simpleTypeName.toString(); // For a Type such as IExample<T>, both "IExample" and "T" will be submitted here as // simple types. As such, we use this imperfect heuristic to filter out "T" from being // added. Note that this will erroneously exclude "URI". In practice, this should // generally be OK. For example, assuming "URI" is also imported, then at least it // will end up in the set of required symbols. To this end, we perform a second check // for "all caps" types to see if there is a corresponding import and if it should be // exported rather than simply required. if (!CharMatcher.javaUpperCase().matchesAllOf(simpleName) || (dependencyType == DependencyType.EXPORTED && simpleImportedTypes.containsKey(simpleName))) { addSimpleTypeName(simpleTypeName, dependencyType); } } else if (type.isArrayType()) { ArrayType arrayType = (ArrayType) type; tryAddType(arrayType.getElementType(), dependencyType); } else if (type.isParameterizedType()) { ParameterizedType parameterizedType = (ParameterizedType) type; tryAddType(parameterizedType.getType(), dependencyType); @SuppressWarnings("unchecked") List<Type> argTypes = parameterizedType.typeArguments(); for (Type argType : argTypes) { tryAddType(argType, dependencyType); } } } private void addSimpleTypeName(Name simpleTypeName, DependencyType dependencyType) { String simpleName = simpleTypeName.toString(); if (JAVA_LANG_TYPES.contains(simpleName)) { return; } String fullyQualifiedNameForSimpleName = simpleImportedTypes.get(simpleName); if (fullyQualifiedNameForSimpleName != null) { // May need to promote from required to exported in this case. if (dependencyType == DependencyType.EXPORTED) { addSymbol(fullyQualifiedNameForSimpleName, DependencyType.EXPORTED); } return; } // For well-behaved source code, this will always be empty, so don't even bother to // create the iterator most of the time. if (!wildcardImports.isEmpty()) { for (Map.Entry<String, ImmutableSet<String>> entry : wildcardImports.entrySet()) { Set<String> types = entry.getValue(); if (types.contains(simpleName)) { String packageName = entry.getKey(); addSymbol(packageName + "." + simpleName, dependencyType); return; } } } String symbol = simpleTypeName.getFullyQualifiedName(); symbol = qualifyWithPackageNameIfNecessary(symbol); addSymbol(symbol, dependencyType); } private void addSymbol(String symbol, DependencyType dependencyType) { ((dependencyType == DependencyType.REQUIRED) ? requiredSymbols : exportedSymbols).add(symbol); } private String qualifyWithPackageNameIfNecessary(String symbol) { if (!startsWithUppercaseChar(symbol)) { return symbol; } // If the symbol starts with a capital letter, then we assume that it is a reference to // a type in the same package. int index = symbol.indexOf('.'); if (index >= 0) { symbol = symbol.substring(0, index); } if (packageName != null) { symbol = packageName + "." + symbol; } return symbol; } }); // TODO(mbolin): Special treatment for exportedSymbols when poisoned by wildcard import. ImmutableSortedSet<String> totalExportedSymbols = exportedSymbols.build(); // If we were poisoned by an unsupported wildcard import, then we should rely exclusively on // the explicit imports to determine the required symbols. Set<String> totalRequiredSymbols = new HashSet<>(); if (isPoisonedByUnsupportedWildcardImport.get()) { totalRequiredSymbols.addAll(requiredSymbolsFromExplicitImports.build()); } else { totalRequiredSymbols.addAll(requiredSymbolsFromExplicitImports.build()); totalRequiredSymbols.addAll(requiredSymbols.build()); } // Make sure that required and exported symbols are disjoint sets. totalRequiredSymbols.removeAll(totalExportedSymbols); return new JavaFileFeatures(providedSymbols.build(), ImmutableSortedSet.copyOf(totalRequiredSymbols), totalExportedSymbols); }
From source file:com.google.gwt.eclipse.core.util.Util.java
License:Open Source License
/** * Sync method has same return type as parameterization of last async * parameter (AsyncCallback). If the async callback parameter type is raw, * just assume sync return type of void. * * @param ast {@link AST} associated with the destination compilation unit * @param asyncMethod the GWT RPC async method declaration * @param imports {@link ImportRewrite} associated with the destination * compilation unit//from w w w . j a v a2 s . c om * @return the computed return {@link Type} */ public static Type computeSyncReturnType(AST ast, MethodDeclaration asyncMethod, ImportRewrite imports) { Type returnType = ast.newPrimitiveType(PrimitiveType.VOID); @SuppressWarnings("unchecked") List<SingleVariableDeclaration> asyncParameters = asyncMethod.parameters(); // Check for no parameters on async method... just in case if (asyncParameters.isEmpty()) { return returnType; } // Grab the last parameter type, which should be the callback Type callbackType = asyncParameters.get(asyncParameters.size() - 1).getType(); // Make sure we have a parameterized callback type; otherwise, we can't // infer the return type of the sync method. if (callbackType.isParameterizedType()) { ParameterizedType callbackParamType = (ParameterizedType) callbackType; ITypeBinding callbackBinding = callbackParamType.getType().resolveBinding(); if (callbackBinding == null) { return returnType; } // Make sure the callback is of type AsyncCallback String callbackBaseTypeName = callbackBinding.getErasure().getQualifiedName(); if (callbackBaseTypeName.equals(RemoteServiceUtilities.ASYNCCALLBACK_QUALIFIED_NAME)) { @SuppressWarnings("unchecked") List<Type> callbackTypeArgs = callbackParamType.typeArguments(); // Make sure we only have one type argument if (callbackTypeArgs.size() == 1) { Type callbackTypeParameter = callbackTypeArgs.get(0); // Check for primitive wrapper type; if we have one use the actual // primitive for the sync return type. // TODO(): Maybe used linked mode to let the user choose whether to // return the primitive or its wrapper type. String qualifiedName = callbackTypeParameter.resolveBinding().getQualifiedName(); String primitiveTypeName = JavaASTUtils.getPrimitiveTypeName(qualifiedName); if (primitiveTypeName != null) { return ast.newPrimitiveType(PrimitiveType.toCode(primitiveTypeName)); } returnType = JavaASTUtils.normalizeTypeAndAddImport(ast, callbackTypeParameter, imports); } } } return returnType; }
From source file:com.halware.nakedide.eclipse.ext.annot.utils.AstUtils.java
License:Open Source License
public static String asString(Type type) { if (type.isArrayType()) { ArrayType arrayType = (ArrayType) type; return asString(arrayType.getComponentType()) + "[]"; }/*from ww w . j a va 2s . c o m*/ if (type.isParameterizedType()) { ParameterizedType parameterizedType = (ParameterizedType) type; List<Type> typeArguments = Generics.asT(parameterizedType.typeArguments()); class TypeToString implements ClosureUtil.IClosure<Type, String> { public String eval(Type type) { return asString(type); } } return asString(parameterizedType.getType()) + "<" + StringUtil.join(ClosureUtil.forEach(typeArguments, new TypeToString()), ", ") + ">"; } if (type.isPrimitiveType()) { PrimitiveType primitiveType = (PrimitiveType) type; return primitiveType.getPrimitiveTypeCode().toString(); } if (type.isQualifiedType()) { QualifiedType qualifiedType = (QualifiedType) type; return qualifiedType.getName().getFullyQualifiedName(); } if (type.isSimpleType()) { SimpleType simpleType = (SimpleType) type; return simpleType.getName().getFullyQualifiedName(); } if (type.isWildcardType()) { WildcardType wildcardType = (WildcardType) type; Type boundType = wildcardType.getBound(); if (boundType != null) { if (wildcardType.isUpperBound()) { return "? extends " + asString(boundType); } else { return "? super " + asString(boundType); } } else { return "?"; } } return "(unknown type)"; }
From source file:com.halware.nakedide.eclipse.ext.annot.utils.AstUtils.java
License:Open Source License
/** * Doesn't support {@link SimpleType}s (so isn't much use). * //w w w.j av a 2s . co m * @param type * @return */ public static boolean isValueType(Type type) { if (type.isArrayType()) { return false; } if (type.isParameterizedType()) { return false; } if (type.isPrimitiveType()) { return true; } if (type.isSimpleType()) { // because we can't tell which package the type is in :-( return false; } if (type.isQualifiedType()) { return MethodUtils.isBuiltInValueType(asString(type)); } if (type.isWildcardType()) { return false; } return false; }
From source file:com.kodebeagle.javaparser.TypeResolver.java
License:Apache License
/** * @param type//from w ww .ja v a 2 s. c o m * @return */ protected String getNameOfType(final Type type) { String nameOfType = ""; if (type != null) { if (type.isPrimitiveType()) { nameOfType = type.toString(); } else if (type.isParameterizedType()) { nameOfType = getParametrizedType((ParameterizedType) type); } else if (type.isArrayType()) { final ArrayType array = (ArrayType) type; nameOfType = getNameOfType(array.getElementType()) /*+ "[]"*/; } else if (type.isUnionType()) { // TODO: this is used for exceptions till now // So we will just capture the first type that we encounter final UnionType uType = (UnionType) type; final StringBuffer sb = new StringBuffer(); for (final Object unionedType : uType.types()) { sb.append(getNameOfType(((Type) unionedType))); break; // sb.append(" | "); } // sb.delete(sb.length() - 3, sb.length()); nameOfType = sb.toString(); } else if (type.isWildcardType()) { final WildcardType wType = (WildcardType) type; nameOfType = (wType.isUpperBound() ? "? extends " : "? super ") + getNameOfType(wType.getBound()); } else { nameOfType = getFullyQualifiedNameFor(type.toString()); } } return nameOfType; }
From source file:com.tsc9526.monalisa.plugin.eclipse.generator.SelectGenerator.java
License:Open Source License
private void findSelectMethods() { Set<String> imps = new HashSet<String>(); for (MethodDeclaration md : unit.getUnitType().getMethods()) { Type rt = md.getReturnType2(); if (rt == null) continue; String returnClazz = rt.toString(); Set<String> returnParameter = new HashSet<String>(); if (rt.isParameterizedType()) { ParameterizedType ptype = (ParameterizedType) rt; returnClazz = ptype.getType().toString(); for (Object arg : ptype.typeArguments()) { returnParameter.add(arg.toString()); referTypes.add(arg.toString()); }//from w w w. j a v a2 s.c o m } else { referTypes.add(returnClazz); } Annotation a = unit.getAnnotation(md, Select.class); if (a != null) { SelectMethod sm = new SelectMethod(unit, md, a); String rcn = sm.getResultClassName(); String newReturnType = null; if (isCollectionType(returnClazz)) { String ps = returnParameter.size() > 0 ? returnParameter.iterator().next() : ""; if (ps.equals("") || isObjectOrDataMap(ps)) { newReturnType = returnClazz + "<" + rcn + ">"; imps.add(sm.getResultClassPackage() + "." + rcn); } else { if (rcn.equals(ps) == false && sm.isForceRenameResultClass()) { newReturnType = returnClazz + "<" + rcn + ">"; imps.add(sm.getResultClassPackage() + "." + rcn); } } } else if (isObjectOrDataMap(returnClazz)) { newReturnType = rcn; imps.add(sm.getResultClassPackage() + "." + rcn); } else { if (rcn.equals(returnClazz) == false && sm.isForceRenameResultClass()) { newReturnType = rcn; imps.add(sm.getResultClassPackage() + "." + rcn); } } if (newReturnType != null) { QueryRewriteVisitor rewrite = new QueryRewriteVisitor(rcn); md.accept(rewrite); List<ReplaceEdit> changes = rewrite.getChanges(); changes.add(new ReplaceEdit(rt.getStartPosition(), rt.getLength(), newReturnType)); for (ReplaceEdit re : changes) { edit.addChild(re); } sm.calculateFingerprint(changes); addSelectMethod(sm); } else if (sm.isChanged()) { addSelectMethod(sm); } } } if (imps.size() > 0) { TextEdit importEdit = unit.createImports(imps); edit.addChild(importEdit); } }
From source file:edu.uci.ics.sourcerer.extractor.ast.ReferenceExtractorVisitor.java
License:Open Source License
@SuppressWarnings("unchecked") private String getTypeFqn(Type type) { if (type == null) { logger.log(Level.SEVERE, "Attempt to get type fqn of null type!"); throw new NullPointerException("Attempt to get type fqn of null type!"); }//from ww w.jav a2 s. c om ITypeBinding binding = type.resolveBinding(); if (binding == null) { if (type.isPrimitiveType()) { return ((PrimitiveType) type).getPrimitiveTypeCode().toString(); } else if (type.isSimpleType()) { return getUnknownFqn(((SimpleType) type).getName().getFullyQualifiedName()); } else if (type.isArrayType()) { ArrayType arrayType = (ArrayType) type; Type elementType = arrayType.getElementType(); if (elementType == null) { return getUnknownFqn(BRACKETS.substring(0, 2 * arrayType.getDimensions())); } else { return getTypeFqn(elementType) + BRACKETS.substring(0, 2 * arrayType.getDimensions()); } } else if (type.isParameterizedType()) { ParameterizedType pType = (ParameterizedType) type; StringBuilder fqn = new StringBuilder(getTypeFqn(pType.getType())); fqn.append("<"); boolean isFirst = true; for (Type arg : (List<Type>) pType.typeArguments()) { if (isFirst) { isFirst = false; } else { fqn.append(","); } try { fqn.append(getTypeFqn(arg)); } catch (NullPointerException e) { logger.log(Level.WARNING, "Eclipse NPE bug in parametrized type", e); fqn.append(UNKNOWN); } } fqn.append(">"); return fqn.toString(); } else if (type.isWildcardType()) { WildcardType wType = (WildcardType) type; Type bound = wType.getBound(); if (bound == null) { return "<?>"; } else { return "<?" + (wType.isUpperBound() ? "+" : "-") + getTypeFqn(bound) + ">"; } } else { logger.log(Level.SEVERE, "Unexpected node type for unresolved type!" + type.toString()); return UNKNOWN; } } else { return getTypeFqn(binding); } }
From source file:edu.uci.ics.sourcerer.tools.java.extractor.eclipse.ReferenceExtractorVisitor.java
License:Open Source License
private String getErasedTypeFqn(Type type) { if (type == null) { logger.log(Level.SEVERE, "Attempt to get type fqn of null type!"); throw new NullPointerException("Attempt to get type fqn of null type!"); }//from w w w . j a v a 2s . c o m ITypeBinding binding = safeResolve(type); if (binding == null) { if (type.isPrimitiveType()) { return ((PrimitiveType) type).getPrimitiveTypeCode().toString(); } else if (type.isSimpleType()) { return createUnknownFqn(((SimpleType) type).getName().getFullyQualifiedName()); } else if (type.isArrayType()) { ArrayType arrayType = (ArrayType) type; Type elementType = arrayType.getElementType(); if (elementType == null) { return createUnknownFqn(BRACKETS.substring(0, 2 * arrayType.getDimensions())); } else { return getErasedTypeFqn(elementType) + BRACKETS.substring(0, 2 * arrayType.getDimensions()); } } else if (type.isParameterizedType()) { ParameterizedType pType = (ParameterizedType) type; return getErasedTypeFqn(pType.getType()); } else { logger.log(Level.SEVERE, "1 - Unexpected node type for unresolved type!" + type.toString()); return UNKNOWN; } } else { return getErasedTypeFqn(binding); } }