List of usage examples for org.eclipse.jdt.core.dom VariableDeclarationFragment resolveBinding
public IVariableBinding resolveBinding()
From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java
License:Open Source License
@Override public boolean visit(final MarkerAnnotation node) { final ITypeBinding binding = node.resolveTypeBinding(); if (ASTCrawler.checkForNull(binding)) return false; final IElement annoteElem = ASTCrawler.convertBinding(binding); this.aDB.addElement(annoteElem, binding.getModifiers()); final ASTNode annotatedNode = node.getParent(); switch (annotatedNode.getNodeType()) { case ASTNode.METHOD_DECLARATION: { final MethodDeclaration annotatedMethod = (MethodDeclaration) annotatedNode; final IMethodBinding mBinding = annotatedMethod.resolveBinding(); return this.addAnnotationRelation(annoteElem, mBinding); }/* w w w . ja va 2 s . co m*/ case ASTNode.ANNOTATION_TYPE_DECLARATION: { final AnnotationTypeDeclaration annotatedAnnotation = (AnnotationTypeDeclaration) annotatedNode; final ITypeBinding tBinding = annotatedAnnotation.resolveBinding(); return this.addAnnotationRelation(annoteElem, tBinding); } case ASTNode.VARIABLE_DECLARATION_STATEMENT: { return processVariableDeclarationStatement(annoteElem, (VariableDeclarationStatement) annotatedNode); } case ASTNode.VARIABLE_DECLARATION_FRAGMENT: { return processVariableDeclarationFragment(annoteElem, (VariableDeclarationFragment) annotatedNode); } case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION: { AnnotationTypeMemberDeclaration atmd = (AnnotationTypeMemberDeclaration) annotatedNode; IMethodBinding methodBinding = atmd.resolveBinding(); return this.addAnnotationRelation(annoteElem, methodBinding); } case ASTNode.PACKAGE_DECLARATION: { final PackageDeclaration packDecl = (PackageDeclaration) annotatedNode; final IPackageBinding pBinding = packDecl.resolveBinding(); return this.addAnnotationRelation(annoteElem, pBinding); } case ASTNode.SINGLE_VARIABLE_DECLARATION: { final SingleVariableDeclaration svd = (SingleVariableDeclaration) annotatedNode; final IVariableBinding vBinding = svd.resolveBinding(); return this.addAnnotationRelation(annoteElem, vBinding); } case ASTNode.TYPE_DECLARATION: { final TypeDeclaration tDecl = (TypeDeclaration) annotatedNode; final ITypeBinding tBinding = tDecl.resolveBinding(); return this.addAnnotationRelation(annoteElem, tBinding); } case ASTNode.ENUM_DECLARATION: { final EnumDeclaration eDecl = (EnumDeclaration) annotatedNode; final ITypeBinding tBinding = eDecl.resolveBinding(); return this.addAnnotationRelation(annoteElem, tBinding); } case ASTNode.FIELD_DECLARATION: { final FieldDeclaration fieldDecl = (FieldDeclaration) annotatedNode; for (final Object obj : fieldDecl.fragments()) { final VariableDeclarationFragment vdf = (VariableDeclarationFragment) obj; final IVariableBinding vBinding = vdf.resolveBinding(); return this.addAnnotationRelation(annoteElem, vBinding); } } default: { throw new IllegalStateException("Illegal annotated node type: " + annotatedNode); } } }
From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java
License:Open Source License
@Override public boolean visit(final NormalAnnotation node) { final ITypeBinding binding = node.resolveTypeBinding(); if (ASTCrawler.checkForNull(binding)) return false; final IElement annoteElem = ASTCrawler.convertBinding(binding); this.aDB.addElement(annoteElem, binding.getModifiers()); final ASTNode annotatedNode = node.getParent(); switch (annotatedNode.getNodeType()) { case ASTNode.METHOD_DECLARATION: { final MethodDeclaration annotatedMethod = (MethodDeclaration) annotatedNode; final IMethodBinding mBinding = annotatedMethod.resolveBinding(); return this.addAnnotationRelation(annoteElem, mBinding); }/*from w w w . j a va2 s . c o m*/ case ASTNode.ANNOTATION_TYPE_DECLARATION: { final AnnotationTypeDeclaration annotatedAnnotation = (AnnotationTypeDeclaration) annotatedNode; final ITypeBinding tBinding = annotatedAnnotation.resolveBinding(); return this.addAnnotationRelation(annoteElem, tBinding); } case ASTNode.VARIABLE_DECLARATION_STATEMENT: { return processVariableDeclarationStatement(annoteElem, (VariableDeclarationStatement) annotatedNode); } case ASTNode.VARIABLE_DECLARATION_FRAGMENT: { return processVariableDeclarationFragment(annoteElem, (VariableDeclarationFragment) annotatedNode); } case ASTNode.PACKAGE_DECLARATION: { final PackageDeclaration packDecl = (PackageDeclaration) annotatedNode; final IPackageBinding pBinding = packDecl.resolveBinding(); return this.addAnnotationRelation(annoteElem, pBinding); } case ASTNode.SINGLE_VARIABLE_DECLARATION: { final SingleVariableDeclaration svd = (SingleVariableDeclaration) annotatedNode; final IVariableBinding vBinding = svd.resolveBinding(); return this.addAnnotationRelation(annoteElem, vBinding); } case ASTNode.TYPE_DECLARATION: { final TypeDeclaration tDecl = (TypeDeclaration) annotatedNode; final ITypeBinding tBinding = tDecl.resolveBinding(); return this.addAnnotationRelation(annoteElem, tBinding); } case ASTNode.ENUM_DECLARATION: { final EnumDeclaration eDecl = (EnumDeclaration) annotatedNode; final ITypeBinding tBinding = eDecl.resolveBinding(); return this.addAnnotationRelation(annoteElem, tBinding); } case ASTNode.FIELD_DECLARATION: { final FieldDeclaration fieldDecl = (FieldDeclaration) annotatedNode; for (final Object obj : fieldDecl.fragments()) { final VariableDeclarationFragment vdf = (VariableDeclarationFragment) obj; final IVariableBinding vBinding = vdf.resolveBinding(); return this.addAnnotationRelation(annoteElem, vBinding); } } default: { throw new IllegalStateException("Illegal annotated node type: " + annotatedNode); } } }
From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java
License:Open Source License
@Override public boolean visit(final SingleMemberAnnotation node) { final ITypeBinding binding = node.resolveTypeBinding(); if (ASTCrawler.checkForNull(binding)) return false; final IElement annoteElem = ASTCrawler.convertBinding(binding); this.aDB.addElement(annoteElem, binding.getModifiers()); final ASTNode annotatedNode = node.getParent(); switch (annotatedNode.getNodeType()) { case ASTNode.METHOD_DECLARATION: { final MethodDeclaration annotatedMethod = (MethodDeclaration) annotatedNode; final IMethodBinding mBinding = annotatedMethod.resolveBinding(); return this.addAnnotationRelation(annoteElem, mBinding); }/*from ww w . j a v a 2 s . c o m*/ case ASTNode.ANNOTATION_TYPE_DECLARATION: { final AnnotationTypeDeclaration annotatedAnnotation = (AnnotationTypeDeclaration) annotatedNode; final ITypeBinding tBinding = annotatedAnnotation.resolveBinding(); return this.addAnnotationRelation(annoteElem, tBinding); } case ASTNode.VARIABLE_DECLARATION_STATEMENT: { VariableDeclarationStatement vds = (VariableDeclarationStatement) annotatedNode; return processVariableDeclarationStatement(annoteElem, vds); } case ASTNode.VARIABLE_DECLARATION_FRAGMENT: { return processVariableDeclarationFragment(annoteElem, (VariableDeclarationFragment) annotatedNode); } case ASTNode.PACKAGE_DECLARATION: { final PackageDeclaration packDecl = (PackageDeclaration) annotatedNode; final IPackageBinding pBinding = packDecl.resolveBinding(); return this.addAnnotationRelation(annoteElem, pBinding); } case ASTNode.SINGLE_VARIABLE_DECLARATION: { final SingleVariableDeclaration svd = (SingleVariableDeclaration) annotatedNode; final IVariableBinding vBinding = svd.resolveBinding(); return this.addAnnotationRelation(annoteElem, vBinding); } case ASTNode.TYPE_DECLARATION: { final TypeDeclaration tDecl = (TypeDeclaration) annotatedNode; final ITypeBinding tBinding = tDecl.resolveBinding(); return this.addAnnotationRelation(annoteElem, tBinding); } case ASTNode.ENUM_DECLARATION: { final EnumDeclaration eDecl = (EnumDeclaration) annotatedNode; final ITypeBinding tBinding = eDecl.resolveBinding(); return this.addAnnotationRelation(annoteElem, tBinding); } case ASTNode.FIELD_DECLARATION: { final FieldDeclaration fieldDecl = (FieldDeclaration) annotatedNode; for (final Object obj : fieldDecl.fragments()) { final VariableDeclarationFragment vdf = (VariableDeclarationFragment) obj; final IVariableBinding vBinding = vdf.resolveBinding(); return this.addAnnotationRelation(annoteElem, vBinding); } } default: { throw new IllegalStateException("Illegal annotated node type: " + annotatedNode); } } }
From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java
License:Open Source License
private boolean processVariableDeclarationFragment(final IElement annoteElem, final VariableDeclarationFragment varDeclFrag) { final IVariableBinding vBinding = varDeclFrag.resolveBinding(); return this.addAnnotationRelation(annoteElem, vBinding); }
From source file:cc.kave.eclipse.commons.analysis.transformer.BodyVisitor.java
License:Apache License
@Override public boolean visit(VariableDeclarationFragment decl) { if (isTargetMatch(decl, CompletionCase.EmptyCompletionBefore)) { body.add(getEmptyCompletionExpression()); }/*from w ww. ja va 2 s . c om*/ String identifier = BindingFactory.getBindingName(decl.resolveBinding().getType()); TypeName type = CsTypeName.newTypeName(identifier); String id = decl.getName().getIdentifier(); // var id = decl.DeclaredName; // TypeName type; // try // { // type = decl.Type.GetName(); // } // catch (AssertException) // { // // TODO this is an intermediate "fix"... the analysis sometimes fails // here ("cannot create name for anonymous type") // type = CsTypeName.UNKNOWN_NAME; // } body.add(SSTUtil.declare(id, type)); IAssignableExpression initializer = null; // if (decl.Initial != null) // { // initializer = exprVisitor.ToAssignableExpr(decl.Initial, body); // } // else if (marker.getAffectedNode() == decl && marker.getCase() == // CompletionCase.Undefined) // { // initializer = new CompletionExpression(); // } if (initializer != null) { body.add(SSTUtil.assignmentToLocal(id, initializer)); } if (decl == marker.getAffectedNode() && marker.getCase() == CompletionCase.EmptyCompletionAfter) { body.add(getEmptyCompletionExpression()); } return super.visit(decl); }
From source file:com.architexa.diagrams.jdt.extractors.ContainmentHeirarchyExtractor.java
License:Open Source License
@Override public boolean visit(VariableDeclarationFragment variableDecl) { // ignore var. decl. in statements (looking for only field declarations) if (getParent(MethodDeclaration.class) != null) return true; if (getParent(Initializer.class) != null) return true; TypeDeclaration typeDecl = (TypeDeclaration) getRequiredParent(TypeDeclaration.class); Resource typeDeclRes = bindingToResource(typeDecl.resolveBinding()); Resource variableDeclRes = bindingToResource(variableDecl.resolveBinding()); addContains(typeDeclRes, variableDeclRes); return true;// ww w. j a v a2 s .c o m }
From source file:com.architexa.diagrams.jdt.extractors.SourceRangeExtractor.java
License:Open Source License
@Override public boolean visit(VariableDeclarationFragment variableDecl) { int ctxDist = getContextDistance(FieldDeclaration.class); if (ctxDist > 1) return true; // var. decl. in statements declareNode(variableDecl, bindingToResource(variableDecl.resolveBinding())); return true;//from w w w . jav a 2 s . c om }
From source file:com.architexa.diagrams.jdt.extractors.TypeMembersModifierExtractor.java
License:Open Source License
@Override public boolean visit(VariableDeclarationFragment variableDecl) { FieldDeclaration fieldDecl = (FieldDeclaration) getParent(FieldDeclaration.class); if (fieldDecl == null) return true; // var. decl. in statements Resource variableDeclRes = bindingToResource(variableDecl.resolveBinding()); addModifiers(variableDeclRes, fieldDecl.getModifiers()); return true;/*from w w w .ja v a2s . c o m*/ }
From source file:com.architexa.diagrams.jdt.extractors.TypeRefExtractor.java
License:Open Source License
@Override public boolean visit(VariableDeclarationFragment variableDecl) { IVariableBinding variableBinding = variableDecl.resolveBinding(); Resource referredTypeRes = bindingToResource(variableBinding.getType()); FieldDeclaration fieldDecl = (FieldDeclaration) getParent(FieldDeclaration.class); if (fieldDecl == null) { // var. decl. in statements Resource methodCallerRes = CallHeirarchyExtractor.getCallingRes(this); addRef(methodCallerRes, referredTypeRes); } else {/*from w w w .ja v a2 s. com*/ // field declaration Resource variableDeclRes = bindingToResource(variableBinding); addRef(variableDeclRes, referredTypeRes); } return true; }
From source file:com.codenvy.ide.ext.java.server.internal.core.util.DOMFinder.java
License:Open Source License
public boolean visit(VariableDeclarationFragment node) { if (found(node, node.getName()) && this.resolveBinding) this.foundBinding = node.resolveBinding(); return true;/*from w w w . ja v a2 s.co m*/ }