Example usage for org.aspectj.org.eclipse.jdt.core.dom PointcutDeclaration getName

List of usage examples for org.aspectj.org.eclipse.jdt.core.dom PointcutDeclaration getName

Introduction

In this page you can find the example usage for org.aspectj.org.eclipse.jdt.core.dom PointcutDeclaration getName.

Prototype

public SimpleName getName() 

Source Link

Usage

From source file:ajdtplugin.AjNaiveASTFlattener.java

License:Open Source License

public boolean visit(PointcutDeclaration node) {
    ///*from  ww w  .  ja v a 2s  . co m*/
    Pointcut point = new Pointcut();

    printIndent();
    buffer.append(" pointcut ");
    node.getName().accept(this);

    point.pointcutName = node.getName().toString();

    buffer.append("(");
    List<?> parameters = node.parameters();
    for (Iterator<?> iter = parameters.iterator(); iter.hasNext();) {
        SingleVariableDeclaration element = (SingleVariableDeclaration) iter.next();
        buffer.append(element.getType().toString() + " " + element.getName() + "");
        //
        point.getParameterTypes().add(element.getType().toString());
        if (iter.hasNext())
            buffer.append(", ");
    }
    buffer.append(") :");
    //add to list of pointcuts 
    points.add(point);

    node.getDesignator().accept(this);
    buffer.append(";\n");
    return false;
}

From source file:org.eclipse.ajdt.core.tests.dom.rewrite.ASTRewritingPointcutDeclTest.java

License:Open Source License

public void testPointcutRename() throws Exception {
    IProject project = createPredefinedProject("AST"); //$NON-NLS-1$
    Map compilerOptions = JavaCore.create(project).getOptions(true);

    Document doc = new Document("package test1;\n" //$NON-NLS-1$
            + "abstract class E {\n" + "    public pointcut a();\n" //$NON-NLS-1$ //$NON-NLS-2$
            + "}\n"); //$NON-NLS-1$
    ASTParser parser = ASTParser.newParser(AST.JLS2); // ajh02: need to
    // use 2 for/*from   w  w  w.j a v  a  2  s  .  com*/
    // returntype - in 3
    // it has
    // "returnType2"

    parser.setSource(doc.get().toCharArray());
    parser.setCompilerOptions(compilerOptions);
    CompilationUnit astRoot = (CompilationUnit) parser.createAST(null);
    AjASTRewrite rewrite = AjASTRewrite.create(astRoot.getAST());
    AST ast = astRoot.getAST();
    TypeDeclaration type = (TypeDeclaration) findAbstractTypeDeclaration(astRoot, "E"); //$NON-NLS-1$
    if (type instanceof AjTypeDeclaration) {
        // rename pointcut name
        PointcutDeclaration pointcutDecl = findPointcutDeclaration((AjTypeDeclaration) type, "a"); //$NON-NLS-1$
        SimpleName name = pointcutDecl.getName();
        SimpleName newName = ast.newSimpleName("b"); //$NON-NLS-1$
        rewrite.replace(name, newName, null);
        String expected = "package test1;\n" + "abstract class E {\n" //$NON-NLS-1$ //$NON-NLS-2$
                + "    public pointcut b();\n" + "}\n"; //$NON-NLS-1$ //$NON-NLS-2$
        check(rewrite, doc, expected, compilerOptions);
    } else {
        fail("should have found an AjTypeDeclaration"); //$NON-NLS-1$
    }
}

From source file:org.eclipse.ajdt.core.tests.dom.rewrite.ASTRewritingPointcutDeclTest.java

License:Open Source License

public void testPointcutWithBodyRename() throws Exception {
    IProject project = createPredefinedProject("AST"); //$NON-NLS-1$
    Map compilerOptions = JavaCore.create(project).getOptions(true);

    Document doc = new Document("package test1;\n" //$NON-NLS-1$
            + "abstract class E {\n" + "    public pointcut temp();\n" //$NON-NLS-1$ //$NON-NLS-2$
            + "    public pointcut a(): temp();\n" + "}\n"); //$NON-NLS-1$ //$NON-NLS-2$
    ASTParser parser = ASTParser.newParser(AST.JLS2); // ajh02: need to
    // use 2 for/*from ww  w .j  a v  a  2s.  c  o  m*/
    // returnType - in 3
    // it has
    // "returnType2"
    parser.setSource(doc.get().toCharArray());
    parser.setCompilerOptions(compilerOptions);
    CompilationUnit astRoot = (CompilationUnit) parser.createAST(null);
    AjASTRewrite rewrite = AjASTRewrite.create(astRoot.getAST());
    AST ast = astRoot.getAST();
    TypeDeclaration type = (TypeDeclaration) findAbstractTypeDeclaration(astRoot, "E"); //$NON-NLS-1$
    if (type instanceof AjTypeDeclaration) {
        { // rename pointcut name
            PointcutDeclaration pointcutDecl = findPointcutDeclaration((AjTypeDeclaration) type, "a"); //$NON-NLS-1$
            SimpleName name = pointcutDecl.getName();
            SimpleName newName = ast.newSimpleName("b"); //$NON-NLS-1$
            rewrite.replace(name, newName, null);
        }
        String expected = "package test1;\n" + "abstract class E {\n" //$NON-NLS-1$ //$NON-NLS-2$
                + "    public pointcut temp();\n" //$NON-NLS-1$
                + "    public pointcut b(): temp();\n" + "}\n"; //$NON-NLS-1$ //$NON-NLS-2$
        check(rewrite, doc, expected, compilerOptions);
    } else {
        fail("should have found an AjTypeDeclaration"); //$NON-NLS-1$
    }
}