Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2004 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 17-31
Link Here
|
17 |
|
17 |
|
18 |
import org.aspectj.org.eclipse.jdt.core.dom.AST; |
18 |
import org.aspectj.org.eclipse.jdt.core.dom.AST; |
19 |
import org.aspectj.org.eclipse.jdt.core.dom.ASTParser; |
19 |
import org.aspectj.org.eclipse.jdt.core.dom.ASTParser; |
|
|
20 |
import org.aspectj.org.eclipse.jdt.core.dom.AbstractBooleanTypePattern; |
20 |
import org.aspectj.org.eclipse.jdt.core.dom.AfterAdviceDeclaration; |
21 |
import org.aspectj.org.eclipse.jdt.core.dom.AfterAdviceDeclaration; |
21 |
import org.aspectj.org.eclipse.jdt.core.dom.AfterReturningAdviceDeclaration; |
22 |
import org.aspectj.org.eclipse.jdt.core.dom.AfterReturningAdviceDeclaration; |
22 |
import org.aspectj.org.eclipse.jdt.core.dom.AfterThrowingAdviceDeclaration; |
23 |
import org.aspectj.org.eclipse.jdt.core.dom.AfterThrowingAdviceDeclaration; |
23 |
import org.aspectj.org.eclipse.jdt.core.dom.AjASTVisitor; |
24 |
import org.aspectj.org.eclipse.jdt.core.dom.AjASTVisitor; |
24 |
import org.aspectj.org.eclipse.jdt.core.dom.AjTypeDeclaration; |
25 |
import org.aspectj.org.eclipse.jdt.core.dom.AjTypeDeclaration; |
|
|
26 |
import org.aspectj.org.eclipse.jdt.core.dom.AndTypePattern; |
27 |
import org.aspectj.org.eclipse.jdt.core.dom.AnyTypePattern; |
28 |
import org.aspectj.org.eclipse.jdt.core.dom.AnyWithAnnotationTypePattern; |
25 |
import org.aspectj.org.eclipse.jdt.core.dom.AroundAdviceDeclaration; |
29 |
import org.aspectj.org.eclipse.jdt.core.dom.AroundAdviceDeclaration; |
26 |
import org.aspectj.org.eclipse.jdt.core.dom.AspectDeclaration; |
30 |
import org.aspectj.org.eclipse.jdt.core.dom.AspectDeclaration; |
27 |
import org.aspectj.org.eclipse.jdt.core.dom.Assignment; |
31 |
import org.aspectj.org.eclipse.jdt.core.dom.Assignment; |
28 |
import org.aspectj.org.eclipse.jdt.core.dom.BeforeAdviceDeclaration; |
32 |
import org.aspectj.org.eclipse.jdt.core.dom.BeforeAdviceDeclaration; |
|
|
33 |
import org.aspectj.org.eclipse.jdt.core.dom.BindingTypePattern; |
29 |
import org.aspectj.org.eclipse.jdt.core.dom.Block; |
34 |
import org.aspectj.org.eclipse.jdt.core.dom.Block; |
30 |
import org.aspectj.org.eclipse.jdt.core.dom.BlockComment; |
35 |
import org.aspectj.org.eclipse.jdt.core.dom.BlockComment; |
31 |
import org.aspectj.org.eclipse.jdt.core.dom.BodyDeclaration; |
36 |
import org.aspectj.org.eclipse.jdt.core.dom.BodyDeclaration; |
Lines 39-56
Link Here
|
39 |
import org.aspectj.org.eclipse.jdt.core.dom.DeclarePrecedenceDeclaration; |
44 |
import org.aspectj.org.eclipse.jdt.core.dom.DeclarePrecedenceDeclaration; |
40 |
import org.aspectj.org.eclipse.jdt.core.dom.DeclareSoftDeclaration; |
45 |
import org.aspectj.org.eclipse.jdt.core.dom.DeclareSoftDeclaration; |
41 |
import org.aspectj.org.eclipse.jdt.core.dom.DeclareWarningDeclaration; |
46 |
import org.aspectj.org.eclipse.jdt.core.dom.DeclareWarningDeclaration; |
42 |
import org.aspectj.org.eclipse.jdt.core.dom.DefaultTypePattern; |
|
|
43 |
import org.aspectj.org.eclipse.jdt.core.dom.EnumDeclaration; |
47 |
import org.aspectj.org.eclipse.jdt.core.dom.EnumDeclaration; |
|
|
48 |
import org.aspectj.org.eclipse.jdt.core.dom.ExactTypePattern; |
44 |
import org.aspectj.org.eclipse.jdt.core.dom.ExpressionStatement; |
49 |
import org.aspectj.org.eclipse.jdt.core.dom.ExpressionStatement; |
45 |
import org.aspectj.org.eclipse.jdt.core.dom.FieldAccess; |
50 |
import org.aspectj.org.eclipse.jdt.core.dom.FieldAccess; |
46 |
import org.aspectj.org.eclipse.jdt.core.dom.FieldDeclaration; |
51 |
import org.aspectj.org.eclipse.jdt.core.dom.FieldDeclaration; |
|
|
52 |
import org.aspectj.org.eclipse.jdt.core.dom.IdentifierTypePattern; |
47 |
import org.aspectj.org.eclipse.jdt.core.dom.InfixExpression; |
53 |
import org.aspectj.org.eclipse.jdt.core.dom.InfixExpression; |
48 |
import org.aspectj.org.eclipse.jdt.core.dom.Initializer; |
54 |
import org.aspectj.org.eclipse.jdt.core.dom.Initializer; |
49 |
import org.aspectj.org.eclipse.jdt.core.dom.InterTypeFieldDeclaration; |
55 |
import org.aspectj.org.eclipse.jdt.core.dom.InterTypeFieldDeclaration; |
50 |
import org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration; |
56 |
import org.aspectj.org.eclipse.jdt.core.dom.InterTypeMethodDeclaration; |
51 |
import org.aspectj.org.eclipse.jdt.core.dom.MethodDeclaration; |
57 |
import org.aspectj.org.eclipse.jdt.core.dom.MethodDeclaration; |
52 |
import org.aspectj.org.eclipse.jdt.core.dom.MethodInvocation; |
58 |
import org.aspectj.org.eclipse.jdt.core.dom.MethodInvocation; |
|
|
59 |
import org.aspectj.org.eclipse.jdt.core.dom.NotTypePattern; |
53 |
import org.aspectj.org.eclipse.jdt.core.dom.NumberLiteral; |
60 |
import org.aspectj.org.eclipse.jdt.core.dom.NumberLiteral; |
|
|
61 |
import org.aspectj.org.eclipse.jdt.core.dom.OrTypePattern; |
54 |
import org.aspectj.org.eclipse.jdt.core.dom.PerCflow; |
62 |
import org.aspectj.org.eclipse.jdt.core.dom.PerCflow; |
55 |
import org.aspectj.org.eclipse.jdt.core.dom.PerObject; |
63 |
import org.aspectj.org.eclipse.jdt.core.dom.PerObject; |
56 |
import org.aspectj.org.eclipse.jdt.core.dom.PerTypeWithin; |
64 |
import org.aspectj.org.eclipse.jdt.core.dom.PerTypeWithin; |
Lines 61-69
Link Here
|
61 |
import org.aspectj.org.eclipse.jdt.core.dom.SignaturePattern; |
69 |
import org.aspectj.org.eclipse.jdt.core.dom.SignaturePattern; |
62 |
import org.aspectj.org.eclipse.jdt.core.dom.SimpleName; |
70 |
import org.aspectj.org.eclipse.jdt.core.dom.SimpleName; |
63 |
import org.aspectj.org.eclipse.jdt.core.dom.StringLiteral; |
71 |
import org.aspectj.org.eclipse.jdt.core.dom.StringLiteral; |
|
|
72 |
import org.aspectj.org.eclipse.jdt.core.dom.TypeCategoryTypePattern; |
64 |
import org.aspectj.org.eclipse.jdt.core.dom.TypeDeclaration; |
73 |
import org.aspectj.org.eclipse.jdt.core.dom.TypeDeclaration; |
65 |
import org.aspectj.org.eclipse.jdt.core.dom.VariableDeclaration; |
74 |
import org.aspectj.org.eclipse.jdt.core.dom.VariableDeclaration; |
66 |
import org.aspectj.org.eclipse.jdt.core.dom.VariableDeclarationStatement; |
75 |
import org.aspectj.org.eclipse.jdt.core.dom.VariableDeclarationStatement; |
|
|
76 |
import org.aspectj.org.eclipse.jdt.core.dom.WildTypePattern; |
67 |
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
77 |
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
68 |
|
78 |
|
69 |
public class ASTVisitorTest extends TestCase { |
79 |
public class ASTVisitorTest extends TestCase { |
Lines 280-289
Link Here
|
280 |
"(compilationUnit(class(simpleName)(method(primitiveType)(simpleName)(block(expressionStatement(methodInvocation(simpleName))))))(aspect(simpleName)(constructorITD(primitiveType)(simpleName)(block))))"); |
290 |
"(compilationUnit(class(simpleName)(method(primitiveType)(simpleName)(block(expressionStatement(methodInvocation(simpleName))))))(aspect(simpleName)(constructorITD(primitiveType)(simpleName)(block))))"); |
281 |
} |
291 |
} |
282 |
|
292 |
|
283 |
public void testDeclareParents(){ |
293 |
/* |
|
|
294 |
* |
295 |
* START: Test TypePattern nodes introduced in Bugzilla 329268. |
296 |
* |
297 |
*/ |
298 |
|
299 |
public void testDeclareParents() { |
284 |
check("class A{}class B{}aspect C {declare parents : A extends B;}", |
300 |
check("class A{}class B{}aspect C {declare parents : A extends B;}", |
285 |
"(compilationUnit(class(simpleName))(class(simpleName))(aspect(simpleName)(declareParents(defaultTypePattern)(defaultTypePattern))))"); |
301 |
"(compilationUnit(class(simpleName))(class(simpleName))(aspect(simpleName)(declareParents(wildTypePattern)(wildTypePattern))))"); |
|
|
302 |
} |
303 |
|
304 |
public void testDeclareParentsAnyTypePattern() { |
305 |
check("class A{}class B{}aspect C {declare parents : * extends B;}", |
306 |
"(compilationUnit(class(simpleName))(class(simpleName))(aspect(simpleName)(declareParents(anyTypePattern)(wildTypePattern))))"); |
307 |
} |
308 |
|
309 |
public void testDeclareParentsAndTypePattern() { |
310 |
check("class A{}class B{}class D{}class E{}aspect C {declare parents : A && B && D extends E;}", |
311 |
"(compilationUnit(class(simpleName))(class(simpleName))(class(simpleName))(class(simpleName))(aspect(simpleName)(declareParents((wildTypePattern)andTypePattern((wildTypePattern)andTypePattern(wildTypePattern)))(wildTypePattern))))"); |
312 |
} |
313 |
|
314 |
public void testDeclareParentsOrTypePattern() { |
315 |
check("class A{}class B{}class D{}class E{}aspect C {declare parents : A || B || D extends E;}", |
316 |
"(compilationUnit(class(simpleName))(class(simpleName))(class(simpleName))(class(simpleName))(aspect(simpleName)(declareParents((wildTypePattern)orTypePattern((wildTypePattern)orTypePattern(wildTypePattern)))(wildTypePattern))))"); |
317 |
} |
318 |
|
319 |
public void testDeclareParentsAndOrTypePattern() { |
320 |
check("class A{}class B{}class D{}class E{}aspect C {declare parents : A && (B || D) extends E;}", |
321 |
"(compilationUnit(class(simpleName))(class(simpleName))(class(simpleName))(class(simpleName))(aspect(simpleName)(declareParents((wildTypePattern)andTypePattern((wildTypePattern)orTypePattern(wildTypePattern)))(wildTypePattern))))"); |
322 |
} |
323 |
|
324 |
public void testDeclareParentsOrAndTypePattern() { |
325 |
check("class A{}class B{}class D{}class E{}aspect C {declare parents : A || B && D extends E;}", |
326 |
"(compilationUnit(class(simpleName))(class(simpleName))(class(simpleName))(class(simpleName))(aspect(simpleName)(declareParents((wildTypePattern)orTypePattern((wildTypePattern)andTypePattern(wildTypePattern)))(wildTypePattern))))"); |
327 |
} |
328 |
|
329 |
public void testDeclareParentsNotTypePattern() { |
330 |
check("class A{}class B{}class D{}class E{}aspect C {declare parents : A && !B extends E;}", |
331 |
"(compilationUnit(class(simpleName))(class(simpleName))(class(simpleName))(class(simpleName))(aspect(simpleName)(declareParents((wildTypePattern)andTypePattern(notTypePattern(wildTypePattern)))(wildTypePattern))))"); |
332 |
} |
333 |
|
334 |
public void testDeclareParentsTypeCategoryTypePattern() { |
335 |
check("class A{}class E{}aspect C {declare parents : A && is(ClassType) extends E;}", |
336 |
"(compilationUnit(class(simpleName))(class(simpleName))(aspect(simpleName)(declareParents((wildTypePattern)andTypePattern(typeCategoryTypePattern))(wildTypePattern))))"); |
337 |
} |
338 |
|
339 |
public void testDeclareParentsTypeCategoryTypePatternNot() { |
340 |
check("class A{}class E{}aspect C {declare parents : A && !is(InnerType) extends E;}", |
341 |
"(compilationUnit(class(simpleName))(class(simpleName))(aspect(simpleName)(declareParents((wildTypePattern)andTypePattern(notTypePattern(typeCategoryTypePattern)))(wildTypePattern))))"); |
342 |
} |
343 |
|
344 |
public void testDeclareParentsAnyWithAnnotationTypePattern() { |
345 |
check("class E{}aspect C {declare parents : (@AnnotationT *) extends E;}", |
346 |
"(compilationUnit(class(simpleName))(aspect(simpleName)(declareParents(anyWithAnnotationTypePattern)(wildTypePattern))))"); |
286 |
} |
347 |
} |
|
|
348 |
|
349 |
|
350 |
/* |
351 |
* |
352 |
* END: Test TypePattern nodes introduced in Bugzilla 329268. |
353 |
* |
354 |
*/ |
355 |
|
356 |
|
287 |
public void testDeclareWarning(){ |
357 |
public void testDeclareWarning(){ |
288 |
check("aspect A {pointcut a();declare warning: a(): \"warning\";}", |
358 |
check("aspect A {pointcut a();declare warning: a(): \"warning\";}", |
289 |
"(compilationUnit(aspect(simpleName)(pointcut(simpleName))(declareWarning(referencePointcut(simpleName))(stringLiteral))))"); |
359 |
"(compilationUnit(aspect(simpleName)(pointcut(simpleName))(declareWarning(referencePointcut(simpleName))(stringLiteral))))"); |
Lines 294-308
Link Here
|
294 |
} |
364 |
} |
295 |
public void testDeclareSoft(){ |
365 |
public void testDeclareSoft(){ |
296 |
check("aspect A {pointcut a();declare soft: Exception+: a();}", |
366 |
check("aspect A {pointcut a();declare soft: Exception+: a();}", |
297 |
"(compilationUnit(aspect(simpleName)(pointcut(simpleName))(declareSoft(referencePointcut(simpleName))(defaultTypePattern))))"); |
367 |
"(compilationUnit(aspect(simpleName)(pointcut(simpleName))(declareSoft(referencePointcut(simpleName))(wildTypePattern))))"); |
298 |
} |
368 |
} |
299 |
public void testDeclarePrecedence(){ |
369 |
public void testDeclarePrecedence(){ |
300 |
check("aspect A{}aspect B{declare precedence: B,A;}", |
370 |
check("aspect A{}aspect B{declare precedence: B,A;}", |
301 |
"(compilationUnit(aspect(simpleName))(aspect(simpleName)(declarePrecedence(defaultTypePattern)(defaultTypePattern))))"); |
371 |
"(compilationUnit(aspect(simpleName))(aspect(simpleName)(declarePrecedence(wildTypePattern)(wildTypePattern))))"); |
302 |
} |
372 |
} |
303 |
public void testDeclareAnnotationType(){ |
373 |
public void testDeclareAnnotationType(){ |
304 |
checkJLS3("@interface MyAnnotation{}class C{}aspect A{declare @type: C : @MyAnnotation;}", |
374 |
checkJLS3("@interface MyAnnotation{}class C{}aspect A{declare @type: C : @MyAnnotation;}", |
305 |
"(compilationUnit(simpleName)(class(simpleName))(aspect(simpleName)(declareAtType(defaultTypePattern)(simpleName))))"); |
375 |
"(compilationUnit(simpleName)(class(simpleName))(aspect(simpleName)(declareAtType(wildTypePattern)(simpleName))))"); |
306 |
} |
376 |
} |
307 |
public void testDeclareAnnotationMethod(){ |
377 |
public void testDeclareAnnotationMethod(){ |
308 |
checkJLS3("@interface MyAnnotation{}class C{}aspect A{declare @method:public * C.*(..) : @MyAnnotation;}", |
378 |
checkJLS3("@interface MyAnnotation{}class C{}aspect A{declare @method:public * C.*(..) : @MyAnnotation;}", |
Lines 727-739
Link Here
|
727 |
public void endVisit(DeclareWarningDeclaration node) { |
797 |
public void endVisit(DeclareWarningDeclaration node) { |
728 |
b.append(")"); //$NON-NLS-1$ |
798 |
b.append(")"); //$NON-NLS-1$ |
729 |
} |
799 |
} |
730 |
public boolean visit(DefaultTypePattern node) { |
800 |
|
731 |
b.append("(defaultTypePattern"); |
801 |
public boolean visit(AbstractBooleanTypePattern node) { |
732 |
return isVisitingChildren(); |
802 |
b.append("("); |
|
|
803 |
node.getLeft().accept(this); |
804 |
if (node instanceof AndTypePattern) { |
805 |
b.append("andTypePattern"); |
806 |
} else if (node instanceof OrTypePattern) { |
807 |
b.append("orTypePattern"); |
808 |
} |
809 |
node.getRight().accept(this); |
810 |
b.append(")"); |
811 |
|
812 |
// Don't visit the children, as that is done above in order (left node first, boolean operator next, right node last |
813 |
return false; |
733 |
} |
814 |
} |
734 |
public void endVisit(DefaultTypePattern node) { |
815 |
|
735 |
b.append(")"); //$NON-NLS-1$ |
816 |
|
|
|
817 |
public boolean visit(AnyTypePattern node) { |
818 |
b.append("(anyTypePattern"); |
819 |
return isVisitingChildren(); |
736 |
} |
820 |
} |
|
|
821 |
|
822 |
|
823 |
public void endVisit(AnyTypePattern node) { |
824 |
b.append(")"); |
825 |
} |
826 |
|
827 |
|
828 |
public boolean visit(AnyWithAnnotationTypePattern node) { |
829 |
b.append("(anyWithAnnotationTypePattern"); |
830 |
return isVisitingChildren(); |
831 |
} |
832 |
|
833 |
|
834 |
public void endVisit(AnyWithAnnotationTypePattern node) { |
835 |
b.append(")"); |
836 |
} |
837 |
|
838 |
public boolean visit(IdentifierTypePattern node) { |
839 |
if (node instanceof WildTypePattern) { |
840 |
b.append("(wildTypePattern"); |
841 |
} else if (node instanceof ExactTypePattern) { |
842 |
b.append("(exactTypePattern"); |
843 |
} else if (node instanceof BindingTypePattern) { |
844 |
b.append("(bindingTypePattern"); |
845 |
} |
846 |
return isVisitingChildren(); |
847 |
} |
848 |
|
849 |
|
850 |
public void endVisit(IdentifierTypePattern node) { |
851 |
b.append(")"); |
852 |
} |
853 |
|
854 |
|
855 |
public boolean visit(NotTypePattern node) { |
856 |
b.append("(notTypePattern"); |
857 |
return isVisitingChildren(); |
858 |
} |
859 |
|
860 |
|
861 |
public void endVisit(NotTypePattern node) { |
862 |
b.append(")"); |
863 |
} |
864 |
|
865 |
|
866 |
public boolean visit(TypeCategoryTypePattern node) { |
867 |
b.append("(typeCategoryTypePattern"); |
868 |
return isVisitingChildren(); |
869 |
} |
870 |
|
871 |
|
872 |
public void endVisit(TypeCategoryTypePattern node) { |
873 |
b.append(")"); |
874 |
} |
875 |
|
876 |
|
877 |
// End of TypePattern additions for Bugzilla 329268 |
878 |
|
737 |
public boolean visit(SignaturePattern node) { |
879 |
public boolean visit(SignaturePattern node) { |
738 |
b.append("(signaturePattern"); |
880 |
b.append("(signaturePattern"); |
739 |
return isVisitingChildren(); |
881 |
return isVisitingChildren(); |