List of usage examples for org.eclipse.jdt.core.dom TypeDeclarationStatement getParent
public final ASTNode getParent()
null
if this is the root node. From source file:com.google.devtools.j2cpp.translate.InnerClassExtractor.java
License:Open Source License
public boolean visitType(AbstractTypeDeclaration node) { ASTNode parentNode = node.getParent(); if (!(parentNode instanceof CompilationUnit)) { ITypeBinding type = Types.getTypeBinding(node); if (!type.isInterface() && !type.isAnnotation() && !Modifier.isStatic(type.getModifiers())) { addOuterFields(node);/*from w w w .j a v a 2 s .co m*/ } if (parentNode instanceof AbstractTypeDeclaration) { // Remove declaration from declaring type. AbstractTypeDeclaration parent = (AbstractTypeDeclaration) node.getParent(); @SuppressWarnings("unchecked") List<AbstractTypeDeclaration> parentTypes = parent.bodyDeclarations(); // safe by definition boolean success = parentTypes.remove(node); assert success; } else { TypeDeclarationStatement typeStatement = (TypeDeclarationStatement) parentNode; node = NodeCopier.copySubtree(node.getAST(), typeStatement.getDeclaration()); // Remove stmt from method body (or an if/else/try/catch/finally clause). Block body = (Block) typeStatement.getParent(); @SuppressWarnings("unchecked") List<Statement> stmts = body.statements(); // safe by definition boolean success = stmts.remove(typeStatement); assert success; } // Make this node non-private, if necessary, and add it to the unit's type // list. @SuppressWarnings("unchecked") // safe by definition List<IExtendedModifier> modifiers = node.modifiers(); for (IExtendedModifier iem : modifiers) { if (iem instanceof Modifier) { Modifier mod = (Modifier) iem; if (mod.getKeyword().equals(ModifierKeyword.PRIVATE_KEYWORD)) { modifiers.remove(mod); break; } } } unitTypes.add(node); } return true; }
From source file:egovframework.mgt.fit.library.parser.visitor.StatementParsingVisitor.java
License:Apache License
/** * ? ? ? ? .//w ww . j a v a2s . co m * @return */ @Override public boolean visit(TypeDeclarationStatement node) { if (node.getParent().getNodeType() == parentType) { addSingleStatement(node.toString(), StatementLine.TYPE); } return super.visit(node); }
From source file:org.eclipse.xtend.core.javaconverter.ASTFlattenerUtils.java
License:Open Source License
public boolean isNotSupportedInnerType(final TypeDeclarationStatement it) { ASTNode _parent = it.getParent(); return (_parent instanceof Block); }