List of usage examples for org.eclipse.jdt.core.dom ASTNode ANNOTATION_TYPE_DECLARATION
int ANNOTATION_TYPE_DECLARATION
To view the source code for org.eclipse.jdt.core.dom ASTNode ANNOTATION_TYPE_DECLARATION.
Click Source Link
AnnotationTypeDeclaration
. 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 ww w .j a v a 2s. 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); }// w w w . j a v a 2 s.com 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 av a2 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:com.drgarbage.ast.ASTGraphUtil.java
License:Apache License
/** * Returns an image corresponding to the AST element. * /*from w w w .j a v a2 s . com*/ * @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.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/* ww w . j a v a2 s . c om*/ 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(); }
From source file:com.google.devtools.j2objc.ast.TreeConverter.java
License:Apache License
public static TreeNode convertInner(ASTNode jdtNode) { switch (jdtNode.getNodeType()) { case ASTNode.ANNOTATION_TYPE_DECLARATION: return new AnnotationTypeDeclaration((org.eclipse.jdt.core.dom.AnnotationTypeDeclaration) jdtNode); case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION: return new AnnotationTypeMemberDeclaration( (org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration) jdtNode); case ASTNode.ANONYMOUS_CLASS_DECLARATION: return new AnonymousClassDeclaration((org.eclipse.jdt.core.dom.AnonymousClassDeclaration) jdtNode); case ASTNode.ARRAY_ACCESS: return new ArrayAccess((org.eclipse.jdt.core.dom.ArrayAccess) jdtNode); case ASTNode.ARRAY_CREATION: return new ArrayCreation((org.eclipse.jdt.core.dom.ArrayCreation) jdtNode); case ASTNode.ARRAY_INITIALIZER: return new ArrayInitializer((org.eclipse.jdt.core.dom.ArrayInitializer) jdtNode); case ASTNode.ARRAY_TYPE: return new ArrayType((org.eclipse.jdt.core.dom.ArrayType) jdtNode); case ASTNode.ASSERT_STATEMENT: return new AssertStatement((org.eclipse.jdt.core.dom.AssertStatement) jdtNode); case ASTNode.ASSIGNMENT: return new Assignment((org.eclipse.jdt.core.dom.Assignment) jdtNode); case ASTNode.BLOCK: return new Block((org.eclipse.jdt.core.dom.Block) jdtNode); case ASTNode.BLOCK_COMMENT: return new BlockComment((org.eclipse.jdt.core.dom.BlockComment) jdtNode); case ASTNode.BOOLEAN_LITERAL: return new BooleanLiteral((org.eclipse.jdt.core.dom.BooleanLiteral) jdtNode); case ASTNode.BREAK_STATEMENT: return new BreakStatement((org.eclipse.jdt.core.dom.BreakStatement) jdtNode); case ASTNode.CAST_EXPRESSION: return new CastExpression((org.eclipse.jdt.core.dom.CastExpression) jdtNode); case ASTNode.CATCH_CLAUSE: return new CatchClause((org.eclipse.jdt.core.dom.CatchClause) jdtNode); case ASTNode.CHARACTER_LITERAL: return new CharacterLiteral((org.eclipse.jdt.core.dom.CharacterLiteral) jdtNode); case ASTNode.CLASS_INSTANCE_CREATION: return new ClassInstanceCreation((org.eclipse.jdt.core.dom.ClassInstanceCreation) jdtNode); case ASTNode.CONDITIONAL_EXPRESSION: return new ConditionalExpression((org.eclipse.jdt.core.dom.ConditionalExpression) jdtNode); case ASTNode.CONSTRUCTOR_INVOCATION: return new ConstructorInvocation((org.eclipse.jdt.core.dom.ConstructorInvocation) jdtNode); case ASTNode.CONTINUE_STATEMENT: return new ContinueStatement((org.eclipse.jdt.core.dom.ContinueStatement) jdtNode); case ASTNode.DO_STATEMENT: return new DoStatement((org.eclipse.jdt.core.dom.DoStatement) jdtNode); case ASTNode.EMPTY_STATEMENT: return new EmptyStatement((org.eclipse.jdt.core.dom.EmptyStatement) jdtNode); case ASTNode.ENHANCED_FOR_STATEMENT: return new EnhancedForStatement((org.eclipse.jdt.core.dom.EnhancedForStatement) jdtNode); case ASTNode.ENUM_CONSTANT_DECLARATION: return new EnumConstantDeclaration((org.eclipse.jdt.core.dom.EnumConstantDeclaration) jdtNode); case ASTNode.ENUM_DECLARATION: return new EnumDeclaration((org.eclipse.jdt.core.dom.EnumDeclaration) jdtNode); case ASTNode.EXPRESSION_STATEMENT: return new ExpressionStatement((org.eclipse.jdt.core.dom.ExpressionStatement) jdtNode); case ASTNode.FIELD_ACCESS: return new FieldAccess((org.eclipse.jdt.core.dom.FieldAccess) jdtNode); case ASTNode.FIELD_DECLARATION: return new FieldDeclaration((org.eclipse.jdt.core.dom.FieldDeclaration) jdtNode); case ASTNode.FOR_STATEMENT: return new ForStatement((org.eclipse.jdt.core.dom.ForStatement) jdtNode); case ASTNode.IF_STATEMENT: return new IfStatement((org.eclipse.jdt.core.dom.IfStatement) jdtNode); case ASTNode.INFIX_EXPRESSION: return new InfixExpression((org.eclipse.jdt.core.dom.InfixExpression) jdtNode); case ASTNode.INITIALIZER: return new Initializer((org.eclipse.jdt.core.dom.Initializer) jdtNode); case ASTNode.INSTANCEOF_EXPRESSION: return new InstanceofExpression((org.eclipse.jdt.core.dom.InstanceofExpression) jdtNode); case ASTNode.JAVADOC: return new Javadoc((org.eclipse.jdt.core.dom.Javadoc) jdtNode); case ASTNode.LABELED_STATEMENT: return new LabeledStatement((org.eclipse.jdt.core.dom.LabeledStatement) jdtNode); case ASTNode.LINE_COMMENT: return new LineComment((org.eclipse.jdt.core.dom.LineComment) jdtNode); case ASTNode.MARKER_ANNOTATION: return new MarkerAnnotation((org.eclipse.jdt.core.dom.MarkerAnnotation) jdtNode); case ASTNode.MEMBER_VALUE_PAIR: return new MemberValuePair((org.eclipse.jdt.core.dom.MemberValuePair) jdtNode); case ASTNode.METHOD_DECLARATION: return new MethodDeclaration((org.eclipse.jdt.core.dom.MethodDeclaration) jdtNode); case ASTNode.METHOD_INVOCATION: return new MethodInvocation((org.eclipse.jdt.core.dom.MethodInvocation) jdtNode); case ASTNode.NORMAL_ANNOTATION: return new NormalAnnotation((org.eclipse.jdt.core.dom.NormalAnnotation) jdtNode); case ASTNode.NULL_LITERAL: return new NullLiteral((org.eclipse.jdt.core.dom.NullLiteral) jdtNode); case ASTNode.NUMBER_LITERAL: return new NumberLiteral((org.eclipse.jdt.core.dom.NumberLiteral) jdtNode); case ASTNode.PACKAGE_DECLARATION: return new PackageDeclaration((org.eclipse.jdt.core.dom.PackageDeclaration) jdtNode); case ASTNode.PARAMETERIZED_TYPE: return new ParameterizedType((org.eclipse.jdt.core.dom.ParameterizedType) jdtNode); case ASTNode.PARENTHESIZED_EXPRESSION: return new ParenthesizedExpression((org.eclipse.jdt.core.dom.ParenthesizedExpression) jdtNode); case ASTNode.POSTFIX_EXPRESSION: return new PostfixExpression((org.eclipse.jdt.core.dom.PostfixExpression) jdtNode); case ASTNode.PREFIX_EXPRESSION: return new PrefixExpression((org.eclipse.jdt.core.dom.PrefixExpression) jdtNode); case ASTNode.PRIMITIVE_TYPE: return new PrimitiveType((org.eclipse.jdt.core.dom.PrimitiveType) jdtNode); case ASTNode.QUALIFIED_NAME: return new QualifiedName((org.eclipse.jdt.core.dom.QualifiedName) jdtNode); case ASTNode.QUALIFIED_TYPE: return new QualifiedType((org.eclipse.jdt.core.dom.QualifiedType) jdtNode); case ASTNode.RETURN_STATEMENT: return new ReturnStatement((org.eclipse.jdt.core.dom.ReturnStatement) jdtNode); case ASTNode.SIMPLE_NAME: return new SimpleName((org.eclipse.jdt.core.dom.SimpleName) jdtNode); case ASTNode.SIMPLE_TYPE: return new SimpleType((org.eclipse.jdt.core.dom.SimpleType) jdtNode); case ASTNode.SINGLE_MEMBER_ANNOTATION: return new SingleMemberAnnotation((org.eclipse.jdt.core.dom.SingleMemberAnnotation) jdtNode); case ASTNode.SINGLE_VARIABLE_DECLARATION: return new SingleVariableDeclaration((org.eclipse.jdt.core.dom.SingleVariableDeclaration) jdtNode); case ASTNode.STRING_LITERAL: return new StringLiteral((org.eclipse.jdt.core.dom.StringLiteral) jdtNode); case ASTNode.SUPER_CONSTRUCTOR_INVOCATION: return new SuperConstructorInvocation((org.eclipse.jdt.core.dom.SuperConstructorInvocation) jdtNode); case ASTNode.SUPER_FIELD_ACCESS: return new SuperFieldAccess((org.eclipse.jdt.core.dom.SuperFieldAccess) jdtNode); case ASTNode.SUPER_METHOD_INVOCATION: return new SuperMethodInvocation((org.eclipse.jdt.core.dom.SuperMethodInvocation) jdtNode); case ASTNode.SWITCH_CASE: return new SwitchCase((org.eclipse.jdt.core.dom.SwitchCase) jdtNode); case ASTNode.SWITCH_STATEMENT: return new SwitchStatement((org.eclipse.jdt.core.dom.SwitchStatement) jdtNode); case ASTNode.SYNCHRONIZED_STATEMENT: return new SynchronizedStatement((org.eclipse.jdt.core.dom.SynchronizedStatement) jdtNode); case ASTNode.TAG_ELEMENT: return new TagElement((org.eclipse.jdt.core.dom.TagElement) jdtNode); case ASTNode.TEXT_ELEMENT: return new TextElement((org.eclipse.jdt.core.dom.TextElement) jdtNode); case ASTNode.THIS_EXPRESSION: return new ThisExpression((org.eclipse.jdt.core.dom.ThisExpression) jdtNode); case ASTNode.THROW_STATEMENT: return new ThrowStatement((org.eclipse.jdt.core.dom.ThrowStatement) jdtNode); case ASTNode.TRY_STATEMENT: return new TryStatement((org.eclipse.jdt.core.dom.TryStatement) jdtNode); case ASTNode.TYPE_DECLARATION: return new TypeDeclaration((org.eclipse.jdt.core.dom.TypeDeclaration) jdtNode); case ASTNode.TYPE_DECLARATION_STATEMENT: return new TypeDeclarationStatement((org.eclipse.jdt.core.dom.TypeDeclarationStatement) jdtNode); case ASTNode.TYPE_LITERAL: return new TypeLiteral((org.eclipse.jdt.core.dom.TypeLiteral) jdtNode); case ASTNode.UNION_TYPE: return new UnionType((org.eclipse.jdt.core.dom.UnionType) jdtNode); case ASTNode.VARIABLE_DECLARATION_EXPRESSION: return new VariableDeclarationExpression( (org.eclipse.jdt.core.dom.VariableDeclarationExpression) jdtNode); case ASTNode.VARIABLE_DECLARATION_FRAGMENT: return new VariableDeclarationFragment((org.eclipse.jdt.core.dom.VariableDeclarationFragment) jdtNode); case ASTNode.VARIABLE_DECLARATION_STATEMENT: return new VariableDeclarationStatement( (org.eclipse.jdt.core.dom.VariableDeclarationStatement) jdtNode); case ASTNode.WHILE_STATEMENT: return new WhileStatement((org.eclipse.jdt.core.dom.WhileStatement) jdtNode); // These nodes only appear in comments and J2ObjC doens't need any // information from their subtree so we just convert them to TextElement. case ASTNode.MEMBER_REF: case ASTNode.METHOD_REF: case ASTNode.METHOD_REF_PARAMETER: return new TextElement(jdtNode); case ASTNode.COMPILATION_UNIT: throw new AssertionError("CompilationUnit must be converted using convertCompilationUnit()"); default:/*from ww w .j a va2 s . c o m*/ throw new AssertionError("Unknown node type: " + jdtNode.getClass().getName()); } }
From source file:com.google.devtools.j2objc.jdt.TreeConverter.java
License:Apache License
private static TreeNode convertInner(ASTNode jdtNode) { switch (jdtNode.getNodeType()) { case ASTNode.ANNOTATION_TYPE_DECLARATION: return convertAnnotationTypeDeclaration((org.eclipse.jdt.core.dom.AnnotationTypeDeclaration) jdtNode); case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION: return convertAnnotationTypeMemberDeclaration( (org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration) jdtNode); case ASTNode.ARRAY_ACCESS: return convertArrayAccess((org.eclipse.jdt.core.dom.ArrayAccess) jdtNode); case ASTNode.ARRAY_CREATION: return convertArrayCreation((org.eclipse.jdt.core.dom.ArrayCreation) jdtNode); case ASTNode.ARRAY_INITIALIZER: return convertArrayInitializer((org.eclipse.jdt.core.dom.ArrayInitializer) jdtNode); case ASTNode.ARRAY_TYPE: return convertArrayType((org.eclipse.jdt.core.dom.ArrayType) jdtNode); case ASTNode.ASSERT_STATEMENT: return convertAssertStatement((org.eclipse.jdt.core.dom.AssertStatement) jdtNode); case ASTNode.ASSIGNMENT: return convertAssignment((org.eclipse.jdt.core.dom.Assignment) jdtNode); case ASTNode.BLOCK: return convertBlock((org.eclipse.jdt.core.dom.Block) jdtNode); case ASTNode.BLOCK_COMMENT: return new BlockComment(); case ASTNode.BOOLEAN_LITERAL: return convertBooleanLiteral((org.eclipse.jdt.core.dom.BooleanLiteral) jdtNode); case ASTNode.BREAK_STATEMENT: return convertBreakStatement((org.eclipse.jdt.core.dom.BreakStatement) jdtNode); case ASTNode.CAST_EXPRESSION: return convertCastExpression((org.eclipse.jdt.core.dom.CastExpression) jdtNode); case ASTNode.CATCH_CLAUSE: return convertCatchClause((org.eclipse.jdt.core.dom.CatchClause) jdtNode); case ASTNode.CHARACTER_LITERAL: return convertCharacterLiteral((org.eclipse.jdt.core.dom.CharacterLiteral) jdtNode); case ASTNode.CLASS_INSTANCE_CREATION: return convertClassInstanceCreation((org.eclipse.jdt.core.dom.ClassInstanceCreation) jdtNode); case ASTNode.CONDITIONAL_EXPRESSION: return convertConditionalExpression((org.eclipse.jdt.core.dom.ConditionalExpression) jdtNode); case ASTNode.CONSTRUCTOR_INVOCATION: return convertConstructorInvocation((org.eclipse.jdt.core.dom.ConstructorInvocation) jdtNode); case ASTNode.CONTINUE_STATEMENT: return convertContinueStatement((org.eclipse.jdt.core.dom.ContinueStatement) jdtNode); case ASTNode.CREATION_REFERENCE: return convertCreationReference((org.eclipse.jdt.core.dom.CreationReference) jdtNode); case ASTNode.DIMENSION: return convertDimension((org.eclipse.jdt.core.dom.Dimension) jdtNode); case ASTNode.DO_STATEMENT: return convertDoStatement((org.eclipse.jdt.core.dom.DoStatement) jdtNode); case ASTNode.EMPTY_STATEMENT: return new EmptyStatement(); case ASTNode.ENHANCED_FOR_STATEMENT: return convertEnhancedForStatement((org.eclipse.jdt.core.dom.EnhancedForStatement) jdtNode); case ASTNode.ENUM_CONSTANT_DECLARATION: return convertEnumConstantDeclaration((org.eclipse.jdt.core.dom.EnumConstantDeclaration) jdtNode); case ASTNode.ENUM_DECLARATION: return convertEnumDeclaration((org.eclipse.jdt.core.dom.EnumDeclaration) jdtNode); case ASTNode.EXPRESSION_METHOD_REFERENCE: return convertExpressionMethodReference((org.eclipse.jdt.core.dom.ExpressionMethodReference) jdtNode); case ASTNode.EXPRESSION_STATEMENT: return convertExpressionStatement((org.eclipse.jdt.core.dom.ExpressionStatement) jdtNode); case ASTNode.FIELD_ACCESS: return convertFieldAccess((org.eclipse.jdt.core.dom.FieldAccess) jdtNode); case ASTNode.FIELD_DECLARATION: return convertFieldDeclaration((org.eclipse.jdt.core.dom.FieldDeclaration) jdtNode); case ASTNode.FOR_STATEMENT: return convertForStatement((org.eclipse.jdt.core.dom.ForStatement) jdtNode); case ASTNode.IF_STATEMENT: return convertIfStatement((org.eclipse.jdt.core.dom.IfStatement) jdtNode); case ASTNode.INFIX_EXPRESSION: return convertInfixExpression((org.eclipse.jdt.core.dom.InfixExpression) jdtNode); case ASTNode.INTERSECTION_TYPE: return convertIntersectionType((org.eclipse.jdt.core.dom.IntersectionType) jdtNode); case ASTNode.INITIALIZER: return convertInitializer((org.eclipse.jdt.core.dom.Initializer) jdtNode); case ASTNode.INSTANCEOF_EXPRESSION: return convertInstanceofExpression((org.eclipse.jdt.core.dom.InstanceofExpression) jdtNode); case ASTNode.JAVADOC: return convertJavadoc((org.eclipse.jdt.core.dom.Javadoc) jdtNode); case ASTNode.LABELED_STATEMENT: return convertLabeledStatement((org.eclipse.jdt.core.dom.LabeledStatement) jdtNode); case ASTNode.LAMBDA_EXPRESSION: return convertLambdaExpression((org.eclipse.jdt.core.dom.LambdaExpression) jdtNode); case ASTNode.LINE_COMMENT: return new LineComment(); case ASTNode.MARKER_ANNOTATION: return convertMarkerAnnotation((org.eclipse.jdt.core.dom.MarkerAnnotation) jdtNode); case ASTNode.MEMBER_VALUE_PAIR: return convertMemberValuePair((org.eclipse.jdt.core.dom.MemberValuePair) jdtNode); case ASTNode.METHOD_DECLARATION: return convertMethodDeclaration((org.eclipse.jdt.core.dom.MethodDeclaration) jdtNode); case ASTNode.METHOD_INVOCATION: return convertMethodInvocation((org.eclipse.jdt.core.dom.MethodInvocation) jdtNode); case ASTNode.NAME_QUALIFIED_TYPE: return convertNameQualifiedType((org.eclipse.jdt.core.dom.NameQualifiedType) jdtNode); case ASTNode.NORMAL_ANNOTATION: return convertNormalAnnotation((org.eclipse.jdt.core.dom.NormalAnnotation) jdtNode); case ASTNode.NULL_LITERAL: return new NullLiteral(BindingConverter.NULL_TYPE); case ASTNode.NUMBER_LITERAL: return convertNumberLiteral((org.eclipse.jdt.core.dom.NumberLiteral) jdtNode); case ASTNode.PACKAGE_DECLARATION: return convertPackageDeclaration((org.eclipse.jdt.core.dom.PackageDeclaration) jdtNode); case ASTNode.PARAMETERIZED_TYPE: return convertParameterizedType((org.eclipse.jdt.core.dom.ParameterizedType) jdtNode); case ASTNode.PARENTHESIZED_EXPRESSION: return convertParenthesizedExpression((org.eclipse.jdt.core.dom.ParenthesizedExpression) jdtNode); case ASTNode.POSTFIX_EXPRESSION: return convertPostfixExpression((org.eclipse.jdt.core.dom.PostfixExpression) jdtNode); case ASTNode.PREFIX_EXPRESSION: return convertPrefixExpression((org.eclipse.jdt.core.dom.PrefixExpression) jdtNode); case ASTNode.PRIMITIVE_TYPE: return convertPrimitiveType((org.eclipse.jdt.core.dom.PrimitiveType) jdtNode); case ASTNode.QUALIFIED_NAME: return convertQualifiedName((org.eclipse.jdt.core.dom.QualifiedName) jdtNode); case ASTNode.QUALIFIED_TYPE: return convertQualifiedType((org.eclipse.jdt.core.dom.QualifiedType) jdtNode); case ASTNode.RETURN_STATEMENT: return convertReturnStatement((org.eclipse.jdt.core.dom.ReturnStatement) jdtNode); case ASTNode.SIMPLE_NAME: return convertSimpleName((org.eclipse.jdt.core.dom.SimpleName) jdtNode); case ASTNode.SIMPLE_TYPE: return convertSimpleType((org.eclipse.jdt.core.dom.SimpleType) jdtNode); case ASTNode.SINGLE_MEMBER_ANNOTATION: return convertSingleMemberAnnotation((org.eclipse.jdt.core.dom.SingleMemberAnnotation) jdtNode); case ASTNode.SINGLE_VARIABLE_DECLARATION: return convertSingleVariableDeclaration((org.eclipse.jdt.core.dom.SingleVariableDeclaration) jdtNode); case ASTNode.STRING_LITERAL: return convertStringLiteral((org.eclipse.jdt.core.dom.StringLiteral) jdtNode); case ASTNode.SUPER_CONSTRUCTOR_INVOCATION: return convertSuperConstructorInvocation((org.eclipse.jdt.core.dom.SuperConstructorInvocation) jdtNode); case ASTNode.SUPER_FIELD_ACCESS: return convertSuperFieldAccess((org.eclipse.jdt.core.dom.SuperFieldAccess) jdtNode); case ASTNode.SUPER_METHOD_INVOCATION: return convertSuperMethodInvocation((org.eclipse.jdt.core.dom.SuperMethodInvocation) jdtNode); case ASTNode.SUPER_METHOD_REFERENCE: return convertSuperMethodReference((org.eclipse.jdt.core.dom.SuperMethodReference) jdtNode); case ASTNode.SWITCH_CASE: return convertSwitchCase((org.eclipse.jdt.core.dom.SwitchCase) jdtNode); case ASTNode.SWITCH_STATEMENT: return convertSwitchStatement((org.eclipse.jdt.core.dom.SwitchStatement) jdtNode); case ASTNode.SYNCHRONIZED_STATEMENT: return convertSynchronizedStatement((org.eclipse.jdt.core.dom.SynchronizedStatement) jdtNode); case ASTNode.TAG_ELEMENT: return convertTagElement((org.eclipse.jdt.core.dom.TagElement) jdtNode); case ASTNode.TEXT_ELEMENT: return convertTextElement(((org.eclipse.jdt.core.dom.TextElement) jdtNode).getText()); case ASTNode.THIS_EXPRESSION: return convertThisExpression((org.eclipse.jdt.core.dom.ThisExpression) jdtNode); case ASTNode.THROW_STATEMENT: return convertThrowStatement((org.eclipse.jdt.core.dom.ThrowStatement) jdtNode); case ASTNode.TRY_STATEMENT: return convertTryStatement((org.eclipse.jdt.core.dom.TryStatement) jdtNode); case ASTNode.TYPE_DECLARATION: return convertTypeDeclaration((org.eclipse.jdt.core.dom.TypeDeclaration) jdtNode); case ASTNode.TYPE_DECLARATION_STATEMENT: return convertTypeDeclarationStatement((org.eclipse.jdt.core.dom.TypeDeclarationStatement) jdtNode); case ASTNode.TYPE_LITERAL: return convertTypeLiteral((org.eclipse.jdt.core.dom.TypeLiteral) jdtNode); case ASTNode.TYPE_METHOD_REFERENCE: return convertTypeMethodReference((org.eclipse.jdt.core.dom.TypeMethodReference) jdtNode); case ASTNode.UNION_TYPE: return convertUnionType((org.eclipse.jdt.core.dom.UnionType) jdtNode); case ASTNode.VARIABLE_DECLARATION_EXPRESSION: return convertVariableDeclarationExpression( (org.eclipse.jdt.core.dom.VariableDeclarationExpression) jdtNode); case ASTNode.VARIABLE_DECLARATION_FRAGMENT: return convertVariableDeclarationFragment( (org.eclipse.jdt.core.dom.VariableDeclarationFragment) jdtNode); case ASTNode.VARIABLE_DECLARATION_STATEMENT: return convertVariableDeclarationStatement( (org.eclipse.jdt.core.dom.VariableDeclarationStatement) jdtNode); case ASTNode.WHILE_STATEMENT: return convertWhileStatement((org.eclipse.jdt.core.dom.WhileStatement) jdtNode); // These nodes only appear in comments and J2ObjC doens't need any // information from their subtree so we just convert them to TextElement. case ASTNode.MEMBER_REF: case ASTNode.METHOD_REF: case ASTNode.METHOD_REF_PARAMETER: return convertTextElement(jdtNode.toString()); case ASTNode.COMPILATION_UNIT: throw new AssertionError("CompilationUnit must be converted using convertCompilationUnit()"); default://from w w w. j a v a 2 s . c o m throw new AssertionError("Unknown node type: " + jdtNode.getClass().getName()); } }
From source file:com.j2swift.ast.TreeConverter.java
License:Apache License
public static TreeNode convertInner(ASTNode jdtNode) { switch (jdtNode.getNodeType()) { case ASTNode.ANNOTATION_TYPE_DECLARATION: return new AnnotationTypeDeclaration((org.eclipse.jdt.core.dom.AnnotationTypeDeclaration) jdtNode); case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION: return new AnnotationTypeMemberDeclaration( (org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration) jdtNode); case ASTNode.ANONYMOUS_CLASS_DECLARATION: return new AnonymousClassDeclaration((org.eclipse.jdt.core.dom.AnonymousClassDeclaration) jdtNode); case ASTNode.ARRAY_ACCESS: return new ArrayAccess((org.eclipse.jdt.core.dom.ArrayAccess) jdtNode); case ASTNode.ARRAY_CREATION: return new ArrayCreation((org.eclipse.jdt.core.dom.ArrayCreation) jdtNode); case ASTNode.ARRAY_INITIALIZER: return new ArrayInitializer((org.eclipse.jdt.core.dom.ArrayInitializer) jdtNode); case ASTNode.ARRAY_TYPE: return new ArrayType((org.eclipse.jdt.core.dom.ArrayType) jdtNode); case ASTNode.ASSERT_STATEMENT: return new AssertStatement((org.eclipse.jdt.core.dom.AssertStatement) jdtNode); case ASTNode.ASSIGNMENT: return new Assignment((org.eclipse.jdt.core.dom.Assignment) jdtNode); case ASTNode.BLOCK: return new Block((org.eclipse.jdt.core.dom.Block) jdtNode); case ASTNode.BLOCK_COMMENT: return new BlockComment((org.eclipse.jdt.core.dom.BlockComment) jdtNode); case ASTNode.BOOLEAN_LITERAL: return new BooleanLiteral((org.eclipse.jdt.core.dom.BooleanLiteral) jdtNode); case ASTNode.BREAK_STATEMENT: return new BreakStatement((org.eclipse.jdt.core.dom.BreakStatement) jdtNode); case ASTNode.CAST_EXPRESSION: return new CastExpression((org.eclipse.jdt.core.dom.CastExpression) jdtNode); case ASTNode.CATCH_CLAUSE: return new CatchClause((org.eclipse.jdt.core.dom.CatchClause) jdtNode); case ASTNode.CHARACTER_LITERAL: return new CharacterLiteral((org.eclipse.jdt.core.dom.CharacterLiteral) jdtNode); case ASTNode.CLASS_INSTANCE_CREATION: return new ClassInstanceCreation((org.eclipse.jdt.core.dom.ClassInstanceCreation) jdtNode); case ASTNode.CONDITIONAL_EXPRESSION: return new ConditionalExpression((org.eclipse.jdt.core.dom.ConditionalExpression) jdtNode); case ASTNode.CONSTRUCTOR_INVOCATION: return new ConstructorInvocation((org.eclipse.jdt.core.dom.ConstructorInvocation) jdtNode); case ASTNode.CONTINUE_STATEMENT: return new ContinueStatement((org.eclipse.jdt.core.dom.ContinueStatement) jdtNode); case ASTNode.CREATION_REFERENCE: return new CreationReference((org.eclipse.jdt.core.dom.CreationReference) jdtNode); case ASTNode.DIMENSION: return new Dimension((org.eclipse.jdt.core.dom.Dimension) jdtNode); case ASTNode.DO_STATEMENT: return new DoStatement((org.eclipse.jdt.core.dom.DoStatement) jdtNode); case ASTNode.EMPTY_STATEMENT: return new EmptyStatement((org.eclipse.jdt.core.dom.EmptyStatement) jdtNode); case ASTNode.ENHANCED_FOR_STATEMENT: return new EnhancedForStatement((org.eclipse.jdt.core.dom.EnhancedForStatement) jdtNode); case ASTNode.ENUM_CONSTANT_DECLARATION: return new EnumConstantDeclaration((org.eclipse.jdt.core.dom.EnumConstantDeclaration) jdtNode); case ASTNode.ENUM_DECLARATION: return new EnumDeclaration((org.eclipse.jdt.core.dom.EnumDeclaration) jdtNode); case ASTNode.EXPRESSION_METHOD_REFERENCE: return new ExpressionMethodReference((org.eclipse.jdt.core.dom.ExpressionMethodReference) jdtNode); case ASTNode.EXPRESSION_STATEMENT: return new ExpressionStatement((org.eclipse.jdt.core.dom.ExpressionStatement) jdtNode); case ASTNode.FIELD_ACCESS: return new FieldAccess((org.eclipse.jdt.core.dom.FieldAccess) jdtNode); case ASTNode.FIELD_DECLARATION: return new FieldDeclaration((org.eclipse.jdt.core.dom.FieldDeclaration) jdtNode); case ASTNode.FOR_STATEMENT: return new ForStatement((org.eclipse.jdt.core.dom.ForStatement) jdtNode); case ASTNode.IF_STATEMENT: return new IfStatement((org.eclipse.jdt.core.dom.IfStatement) jdtNode); case ASTNode.INFIX_EXPRESSION: return new InfixExpression((org.eclipse.jdt.core.dom.InfixExpression) jdtNode); case ASTNode.INTERSECTION_TYPE: return new IntersectionType((org.eclipse.jdt.core.dom.IntersectionType) jdtNode); case ASTNode.INITIALIZER: return new Initializer((org.eclipse.jdt.core.dom.Initializer) jdtNode); case ASTNode.INSTANCEOF_EXPRESSION: return new InstanceofExpression((org.eclipse.jdt.core.dom.InstanceofExpression) jdtNode); case ASTNode.JAVADOC: return new Javadoc((org.eclipse.jdt.core.dom.Javadoc) jdtNode); case ASTNode.LABELED_STATEMENT: return new LabeledStatement((org.eclipse.jdt.core.dom.LabeledStatement) jdtNode); case ASTNode.LAMBDA_EXPRESSION: return new LambdaExpression((org.eclipse.jdt.core.dom.LambdaExpression) jdtNode); case ASTNode.LINE_COMMENT: return new LineComment((org.eclipse.jdt.core.dom.LineComment) jdtNode); case ASTNode.MARKER_ANNOTATION: return MarkerAnnotation.convert((org.eclipse.jdt.core.dom.MarkerAnnotation) jdtNode); case ASTNode.MEMBER_VALUE_PAIR: return new MemberValuePair((org.eclipse.jdt.core.dom.MemberValuePair) jdtNode); case ASTNode.METHOD_DECLARATION: return new MethodDeclaration((org.eclipse.jdt.core.dom.MethodDeclaration) jdtNode); case ASTNode.METHOD_INVOCATION: return new MethodInvocation((org.eclipse.jdt.core.dom.MethodInvocation) jdtNode); case ASTNode.NAME_QUALIFIED_TYPE: return new NameQualifiedType((org.eclipse.jdt.core.dom.NameQualifiedType) jdtNode); case ASTNode.NORMAL_ANNOTATION: return new NormalAnnotation((org.eclipse.jdt.core.dom.NormalAnnotation) jdtNode); case ASTNode.NULL_LITERAL: return new NullLiteral((org.eclipse.jdt.core.dom.NullLiteral) jdtNode); case ASTNode.NUMBER_LITERAL: return new NumberLiteral((org.eclipse.jdt.core.dom.NumberLiteral) jdtNode); case ASTNode.PACKAGE_DECLARATION: return new PackageDeclaration((org.eclipse.jdt.core.dom.PackageDeclaration) jdtNode); case ASTNode.PARAMETERIZED_TYPE: return new ParameterizedType((org.eclipse.jdt.core.dom.ParameterizedType) jdtNode); case ASTNode.PARENTHESIZED_EXPRESSION: return new ParenthesizedExpression((org.eclipse.jdt.core.dom.ParenthesizedExpression) jdtNode); case ASTNode.POSTFIX_EXPRESSION: return new PostfixExpression((org.eclipse.jdt.core.dom.PostfixExpression) jdtNode); case ASTNode.PREFIX_EXPRESSION: return new PrefixExpression((org.eclipse.jdt.core.dom.PrefixExpression) jdtNode); case ASTNode.PRIMITIVE_TYPE: return new PrimitiveType((org.eclipse.jdt.core.dom.PrimitiveType) jdtNode); case ASTNode.QUALIFIED_NAME: return new QualifiedName((org.eclipse.jdt.core.dom.QualifiedName) jdtNode); case ASTNode.QUALIFIED_TYPE: return new QualifiedType((org.eclipse.jdt.core.dom.QualifiedType) jdtNode); case ASTNode.RETURN_STATEMENT: return new ReturnStatement((org.eclipse.jdt.core.dom.ReturnStatement) jdtNode); case ASTNode.SIMPLE_NAME: return new SimpleName((org.eclipse.jdt.core.dom.SimpleName) jdtNode); case ASTNode.SIMPLE_TYPE: return new SimpleType((org.eclipse.jdt.core.dom.SimpleType) jdtNode); case ASTNode.SINGLE_MEMBER_ANNOTATION: return SingleMemberAnnotation.convert((org.eclipse.jdt.core.dom.SingleMemberAnnotation) jdtNode); case ASTNode.SINGLE_VARIABLE_DECLARATION: return new SingleVariableDeclaration((org.eclipse.jdt.core.dom.SingleVariableDeclaration) jdtNode); case ASTNode.STRING_LITERAL: return new StringLiteral((org.eclipse.jdt.core.dom.StringLiteral) jdtNode); case ASTNode.SUPER_CONSTRUCTOR_INVOCATION: return new SuperConstructorInvocation((org.eclipse.jdt.core.dom.SuperConstructorInvocation) jdtNode); case ASTNode.SUPER_FIELD_ACCESS: return new SuperFieldAccess((org.eclipse.jdt.core.dom.SuperFieldAccess) jdtNode); case ASTNode.SUPER_METHOD_INVOCATION: return new SuperMethodInvocation((org.eclipse.jdt.core.dom.SuperMethodInvocation) jdtNode); case ASTNode.SUPER_METHOD_REFERENCE: return new SuperMethodReference((org.eclipse.jdt.core.dom.SuperMethodReference) jdtNode); case ASTNode.SWITCH_CASE: return new SwitchCase((org.eclipse.jdt.core.dom.SwitchCase) jdtNode); case ASTNode.SWITCH_STATEMENT: return new SwitchStatement((org.eclipse.jdt.core.dom.SwitchStatement) jdtNode); case ASTNode.SYNCHRONIZED_STATEMENT: return new SynchronizedStatement((org.eclipse.jdt.core.dom.SynchronizedStatement) jdtNode); case ASTNode.TAG_ELEMENT: return new TagElement((org.eclipse.jdt.core.dom.TagElement) jdtNode); case ASTNode.TEXT_ELEMENT: return new TextElement((org.eclipse.jdt.core.dom.TextElement) jdtNode); case ASTNode.THIS_EXPRESSION: return new ThisExpression((org.eclipse.jdt.core.dom.ThisExpression) jdtNode); case ASTNode.THROW_STATEMENT: return new ThrowStatement((org.eclipse.jdt.core.dom.ThrowStatement) jdtNode); case ASTNode.TRY_STATEMENT: return new TryStatement((org.eclipse.jdt.core.dom.TryStatement) jdtNode); case ASTNode.TYPE_DECLARATION: return new TypeDeclaration((org.eclipse.jdt.core.dom.TypeDeclaration) jdtNode); case ASTNode.TYPE_DECLARATION_STATEMENT: return new TypeDeclarationStatement((org.eclipse.jdt.core.dom.TypeDeclarationStatement) jdtNode); case ASTNode.TYPE_LITERAL: return new TypeLiteral((org.eclipse.jdt.core.dom.TypeLiteral) jdtNode); case ASTNode.TYPE_METHOD_REFERENCE: return new TypeMethodReference((org.eclipse.jdt.core.dom.TypeMethodReference) jdtNode); case ASTNode.UNION_TYPE: return new UnionType((org.eclipse.jdt.core.dom.UnionType) jdtNode); case ASTNode.VARIABLE_DECLARATION_EXPRESSION: return new VariableDeclarationExpression( (org.eclipse.jdt.core.dom.VariableDeclarationExpression) jdtNode); case ASTNode.VARIABLE_DECLARATION_FRAGMENT: return new VariableDeclarationFragment((org.eclipse.jdt.core.dom.VariableDeclarationFragment) jdtNode); case ASTNode.VARIABLE_DECLARATION_STATEMENT: return new VariableDeclarationStatement( (org.eclipse.jdt.core.dom.VariableDeclarationStatement) jdtNode); case ASTNode.WHILE_STATEMENT: return new WhileStatement((org.eclipse.jdt.core.dom.WhileStatement) jdtNode); // These nodes only appear in comments and J2ObjC doens't need any // information from their subtree so we just convert them to TextElement. case ASTNode.MEMBER_REF: case ASTNode.METHOD_REF: case ASTNode.METHOD_REF_PARAMETER: return new TextElement(jdtNode); case ASTNode.COMPILATION_UNIT: throw new AssertionError("CompilationUnit must be converted using convertCompilationUnit()"); default://from ww w . java 2 s . c om throw new AssertionError("Unknown node type: " + jdtNode.getClass().getName()); } }
From source file:edu.brown.cs.bubbles.bedrock.BedrockEditor.java
License:Open Source License
/********************************************************************************/ void getTextRegions(String proj, String bid, String file, String cls, boolean pfx, boolean statics, boolean compunit, boolean imports, boolean pkgfg, boolean topdecls, boolean fields, boolean all, IvyXmlWriter xw) throws BedrockException { if (file == null) { file = getFileFromClass(proj, cls); }/* w w w . j a v a 2 s . c o m*/ FileData fd = findFile(proj, file, bid, null); if (fd == null) throw new BedrockException("Can't find file " + file + " in " + proj); CompilationUnit cu = fd.getDefaultRoot(bid); if (cu == null) throw new BedrockException("Can't get compilation unit for " + file); List<?> typs = cu.types(); AbstractTypeDeclaration atd = findTypeDecl(cls, typs); int start = 0; if (atd != null && atd != typs.get(0)) start = cu.getExtendedStartPosition(atd); if (compunit) { xw.begin("RANGE"); xw.field("PATH", file); xw.field("START", 0); int ln = fd.getLength(); if (ln < 0) { File f = new File(file); ln = (int) f.length(); } xw.field("END", ln); xw.end("RANGE"); } if (pfx && atd != null) { int xpos = cu.getExtendedStartPosition(atd); int xlen = cu.getExtendedLength(atd); int spos = atd.getStartPosition(); int len = atd.getLength(); int epos = -1; for (Object o : atd.bodyDeclarations()) { ASTNode an = (ASTNode) o; int apos = cu.getExtendedStartPosition(an); if (epos < 0 || epos >= apos) epos = apos - 1; } if (epos < 0) { // no body declarations xw.begin("RANGE"); xw.field("PATH", file); xw.field("START", start); xw.field("END", xpos + xlen); xw.end("RANGE"); } else { xw.begin("RANGE"); xw.field("PATH", file); xw.field("START", start); xw.field("END", epos); xw.end("RANGE"); xw.begin("RANGE"); xw.field("PATH", file); xw.field("START", spos + len - 1); xw.field("END", xpos + xlen); xw.end("RANGE"); } } if (pkgfg) { PackageDeclaration pkg = cu.getPackage(); if (pkg != null) { outputRange(cu, pkg, file, xw); } } if (imports) { for (Iterator<?> it = cu.imports().iterator(); it.hasNext();) { ImportDeclaration id = (ImportDeclaration) it.next(); outputRange(cu, id, file, xw); } } if (topdecls && atd != null) { int spos = atd.getStartPosition(); int len = atd.getLength(); int epos = -1; for (Object o : atd.bodyDeclarations()) { ASTNode an = (ASTNode) o; int apos = cu.getExtendedStartPosition(an); if (epos < 0 || epos >= apos) epos = apos - 1; } if (epos < 0) { // no body declarations xw.begin("RANGE"); xw.field("PATH", file); xw.field("START", spos); xw.field("END", spos + len); xw.end("RANGE"); } else { xw.begin("RANGE"); xw.field("PATH", file); xw.field("START", spos); xw.field("END", epos); xw.end("RANGE"); } } if ((statics || all) && atd != null) { for (Object o : atd.bodyDeclarations()) { ASTNode an = (ASTNode) o; if (an.getNodeType() == ASTNode.INITIALIZER) { outputRange(cu, an, file, xw); } } } if (fields && atd != null) { for (Object o : atd.bodyDeclarations()) { ASTNode an = (ASTNode) o; switch (an.getNodeType()) { case ASTNode.FIELD_DECLARATION: outputRange(cu, an, file, xw); break; case ASTNode.ENUM_CONSTANT_DECLARATION: outputRange(cu, an, file, xw); break; } } if (atd instanceof EnumDeclaration) { for (Object o : ((EnumDeclaration) atd).enumConstants()) { ASTNode an = (ASTNode) o; switch (an.getNodeType()) { case ASTNode.FIELD_DECLARATION: outputRange(cu, an, file, xw); break; case ASTNode.ENUM_CONSTANT_DECLARATION: outputRange(cu, an, file, xw); break; } } } } if (all && atd != null) { for (Object o : atd.bodyDeclarations()) { ASTNode an = (ASTNode) o; IJavaElement elt = null; switch (an.getNodeType()) { case ASTNode.ANNOTATION_TYPE_DECLARATION: case ASTNode.ENUM_DECLARATION: case ASTNode.TYPE_DECLARATION: AbstractTypeDeclaration atdecl = (AbstractTypeDeclaration) an; ITypeBinding atbnd = atdecl.resolveBinding(); if (atbnd != null) elt = atbnd.getJavaElement(); break; case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION: break; case ASTNode.ENUM_CONSTANT_DECLARATION: EnumConstantDeclaration ecdecl = (EnumConstantDeclaration) an; IVariableBinding ecbnd = ecdecl.resolveVariable(); if (ecbnd != null) elt = ecbnd.getJavaElement(); break; case ASTNode.FIELD_DECLARATION: FieldDeclaration fdecl = (FieldDeclaration) an; for (Iterator<?> it = fdecl.fragments().iterator(); it.hasNext();) { VariableDeclarationFragment vdf = (VariableDeclarationFragment) it.next(); IVariableBinding vbnd = vdf.resolveBinding(); if (vbnd != null) { IJavaElement velt = vbnd.getJavaElement(); if (velt != null) BedrockUtil.outputJavaElement(velt, xw); } } break; case ASTNode.INITIALIZER: break; case ASTNode.METHOD_DECLARATION: MethodDeclaration mdecl = (MethodDeclaration) an; IMethodBinding mbnd = mdecl.resolveBinding(); if (mbnd != null) elt = mbnd.getJavaElement(); break; default: break; } if (elt != null) BedrockUtil.outputJavaElement(elt, false, xw); } } }
From source file:edu.brown.cs.bubbles.bedrock.BedrockElider.java
License:Open Source License
/********************************************************************************/ private String getFormatType(ASTNode n) { String typ = null;//w ww . j ava 2 s .com if (n instanceof Name) { ASTNode p = n.getParent(); ASTNode pp = p.getParent(); StructuralPropertyDescriptor spd = n.getLocationInParent(); switch (p.getNodeType()) { case ASTNode.METHOD_INVOCATION: if (n.getLocationInParent() == MethodInvocation.NAME_PROPERTY) { typ = "CALL" + getMethodType((Name) n); } break; case ASTNode.SIMPLE_TYPE: case ASTNode.QUALIFIED_TYPE: case ASTNode.TYPE_PARAMETER: typ = "TYPE"; break; case ASTNode.METHOD_DECLARATION: if (spd == MethodDeclaration.NAME_PROPERTY) { typ = "METHODDECL" + getMethodType((Name) n); } else if (spd == MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY) typ = "TYPE"; break; case ASTNode.SINGLE_VARIABLE_DECLARATION: if (pp.getNodeType() == ASTNode.CATCH_CLAUSE) typ = "EXCEPTIONDECL"; else typ = "PARAMDECL"; break; case ASTNode.VARIABLE_DECLARATION_FRAGMENT: if (pp.getNodeType() == ASTNode.FIELD_DECLARATION) typ = "FIELDDECL"; else typ = "LOCALDECL"; break; case ASTNode.ENUM_DECLARATION: case ASTNode.TYPE_DECLARATION: case ASTNode.ANNOTATION_TYPE_DECLARATION: typ = "CLASSDECL" + getClassType((Name) n); break; case ASTNode.MARKER_ANNOTATION: case ASTNode.NORMAL_ANNOTATION: case ASTNode.SINGLE_MEMBER_ANNOTATION: typ = "ANNOT"; break; } } if (typ == null) { if (n instanceof SimpleName) { IBinding ib = ((Name) n).resolveBinding(); // BedrockPlugin.logD("BINDING FOR " + ((SimpleName) n).getIdentifier() + " = " + ib); if (ib != null && ib.getKind() == IBinding.VARIABLE) { IVariableBinding vb = (IVariableBinding) ib; if (vb.isEnumConstant()) typ = "ENUMC"; else if (vb.isField()) { typ = "FIELD" + getVariableType((Name) n); } } else if (ib != null && ib.getKind() == IBinding.METHOD) { typ = "CALL" + getMethodType((Name) n); } else if (ib != null && ib.getKind() == IBinding.ANNOTATION) { typ = "ANNOT"; } else if (ib != null && ib.getKind() == IBinding.TYPE) { typ = "TYPE"; } else if (ib == null) typ = "UNDEF"; } } // TODO: indicate whether the name is a user or system name return typ; }