List of usage examples for org.eclipse.jdt.core.dom ITypeBinding getModifiers
@Override public int getModifiers();
From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java
License:Open Source License
@Override public boolean visit(final AnonymousClassDeclaration pNode) { final ITypeBinding lBinding = pNode.resolveBinding(); if (ASTCrawler.checkForNull(lBinding)) return false; if (ASTCrawler.checkForNull(this.aCurrType)) return false; final IElement lAnonymousClass = ASTCrawler.convertBinding(lBinding); this.aCurrTypeReminder.push(this.aCurrType); this.aCurrType = (ClassElement) lAnonymousClass; this.aDB.addElement(this.aCurrType, pNode.resolveBinding().getModifiers()); this.aDB.addRelation(this.aCurrMethod, Relation.DECLARES_TYPE, this.aCurrType); final ITypeBinding lSuperBinding = lBinding.getSuperclass(); if (lSuperBinding != null) { final IElement lSuperClass = ASTCrawler.convertBinding(lSuperBinding); this.aDB.addElement(lSuperClass, lSuperBinding.getModifiers()); this.aDB.addRelationAndTranspose(this.aCurrType, Relation.EXTENDS_CLASS, lSuperClass); }/*from w w w . j a v a2s. c o m*/ final ITypeBinding lInterfaceBindings[] = lBinding.getInterfaces(); for (final ITypeBinding element : lInterfaceBindings) { final IElement lInterface = ASTCrawler.convertBinding(element); this.aDB.addElement(lInterface, element.getModifiers() | ASTCrawler.ABSTRACT_FLAG); this.aDB.addRelationAndTranspose(this.aCurrType, Relation.IMPLEMENTS_INTERFACE, lInterface); } return true; }
From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java
License:Open Source License
@Override public boolean visit(final CastExpression pNode) { // assert (aCurrMethod != null); final ITypeBinding lBinding = pNode.resolveTypeBinding(); if (lBinding != null) { final IElement lClass = ASTCrawler.convertBinding(lBinding); this.aDB.addElement(lClass, lBinding.getModifiers() | (lBinding.isInterface() ? ASTCrawler.ABSTRACT_FLAG : 0)); this.aDB.addRelationAndTranspose(this.aCurrMethod, Relation.CHECKS, lClass); }//from w ww . j a v a2s .c o m return true; }
From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java
License:Open Source License
@Override public boolean visit(final ClassInstanceCreation pNode) { if (ASTCrawler.checkForNull(this.aCurrMethod)) return false; final IMethodBinding lCBinding = pNode.resolveConstructorBinding(); final ITypeBinding lTBinding = pNode.resolveTypeBinding(); if (ASTCrawler.checkForNull(lCBinding)) return false; if (ASTCrawler.checkForNull(lTBinding)) return false; MethodElement lConstructor = null;/*w w w . ja v a 2 s. c om*/ if (lTBinding.isAnonymous()) { final IElement lDeclaringClass = ASTCrawler.convertBinding(lTBinding); // TODO HACK A bug in Eclipse occasionally causes binary names to // crap out. if (lDeclaringClass == null || lDeclaringClass.getId() == null) return false; lConstructor = (MethodElement) FlyweightElementFactory.getElement(Category.METHOD, lDeclaringClass.getId() + "." + ASTCrawler.aINIT_METHOD_NAME); this.aDB.addElement(lConstructor, ASTCrawler.aINIT_METHOD_MODIFIERS); } else lConstructor = (MethodElement) ASTCrawler.convertBinding(lCBinding); final IElement lClass = lConstructor.getDeclaringClass(); // Register CALLS relationship to constructor this.addCallRelation(pNode, lCBinding, true); try { this.aDB.contains(lClass); } catch (final RuntimeException pException) { System.out.println(lClass.getId()); System.out.println(lConstructor.getId()); throw pException; } if (!this.aDB.contains(lClass)) { final ITypeBinding lType = lCBinding.getDeclaringClass(); this.aDB.addElement(lClass, lType.getModifiers()); } // Register CREATES relationship this.aDB.addRelationAndTranspose(this.aCurrMethod, Relation.CREATES, lClass); return true; }
From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java
License:Open Source License
/** * Generated the DECLARES relations between a enum and and nested types. *//* ww w.j a v a 2 s.c o m*/ @Override public boolean visit(final EnumDeclaration pNode) { final ITypeBinding lBinding = pNode.resolveBinding(); // assert (lBinding.isEnum()); if (ASTCrawler.checkForNull(lBinding)) return false; try { this.saveTypeRelation(lBinding); // JLS3(8.9): It is impossible to define a local (14.3) enum, or // to define an enum in an inner class (8.1.3). // TODO: check if enum type is always a member class of an closing // class if (lBinding.isMember()) this.aDB.addRelation(this.aCurrTypeReminder.peek(), Relation.DECLARES_TYPE, this.aCurrType); // Find interfaces. final ITypeBinding lInterfaceBindings[] = lBinding.getInterfaces(); for (final ITypeBinding element : lInterfaceBindings) { final IElement lInterface = ASTCrawler.convertBinding(element); this.aDB.addElement(lInterface, element.getModifiers() | ASTCrawler.ABSTRACT_FLAG); this.aDB.addRelationAndTranspose(this.aCurrType, Relation.IMPLEMENTS_INTERFACE, lInterface); } } catch (final Exception pException) { ProblemManager.reportException(pException); } return true; }
From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java
License:Open Source License
@Override public boolean visit(final InstanceofExpression pNode) { if (ASTCrawler.checkForNull(this.aCurrMethod)) return false; final ITypeBinding lBinding = pNode.getRightOperand().resolveBinding(); if (lBinding != null) { final IElement lClass = ASTCrawler.convertBinding(lBinding); this.aDB.addElement(lClass, lBinding.getModifiers() | (lBinding.isInterface() ? ASTCrawler.ABSTRACT_FLAG : 0)); this.aDB.addRelationAndTranspose(this.aCurrMethod, Relation.CHECKS, lClass); }/*from w w w . j ava 2 s . c o m*/ return true; }
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 . j a va 2s . c om*/ 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 ww .ja va 2 s . c om 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 PackageDeclaration pNode) { final IPackageBinding binding = pNode.resolveBinding(); if (ASTCrawler.checkForNull(binding)) return false; final IElement packageElem = this.convertBinding(binding); this.aDB.addElement(packageElem, binding.getModifiers()); final CompilationUnit parent = (CompilationUnit) pNode.getParent(); @SuppressWarnings("rawtypes") final List containedTypes = parent.types(); for (@SuppressWarnings("rawtypes") final Iterator it = containedTypes.iterator(); it.hasNext();) { final AbstractTypeDeclaration type = (AbstractTypeDeclaration) it.next(); final ITypeBinding typeBinding = type.resolveBinding(); final IElement typeElem = ASTCrawler.convertBinding(typeBinding); this.aDB.addElement(typeElem, typeBinding.getModifiers()); this.aDB.addRelation(packageElem, Relation.CONTAINS, typeElem); }/*from w w w .j ava 2 s . c o m*/ return true; }
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 w ww .jav a2 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: { 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
/** * Generated the DECLARES relations between a type and and nested types, the * EXTENDS relations, and the IMPLEMENTS relation *///from ww w .j a v a2 s .co m @Override public boolean visit(final TypeDeclaration pNode) { final ITypeBinding lBinding = pNode.resolveBinding(); if (ASTCrawler.checkForNull(lBinding)) return false; try { this.saveTypeRelation(lBinding); // Add Declaration relations if this is a local or nested class if (lBinding.isLocal() || lBinding.isAnonymous()) this.aDB.addRelation(this.aCurrMethod, Relation.DECLARES_TYPE, this.aCurrType); else if (lBinding.isNested()) this.aDB.addRelation(this.aCurrTypeReminder.peek(), Relation.DECLARES_TYPE, this.aCurrType); // Find superclass if (!pNode.isInterface()) { final ITypeBinding lSuperBinding = lBinding.getSuperclass(); if (lSuperBinding != null) { final IElement lSuperClass = ASTCrawler.convertBinding(lSuperBinding); this.aDB.addElement(lSuperClass, lSuperBinding.getModifiers()); this.aDB.addRelationAndTranspose(this.aCurrType, Relation.EXTENDS_CLASS, lSuperClass); } } // Find interfaces. final ITypeBinding lInterfaceBindings[] = lBinding.getInterfaces(); for (final ITypeBinding element : lInterfaceBindings) { final IElement lInterface = ASTCrawler.convertBinding(element); this.aDB.addElement(lInterface, element.getModifiers() | ASTCrawler.ABSTRACT_FLAG); if (pNode.isInterface()) this.aDB.addRelationAndTranspose(this.aCurrType, Relation.EXTENDS_INTERFACES, lInterface); else this.aDB.addRelationAndTranspose(this.aCurrType, Relation.IMPLEMENTS_INTERFACE, lInterface); } } catch (final Exception pException) { ProblemManager.reportException(pException); } return true; }