@Override public final boolean visit(final SimpleName node) { Assert.isNotNull(node); final ITypeBinding binding= node.resolveTypeBinding(); if (binding != null && binding.isTypeVariable() && !fBindings.containsKey(binding.getKey())) { fBindings.put(binding.getKey(), binding); fFound.add(binding); } return true; }
public final boolean visit(final SimpleName node) { Assert.isNotNull(node); final ITypeBinding binding= node.resolveTypeBinding(); if (binding != null && binding.isTypeVariable() && !fBindings.containsKey(binding.getKey())) { fBindings.put(binding.getKey(), binding); fFound.add(binding); } return true; }
@Override public final boolean visit(final SimpleName node) { Assert.isNotNull(node); final ITypeBinding binding= node.resolveTypeBinding(); if (binding != null && binding.isTypeVariable() && !fBindings.containsKey(binding.getKey())) { fBindings.put(binding.getKey(), binding); fFound.add(binding); } return true; }
public boolean match(SimpleName node, Object other) { boolean isomorphic= super.match(node, other); if (! isomorphic || !(other instanceof SimpleName)) return false; SimpleName name= (SimpleName)other; IBinding nodeBinding= node.resolveBinding(); IBinding otherBinding= name.resolveBinding(); if (nodeBinding == null) { if (otherBinding != null) { return false; } } else { if (nodeBinding != otherBinding) { return false; } } if (node.resolveTypeBinding() != name.resolveTypeBinding()) return false; return true; }
@Override public boolean match(SimpleName node, Object other) { boolean isomorphic = super.match(node, other); if (!isomorphic || !(other instanceof SimpleName)) { return false; } SimpleName name = (SimpleName) other; IBinding nodeBinding = node.resolveBinding(); IBinding otherBinding = name.resolveBinding(); if (nodeBinding == null) { if (otherBinding != null) { return false; } } else { if (nodeBinding != otherBinding) { return false; } } if (node.resolveTypeBinding() != name.resolveTypeBinding()) { return false; } return true; }
@Override public boolean match(SimpleName node, Object other) { boolean isomorphic= super.match(node, other); if (! isomorphic || !(other instanceof SimpleName)) return false; SimpleName name= (SimpleName)other; IBinding nodeBinding= node.resolveBinding(); IBinding otherBinding= name.resolveBinding(); if (nodeBinding == null) { if (otherBinding != null) { return false; } } else { if (nodeBinding != otherBinding) { return false; } } if (node.resolveTypeBinding() != name.resolveTypeBinding()) return false; return true; }
@Override public boolean match(SimpleName node, Object other) { boolean isomorphic= super.match(node, other); if (! isomorphic || !(other instanceof SimpleName)) return false; SimpleName name= (SimpleName)other; IBinding nodeBinding= node.resolveBinding(); IBinding otherBinding= name.resolveBinding(); if (nodeBinding == null) { if (otherBinding != null) { return false; } } else { if (nodeBinding != otherBinding) { return false; } } if (node.resolveTypeBinding() != name.resolveTypeBinding()) return false; return true; }
public boolean visit(SimpleName node) { ITypeBinding binding= node.resolveTypeBinding(); if (binding != null) { boolean res= fVisitor.visit(binding); if (res) { res= Bindings.visitHierarchy(binding, fVisitor); } if (!res) { throw new VisitCancelledException(); } } return false; } }
@Override public boolean visit(SimpleName node) { ITypeBinding binding= node.resolveTypeBinding(); if (binding != null) { boolean res= fVisitor.visit(binding); if (res) { res= Bindings.visitHierarchy(binding, fVisitor); } if (!res) { throw new VisitCancelledException(); } } return false; } }
@Override public boolean visit(SimpleName node) { ITypeBinding binding= node.resolveTypeBinding(); if (binding != null) { boolean res= fVisitor.visit(binding); if (res) { res= Bindings.visitHierarchy(binding, fVisitor); } if (!res) { throw new VisitCancelledException(); } } return false; } }
@Override public final boolean visit(final VariableDeclarationFragment node) { if (node.getInitializer() instanceof NullLiteral) { SimpleName name= node.getName(); if (elementType.equals(name.resolveTypeBinding()) && fElementVariable.equals(name.resolveBinding())) { fOccurrences.add(name); } } return true; } });
@Override public final boolean visit(final VariableDeclarationFragment node) { if (node.getInitializer() instanceof NullLiteral) { SimpleName name= node.getName(); if (elementType.equals(name.resolveTypeBinding()) && fElementVariable.equals(name.resolveBinding())) { fOccurrences.add(name); } } return true; } });
private boolean canVarOccurrenceBeRefactored0(final Block node, final List<VariableDeclaration> varDecls, final List<MethodInvocation> methodCallsToRefactor, final List<VariableDeclaration> otherVarDecls) { for (final VariableDeclaration varDecl : varDecls) { final VarOccurrenceVisitor varOccurrenceVisitor = new VarOccurrenceVisitor(varDecl); final Statement parent = getAncestorOrNull(varDecl, Statement.class); Statement nextSibling = getNextSibling(parent); while (nextSibling != null) { varOccurrenceVisitor.visitNode(nextSibling); nextSibling = getNextSibling(nextSibling); } if (varOccurrenceVisitor.isUsedInAnnonymousClass()) { return false; } for (final SimpleName varOccurrence : varOccurrenceVisitor.getVarOccurrences()) { final List<VariableDeclaration> subVarDecls = new ArrayList<VariableDeclaration>(); if (!canBeRefactored(node, varOccurrence, varOccurrence.resolveTypeBinding(), subVarDecls, methodCallsToRefactor)) { return false; } otherVarDecls.addAll(subVarDecls); } } return true; }
private static ITypeBinding getTargetTypeForArrayInitializer(ArrayInitializer arrayInitializer) { ASTNode initializerParent= arrayInitializer.getParent(); while (initializerParent instanceof ArrayInitializer) { initializerParent= initializerParent.getParent(); } if (initializerParent instanceof ArrayCreation) { return ((ArrayCreation) initializerParent).getType().getElementType().resolveBinding(); } else if (initializerParent instanceof VariableDeclaration) { ITypeBinding typeBinding= ((VariableDeclaration) initializerParent).getName().resolveTypeBinding(); if (typeBinding != null) { return typeBinding.getElementType(); } } return null; }
@Override public final boolean visit(final SimpleName node) { final ITypeBinding binding= node.resolveTypeBinding(); if (binding != null && binding.isTypeVariable()) { String name= null; for (int index= 0; index < fMapping.length; index++) { name= binding.getName(); if (fMapping[index].getSourceName().equals(name) && node.getIdentifier().equals(name)) { final MethodDeclaration declaration= ASTNodes.getParent(node, MethodDeclaration.class); if (declaration != null) { final IMethodBinding method= declaration.resolveBinding(); if (method != null) { final ITypeBinding[] bindings= method.getTypeParameters(); for (int offset= 0; offset < bindings.length; offset++) { if (bindings[offset].isEqualTo(binding)) return true; } } } fRewrite.set(node, SimpleName.IDENTIFIER_PROPERTY, fMapping[index].getTargetName(), null); } } } return true; } }
public final boolean visit(final SimpleName node) { final ITypeBinding binding= node.resolveTypeBinding(); if (binding != null && binding.isTypeVariable()) { String name= null; for (int index= 0; index < fMapping.length; index++) { name= binding.getName(); if (fMapping[index].getSourceName().equals(name) && node.getIdentifier().equals(name)) { final MethodDeclaration declaration= (MethodDeclaration) ASTNodes.getParent(node, MethodDeclaration.class); if (declaration != null) { final IMethodBinding method= declaration.resolveBinding(); if (method != null) { final ITypeBinding[] bindings= method.getTypeParameters(); for (int offset= 0; offset < bindings.length; offset++) { if (bindings[offset].isEqualTo(binding)) return true; } } } fRewrite.set(node, SimpleName.IDENTIFIER_PROPERTY, fMapping[index].getTargetName(), null); } } } return true; } }
private static ITypeBinding getTargetTypeForArrayInitializer(ArrayInitializer arrayInitializer) { ASTNode initializerParent= arrayInitializer.getParent(); while (initializerParent instanceof ArrayInitializer) { initializerParent= initializerParent.getParent(); } if (initializerParent instanceof ArrayCreation) { return ((ArrayCreation) initializerParent).getType().getElementType().resolveBinding(); } else if (initializerParent instanceof VariableDeclaration) { ITypeBinding typeBinding= ((VariableDeclaration) initializerParent).getName().resolveTypeBinding(); if (typeBinding != null) { return typeBinding.getElementType(); } } return null; }
public final boolean visit(final SimpleName node) { final ITypeBinding binding= node.resolveTypeBinding(); if (binding != null && binding.isTypeVariable() && Bindings.equals(binding, fBinding) && node.getIdentifier().equals(fName.getIdentifier())) { if (node != fName) { if (fUpdateReferences) fRewrite.getASTRewrite().set(node, SimpleName.IDENTIFIER_PROPERTY, getNewElementName(), fRewrite.createGroupDescription(RefactoringCoreMessages.RenameTypeParameterRefactoring_update_type_parameter_reference)); } else fRewrite.getASTRewrite().set(node, SimpleName.IDENTIFIER_PROPERTY, getNewElementName(), fRewrite.createGroupDescription(RefactoringCoreMessages.RenameTypeParameterRefactoring_update_type_parameter_declaration)); } return true; }
public boolean visit(SimpleName node) { insert(names, values.string(node.getIdentifier()), ownValue); if (!simpleNameIsConstructorDecl(node)) { addTypeDependency(resolveBinding(node.resolveTypeBinding())); if (!node.isDeclaration()) { addTypeDependency(resolveDeclaringClass(node.resolveBinding())); } } return true; }
public boolean visit(SimpleName node) { if (isTypeReference(node)) { pushTypeReference(node.resolveTypeBinding()); } else if (_currentExpression == null){ String ident = mapVariableName (identifier (node)); IBinding b = node.resolveBinding(); IVariableBinding vb = b instanceof IVariableBinding ? (IVariableBinding) b : null; if (vb != null) { ITypeBinding cls = vb.getDeclaringClass(); if (cls != null) { if (isStaticImport(vb, _ast.imports())) { if (cls != null) { pushExpression(new CSMemberReferenceExpression(mappedTypeReference(cls), ident)); return false; } } else if (cls.isEnum() && ident.indexOf('.') == -1){ pushExpression(new CSMemberReferenceExpression(mappedTypeReference(cls), ident)); return false; } else if (_configuration.separateInterfaceConstants() && cls.isInterface() && ident.indexOf('.') == -1) { pushExpression(new CSMemberReferenceExpression(mappedAuxillaryTypeReference(cls), ident)); return false; } } } pushExpression(new CSReferenceExpression(ident)); } return false; }