List of usage examples for org.eclipse.jdt.core.dom ASTNode FIELD_DECLARATION
int FIELD_DECLARATION
To view the source code for org.eclipse.jdt.core.dom ASTNode FIELD_DECLARATION.
Click Source Link
FieldDeclaration
. 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); }/*from w w w . j ava 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.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 ww w. j a va2s . 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); }//w w w .j ava2 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:cc.kave.eclipse.namefactory.NodeFactory.java
License:Apache License
public static Name createNodeName(ASTNode node) { switch (node.getNodeType()) { case ASTNode.METHOD_DECLARATION: return createMethodDeclName((MethodDeclaration) node); case ASTNode.METHOD_INVOCATION: return createMethodInvName(node); case ASTNode.SUPER_METHOD_INVOCATION: return createSuperMethodInvName(node); case ASTNode.VARIABLE_DECLARATION_FRAGMENT: return createVariableName(node.getParent()); case ASTNode.QUALIFIED_NAME: return createQualifiedName(node); case ASTNode.SINGLE_VARIABLE_DECLARATION: return createSingleVariableDeclName(node); case ASTNode.IMPORT_DECLARATION: ImportDeclaration importNode = (ImportDeclaration) node; return CsTypeName.newTypeName(BindingFactory.getBindingName(importNode.resolveBinding())); case ASTNode.PACKAGE_DECLARATION: PackageDeclaration packageNode = (PackageDeclaration) node; return CsNamespaceName.newNamespaceName(packageNode.resolveBinding().getName()); case ASTNode.FIELD_DECLARATION: return createVariableName(node); case ASTNode.VARIABLE_DECLARATION_STATEMENT: return createVariableName(node); case ASTNode.VARIABLE_DECLARATION_EXPRESSION: return createVariableName(node); default:/*from w w w . jav a 2s. c o m*/ return null; } }
From source file:cc.kave.eclipse.namefactory.NodeFactory.java
License:Apache License
private static Name createVariableName(ASTNode node) { StringBuilder sb = new StringBuilder(); switch (node.getNodeType()) { case ASTNode.FIELD_DECLARATION: FieldDeclaration fieldNode = (FieldDeclaration) node; Object field = fieldNode.fragments().get(0); if (field instanceof VariableDeclarationFragment) { sb.append(modifierHelper(((VariableDeclarationFragment) field).resolveBinding())); sb.append("["); sb.append(BindingFactory/*from w ww . j a v a2 s. c o m*/ .getBindingName(((VariableDeclarationFragment) field).resolveBinding().getType())); sb.append("] ["); sb.append(getDeclaringType(fieldNode)); sb.append("]."); sb.append(((VariableDeclarationFragment) field).getName().getIdentifier()); return CsFieldName.newFieldName(sb.toString()); } break; case ASTNode.VARIABLE_DECLARATION_STATEMENT: VariableDeclarationStatement variableStatementNode = (VariableDeclarationStatement) node; Object variableStatement = variableStatementNode.fragments().get(0); if (variableStatement instanceof VariableDeclarationFragment) { sb.append("["); sb.append(BindingFactory.getBindingName( ((VariableDeclarationFragment) variableStatement).resolveBinding().getType())); sb.append("] "); sb.append(((VariableDeclarationFragment) variableStatement).getName().getIdentifier()); return CsLocalVariableName.newLocalVariableName(sb.toString()); } break; case ASTNode.VARIABLE_DECLARATION_EXPRESSION: VariableDeclarationExpression variableExpressionNode = (VariableDeclarationExpression) node; Object variableExpression = variableExpressionNode.fragments().get(0); if (variableExpression instanceof VariableDeclarationFragment) { sb.append("["); sb.append(BindingFactory.getBindingName( ((VariableDeclarationFragment) variableExpression).resolveBinding().getType())); sb.append("] "); sb.append(((VariableDeclarationFragment) variableExpression).getName().getIdentifier()); return CsLocalVariableName.newLocalVariableName(sb.toString()); } break; } throw new RuntimeException("should not happen"); }
From source file:cideplus.ui.astview.ASTViewLabelProvider.java
License:Open Source License
public Image getImage(Object obj) { if (obj instanceof ASTNode) { int nodeType = ((ASTNode) obj).getNodeType(); String image = ISharedImages.IMG_OBJS_CFILE; //new JavaElementImageDescriptor() switch (nodeType) { case ASTNode.ENUM_CONSTANT_DECLARATION: image = ISharedImages.IMG_OBJS_ENUM_DEFAULT; break; case ASTNode.FIELD_DECLARATION: image = ISharedImages.IMG_FIELD_DEFAULT; break; case ASTNode.METHOD_DECLARATION: image = ISharedImages.IMG_OBJS_PUBLIC; break; case ASTNode.MODIFIER: image = ISharedImages.IMG_OBJS_DEFAULT; break; case ASTNode.JAVADOC: image = ISharedImages.IMG_OBJS_JAVADOCTAG; break; case ASTNode.PACKAGE_DECLARATION: image = ISharedImages.IMG_OBJS_PACKDECL; break; case ASTNode.IMPORT_DECLARATION: image = ISharedImages.IMG_OBJS_IMPDECL; break; case ASTNode.ENUM_DECLARATION: image = ISharedImages.IMG_OBJS_ENUM; break; case ASTNode.TYPE_DECLARATION: if (((TypeDeclaration) obj).isInterface()) { image = ISharedImages.IMG_OBJS_INTERFACE; } else { image = ISharedImages.IMG_OBJS_CLASS; }//from w ww . j ava 2s . c o m break; } if (image != null) { return JavaUI.getSharedImages().getImage(image); } return null; } else if (obj instanceof ASTAttribute) { Image image = ((ASTAttribute) obj).getImage(); if (image == null) { if (((ASTAttribute) obj).getChildren().length > 0) { image = PlatformUI.getWorkbench().getSharedImages() .getImage(org.eclipse.ui.ISharedImages.IMG_OBJ_FOLDER); } else { image = PlatformUI.getWorkbench().getSharedImages() .getImage(org.eclipse.ui.ISharedImages.IMG_TOOL_FORWARD); } } return image; } return null; // String imageKey = ISharedImages.IMG_OBJ_ELEMENT; // if (obj instanceof ASTNode) { // imageKey = ISharedImages.IMG_OBJ_FOLDER; // } // return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey); }
From source file:com.drgarbage.ast.ASTGraphUtil.java
License:Apache License
/** * Returns an image corresponding to the AST element. * /*from www . ja va2s . c om*/ * @param node the AST-node * @return the image */ @SuppressWarnings("restriction") public static Image getImage(ASTNode node) { switch (node.getNodeType()) { case ASTNode.COMPILATION_UNIT: return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CUNIT); case ASTNode.PACKAGE_DECLARATION: return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_PACKDECL); case ASTNode.IMPORT_DECLARATION: return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_IMPDECL); case ASTNode.TYPE_DECLARATION: return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_CLASS); case ASTNode.ANNOTATION_TYPE_DECLARATION: return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_ANNOTATION); case ASTNode.ANONYMOUS_CLASS_DECLARATION: return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_INNER_CLASS_DEFAULT); case ASTNode.ENUM_DECLARATION: return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_ENUM); case ASTNode.FIELD_DECLARATION: case ASTNode.ENUM_CONSTANT_DECLARATION: return JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PROTECTED); case ASTNode.METHOD_DECLARATION: return JavaPluginImages.get(JavaPluginImages.IMG_MISC_PUBLIC); case ASTNode.JAVADOC: return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_JAVADOCTAG); case ASTNode.VARIABLE_DECLARATION_STATEMENT: return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_LOCAL_VARIABLE); case ASTNode.BLOCK: return blockImage; case ASTNode.MODIFIER: return JavaPluginImages.get(JavaPluginImages.IMG_FIELD_DEFAULT); } /* default */ return JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE); }
From source file:com.drgarbage.ast.ASTPanel.java
License:Apache License
/** * Hide Fields.//ww w . j av a 2 s .c o m */ public void hideFields(boolean hidden) { if (hidden) { ((TreeContentProvider) treeViewer.getContentProvider()).hide(ASTNode.FIELD_DECLARATION); } else { ((TreeContentProvider) treeViewer.getContentProvider()).show(ASTNode.FIELD_DECLARATION); } treeViewer.refresh(); }
From source file:com.github.parzonka.ccms.sorter.comparator.BodyDeclarationComparator.java
License:Open Source License
private boolean isSortPreserved(BodyDeclaration bodyDeclaration) { switch (bodyDeclaration.getNodeType()) { case ASTNode.FIELD_DECLARATION: case ASTNode.ENUM_CONSTANT_DECLARATION: case ASTNode.INITIALIZER: case ASTNode.TYPE_DECLARATION: return true; default://from w w w . j a va 2 s .c o m return false; } }
From source file:com.github.parzonka.ccms.sorter.comparator.BodyDeclarationComparator.java
License:Open Source License
private int category(BodyDeclaration bodyDeclaration) { switch (bodyDeclaration.getNodeType()) { case ASTNode.METHOD_DECLARATION: { final MethodDeclaration method = (MethodDeclaration) bodyDeclaration; if (method.isConstructor()) { return getMemberCategory(MembersOrderPreferenceCache.CONSTRUCTORS_INDEX); } else//from www. j av a 2 s. co m return getMemberCategory(MembersOrderPreferenceCache.METHOD_INDEX); } case ASTNode.FIELD_DECLARATION: { return getMemberCategory(MembersOrderPreferenceCache.FIELDS_INDEX); } case ASTNode.INITIALIZER: { final int flags = ((Initializer) bodyDeclaration).getModifiers(); if (Modifier.isStatic(flags)) return getMemberCategory(MembersOrderPreferenceCache.STATIC_INIT_INDEX); else return getMemberCategory(MembersOrderPreferenceCache.INIT_INDEX); } case ASTNode.TYPE_DECLARATION: case ASTNode.ENUM_DECLARATION: case ASTNode.ANNOTATION_TYPE_DECLARATION: return getMemberCategory(MembersOrderPreferenceCache.TYPE_INDEX); case ASTNode.ENUM_CONSTANT_DECLARATION: return getMemberCategory(MembersOrderPreferenceCache.ENUM_CONSTANTS_INDEX); case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION: return getMemberCategory(MembersOrderPreferenceCache.METHOD_INDEX); } throw new IllegalStateException(); }