private static String fqTypeName(ITypeBinding type) { type = canonicalType(type); // TODO Need to get rid of type variables String type_name = type.getQualifiedName(); if ("".equals(type_name)) { // only okay if this is a top-level class. if (type.getDeclaringClass() != null) { return null; } // Will the 'else' branch _ever_ be taken? } return type.getQualifiedName(); }
/** * Ensures that creating a DOM AST and computing the bindings takes the owner's working copies * into account. * * @deprecated using deprecated code */ public void testParseCompilationUnit3() throws CoreException { try { createJavaProject("P1", new String[] {"src"}, new String[] {"JCL_LIB", "lib"}, "bin"); // create X.class in lib folder /* Evaluate the following in a scrapbook: org.eclipse.jdt.core.tests.model.ModifyingResourceTests.generateClassFile( "X", "public class X {\n" + "}") */ byte[] bytes = new byte[] { -54, -2, -70, -66, 0, 3, 0, 45, 0, 13, 1, 0, 1, 88, 7, 0, 1, 1, 0, 16, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 79, 98, 106, 101, 99, 116, 7, 0, 3, 1, 0, 6, 60, 105, 110, 105, 116, 62, 1, 0, 3, 40, 41, 86, 1, 0, 4, 67, 111, 100, 101, 12, 0, 5, 0, 6, 10, 0, 4, 0, 8, 1, 0, 15, 76, 105, 110, 101, 78, 117, 109, 98, 101, 114, 84, 97, 98, 108, 101, 1, 0, 10, 83, 111, 117, 114, 99, 101, 70, 105, 108, 101, 1, 0, 6, 88, 46, 106, 97, 118, 97, 0, 33, 0, 2, 0, 4, 0, 0, 0, 0, 0, 1, 0, 1, 0, 5, 0, 6, 0, 1, 0, 7, 0, 0, 0, 29, 0, 1, 0, 1, 0, 0, 0, 5, 42, -73, 0, 9, -79, 0, 0, 0, 1, 0, 10, 0, 0, 0, 6, 0, 1, 0, 0, 0, 1, 0, 1, 0, 11, 0, 0, 0, 2, 0, 12, }; this.createFile("P1/lib/X.class", bytes); // create libsrc and attach source createFolder("P1/libsrc"); createFile("P1/libsrc/X.java", "public class X extends Y {\n" + "}"); IPackageFragmentRoot lib = getPackageFragmentRoot("P1/lib"); lib.attachSource(new Path("/P1/libsrc"), null, null); // create Y.java in src folder createFile("P1/src/Y.java", ""); // create working copy on Y.java TestWorkingCopyOwner owner = new TestWorkingCopyOwner(); this.workingCopy = getCompilationUnit("P1/src/Y.java").getWorkingCopy(owner, null); this.workingCopy.getBuffer().setContents("public class Y {\n" + "}"); this.workingCopy.makeConsistent(null); // parse and resolve class file IClassFile classFile = getClassFile("P1/lib/X.class"); ASTParser parser = ASTParser.newParser(AST.JLS2); parser.setSource(classFile); parser.setResolveBindings(true); parser.setWorkingCopyOwner(owner); CompilationUnit cu = (CompilationUnit) parser.createAST(null); List types = cu.types(); assertEquals("Unexpected number of types in AST", 1, types.size()); TypeDeclaration type = (TypeDeclaration) types.get(0); ITypeBinding typeBinding = type.resolveBinding(); ITypeBinding superType = typeBinding.getSuperclass(); assertEquals( "Unexpected super type", "Y", superType == null ? "<null>" : superType.getQualifiedName()); } finally { deleteProject("P1"); } }
// Função auxiliar para copiar o tipo da variável // considerando que um tipo nao pode pertencer a outra AST private Type getType(ITypeBinding typeBinding, AST newAST) { if (typeBinding.isPrimitive()) { return newAST.newPrimitiveType(PrimitiveType.toCode(typeBinding.getName())); } else if (typeBinding.isArray()) { return newAST.newArrayType( this.getType(typeBinding.getElementType(), newAST), typeBinding.getDimensions()); } else if (typeBinding.isParameterizedType()) { ParameterizedType pt = newAST.newParameterizedType(this.getType(typeBinding.getTypeDeclaration(), newAST)); for (ITypeBinding itb : typeBinding.getTypeArguments()) { pt.typeArguments().add(this.getType(itb, newAST)); } return pt; } else if (typeBinding.isWildcardType()) { WildcardType wt = newAST.newWildcardType(); wt.setBound( typeBinding.getBound() == null ? null : this.getType(typeBinding.getBound(), newAST), typeBinding.isUpperbound()); return wt; } else { try { return newAST.newSimpleType(newAST.newName(typeBinding.getQualifiedName())); } catch (Exception e) { return newAST.newSimpleType(newAST.newName(typeBinding.getName())); } } }
// Metodo para tratamento de declarações de métodos private void methodDeclarationHandler(MethodDeclaration methodDeclaration, ApiClass apiClass) { IMethodBinding mb = methodDeclaration.resolveBinding(); if (mb == null) { return; } LinkedList<String> paramsType = new LinkedList<String>(); for (ITypeBinding pt : mb.getParameterTypes()) { paramsType.add(pt.getQualifiedName().toString()); } ApiMethod apiMethod = new ApiMethod(apiClass, mb.getName(), paramsType); this.setModifiers(apiMethod, methodDeclaration); if (mb.isConstructor()) { apiMethod.setConstructor(true); apiMethod.setVoid(false); apiMethod.setFunction(false); apiMethod.setReturnType(null); } else if (mb.getReturnType().getQualifiedName().equalsIgnoreCase("void")) { apiMethod.setVoid(true); apiMethod.setFunction(false); apiMethod.setReturnType(null); } else { apiMethod.setVoid(false); apiMethod.setFunction(true); apiMethod.setReturnType(mb.getReturnType().getQualifiedName()); } apiClass.getApiMethods().add(apiMethod); this.methodMap.put(mb, apiMethod); }
public TypeName(ITypeBinding binding, boolean varargs) { this.varargs = varargs; ITypeBinding inner = binding; if (varargs) { dimensions = 1; } else { int dims = 0; while (inner.isArray()) { inner = inner.getComponentType(); dims += 1; } dimensions = dims; } if (inner.isParameterizedType()) { inner = inner.getErasure(); } ITypeBinding parent = inner; int nesting = 0; while (parent.isNested()) { nesting++; parent = parent.getDeclaringClass(); } nestingLevel = nesting; primitive = inner.isPrimitive(); baseQualifiedName = adaptQualifiedName(inner.getQualifiedName()); baseBinaryName = inner.getBinaryName(); shortName = buildShortName(); qualifiedName = buildQualifiedName(); binaryName = buildBinaryName(); }
public static void getInvalidQualificationProposals( IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { ASTNode node = problem.getCoveringNode(context.getASTRoot()); if (!(node instanceof Name)) { return; } Name name = (Name) node; IBinding binding = name.resolveBinding(); if (!(binding instanceof ITypeBinding)) { return; } ITypeBinding typeBinding = (ITypeBinding) binding; AST ast = node.getAST(); ASTRewrite rewrite = ASTRewrite.create(ast); rewrite.replace(name, ast.newName(typeBinding.getQualifiedName()), null); String label = CorrectionMessages.JavadocTagsSubProcessor_qualifylinktoinner_description; Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); ASTRewriteCorrectionProposal proposal = new ASTRewriteCorrectionProposal( label, context.getCompilationUnit(), rewrite, IProposalRelevance.QUALIFY_INNER_TYPE_NAME, image); proposals.add(proposal); }
public static boolean hasAnnotation(Class<?> annotationClass, List<Annotation> annotations) { for (Annotation annotation : annotations) { ITypeBinding annotationType = annotation.getAnnotationBinding().getAnnotationType(); if (annotationType.getQualifiedName().equals(annotationClass.getName())) { return true; } } return false; }
private SmellyClass getPossibleRole(ITypeBinding tb) { String className = tb.getQualifiedName(); SmellyClass possibleService; if (tb.isInterface()) { List<SmellyClass> subtypes = repo.getSubtypesOf(className); possibleService = findRole(subtypes); } else { possibleService = repo.getByClass(className); } return possibleService; }
/** @since 2.4 */ protected SegmentSequence.Builder getQualifiedName( ITypeBinding binding, SegmentSequence.Builder builder) { if (binding.isParameterizedType()) { getQualifiedName(binding.getErasure(), builder); } else if (binding.isArray()) { getQualifiedName(binding.getComponentType(), builder).append("[]"); } else if (binding.isTopLevel() || binding.isTypeVariable() || binding.isPrimitive()) { builder.append(binding.getQualifiedName()); } else { getQualifiedName(binding.getDeclaringClass(), builder).append('$').append(binding.getName()); } return builder; }
/** @since 2.4 */ public StringBuilder getQualifiedName(ITypeBinding binding, StringBuilder stringBuilder) { if (binding.isParameterizedType()) { getQualifiedName(binding.getErasure(), stringBuilder); } else if (binding.isArray()) { getQualifiedName(binding.getComponentType(), stringBuilder).append("[]"); } else if (binding.isTopLevel() || binding.isTypeVariable() || binding.isPrimitive()) { stringBuilder.append(binding.getQualifiedName()); } else { getQualifiedName(binding.getDeclaringClass(), stringBuilder) .append('$') .append(binding.getName()); } return stringBuilder; }
@SuppressWarnings("unchecked") // copied from // org.eclipse.jdt.internal.ui.text.correction.ModifierCorrectionSubProcessor private Annotation findAnnotation(List modifiers) { for (int i = 0; i < modifiers.size(); i++) { Object curr = modifiers.get(i); if (curr instanceof Annotation) { Annotation annot = (Annotation) curr; ITypeBinding binding = annot.getTypeName().resolveTypeBinding(); if (binding != null && "java.lang.Deprecated".equals(binding.getQualifiedName())) { return annot; } } } return null; }
public String getQualifiedName(ITypeBinding binding) { if (binding.isParameterizedType()) { return getQualifiedName(binding.getErasure()); } if (binding.isArray()) { return getQualifiedName(binding.getComponentType(), new StringBuilder()) .append("[]") .toString(); } if (binding.isTopLevel() || binding.isTypeVariable() || binding.isPrimitive()) return binding.getQualifiedName(); return getQualifiedName(binding.getDeclaringClass(), new StringBuilder()) .append('$') .append(binding.getName()) .toString(); }
private void printMethods(TypeDeclaration node) { printMethodsAndOcni(node, Arrays.asList(node.getMethods()), blockComments.get(node)); // If node implements CharSequence, add forwarding method from the // sequenceDescription method to description (toString()). See // JavaToIOSMethodTranslator.loadCharSequenceMethods() for details. ITypeBinding binding = Types.getTypeBinding(node); for (ITypeBinding interfaze : binding.getInterfaces()) { if (interfaze.getQualifiedName().equals("java.lang.CharSequence")) { println("- (NSString *)description {\n return [self sequenceDescription];\n}\n"); } } List<VariableDeclarationFragment> properties = getProperties(node.getFields()); if (properties.size() > 0) { printStrongReferencesMethod(properties); } }
/** * Tests if the used type is contained in the project containing the type use. * * @param tbinding the type binding of the type use * @return <code>true</code> if the used type is contained in the project, otherwise <code>false * </code> */ private boolean isInProject(ITypeBinding tbinding) { IJavaProject project = jproject.getJavaProject(); if (project == null) { return true; } try { IType type = project.findType(tbinding.getQualifiedName()); if (type != null) { String pdir = project.getPath().toString(); String tname = type.getPath().toString(); return pdir != null && tname != null && tname.startsWith(pdir); } } catch (JavaModelException e) { return false; } return false; }
@Override public boolean visit(SimpleName node) { IBinding binding = node.resolveBinding(); if (binding != null && binding instanceof ITypeBinding) { ITypeBinding tb = (ITypeBinding) binding; String className = tb.getQualifiedName(); SmellyClass possibleRole = getPossibleRole(tb); boolean notMySelf = possibleRole != null && !possibleRole.equals(clazz); if (possibleRole != null && possibleRole.is(ar) && notMySelf) { clazz.appendNote(attributeName + "-violations", className); roles.add(className); clazz.setAttribute(attributeName, roles.size()); } } return super.visit(node); }
/* * Must be one of: * <ul> * <li>int [result]= 0;</li> * <li>int [result]= 0, [lengthBinding]= [arrayBinding].length;</li> * <li>int , [result]= 0;</li> * </ul> */ private boolean validateInitializers(ForStatement statement) { List<Expression> initializers = statement.initializers(); if (initializers.size() != 1) return false; Expression expression = initializers.get(0); if (!(expression instanceof VariableDeclarationExpression)) return false; VariableDeclarationExpression declaration = (VariableDeclarationExpression) expression; ITypeBinding declarationBinding = declaration.resolveTypeBinding(); if (declarationBinding == null) return false; if (!declarationBinding.isPrimitive()) return false; if (!PrimitiveType.INT.toString().equals(declarationBinding.getQualifiedName())) return false; List<VariableDeclarationFragment> fragments = declaration.fragments(); if (fragments.size() == 1) { IVariableBinding indexBinding = getIndexBindingFromFragment(fragments.get(0)); if (indexBinding == null) return false; fIndexBinding = indexBinding; return true; } else if (fragments.size() == 2) { IVariableBinding indexBinding = getIndexBindingFromFragment(fragments.get(0)); if (indexBinding == null) { indexBinding = getIndexBindingFromFragment(fragments.get(1)); if (indexBinding == null) return false; if (!validateLengthFragment(fragments.get(0))) return false; } else { if (!validateLengthFragment(fragments.get(1))) return false; } fIndexBinding = indexBinding; return true; } return false; }
@Override public boolean visit(TypeDeclaration node) { if (node.isPackageMemberTypeDeclaration() || node.isMemberTypeDeclaration()) { ITypeBinding typeBinding = node.resolveBinding(); if (typeBinding != null) { // Criando classe ApiClass apiClass = new ApiClass(typeBinding.getQualifiedName()); apiClass.setInterface(typeBinding.isInterface()); this.setModifiers(apiClass, node); this.classMap.put(typeBinding, apiClass); if (!this.attachmentMap.containsKey(node.getRoot())) { Attachment attachment = new Attachment( typeBinding.getQualifiedName().concat(".java"), node.getRoot().toString().getBytes()); this.attachmentMap.put(node.getRoot(), attachment); } List<MethodDeclaration> declarations = new LinkedList<MethodDeclaration>(); for (Object o : node.bodyDeclarations()) { if (o instanceof MethodDeclaration) { declarations.add((MethodDeclaration) o); } } for (final MethodDeclaration declaration : declarations) { final List<Expression> invocations = new LinkedList<Expression>(); this.methodDeclarationHandler(declaration, apiClass); InvocationVisitor visitor = new InvocationVisitor(); declaration.accept(visitor); invocations.addAll(visitor.invocations); // Parte de extracao de exemplos, se não houver invocações eu pulo esta parte if (invocations.isEmpty()) { continue; } else { // Faço a extração de exemplos para cada invocação em separado Set<ApiMethod> methodsInvocations = new HashSet<ApiMethod>(); for (Expression mi : invocations) { methodsInvocations.add(this.mapInvocations.get(mi)); Example newExample = makeExample( declaration, Collections.singleton(mi), Collections.singletonList(this.mapInvocations.get(mi))); if (newExample != null) { this.examples.add(newExample); } } // Se houver mais de uma invocacao faço o slicing com sementes multiplas if (invocations.size() > 1) { // Itero sobre os conjuntos das regras Iterator<Set<ApiMethod>> it = this.methodSets.iterator(); while (it.hasNext()) { // Podando conjuntos Set<ApiMethod> s = it.next(); if (s.size() > methodsInvocations.size()) { break; } else { // Se as invocacoes identificadas envolvem metodos desejados eu processo if (methodsInvocations.containsAll(s)) { List<ApiMethod> methods = new ArrayList<ApiMethod>(); Set<Expression> invocationsTemp = new HashSet<Expression>(); for (Expression mi : invocations) { ApiMethod relatedMethod = this.mapInvocations.get(mi); if (s.contains(relatedMethod)) { methods.add(relatedMethod); invocationsTemp.add(mi); } } Example newExample = makeExample(declaration, invocationsTemp, methods); if (newExample != null) { this.examples.add(newExample); } } } } } } } } } return super.visit(node); }
public static boolean typeEqualsClass(ITypeBinding type, Class<?> cls) { return type.getQualifiedName().equals(cls.getName()); }
private List<ClassObject> parseAST(CompilationUnit compilationUnit, IFile iFile) { List<ClassObject> classObjects = new ArrayList<ClassObject>(); List<AbstractTypeDeclaration> topLevelTypeDeclarations = compilationUnit.types(); for (AbstractTypeDeclaration abstractTypeDeclaration : topLevelTypeDeclarations) { if (abstractTypeDeclaration instanceof TypeDeclaration) { TypeDeclaration topLevelTypeDeclaration = (TypeDeclaration) abstractTypeDeclaration; List<TypeDeclaration> typeDeclarations = new ArrayList<TypeDeclaration>(); typeDeclarations.add(topLevelTypeDeclaration); typeDeclarations.addAll(getRecursivelyInnerTypes(topLevelTypeDeclaration)); for (TypeDeclaration typeDeclaration : typeDeclarations) { final ClassObject classObject = new ClassObject(); classObject.setIFile(iFile); classObject.setName(typeDeclaration.resolveBinding().getQualifiedName()); classObject.setTypeDeclaration(typeDeclaration); if (typeDeclaration.isInterface()) { classObject.setInterface(true); } int modifiers = typeDeclaration.getModifiers(); if ((modifiers & Modifier.ABSTRACT) != 0) classObject.setAbstract(true); if ((modifiers & Modifier.PUBLIC) != 0) classObject.setAccess(Access.PUBLIC); else if ((modifiers & Modifier.PROTECTED) != 0) classObject.setAccess(Access.PROTECTED); else if ((modifiers & Modifier.PRIVATE) != 0) classObject.setAccess(Access.PRIVATE); else classObject.setAccess(Access.NONE); if ((modifiers & Modifier.STATIC) != 0) classObject.setStatic(true); Type superclassType = typeDeclaration.getSuperclassType(); if (superclassType != null) { ITypeBinding binding = superclassType.resolveBinding(); String qualifiedName = binding.getQualifiedName(); TypeObject typeObject = TypeObject.extractTypeObject(qualifiedName); classObject.setSuperclass(typeObject); } List<Type> superInterfaceTypes = typeDeclaration.superInterfaceTypes(); for (Type interfaceType : superInterfaceTypes) { ITypeBinding binding = interfaceType.resolveBinding(); String qualifiedName = binding.getQualifiedName(); TypeObject typeObject = TypeObject.extractTypeObject(qualifiedName); classObject.addInterface(typeObject); } FieldDeclaration[] fieldDeclarations = typeDeclaration.getFields(); for (FieldDeclaration fieldDeclaration : fieldDeclarations) { Type fieldType = fieldDeclaration.getType(); ITypeBinding binding = fieldType.resolveBinding(); List<VariableDeclarationFragment> fragments = fieldDeclaration.fragments(); for (VariableDeclarationFragment fragment : fragments) { String qualifiedName = binding.getQualifiedName(); TypeObject typeObject = TypeObject.extractTypeObject(qualifiedName); typeObject.setArrayDimension( typeObject.getArrayDimension() + fragment.getExtraDimensions()); FieldObject fieldObject = new FieldObject(typeObject, fragment.getName().getIdentifier()); fieldObject.setClassName(classObject.getName()); fieldObject.setVariableDeclarationFragment(fragment); int fieldModifiers = fieldDeclaration.getModifiers(); if ((fieldModifiers & Modifier.PUBLIC) != 0) fieldObject.setAccess(Access.PUBLIC); else if ((fieldModifiers & Modifier.PROTECTED) != 0) fieldObject.setAccess(Access.PROTECTED); else if ((fieldModifiers & Modifier.PRIVATE) != 0) fieldObject.setAccess(Access.PRIVATE); else fieldObject.setAccess(Access.NONE); if ((fieldModifiers & Modifier.STATIC) != 0) fieldObject.setStatic(true); classObject.addField(fieldObject); } } MethodDeclaration[] methodDeclarations = typeDeclaration.getMethods(); for (MethodDeclaration methodDeclaration : methodDeclarations) { String methodName = methodDeclaration.getName().getIdentifier(); final ConstructorObject constructorObject = new ConstructorObject(); constructorObject.setMethodDeclaration(methodDeclaration); constructorObject.setName(methodName); constructorObject.setClassName(classObject.getName()); int methodModifiers = methodDeclaration.getModifiers(); if ((methodModifiers & Modifier.PUBLIC) != 0) constructorObject.setAccess(Access.PUBLIC); else if ((methodModifiers & Modifier.PROTECTED) != 0) constructorObject.setAccess(Access.PROTECTED); else if ((methodModifiers & Modifier.PRIVATE) != 0) constructorObject.setAccess(Access.PRIVATE); else constructorObject.setAccess(Access.NONE); List<SingleVariableDeclaration> parameters = methodDeclaration.parameters(); for (SingleVariableDeclaration parameter : parameters) { Type parameterType = parameter.getType(); ITypeBinding binding = parameterType.resolveBinding(); String qualifiedName = binding.getQualifiedName(); TypeObject typeObject = TypeObject.extractTypeObject(qualifiedName); typeObject.setArrayDimension( typeObject.getArrayDimension() + parameter.getExtraDimensions()); if (parameter.isVarargs()) { typeObject.setArrayDimension(1); } ParameterObject parameterObject = new ParameterObject(typeObject, parameter.getName().getIdentifier()); parameterObject.setSingleVariableDeclaration(parameter); constructorObject.addParameter(parameterObject); } Block methodBody = methodDeclaration.getBody(); if (methodBody != null) { MethodBodyObject methodBodyObject = new MethodBodyObject(methodBody); constructorObject.setMethodBody(methodBodyObject); } if (methodDeclaration.isConstructor()) { classObject.addConstructor(constructorObject); } else { MethodObject methodObject = new MethodObject(constructorObject); List<IExtendedModifier> extendedModifiers = methodDeclaration.modifiers(); for (IExtendedModifier extendedModifier : extendedModifiers) { if (extendedModifier.isAnnotation()) { Annotation annotation = (Annotation) extendedModifier; if (annotation.getTypeName().getFullyQualifiedName().equals("Test")) { methodObject.setTestAnnotation(true); break; } } } Type returnType = methodDeclaration.getReturnType2(); ITypeBinding binding = returnType.resolveBinding(); String qualifiedName = binding.getQualifiedName(); TypeObject typeObject = TypeObject.extractTypeObject(qualifiedName); methodObject.setReturnType(typeObject); if ((methodModifiers & Modifier.ABSTRACT) != 0) methodObject.setAbstract(true); if ((methodModifiers & Modifier.STATIC) != 0) methodObject.setStatic(true); if ((methodModifiers & Modifier.SYNCHRONIZED) != 0) methodObject.setSynchronized(true); if ((methodModifiers & Modifier.NATIVE) != 0) methodObject.setNative(true); classObject.addMethod(methodObject); FieldInstructionObject fieldInstruction = methodObject.isGetter(); if (fieldInstruction != null) systemObject.addGetter(methodObject.generateMethodInvocation(), fieldInstruction); fieldInstruction = methodObject.isSetter(); if (fieldInstruction != null) systemObject.addSetter(methodObject.generateMethodInvocation(), fieldInstruction); fieldInstruction = methodObject.isCollectionAdder(); if (fieldInstruction != null) systemObject.addCollectionAdder( methodObject.generateMethodInvocation(), fieldInstruction); MethodInvocationObject methodInvocation = methodObject.isDelegate(); if (methodInvocation != null) systemObject.addDelegate(methodObject.generateMethodInvocation(), methodInvocation); } } classObjects.add(classObject); } } } return classObjects; }
/** * Create an instance based on a JDT type. * * <p>The location, context and warnings parameters are used for raising warnings when the type * bindings cannot be resolved. */ public TypeName( Type t, boolean varargs, String location, String context, Set<DocumentationWarning> warnings) { this.varargs = varargs; // Try to resolve the binding. ITypeBinding binding = t.resolveBinding(); // If binding was resolved, then use it to extract the names. if (binding != null) { ITypeBinding inner = binding; if (varargs) { dimensions = 1; } else { int dims = 0; while (inner.isArray()) { inner = inner.getComponentType(); dims += 1; } dimensions = dims; } if (inner.isParameterizedType()) { inner = inner.getErasure(); } ITypeBinding parent = inner; int nesting = 0; while (parent.isNested()) { nesting++; parent = parent.getDeclaringClass(); } nestingLevel = nesting; primitive = inner.isPrimitive(); baseQualifiedName = adaptQualifiedName(inner.getQualifiedName()); baseBinaryName = inner.getBinaryName(); } // If the binding was not resolved, then use the type name anyway. // This may not be accurate, but is better than nothing. // Also raise a warning in this case. else { String rawName = t.toString(); int idx = rawName.indexOf("["); if (idx >= 0) { baseQualifiedName = rawName.substring(0, idx); String dimPart = rawName.substring(idx); dimensions = dimPart.length() / 2; } else { baseQualifiedName = rawName; dimensions = 0; } nestingLevel = 0; baseBinaryName = baseQualifiedName; primitive = t.isPrimitiveType(); DocumentationWarning dw = new DocumentationWarning( WarningType.UnresolvedBinding, location, "Cannot resolve binding for " + context + " type: '" + baseQualifiedName + "'."); warnings.add(dw); } shortName = buildShortName(); qualifiedName = buildQualifiedName(); binaryName = buildBinaryName(); }