@Override public String getQualifiedName() { return imprt.getName().getFullyQualifiedName(); }
@Override public String toString() { return this.name.toString(); } }
public static boolean isExtractableExpression(ASTNode node) { if (!(node instanceof Expression)) return false; if (node instanceof Name) { IBinding binding= ((Name) node).resolveBinding(); return !(binding instanceof ITypeBinding); } return true; }
public static String getQualifier(Name name) { if (name.isQualifiedName()) { return ((QualifiedName) name).getQualifier().getFullyQualifiedName(); } return ""; //$NON-NLS-1$ }
public String initialize(CompilationUnit root, ASTNode node) { if (!(node instanceof Name)) return SearchMessages.OccurrencesFinder_no_element; fRoot= root; fSelectedNode= (Name)node; fTarget= fSelectedNode.resolveBinding(); if (fTarget == null) return SearchMessages.OccurrencesFinder_no_binding; fTarget= getBindingDeclaration(fTarget); fTargetIsStaticMethodImport= isStaticImport(fSelectedNode.getParent()); return null; }
@Override public boolean visit(SimpleType type) { if (type.getName().isSimpleName()) { ignoredSimpleNames.add(type.getName().getFullyQualifiedName()); } return true; } };
private boolean addPossibleStaticImport(Name node, IMethodBinding binding) { if (binding == null || node == null || !(fTarget instanceof IMethodBinding) || !Modifier.isStatic(binding.getModifiers())) return false; IMethodBinding targetMethodBinding= (IMethodBinding)fTarget; if ((fTargetIsStaticMethodImport || Modifier.isStatic(targetMethodBinding.getModifiers())) && (targetMethodBinding.getDeclaringClass().getTypeDeclaration() == binding.getDeclaringClass().getTypeDeclaration())) { if (node.getFullyQualifiedName().equals(targetMethodBinding.getName())) { fResult.add(new OccurrenceLocation(node.getStartPosition(), node.getLength(), 0, fReadDescription)); return true; } } return false; }
IPackageFragment enclosingPackage= null; IType enclosingType= null; if (node.isSimpleName()) { enclosingPackage= (IPackageFragment) cu.getParent(); IBinding binding= qualifierName.resolveBinding(); if (binding != null && binding.isRecovered()) { binding= null; enclosingPackage= (IPackageFragment) binding.getJavaElement(); } else { IJavaElement[] res= cu.codeSelect(qualifierName.getStartPosition(), qualifierName.getLength()); if (res!= null && res.length > 0 && res[0] instanceof IType) { enclosingType= (IType) res[0]; if (refNode.isSimpleName() && ((kind & SimilarElementsRequestor.VARIABLES) != 0)) { CompilationUnit root= (CompilationUnit) refNode.getRoot(); String name= ((SimpleName) refNode).getIdentifier(); BodyDeclaration declaration= ASTResolving.findParentBodyDeclaration(refNode);
@Override public final void endVisit(final QualifiedName node) { final ASTNode parent= node.getParent(); final Name qualifier= node.getQualifier(); IBinding binding= qualifier.resolveBinding(); if (binding instanceof ITypeBinding) { final ConstraintVariable2 variable= fModel.createTypeVariable((ITypeBinding) binding, new CompilationUnitRange(RefactoringASTParser.getCompilationUnit(node), new SourceRange(qualifier.getStartPosition(), qualifier.getLength()))); if (variable != null) qualifier.setProperty(PROPERTY_CONSTRAINT_VARIABLE, variable); } binding= node.getName().resolveBinding(); if (binding instanceof IVariableBinding && !(parent instanceof ImportDeclaration)) endVisit((IVariableBinding) binding, qualifier, node); else if (binding instanceof ITypeBinding && parent instanceof MethodDeclaration) endVisit((ITypeBinding) binding, node); }
@Override public boolean visit(ImportDeclaration node) { String name = node.getName().toString(); if (node.isOnDemand()) { wildcardImports.add(name); Iterable<JavaClassModel> classModels = javaClassService.findByJavaPackage(name); for (JavaClassModel classModel : classModels) { processImport(classModel.getQualifiedName(), cu.getLineNumber(node.getName().getStartPosition()), cu.getColumnNumber(node.getName().getStartPosition()), node.getName().getLength()); } } else { String clzName = StringUtils.substringAfterLast(name, "."); classNameLookedUp.add(clzName); classNameToFQCN.put(clzName, name); processImport(node.getName().toString(), cu.getLineNumber(node.getName().getStartPosition()), cu.getColumnNumber(node.getName().getStartPosition()), node.getName().getLength()); } return super.visit(node); }
typeBinding= ((VariableDeclarationExpression) variable).getType().resolveBinding(); } else if (variable instanceof Name) { typeBinding= ((Name) variable).resolveTypeBinding(); fResult.add(new OccurrenceLocation(name.getStartPosition(), name.getLength(), 0, fDescription));
private void possibleTypeRefFound(Name node) { while (node.isQualifiedName()) { node= ((QualifiedName) node).getQualifier(); } IBinding binding= node.resolveBinding(); if (binding == null || binding.getKind() == IBinding.TYPE) { // if the binding is null, we cannot determine if // we have a type binding or not, so we will assume // we do. addReference((SimpleName) node); } }
private boolean addUsage(Name node, IBinding binding) { if (binding != null && Bindings.equals(getBindingDeclaration(binding), fTarget)) { int flag= 0; String description= fReadDescription; if (fTarget instanceof IVariableBinding) { boolean isWrite= fWriteUsages.remove(node); flag= isWrite ? F_WRITE_OCCURRENCE : F_READ_OCCURRENCE; if (isWrite) description= fWriteDescription; } fResult.add(new OccurrenceLocation(node.getStartPosition(), node.getLength(), flag, description)); return true; } return false; }
private boolean isOfType(final Name name) { if (hasType(name.resolveTypeBinding(), getPrimitiveTypeName())) { return true; } else if (hasType(name.resolveTypeBinding(), getWrapperFullyQualifiedName())) { autoBoxingCount++; return true; } else { return false; } } }
/** * Returns the standard dot-separated representation of this name. * If the name is a simple name, the result is the name's identifier. * If the name is a qualified name, the result is the name of the qualifier * (as computed by this method) followed by "." followed by the name's * identifier. * * @return the fully qualified name * @since 3.0 */ public final String getFullyQualifiedName() { if (isSimpleName()) { // avoid creating garbage for common case return ((SimpleName) this).getIdentifier(); } else { StringBuffer buffer = new StringBuffer(50); appendName(buffer); return new String(buffer); } }
private void typeRefFound(Name node) { if (node != null) { while (node.isQualifiedName()) { node= ((QualifiedName) node).getQualifier(); } addReference((SimpleName) node); } }
protected Object createFieldReference(Object receiver) throws InvalidInputException { try { MemberRef fieldRef = this.ast.newMemberRef(); SimpleName fieldName = new SimpleName(this.ast); fieldName.internalSetIdentifier(new String(this.identifierStack[0])); fieldRef.setName(fieldName); int start = (int) (this.identifierPositionStack[0] >>> 32); int end = (int) this.identifierPositionStack[0]; fieldName.setSourceRange(start, end - start + 1); if (receiver == null) { start = this.memberStart; fieldRef.setSourceRange(start, end - start + 1); } else { Name typeRef = (Name) receiver; fieldRef.setQualifier(typeRef); start = typeRef.getStartPosition(); end = fieldName.getStartPosition()+fieldName.getLength()-1; fieldRef.setSourceRange(start, end-start+1); } return fieldRef; } catch (ClassCastException ex) { throw new InvalidInputException(); } } /* (non-Javadoc)
public boolean isMissingType(final Type type) { if ((type instanceof SimpleType)) { boolean _isSimpleName = ((SimpleType)type).getName().isSimpleName(); if (_isSimpleName) { Name _name = ((SimpleType)type).getName(); return "MISSING".equals(((SimpleName) _name).getIdentifier()); } } return false; }
public static String getQualifier(Name name) { if (name.isQualifiedName()) { return ((QualifiedName) name).getQualifier().getFullyQualifiedName(); } return ""; //$NON-NLS-1$ }
private boolean addPossibleStaticImport(Name node, IMethodBinding binding) { if (binding == null || node == null || !(fTarget instanceof IMethodBinding) || !Modifier.isStatic(binding.getModifiers())) return false; IMethodBinding targetMethodBinding= (IMethodBinding)fTarget; if ((fTargetIsStaticMethodImport || Modifier.isStatic(targetMethodBinding.getModifiers())) && (targetMethodBinding.getDeclaringClass().getTypeDeclaration() == binding.getDeclaringClass().getTypeDeclaration())) { if (node.getFullyQualifiedName().equals(targetMethodBinding.getName())) { fResult.add(new OccurrenceLocation(node.getStartPosition(), node.getLength(), 0, fReadDescription)); return true; } } return false; }