Java Code Examples for org.eclipse.jdt.internal.corext.dom.ASTNodes#getLeftMostSimpleName()
The following examples show how to use
org.eclipse.jdt.internal.corext.dom.ASTNodes#getLeftMostSimpleName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MoveStaticMemberAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void rewriteName(Name name, ITypeBinding type) { AST creator= name.getAST(); boolean fullyQualified= false; if (name instanceof QualifiedName) { SimpleName left= ASTNodes.getLeftMostSimpleName(name); if (left.resolveBinding() instanceof IPackageBinding) fullyQualified= true; } if (fullyQualified) { fCuRewrite.getASTRewrite().replace( name, ASTNodeFactory.newName(creator, type.getQualifiedName()), fCuRewrite.createGroupDescription(REFERENCE_UPDATE)); fCuRewrite.getImportRemover().registerRemovedNode(name); } else { ImportRewriteContext context= new ContextSensitiveImportRewriteContext(name, fCuRewrite.getImportRewrite()); Type result= fCuRewrite.getImportRewrite().addImport(type, fCuRewrite.getAST(), context); fCuRewrite.getImportRemover().registerAddedImport(type.getQualifiedName()); Name n= ASTNodeFactory.newName(fCuRewrite.getAST(), ASTFlattener.asString(result)); fCuRewrite.getASTRewrite().replace( name, n, fCuRewrite.createGroupDescription(REFERENCE_UPDATE)); fCuRewrite.getImportRemover().registerRemovedNode(name); fNeedsImport= true; } }
Example 2
Source File: SourceAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean visit(SimpleName node) { addReferencesToName(node); IBinding binding= node.resolveBinding(); if (binding instanceof ITypeBinding) { ITypeBinding type= (ITypeBinding)binding; if (type.isTypeVariable()) { addTypeVariableReference(type, node); } } else if (binding instanceof IVariableBinding) { IVariableBinding vb= (IVariableBinding)binding; if (vb.isField() && ! isStaticallyImported(node)) { Name topName= ASTNodes.getTopMostName(node); if (node == topName || node == ASTNodes.getLeftMostSimpleName(topName)) { StructuralPropertyDescriptor location= node.getLocationInParent(); if (location != SingleVariableDeclaration.NAME_PROPERTY && location != VariableDeclarationFragment.NAME_PROPERTY) { fImplicitReceivers.add(node); } } } else if (!vb.isField()) { // we have a local. Check if it is a parameter. ParameterData data= fParameters.get(binding); if (data != null) { ASTNode parent= node.getParent(); if (parent instanceof Expression) { int precedence= OperatorPrecedence.getExpressionPrecedence((Expression)parent); if (precedence != Integer.MAX_VALUE) { data.setOperatorPrecedence(precedence); } } } } } return true; }