List of usage examples for org.aspectj.org.eclipse.jdt.core.dom PointcutDeclaration getDesignator
public PointcutDesignator getDesignator()
From source file:ajdtplugin.AjNaiveASTFlattener.java
License:Open Source License
public boolean visit(PointcutDeclaration node) { ///* w w w .j a v a2 s . c o 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 testPointcutDesignatorRename() throws Exception { IProject project = createPredefinedProject("AST"); //$NON-NLS-1$ Map compilerOptions = JavaCore.create(project).getOptions(true); Document doc = new Document("aspect A {\n" //$NON-NLS-1$ + " public pointcut a();\n" //$NON-NLS-1$ + " public pointcut b();\n" //$NON-NLS-1$ + " public pointcut c():a();\n" + "}\n"); //$NON-NLS-1$ //$NON-NLS-2$ ASTParser parser = ASTParser.newParser(AST.JLS2); // ajh02: need to // use 2 for/* w ww .j a v a 2 s . 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(); AspectDeclaration type = (AspectDeclaration) findAbstractTypeDeclaration(astRoot, "A"); //$NON-NLS-1$ { // rename pointcutDesignator name PointcutDeclaration pointcutDecl = findPointcutDeclaration(type, "c"); //$NON-NLS-1$ ReferencePointcut referencePointcut = (ReferencePointcut) pointcutDecl.getDesignator(); SimpleName name = referencePointcut.getName(); SimpleName newName = ast.newSimpleName("b"); //$NON-NLS-1$ rewrite.replace(name, newName, null); } String expected = "aspect A {\n" + " public pointcut a();\n" //$NON-NLS-1$ //$NON-NLS-2$ + " public pointcut b();\n" //$NON-NLS-1$ + " public pointcut c():b();\n" + "}\n"; //$NON-NLS-1$ //$NON-NLS-2$ check(rewrite, doc, expected, compilerOptions); }
From source file:org.eclipse.ajdt.core.tests.dom.rewrite.ASTRewritingPointcutDeclTest.java
License:Open Source License
public void testNotPointcutRename() throws Exception { IProject project = createPredefinedProject("AST"); //$NON-NLS-1$ Map compilerOptions = JavaCore.create(project).getOptions(true); // add node, change ASTVisitor and ASTMatcher // update ASTConverter and ASTRewriteAnalyzer Document doc = new Document("aspect A {\n" //$NON-NLS-1$ + " public pointcut a();\n" //$NON-NLS-1$ + " public pointcut b();\n" //$NON-NLS-1$ + " public pointcut c():!a();\n" + "}\n"); //$NON-NLS-1$ //$NON-NLS-2$ ASTParser parser = ASTParser.newParser(AST.JLS2); // ajh02: need to // use 2 for/*ww w . j a v a 2 s . 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(); AspectDeclaration type = (AspectDeclaration) findAbstractTypeDeclaration(astRoot, "A"); //$NON-NLS-1$ { // rename pointcutDesignator name PointcutDeclaration pointcutDecl = findPointcutDeclaration(type, "c"); //$NON-NLS-1$ NotPointcut notPointcut = (NotPointcut) pointcutDecl.getDesignator(); ReferencePointcut referencePointcut = (ReferencePointcut) notPointcut.getBody(); SimpleName name = referencePointcut.getName(); SimpleName newName = ast.newSimpleName("b"); //$NON-NLS-1$ rewrite.replace(name, newName, null); } String expected = "aspect A {\n" + " public pointcut a();\n" //$NON-NLS-1$ //$NON-NLS-2$ + " public pointcut b();\n" //$NON-NLS-1$ + " public pointcut c():!b();\n" + "}\n"; //$NON-NLS-1$ //$NON-NLS-2$ check(rewrite, doc, expected, compilerOptions); }
From source file:org.eclipse.ajdt.core.tests.dom.rewrite.ASTRewritingPointcutDeclTest.java
License:Open Source License
public void testCflowPointcutRename() throws Exception { IProject project = createPredefinedProject("AST"); //$NON-NLS-1$ Map compilerOptions = JavaCore.create(project).getOptions(true); // add node, change ASTVisitor and ASTMatcher // update ASTConverter and ASTRewriteAnalyzer Document doc = new Document("aspect A {\n" //$NON-NLS-1$ + " public pointcut a();\n" //$NON-NLS-1$ + " public pointcut b();\n" //$NON-NLS-1$ + " public pointcut c(): cflow(a());\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 va2 s . 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(); AspectDeclaration type = (AspectDeclaration) findAbstractTypeDeclaration(astRoot, "A"); //$NON-NLS-1$ { // rename cflow pointcutDesignator name PointcutDeclaration pointcutDecl = findPointcutDeclaration(type, "c"); //$NON-NLS-1$ CflowPointcut cflowPointcut = (CflowPointcut) pointcutDecl.getDesignator(); ReferencePointcut referencePointcut = (ReferencePointcut) cflowPointcut.getBody(); SimpleName name = referencePointcut.getName(); SimpleName newName = ast.newSimpleName("b"); //$NON-NLS-1$ rewrite.replace(name, newName, null); } String expected = "aspect A {\n" + " public pointcut a();\n" //$NON-NLS-1$ //$NON-NLS-2$ + " public pointcut b();\n" //$NON-NLS-1$ + " public pointcut c(): cflow(b());\n" + "}\n"; //$NON-NLS-1$ //$NON-NLS-2$ check(rewrite, doc, expected, compilerOptions); }
From source file:org.eclipse.ajdt.core.tests.dom.rewrite.ASTRewritingPointcutDeclTest.java
License:Open Source License
public void testCflowbelowPointcutRename() throws Exception { IProject project = createPredefinedProject("AST"); //$NON-NLS-1$ Map compilerOptions = JavaCore.create(project).getOptions(true); // add node, change ASTVisitor and ASTMatcher // update ASTConverter and ASTRewriteAnalyzer Document doc = new Document("aspect A {\n" //$NON-NLS-1$ + " public pointcut a();\n" //$NON-NLS-1$ + " public pointcut b();\n" //$NON-NLS-1$ + " public pointcut c(): cflowbelow(a());\n" + "}\n"); //$NON-NLS-1$ //$NON-NLS-2$ ASTParser parser = ASTParser.newParser(AST.JLS2); // ajh02: need to // use 2 for/*from w ww . j ava 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(); AspectDeclaration type = (AspectDeclaration) findAbstractTypeDeclaration(astRoot, "A"); //$NON-NLS-1$ { // rename cflowbelow pointcutDesignator name PointcutDeclaration pointcutDecl = findPointcutDeclaration(type, "c"); //$NON-NLS-1$ CflowPointcut cflowbelowPointcut = (CflowPointcut) pointcutDecl.getDesignator(); ReferencePointcut referencePointcut = (ReferencePointcut) cflowbelowPointcut.getBody(); SimpleName name = referencePointcut.getName(); SimpleName newName = ast.newSimpleName("b"); //$NON-NLS-1$ rewrite.replace(name, newName, null); } String expected = "aspect A {\n" + " public pointcut a();\n" //$NON-NLS-1$ //$NON-NLS-2$ + " public pointcut b();\n" //$NON-NLS-1$ + " public pointcut c(): cflowbelow(b());\n" + "}\n"; //$NON-NLS-1$ //$NON-NLS-2$ check(rewrite, doc, expected, compilerOptions); }
From source file:org.eclipse.ajdt.core.tests.dom.rewrite.ASTRewritingPointcutDeclTest.java
License:Open Source License
public void testAndPointcutRename() throws Exception { IProject project = createPredefinedProject("AST"); //$NON-NLS-1$ Map compilerOptions = JavaCore.create(project).getOptions(true); // add node, change ASTVisitor and ASTMatcher // update ASTConverter and ASTRewriteAnalyzer Document doc = new Document("aspect A {\n" //$NON-NLS-1$ + " public pointcut a();\n" //$NON-NLS-1$ + " public pointcut b();\n" //$NON-NLS-1$ + " public pointcut c(): a() && b();\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 2 s. co 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(); AspectDeclaration type = (AspectDeclaration) findAbstractTypeDeclaration(astRoot, "A"); //$NON-NLS-1$ { // rename the left one in the && PointcutDeclaration pointcutDecl = findPointcutDeclaration(type, "c"); //$NON-NLS-1$ AndPointcut andPointcut = (AndPointcut) pointcutDecl.getDesignator(); ReferencePointcut referencePointcut = (ReferencePointcut) andPointcut.getLeft(); SimpleName name = referencePointcut.getName(); SimpleName newName = ast.newSimpleName("b"); //$NON-NLS-1$ rewrite.replace(name, newName, null); } String expected = "aspect A {\n" + " public pointcut a();\n" //$NON-NLS-1$ //$NON-NLS-2$ + " public pointcut b();\n" //$NON-NLS-1$ + " public pointcut c(): b() && b();\n" + "}\n"; //$NON-NLS-1$ //$NON-NLS-2$ check(rewrite, doc, expected, compilerOptions); }
From source file:org.eclipse.ajdt.core.tests.dom.rewrite.ASTRewritingPointcutDeclTest.java
License:Open Source License
public void testOrPointcutRename() throws Exception { IProject project = createPredefinedProject("AST"); //$NON-NLS-1$ Map compilerOptions = JavaCore.create(project).getOptions(true); // add node, change ASTVisitor and ASTMatcher // update ASTConverter and ASTRewriteAnalyzer Document doc = new Document("aspect A {\n" //$NON-NLS-1$ + " public pointcut a();\n" //$NON-NLS-1$ + " public pointcut b();\n" //$NON-NLS-1$ + " public pointcut c(): a() || b();\n" + "}\n"); //$NON-NLS-1$ //$NON-NLS-2$ ASTParser parser = ASTParser.newParser(AST.JLS2); // ajh02: need to // use 2 for/*from w ww . j av a 2 s . co 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(); AspectDeclaration type = (AspectDeclaration) findAbstractTypeDeclaration(astRoot, "A"); //$NON-NLS-1$ { // rename the left one in the || PointcutDeclaration pointcutDecl = findPointcutDeclaration(type, "c"); //$NON-NLS-1$ OrPointcut orPointcut = (OrPointcut) pointcutDecl.getDesignator(); ReferencePointcut referencePointcut = (ReferencePointcut) orPointcut.getLeft(); SimpleName name = referencePointcut.getName(); SimpleName newName = ast.newSimpleName("b"); //$NON-NLS-1$ rewrite.replace(name, newName, null); } String expected = "aspect A {\n" + " public pointcut a();\n" //$NON-NLS-1$ //$NON-NLS-2$ + " public pointcut b();\n" //$NON-NLS-1$ + " public pointcut c(): b() || b();\n" + "}\n"; //$NON-NLS-1$ //$NON-NLS-2$ check(rewrite, doc, expected, compilerOptions); }