Example usage for org.eclipse.jdt.core.dom TypeDeclarationStatement getDeclaration

List of usage examples for org.eclipse.jdt.core.dom TypeDeclarationStatement getDeclaration

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom TypeDeclarationStatement getDeclaration.

Prototype

public AbstractTypeDeclaration getDeclaration() 

Source Link

Document

Returns the abstract type declaration of this local type declaration statement (added in JLS3 API).

Usage

From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java

License:Open Source License

@Override
public boolean visit(TypeDeclarationStatement node) {
    if (node.getAST().apiLevel() >= JLS3) {
        node.getDeclaration().accept(this);
    }/*from w w w  .  j av a  2 s .c  o  m*/
    return false;
}

From source file:boa.datagen.util.Java7Visitor.java

License:Apache License

@Override
public boolean visit(TypeDeclarationStatement node) {
    boa.types.Ast.Statement.Builder b = boa.types.Ast.Statement.newBuilder();
    //      b.setPosition(pos.build());
    List<boa.types.Ast.Statement> list = statements.peek();
    b.setKind(boa.types.Ast.Statement.StatementKind.TYPEDECL);
    declarations.push(new ArrayList<boa.types.Ast.Declaration>());
    node.getDeclaration().accept(this);
    for (boa.types.Ast.Declaration d : declarations.pop())
        b.setTypeDeclaration(d);/* w  ww . ja  v  a2 s .  co m*/
    list.add(b.build());
    return false;
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

public boolean visit(TypeDeclarationStatement node) {
    if (node.getAST().apiLevel() >= AST.JLS3) {
        node.getDeclaration().accept(this);
    }/*from   w  w w. j av  a2  s. co m*/
    return false;
}

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 av a2  s.  c om*/
        }

        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:com.google.googlejavaformat.java.JavaInputAstVisitor.java

License:Apache License

/** Visitor method for {@link TypeDeclarationStatement}s. */
@Override/*  w ww  .  j av a  2  s .c om*/
public boolean visit(TypeDeclarationStatement node) {
    sync(node);
    node.getDeclaration().accept(this);
    return false;
}

From source file:com.ibm.wala.cast.java.translator.jdt.JDTJava2CAstTranslator.java

License:Open Source License

private CAstNode visit(TypeDeclarationStatement n, WalkContext context) {
    // TODO 1.6: enums of course...
    AbstractTypeDeclaration decl = n.getDeclaration();
    assert decl instanceof TypeDeclaration : "Local enum declaration not yet supported";
    CAstEntity classEntity = visitTypeDecl((TypeDeclaration) decl, context);

    // these statements doin't actually do anything, just define a type
    final CAstNode lcdNode = makeNode(context, fFactory, n, CAstNode.EMPTY);

    // so define it!
    context.addScopedEntity(lcdNode, classEntity);
    return lcdNode;
}

From source file:java5totext.input.JDTVisitor.java

License:Open Source License

@Override
public void endVisit(org.eclipse.jdt.core.dom.TypeDeclarationStatement node) {
    TypeDeclarationStatement element = (TypeDeclarationStatement) this.binding.get(node);
    this.initializeNode(element, node);
    if (this.binding.get(node.getDeclaration()) != null)
        element.setDeclaration((AbstractTypeDeclaration) this.binding.get(node.getDeclaration()));
}

From source file:lang.java.jdt.internal.JdtAstToRascalAstConverter.java

License:Open Source License

public boolean visit(TypeDeclarationStatement node) {
    IValue typeDeclaration;// ww w. j  a  va  2 s  .c  o  m
    if (node.getAST().apiLevel() == AST.JLS2) {
        typeDeclaration = visitChild(node.getTypeDeclaration());
    } else {
        typeDeclaration = visitChild(node.getDeclaration());
    }

    ownValue = constructRascalNode(node, typeDeclaration);
    return false;
}

From source file:org.codemucker.jmutate.ast.JAstFlattener.java

License:Open Source License

public boolean visit(TypeDeclarationStatement node) {
    if (node.getAST().apiLevel() == JLS2) {
        getTypeDeclaration(node).accept(this);
    }/*from   w  w  w  .j  av a2s  .co m*/
    if (node.getAST().apiLevel() >= JLS3) {
        node.getDeclaration().accept(this);
    }
    return false;
}

From source file:org.ebayopensource.dsf.javatojs.parse.TypeDependencyVisitor.java

License:Open Source License

@Override
public boolean visit(TypeDeclarationStatement node) {
    String typeName = node.getDeclaration().getName().getFullyQualifiedName();
    JstType jstType = TranslateHelper.Factory.createJstType(node, getCurType());
    jstType.setSimpleName(typeName);/*from  w w  w  . jav a 2s  .c  om*/
    jstType.setParent(getScopeParent());
    getCurScope().addChild(jstType);
    setCurType(jstType);
    return true;
}