Example usage for org.eclipse.jdt.core.dom VariableDeclarationStatement MODIFIERS2_PROPERTY

List of usage examples for org.eclipse.jdt.core.dom VariableDeclarationStatement MODIFIERS2_PROPERTY

Introduction

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

Prototype

ChildListPropertyDescriptor MODIFIERS2_PROPERTY

To view the source code for org.eclipse.jdt.core.dom VariableDeclarationStatement MODIFIERS2_PROPERTY.

Click Source Link

Document

The "modifiers" structural property of this node type (element type: IExtendedModifier ) (added in JLS3 API).

Usage

From source file:edu.umd.cs.findbugs.plugin.eclipse.quickfix.CreateDoPrivilegedBlockResolution.java

License:Open Source License

protected void updateLocalVariableDeclarations(final ASTRewrite rewrite, final Set<String> variables,
        Block block) {//from  w w w  . j av  a  2 s. c o  m
    Assert.isNotNull(rewrite);
    Assert.isNotNull(block);
    Assert.isNotNull(variables);

    final AST ast = rewrite.getAST();
    block.accept(new ASTVisitor() {

        @Override
        public boolean visit(VariableDeclarationFragment fragment) {
            if (variables.contains(fragment.getName().getFullyQualifiedName())) {
                ASTNode parent = fragment.getParent();
                if (parent instanceof VariableDeclarationStatement) {
                    ListRewrite listRewrite = rewrite.getListRewrite(parent,
                            VariableDeclarationStatement.MODIFIERS2_PROPERTY);
                    listRewrite.insertLast(ast.newModifier(ModifierKeyword.FINAL_KEYWORD), null);
                }
            }
            return true;
        }

    });

}

From source file:edu.umd.cs.findbugs.quickfix.resolution.CreateDoPrivilegedBlockResolution.java

License:Open Source License

protected void updateLocalVariableDeclarations(final ASTRewrite rewrite, final Set<String> variables,
        Block block) {//from w  ww .ja  va2 s.  co m
    assert rewrite != null;
    assert block != null;
    assert variables != null;

    final AST ast = rewrite.getAST();
    block.accept(new ASTVisitor() {

        @Override
        public boolean visit(VariableDeclarationFragment fragment) {
            if (variables.contains(fragment.getName().getFullyQualifiedName())) {
                ASTNode parent = fragment.getParent();
                if (parent instanceof VariableDeclarationStatement) {
                    ListRewrite listRewrite = rewrite.getListRewrite(parent,
                            VariableDeclarationStatement.MODIFIERS2_PROPERTY);
                    listRewrite.insertLast(ast.newModifier(ModifierKeyword.FINAL_KEYWORD), null);
                }
            }
            return true;
        }

    });

}