org.eclipse.jdt.core.dom.QualifiedName Java Examples
The following examples show how to use
org.eclipse.jdt.core.dom.QualifiedName.
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: SnippetFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static boolean isLeftHandSideOfAssignment(ASTNode node) { Assignment assignment= (Assignment)ASTNodes.getParent(node, ASTNode.ASSIGNMENT); if (assignment != null) { Expression leftHandSide= assignment.getLeftHandSide(); if (leftHandSide == node) { return true; } if (ASTNodes.isParent(node, leftHandSide)) { switch (leftHandSide.getNodeType()) { case ASTNode.SIMPLE_NAME: return true; case ASTNode.FIELD_ACCESS: return node == ((FieldAccess)leftHandSide).getName(); case ASTNode.QUALIFIED_NAME: return node == ((QualifiedName)leftHandSide).getName(); case ASTNode.SUPER_FIELD_ACCESS: return node == ((SuperFieldAccess)leftHandSide).getName(); default: return false; } } } return false; }
Example #2
Source File: ChangeTypeRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void updateCu(CompilationUnit unit, Set<ConstraintVariable> vars, CompilationUnitChange unitChange, ASTRewrite unitRewriter, String typeName) throws JavaModelException { // use custom SourceRangeComputer to avoid losing comments unitRewriter.setTargetSourceRangeComputer(new SourceRangeComputer()); for (Iterator<ConstraintVariable> it=vars.iterator(); it.hasNext(); ){ ConstraintVariable cv = it.next(); ASTNode decl= findDeclaration(unit, cv); if ((decl instanceof SimpleName || decl instanceof QualifiedName) && cv instanceof ExpressionVariable) { ASTNode gp= decl.getParent().getParent(); updateType(unit, getType(gp), unitChange, unitRewriter, typeName); // local variable or parameter } else if (decl instanceof MethodDeclaration || decl instanceof FieldDeclaration) { updateType(unit, getType(decl), unitChange, unitRewriter, typeName); // method return or field type } else if (decl instanceof ParameterizedType){ updateType(unit, getType(decl), unitChange, unitRewriter, typeName); } } }
Example #3
Source File: SuperTypeConstraintsCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@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); }
Example #4
Source File: CastCorrectionProposal.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private static boolean needsOuterParantheses(ASTNode nodeToCast) { ASTNode parent= nodeToCast.getParent(); if (parent instanceof MethodInvocation) { if (((MethodInvocation)parent).getExpression() == nodeToCast) { return true; } } else if (parent instanceof QualifiedName) { if (((QualifiedName)parent).getQualifier() == nodeToCast) { return true; } } else if (parent instanceof FieldAccess) { if (((FieldAccess)parent).getExpression() == nodeToCast) { return true; } } return false; }
Example #5
Source File: IntroduceParameterObjectProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void updateSimpleName(ASTRewrite rewriter, ParameterInfo pi, SimpleName node, List<SingleVariableDeclaration> enclosingParameters, IJavaProject project) { AST ast= rewriter.getAST(); IBinding binding= node.resolveBinding(); Expression replacementNode= fParameterObjectFactory.createFieldReadAccess(pi, getParameterName(), ast, project, false, null); if (binding instanceof IVariableBinding) { IVariableBinding variable= (IVariableBinding) binding; if (variable.isParameter() && variable.getName().equals(getNameInScope(pi, enclosingParameters))) { rewriter.replace(node, replacementNode, null); } } else { ASTNode parent= node.getParent(); if (!(parent instanceof QualifiedName || parent instanceof FieldAccess || parent instanceof SuperFieldAccess)) { if (node.getIdentifier().equals(getNameInScope(pi, enclosingParameters))) { rewriter.replace(node, replacementNode, null); } } } }
Example #6
Source File: CodeStyleFix.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel model) throws CoreException { ASTRewrite rewrite= cuRewrite.getASTRewrite(); CompilationUnit compilationUnit= cuRewrite.getRoot(); importType(fDeclaringClass, fName, cuRewrite.getImportRewrite(), compilationUnit); TextEditGroup group; if (fName.resolveBinding() instanceof IMethodBinding) { group= createTextEditGroup(FixMessages.CodeStyleFix_QualifyMethodWithDeclClass_description, cuRewrite); } else { group= createTextEditGroup(FixMessages.CodeStyleFix_QualifyFieldWithDeclClass_description, cuRewrite); } IJavaElement javaElement= fDeclaringClass.getJavaElement(); if (javaElement instanceof IType) { Name qualifierName= compilationUnit.getAST().newName(((IType)javaElement).getElementName()); SimpleName simpleName= (SimpleName)rewrite.createMoveTarget(fName); QualifiedName qualifiedName= compilationUnit.getAST().newQualifiedName(qualifierName, simpleName); rewrite.replace(fName, qualifiedName, group); } }
Example #7
Source File: ASTNodeMatcher.java From JDeodorant with MIT License | 6 votes |
protected boolean isTypeHolder(Object o) { if(o.getClass().equals(MethodInvocation.class) || o.getClass().equals(SuperMethodInvocation.class) || o.getClass().equals(NumberLiteral.class) || o.getClass().equals(StringLiteral.class) || o.getClass().equals(CharacterLiteral.class) || o.getClass().equals(BooleanLiteral.class) || o.getClass().equals(TypeLiteral.class) || o.getClass().equals(NullLiteral.class) || o.getClass().equals(ArrayCreation.class) || o.getClass().equals(ClassInstanceCreation.class) || o.getClass().equals(ArrayAccess.class) || o.getClass().equals(FieldAccess.class) || o.getClass().equals(SuperFieldAccess.class) || o.getClass().equals(ParenthesizedExpression.class) || o.getClass().equals(SimpleName.class) || o.getClass().equals(QualifiedName.class) || o.getClass().equals(CastExpression.class) || o.getClass().equals(InfixExpression.class) || o.getClass().equals(PrefixExpression.class) || o.getClass().equals(InstanceofExpression.class) || o.getClass().equals(ThisExpression.class) || o.getClass().equals(ConditionalExpression.class)) return true; return false; }
Example #8
Source File: MoveInstanceMethodProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Is the specified name a target access? * * @param name * the name to check * @return <code>true</code> if this name is a target access, * <code>false</code> otherwise */ protected boolean isTargetAccess(final Name name) { Assert.isNotNull(name); final IBinding binding= name.resolveBinding(); if (Bindings.equals(fTarget, binding)) return true; if (name.getParent() instanceof FieldAccess) { final FieldAccess access= (FieldAccess) name.getParent(); final Expression expression= access.getExpression(); if (expression instanceof Name) return isTargetAccess((Name) expression); } else if (name instanceof QualifiedName) { final QualifiedName qualified= (QualifiedName) name; if (qualified.getQualifier() != null) return isTargetAccess(qualified.getQualifier()); } return false; }
Example #9
Source File: CastCorrectionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static boolean needsOuterParantheses(ASTNode nodeToCast) { ASTNode parent= nodeToCast.getParent(); if (parent instanceof MethodInvocation) { if (((MethodInvocation)parent).getExpression() == nodeToCast) { return true; } } else if (parent instanceof QualifiedName) { if (((QualifiedName)parent).getQualifier() == nodeToCast) { return true; } } else if (parent instanceof FieldAccess) { if (((FieldAccess)parent).getExpression() == nodeToCast) { return true; } } return false; }
Example #10
Source File: QuickAssistProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static ITypeBinding extractExpressionType(SimpleType variableIdentifier) { ScopeAnalyzer analyzer= new ScopeAnalyzer((CompilationUnit) variableIdentifier.getRoot()); // get the name of the variable to search the type for Name name= null; if (variableIdentifier.getName() instanceof SimpleName) { name= variableIdentifier.getName(); } else if (variableIdentifier.getName() instanceof QualifiedName) { name= ((QualifiedName) variableIdentifier.getName()).getName(); } // analyze variables which are available in the scope at the position of the quick assist invokation IBinding[] declarationsInScope= analyzer.getDeclarationsInScope(name.getStartPosition(), ScopeAnalyzer.VARIABLES); for (int i= 0; i < declarationsInScope.length; i++) { IBinding currentVariable= declarationsInScope[i]; if (((IVariableBinding) currentVariable).getName().equals(name.getFullyQualifiedName())) { return ((IVariableBinding) currentVariable).getType(); } } return null; }
Example #11
Source File: MoveInstanceMethodProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Is the specified name a field access? * * @param name * the name to check * @return <code>true</code> if this name is a field access, * <code>false</code> otherwise */ protected static boolean isFieldAccess(final SimpleName name) { Assert.isNotNull(name); final IBinding binding= name.resolveBinding(); if (!(binding instanceof IVariableBinding)) return false; final IVariableBinding variable= (IVariableBinding) binding; if (!variable.isField()) return false; if ("length".equals(name.getIdentifier())) { //$NON-NLS-1$ final ASTNode parent= name.getParent(); if (parent instanceof QualifiedName) { final QualifiedName qualified= (QualifiedName) parent; final ITypeBinding type= qualified.getQualifier().resolveTypeBinding(); if (type != null && type.isArray()) return false; } } return !Modifier.isStatic(variable.getModifiers()); }
Example #12
Source File: RefactoringUtility.java From JDeodorant with MIT License | 6 votes |
private static boolean isQualifiedType(Type type) { if(type instanceof SimpleType) { SimpleType simpleType = (SimpleType)type; Name name = simpleType.getName(); if(name instanceof QualifiedName) { return true; } } else if(type instanceof QualifiedType) { QualifiedType qualifiedType = (QualifiedType)type; Type qualifier = qualifiedType.getQualifier(); return isQualifiedType(qualifier); } else if(type instanceof ArrayType) { ArrayType arrayType = (ArrayType)type; Type elementType = arrayType.getElementType(); return isQualifiedType(elementType); } else if(type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType)type; Type erasureType = parameterizedType.getType(); return isQualifiedType(erasureType); } return false; }
Example #13
Source File: ExtractTempRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private RefactoringStatus checkExpression() throws JavaModelException { Expression selectedExpression= getSelectedExpression().getAssociatedExpression(); if (selectedExpression != null) { final ASTNode parent= selectedExpression.getParent(); if (selectedExpression instanceof NullLiteral) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_null_literals); } else if (selectedExpression instanceof ArrayInitializer) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_array_initializer); } else if (selectedExpression instanceof Assignment) { if (parent instanceof Expression && !(parent instanceof ParenthesizedExpression)) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_assignment); else return null; } else if (selectedExpression instanceof SimpleName) { if ((((SimpleName) selectedExpression)).isDeclaration()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_names_in_declarations); if (parent instanceof QualifiedName && selectedExpression.getLocationInParent() == QualifiedName.NAME_PROPERTY || parent instanceof FieldAccess && selectedExpression.getLocationInParent() == FieldAccess.NAME_PROPERTY) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_select_expression); } else if (selectedExpression instanceof VariableDeclarationExpression && parent instanceof TryStatement) { return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_resource_in_try_with_resources); } } return null; }
Example #14
Source File: ASTResolving.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static ITypeBinding guessBindingForTypeReference(ASTNode node) { StructuralPropertyDescriptor locationInParent= node.getLocationInParent(); if (locationInParent == QualifiedName.QUALIFIER_PROPERTY) { return null; // can't guess type for X.A } if (locationInParent == SimpleType.NAME_PROPERTY || locationInParent == NameQualifiedType.NAME_PROPERTY) { node= node.getParent(); } ITypeBinding binding= Bindings.normalizeTypeBinding(getPossibleTypeBinding(node)); if (binding != null) { if (binding.isWildcardType()) { return normalizeWildcardType(binding, true, node.getAST()); } } return binding; }
Example #15
Source File: MoveInstanceMethodProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public final boolean visit(final QualifiedName node) { Assert.isNotNull(node); IBinding binding= node.resolveBinding(); if (binding instanceof ITypeBinding) { final ITypeBinding type= (ITypeBinding) binding; if (type.isClass() && type.getDeclaringClass() != null) { final Type newType= fTargetRewrite.getImportRewrite().addImport(type, node.getAST()); fRewrite.replace(node, newType, null); return false; } } binding= node.getQualifier().resolveBinding(); if (Bindings.equals(fTarget, binding)) { fRewrite.replace(node, getFieldReference(node.getName(), fRewrite), null); return false; } node.getQualifier().accept(this); return false; }
Example #16
Source File: NullAnnotationsCorrectionProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static SimpleName findProblemFieldName(ASTNode selectedNode, int problemID) { // if a field access occurs in an compatibility situation (assignment/return/argument) // with expected type declared @NonNull we first need to find the SimpleName inside: if (selectedNode instanceof FieldAccess) selectedNode= ((FieldAccess) selectedNode).getName(); else if (selectedNode instanceof QualifiedName) selectedNode= ((QualifiedName) selectedNode).getName(); if (selectedNode instanceof SimpleName) { SimpleName name= (SimpleName) selectedNode; if (problemID == IProblem.NullableFieldReference) return name; // not field dereference, but compatibility issue - is value a field reference? IBinding binding= name.resolveBinding(); if ((binding instanceof IVariableBinding) && ((IVariableBinding) binding).isField()) return name; } return null; }
Example #17
Source File: Bindings.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Returns the binding of the variable written in an Assignment. * @param assignment The assignment * @return The binding or <code>null</code> if no bindings are available. */ public static IVariableBinding getAssignedVariable(Assignment assignment) { Expression leftHand = assignment.getLeftHandSide(); switch (leftHand.getNodeType()) { case ASTNode.SIMPLE_NAME: return (IVariableBinding) ((SimpleName) leftHand).resolveBinding(); case ASTNode.QUALIFIED_NAME: return (IVariableBinding) ((QualifiedName) leftHand).getName().resolveBinding(); case ASTNode.FIELD_ACCESS: return ((FieldAccess) leftHand).resolveFieldBinding(); case ASTNode.SUPER_FIELD_ACCESS: return ((SuperFieldAccess) leftHand).resolveFieldBinding(); default: return null; } }
Example #18
Source File: ASTNodes.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static SimpleName getLeftMostSimpleName(Name name) { if (name instanceof SimpleName) { return (SimpleName)name; } else { final SimpleName[] result= new SimpleName[1]; ASTVisitor visitor= new ASTVisitor() { @Override public boolean visit(QualifiedName qualifiedName) { Name left= qualifiedName.getQualifier(); if (left instanceof SimpleName) result[0]= (SimpleName)left; else left.accept(this); return false; } }; name.accept(visitor); return result[0]; } }
Example #19
Source File: ASTNodes.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static String getSimpleNameIdentifier(Name name) { if (name.isQualifiedName()) { return ((QualifiedName) name).getName().getIdentifier(); } else { return ((SimpleName) name).getIdentifier(); } }
Example #20
Source File: FullConstraintCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public ITypeConstraint[] create(QualifiedName qualifiedName){ SimpleName name= qualifiedName.getName(); Name qualifier= qualifiedName.getQualifier(); IBinding nameBinding= name.resolveBinding(); if (nameBinding instanceof IVariableBinding){ IVariableBinding vb= (IVariableBinding)nameBinding; if (vb.isField()) return createConstraintsForAccessToField(vb, qualifier, qualifiedName); } //TODO other bindings return new ITypeConstraint[0]; }
Example #21
Source File: AccessAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IBinding resolveBinding(Expression expression) { if (expression instanceof SimpleName) return ((SimpleName)expression).resolveBinding(); else if (expression instanceof QualifiedName) return ((QualifiedName)expression).resolveBinding(); else if (expression instanceof FieldAccess) return ((FieldAccess)expression).getName().resolveBinding(); else if (expression instanceof ParenthesizedExpression) return resolveBinding(((ParenthesizedExpression) expression).getExpression()); return null; }
Example #22
Source File: ConstantChecks.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private boolean isMemberReferenceValidInClassInitialization(Name name) { IBinding binding= name.resolveBinding(); Assert.isTrue(binding instanceof IVariableBinding || binding instanceof IMethodBinding); if(name instanceof SimpleName) return Modifier.isStatic(binding.getModifiers()); else { Assert.isTrue(name instanceof QualifiedName); return checkName(((QualifiedName) name).getQualifier()); } }
Example #23
Source File: CodeStyleFix.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static SimpleName getName(CompilationUnit compilationUnit, IProblemLocation problem) { ASTNode selectedNode= problem.getCoveringNode(compilationUnit); while (selectedNode instanceof QualifiedName) { selectedNode= ((QualifiedName) selectedNode).getQualifier(); } if (!(selectedNode instanceof SimpleName)) { return null; } return (SimpleName) selectedNode; }
Example #24
Source File: InferTypeArgumentsConstraintCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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; }
Example #25
Source File: AccessAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Expression getReceiver(Expression expression) { int type= expression.getNodeType(); switch(type) { case ASTNode.SIMPLE_NAME: return null; case ASTNode.QUALIFIED_NAME: return ((QualifiedName)expression).getQualifier(); case ASTNode.FIELD_ACCESS: return ((FieldAccess)expression).getExpression(); case ASTNode.PARENTHESIZED_EXPRESSION: return getReceiver(((ParenthesizedExpression)expression).getExpression()); } return null; }
Example #26
Source File: MoveInstanceMethodProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Is the specified name a qualified entity, e.g. preceded by 'this', * 'super' or part of a method invocation? * * @param name * the name to check * @return <code>true</code> if this entity is qualified, * <code>false</code> otherwise */ protected static boolean isQualifiedEntity(final Name name) { Assert.isNotNull(name); final ASTNode parent= name.getParent(); if (parent instanceof QualifiedName && ((QualifiedName) parent).getName().equals(name) || parent instanceof FieldAccess && ((FieldAccess) parent).getName().equals(name) || parent instanceof SuperFieldAccess) return true; else if (parent instanceof MethodInvocation) { final MethodInvocation invocation= (MethodInvocation) parent; return invocation.getExpression() != null && invocation.getName().equals(name); } return false; }
Example #27
Source File: ExtractClassRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Expression getQualifier(ASTNode parent) { switch (parent.getNodeType()) { case ASTNode.FIELD_ACCESS: return ((FieldAccess) parent).getExpression(); case ASTNode.QUALIFIED_NAME: return ((QualifiedName)parent).getQualifier(); case ASTNode.SUPER_FIELD_ACCESS: return ((SuperFieldAccess)parent).getQualifier(); default: return null; } }
Example #28
Source File: NLSKeyHyperlinkDetector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { ITextEditor textEditor= (ITextEditor)getAdapter(ITextEditor.class); if (region == null || textEditor == null) return null; IEditorSite site= textEditor.getEditorSite(); if (site == null) return null; ITypeRoot javaElement= getInputJavaElement(textEditor); if (javaElement == null) return null; CompilationUnit ast= SharedASTProvider.getAST(javaElement, SharedASTProvider.WAIT_NO, null); if (ast == null) return null; ASTNode node= NodeFinder.perform(ast, region.getOffset(), 1); if (!(node instanceof StringLiteral) && !(node instanceof SimpleName)) return null; if (node.getLocationInParent() == QualifiedName.QUALIFIER_PROPERTY) return null; IRegion nlsKeyRegion= new Region(node.getStartPosition(), node.getLength()); AccessorClassReference ref= NLSHintHelper.getAccessorClassReference(ast, nlsKeyRegion); if (ref == null) return null; String keyName= null; if (node instanceof StringLiteral) { keyName= ((StringLiteral)node).getLiteralValue(); } else { keyName= ((SimpleName)node).getIdentifier(); } if (keyName != null) return new IHyperlink[] {new NLSKeyHyperlink(nlsKeyRegion, keyName, ref, textEditor)}; return null; }
Example #29
Source File: StyledStringVisitor.java From JDeodorant with MIT License | 5 votes |
public boolean visit(QualifiedName name) { /* * Name . SimpleName */ activateDiffStyle(name); if (name.getQualifier() != null) { handleExpression(name.getQualifier()); appendPeriod(); } handleExpression(name.getName()); deactivateDiffStyle(name); return false; }
Example #30
Source File: MoveStaticMemberAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void rewrite(SimpleName node, ITypeBinding type) { AST ast= node.getAST(); ImportRewriteContext context= new ContextSensitiveImportRewriteContext(node, fCuRewrite.getImportRewrite()); Type result= fCuRewrite.getImportRewrite().addImport(type, fCuRewrite.getAST(), context); fCuRewrite.getImportRemover().registerAddedImport(type.getQualifiedName()); Name dummy= ASTNodeFactory.newName(fCuRewrite.getAST(), ASTFlattener.asString(result)); QualifiedName name= ast.newQualifiedName(dummy, ast.newSimpleName(node.getIdentifier())); fCuRewrite.getASTRewrite().replace(node, name, fCuRewrite.createGroupDescription(REFERENCE_UPDATE)); fCuRewrite.getImportRemover().registerRemovedNode(node); fProcessed.add(node); fNeedsImport= true; }