private void addDefinitionOrUse(SimpleName node, ChildPropertyDescriptor definitionPropertyDescriptor) { if (node.getLocationInParent() == definitionPropertyDescriptor) { definitions.add(node); } else { uses.add(node); } }
@Override public boolean consumes(SemanticToken token) { StructuralPropertyDescriptor location = token.getNode().getLocationInParent(); return location == MethodDeclaration.NAME_PROPERTY || location == AnnotationTypeMemberDeclaration.NAME_PROPERTY; } }
public boolean consumes(SemanticToken token) { StructuralPropertyDescriptor location= token.getNode().getLocationInParent(); return location == MethodDeclaration.NAME_PROPERTY || location == AnnotationTypeMemberDeclaration.NAME_PROPERTY; } }
@Override public boolean consumes(SemanticToken token) { StructuralPropertyDescriptor location= token.getNode().getLocationInParent(); return location == MethodDeclaration.NAME_PROPERTY || location == AnnotationTypeMemberDeclaration.NAME_PROPERTY; } }
@Override public boolean consumes(SemanticToken token) { StructuralPropertyDescriptor location= token.getNode().getLocationInParent(); return location == MethodDeclaration.NAME_PROPERTY || location == AnnotationTypeMemberDeclaration.NAME_PROPERTY; } }
public boolean consumes(SemanticToken token) { SimpleName node= token.getNode(); StructuralPropertyDescriptor location= node.getLocationInParent(); if (location == VariableDeclarationFragment.NAME_PROPERTY || location == SingleVariableDeclaration.NAME_PROPERTY) { ASTNode parent= node.getParent(); if (parent instanceof VariableDeclaration) { parent= parent.getParent(); return parent == null || !(parent instanceof FieldDeclaration); } } return false; } }
@Override public boolean consumes(SemanticToken token) { SimpleName node= token.getNode(); StructuralPropertyDescriptor location= node.getLocationInParent(); if (location == VariableDeclarationFragment.NAME_PROPERTY || location == SingleVariableDeclaration.NAME_PROPERTY) { ASTNode parent= node.getParent(); if (parent instanceof VariableDeclaration) { parent= parent.getParent(); return parent == null || !(parent instanceof FieldDeclaration); } } return false; } }
@Override public boolean consumes(SemanticToken token) { SimpleName node = token.getNode(); StructuralPropertyDescriptor location = node.getLocationInParent(); if (location == VariableDeclarationFragment.NAME_PROPERTY || location == SingleVariableDeclaration.NAME_PROPERTY) { ASTNode parent = node.getParent(); if (parent instanceof VariableDeclaration) { parent = parent.getParent(); return parent == null || !(parent instanceof FieldDeclaration); } } return false; } }
private Expression getSimpleNameReceiver(SimpleName node) { Expression receiver; if (node.getParent() instanceof QualifiedName && node.getLocationInParent() == QualifiedName.NAME_PROPERTY) { receiver= ((QualifiedName) node.getParent()).getQualifier(); } else if (node.getParent() instanceof FieldAccess && node.getLocationInParent() == FieldAccess.NAME_PROPERTY) { receiver= ((FieldAccess) node.getParent()).getExpression(); } else { //TODO other cases? (ThisExpression, SuperAccessExpression, ...) receiver= null; } if (receiver instanceof ThisExpression) return null; else return receiver; }
private Expression getSimpleNameReceiver(SimpleName node) { Expression receiver; if (node.getParent() instanceof QualifiedName && node.getLocationInParent() == QualifiedName.NAME_PROPERTY) { receiver= ((QualifiedName) node.getParent()).getQualifier(); } else if (node.getParent() instanceof FieldAccess && node.getLocationInParent() == FieldAccess.NAME_PROPERTY) { receiver= ((FieldAccess) node.getParent()).getExpression(); } else { //TODO other cases? (ThisExpression, SuperAccessExpression, ...) receiver= null; } if (receiver instanceof ThisExpression) return null; else return receiver; }
@Override public boolean consumes(SemanticToken token) { SimpleName node= token.getNode(); StructuralPropertyDescriptor location= node.getLocationInParent(); if (location == VariableDeclarationFragment.NAME_PROPERTY || location == SingleVariableDeclaration.NAME_PROPERTY) { ASTNode parent= node.getParent(); if (parent instanceof VariableDeclaration) { parent= parent.getParent(); return parent == null || !(parent instanceof FieldDeclaration); } } return false; } }
private Expression getSimpleNameReceiver(SimpleName node) { Expression receiver; if (node.getParent() instanceof QualifiedName && node.getLocationInParent() == QualifiedName.NAME_PROPERTY) { receiver= ((QualifiedName) node.getParent()).getQualifier(); } else if (node.getParent() instanceof FieldAccess && node.getLocationInParent() == FieldAccess.NAME_PROPERTY) { receiver= ((FieldAccess) node.getParent()).getExpression(); } else { //TODO other cases? (ThisExpression, SuperAccessExpression, ...) receiver= null; } if (receiver instanceof ThisExpression) return null; else return receiver; }
public static IMethodBinding staticImportMethodBinding(SimpleName node, List imports) { if (node.getLocationInParent() != MethodInvocation.NAME_PROPERTY) return null; final MethodInvocation invocation = parentMethodInvocation(node); if (invocation.getExpression() != null) return null; final IMethodBinding method = invocation.resolveMethodBinding(); if (!isStaticImport(method, imports)) return null; return method; }
private void handleSimpleName(SimpleName node) { ASTNode firstExpression= node.getParent(); if (firstExpression instanceof FieldAccess) { while (firstExpression instanceof FieldAccess) { firstExpression= ((FieldAccess)firstExpression).getExpression(); } if (!(firstExpression instanceof SimpleName)) return; node= (SimpleName)firstExpression; } else if (firstExpression instanceof SuperFieldAccess) return; StructuralPropertyDescriptor parentDescription= node.getLocationInParent(); if (parentDescription == VariableDeclarationFragment.NAME_PROPERTY || parentDescription == SwitchCase.EXPRESSION_PROPERTY) return; IBinding binding= node.resolveBinding(); if (!(binding instanceof IVariableBinding)) return; handleVariable(node, (IVariableBinding) binding); }
private void handleSimpleName(SimpleName node) { ASTNode firstExpression= node.getParent(); if (firstExpression instanceof FieldAccess) { while (firstExpression instanceof FieldAccess) { firstExpression= ((FieldAccess)firstExpression).getExpression(); } if (!(firstExpression instanceof SimpleName)) return; node= (SimpleName)firstExpression; } else if (firstExpression instanceof SuperFieldAccess) return; StructuralPropertyDescriptor parentDescription= node.getLocationInParent(); if (parentDescription == VariableDeclarationFragment.NAME_PROPERTY || parentDescription == SwitchCase.EXPRESSION_PROPERTY) return; IBinding binding= node.resolveBinding(); if (!(binding instanceof IVariableBinding)) return; handleVariable(node, (IVariableBinding) binding); }
private void handleSimpleName(SimpleName node) { ASTNode firstExpression= node.getParent(); if (firstExpression instanceof FieldAccess) { while (firstExpression instanceof FieldAccess) { firstExpression= ((FieldAccess)firstExpression).getExpression(); } if (!(firstExpression instanceof SimpleName)) return; node= (SimpleName)firstExpression; } else if (firstExpression instanceof SuperFieldAccess) return; StructuralPropertyDescriptor parentDescription= node.getLocationInParent(); if (parentDescription == VariableDeclarationFragment.NAME_PROPERTY || parentDescription == SwitchCase.EXPRESSION_PROPERTY) return; IBinding binding= node.resolveBinding(); if (!(binding instanceof IVariableBinding)) return; handleVariable(node, (IVariableBinding) binding); }
private Expression getInitializerSource(CompilationUnitRewrite rewrite, SimpleName reference) throws JavaModelException { Expression copy= getModifiedInitializerSource(rewrite, reference); if (NecessaryParenthesesChecker.needsParentheses(copy, reference.getParent(), reference.getLocationInParent())) { ParenthesizedExpression parentExpr= rewrite.getAST().newParenthesizedExpression(); parentExpr.setExpression(copy); return parentExpr; } return copy; }
private Expression getInitializerSource(CompilationUnitRewrite rewrite, SimpleName reference) throws JavaModelException { Expression copy= getModifiedInitializerSource(rewrite, reference); if (NecessaryParenthesesChecker.needsParentheses(copy, reference.getParent(), reference.getLocationInParent())) { ParenthesizedExpression parentExpr= rewrite.getAST().newParenthesizedExpression(); parentExpr.setExpression(copy); return parentExpr; } return copy; }
@Override public boolean visit(SimpleName node) { IBinding nodeBinding= node.resolveBinding(); if (fElementVariable != null && fElementVariable.equals(nodeBinding)) { fMakeFinal= false; } if (nodeBinding == fIteratorVariable) { if (node.getLocationInParent() == MethodInvocation.EXPRESSION_PROPERTY) { MethodInvocation invocation= (MethodInvocation) node.getParent(); String name= invocation.getName().getIdentifier(); if (name.equals("next") || name.equals("nextElement")) { //$NON-NLS-1$ //$NON-NLS-2$ nextInvocationCount[0]++; Expression left= null; if (invocation.getLocationInParent() == Assignment.RIGHT_HAND_SIDE_PROPERTY) { left= ((Assignment) invocation.getParent()).getLeftHandSide(); } else if (invocation.getLocationInParent() == VariableDeclarationFragment.INITIALIZER_PROPERTY) { left= ((VariableDeclarationFragment) invocation.getParent()).getName(); } return visitElementVariable(left); } } otherInvocationThenNext[0]= true; } return true; }
@Override public boolean visit(SimpleName node) { IBinding nodeBinding= node.resolveBinding(); if (fElementVariable != null && fElementVariable.equals(nodeBinding)) { fMakeFinal= false; } if (nodeBinding == fIteratorVariable) { if (node.getLocationInParent() == MethodInvocation.EXPRESSION_PROPERTY) { MethodInvocation invocation= (MethodInvocation) node.getParent(); String name= invocation.getName().getIdentifier(); if (name.equals("next") || name.equals("nextElement")) { //$NON-NLS-1$ //$NON-NLS-2$ nextInvocationCount[0]++; Expression left= null; if (invocation.getLocationInParent() == Assignment.RIGHT_HAND_SIDE_PROPERTY) { left= ((Assignment) invocation.getParent()).getLeftHandSide(); } else if (invocation.getLocationInParent() == VariableDeclarationFragment.INITIALIZER_PROPERTY) { left= ((VariableDeclarationFragment) invocation.getParent()).getName(); } return visitElementVariable(left); } } otherInvocationThenNext[0]= true; } return true; }