Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 4580 Details for
Bug 36142
[DOM/AST] DOM support for JSR-014 generics
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
DOM/AST experimental API for JSR-014 support - API test suites
ast-JSR-014-tests-patch-20030410.txt (text/plain), 31.44 KB, created by
Jim des Rivieres
on 2003-04-14 13:56:22 EDT
(
hide
)
Description:
DOM/AST experimental API for JSR-014 support - API test suites
Filename:
MIME Type:
Creator:
Jim des Rivieres
Created:
2003-04-14 13:56:22 EDT
Size:
31.44 KB
patch
obsolete
>Index: src/org/eclipse/jdt/core/tests/dom/ASTMatcherTest.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTMatcherTest.java,v >retrieving revision 1.6 >diff -u -r1.6 ASTMatcherTest.java >--- src/org/eclipse/jdt/core/tests/dom/ASTMatcherTest.java 11 Mar 2003 15:07:11 -0000 1.6 >+++ src/org/eclipse/jdt/core/tests/dom/ASTMatcherTest.java 10 Apr 2003 20:12:50 -0000 >@@ -48,6 +48,10 @@ > String E2S; > Type T1; > String T1S; >+ Type T2; >+ String T2S; >+ ParameterizedType PT1; >+ String PT1S; > Statement S1; > String S1S; > Statement S2; >@@ -82,6 +86,10 @@ > String JD1S; > Javadoc JD2; > String JD2S; >+ TypeParameter TP1; >+ String TP1S; >+ TypeParameter TP2; >+ String TP2S; > > final StringBuffer b = new StringBuffer(); > >@@ -103,6 +111,10 @@ > E2S = "(nSYYnS)"; //$NON-NLS-1$ > T1 = ast.newSimpleType(ast.newSimpleName("Z")); //$NON-NLS-1$ > T1S = "(tS(nSZZnS)tS)"; //$NON-NLS-1$ >+ T2 = ast.newSimpleType(ast.newSimpleName("Y")); //$NON-NLS-1$ >+ T2S = "(tS(nSYYnS)tS)"; //$NON-NLS-1$ >+ PT1 = ast.newParameterizedType(ast.newSimpleName("Z")); //$NON-NLS-1$ >+ PT1S = "(tM(nSZZnS)tM)"; //$NON-NLS-1$ > S1 = ast.newContinueStatement(); > S1S = "(sCNsCN)"; //$NON-NLS-1$ > S2 = ast.newBreakStatement(); >@@ -163,6 +175,13 @@ > JD2.setComment("/**Y*/"); //$NON-NLS-1$ > JD2S = "(JD/**Y*//**Y*/JD)"; //$NON-NLS-1$ > >+ TP1 = ast.newTypeParameter(); >+ TP1.setName(ast.newSimpleName("x")); //$NON-NLS-1$ >+ TP1S = "[(tTP[(nSxxnS)]tTP)]"; //$NON-NLS-1$ >+ >+ TP2 = ast.newTypeParameter(); >+ TP2.setName(ast.newSimpleName("y")); //$NON-NLS-1$ >+ TP2S = "[(tTP[(nSyynS)]tTP)]"; //$NON-NLS-1$ > } > > protected void tearDown() { >@@ -304,6 +323,9 @@ > public boolean match(PackageDeclaration node, Object other) { > return standardBody(node, other, superMatch ? super.match(node, other) : false); > } >+ public boolean match(ParameterizedType node, Object other) { >+ return standardBody(node, other, superMatch ? super.match(node, other) : false); >+ } > public boolean match(ParenthesizedExpression node, Object other) { > return standardBody(node, other, superMatch ? super.match(node, other) : false); > } >@@ -319,6 +341,9 @@ > public boolean match(QualifiedName node, Object other) { > return standardBody(node, other, superMatch ? super.match(node, other) : false); > } >+ public boolean match(QualifiedType node, Object other) { >+ return standardBody(node, other, superMatch ? super.match(node, other) : false); >+ } > public boolean match(ReturnStatement node, Object other) { > return standardBody(node, other, superMatch ? super.match(node, other) : false); > } >@@ -370,6 +395,9 @@ > public boolean match(TypeLiteral node, Object other) { > return standardBody(node, other, superMatch ? super.match(node, other) : false); > } >+ public boolean match(TypeParameter node, Object other) { >+ return standardBody(node, other, superMatch ? super.match(node, other) : false); >+ } > public boolean match(VariableDeclarationExpression node, Object other) { > return standardBody(node, other, superMatch ? super.match(node, other) : false); > } >@@ -468,7 +496,7 @@ > } > > public void testSimpleType() { >- Type x1 = ast.newSimpleType(ast.newName(new String[]{"Z"})); //$NON-NLS-1$ >+ Type x1 = ast.newSimpleType(N1); > basicMatch(x1); > } > >@@ -478,6 +506,16 @@ > basicMatch(x1); > } > >+ public void testParameterizedType() { >+ ParameterizedType x1 = ast.newParameterizedType(ast.newSimpleName("X")); //$NON-NLS-1$ >+ basicMatch(x1); >+ } >+ >+ public void testQualifiedType() { >+ Type x1 = ast.newQualifiedType(T1, N1); >+ basicMatch(x1); >+ } >+ > // EXPRESSIONS and STATEMENTS > > public void testAnonymousClassDeclaration() { >@@ -553,7 +591,7 @@ > public void testClassInstanceCreation() { > ClassInstanceCreation x1 = ast.newClassInstanceCreation(); > x1.setExpression(E1); >- x1.setName(N1); >+ x1.setType(PT1); > x1.setAnonymousClassDeclaration(ACD1); > basicMatch(x1); > } >@@ -663,6 +701,8 @@ > public void testMethodDeclaration() { > MethodDeclaration x1 = ast.newMethodDeclaration(); > x1.setJavadoc(JD1); >+ x1.typeParameters().add(TP1); >+ x1.typeParameters().add(TP2); > x1.setReturnType(T1); > x1.setName(N1); > x1.parameters().add(V1); >@@ -792,9 +832,11 @@ > TypeDeclaration x1 = ast.newTypeDeclaration(); > x1.setJavadoc(JD1); > x1.setName(N1); >- x1.setSuperclass(N2); >- x1.superInterfaces().add(N3); >- x1.superInterfaces().add(ast.newSimpleName("J")); //$NON-NLS-1$ >+ x1.typeParameters().add(TP1); >+ x1.typeParameters().add(TP2); >+ x1.setSuperclassType(PT1); >+ x1.superInterfaceTypes().add(T1); >+ x1.superInterfaceTypes().add(T2); > x1.bodyDeclarations().add(FD1); > x1.bodyDeclarations().add(FD2); > basicMatch(x1); >@@ -806,6 +848,13 @@ > public void testTypeLiteral() { > TypeLiteral x1 = ast.newTypeLiteral(); > x1.setType(T1); >+ basicMatch(x1); >+ } >+ public void testTypeParameter() { >+ TypeParameter x1 = ast.newTypeParameter(); >+ x1.setName(N1); >+ x1.typeBounds().add(T1); >+ x1.typeBounds().add(T2); > basicMatch(x1); > } > public void testVariableDeclarationFragment() { >Index: src/org/eclipse/jdt/core/tests/dom/ASTNodesCollectorVisitor.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTNodesCollectorVisitor.java,v >retrieving revision 1.6 >diff -u -r1.6 ASTNodesCollectorVisitor.java >--- src/org/eclipse/jdt/core/tests/dom/ASTNodesCollectorVisitor.java 11 Mar 2003 15:07:11 -0000 1.6 >+++ src/org/eclipse/jdt/core/tests/dom/ASTNodesCollectorVisitor.java 10 Apr 2003 20:12:50 -0000 >@@ -124,7 +124,9 @@ > * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.ClassInstanceCreation) > */ > public void endVisit(ClassInstanceCreation node) { >- node.setName(node.getAST().newSimpleName("XXX")); //$NON-NLS-1$ >+ node.setType( >+ node.getAST().newSimpleType( >+ node.getAST().newSimpleName("XXX"))); //$NON-NLS-1$ > } > > /** >@@ -271,6 +273,13 @@ > } > > /** >+ * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.ParameterizedType) >+ * @since 2.2 >+ */ >+ public void endVisit(ParameterizedType node) { >+ } >+ >+ /** > * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.ParenthesizedExpression) > */ > public void endVisit(ParenthesizedExpression node) { >@@ -423,6 +432,13 @@ > * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.TypeLiteral) > */ > public void endVisit(TypeLiteral node) { >+ } >+ >+ /** >+ * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.TypeParameter) >+ * @since 2.2 >+ */ >+ public void endVisit(TypeParameter node) { > } > > /** >Index: src/org/eclipse/jdt/core/tests/dom/ASTTest.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java,v >retrieving revision 1.15 >diff -u -r1.15 ASTTest.java >--- src/org/eclipse/jdt/core/tests/dom/ASTTest.java 11 Mar 2003 15:07:11 -0000 1.15 >+++ src/org/eclipse/jdt/core/tests/dom/ASTTest.java 10 Apr 2003 20:12:54 -0000 >@@ -330,6 +330,15 @@ > } > > /** >+ * @see org.eclipse.jdt.core.dom.ASTMatcher#match(ParameterizedType, Object) >+ * @since 2.2 >+ */ >+ public boolean match(ParameterizedType node, Object other) { >+ checkPositions(node, other); >+ return super.match(node, other); >+ } >+ >+ /** > * @see org.eclipse.jdt.core.dom.ASTMatcher#match(ParenthesizedExpression, Object) > */ > public boolean match(ParenthesizedExpression node, Object other) { >@@ -370,6 +379,14 @@ > } > > /** >+ * @see org.eclipse.jdt.core.dom.ASTMatcher#match(QualifiedType, Object) >+ */ >+ public boolean match(QualifiedType node, Object other) { >+ checkPositions(node, other); >+ return super.match(node, other); >+ } >+ >+ /** > * @see org.eclipse.jdt.core.dom.ASTMatcher#match(ReturnStatement, Object) > */ > public boolean match(ReturnStatement node, Object other) { >@@ -506,6 +523,15 @@ > } > > /** >+ * @see org.eclipse.jdt.core.dom.ASTMatcher#match(TypeParameter, Object) >+ * @since 2.2 >+ */ >+ public boolean match(TypeParameter node, Object other) { >+ checkPositions(node, other); >+ return super.match(node, other); >+ } >+ >+ /** > * @see org.eclipse.jdt.core.dom.ASTMatcher#match(VariableDeclarationExpression, Object) > */ > public boolean match(VariableDeclarationExpression node, Object other) { >@@ -1138,7 +1164,6 @@ > assertTrue(x.isDeclaration() == true); > fd.setName(ast.newSimpleName("b")); //$NON-NLS-1$ > assertTrue(x.isDeclaration() == false); >- > } > > public void testQualifiedName() { >@@ -1199,7 +1224,66 @@ > x.setName((SimpleName) value); > } > }); >+ } >+ >+ public void testQualifiedType() { >+ long previousCount = ast.modificationCount(); >+ final QualifiedType x = ast.newQualifiedType( >+ ast.newSimpleType(ast.newSimpleName("q")), //$NON-NLS-1$ >+ ast.newSimpleName("i")); //$NON-NLS-1$ >+ assertTrue(ast.modificationCount() > previousCount); >+ previousCount = ast.modificationCount(); >+ assertTrue(x instanceof Type); >+ assertTrue(x.getAST() == ast); >+ assertTrue(x.getParent() == null); >+ assertTrue(x.getQualifier().getParent() == x); >+ assertTrue(x.getName().getParent() == x); >+ assertTrue(x.getName().isDeclaration() == false); >+ assertTrue(x.getNodeType() == ASTNode.QUALIFIED_TYPE); >+ // make sure that reading did not change modification count >+ assertTrue(ast.modificationCount() == previousCount); >+ >+ genericPropertyTest(x, new Property("Qualifier", true, Type.class) { //$NON-NLS-1$ >+ public ASTNode sample(AST targetAst, boolean parented) { >+ SimpleType result = >+ targetAst.newSimpleType( >+ targetAst.newSimpleName("a")); //$NON-NLS-1$ >+ if (parented) { >+ targetAst.newArrayType(result); >+ } >+ return result; >+ } >+ public ASTNode wrap() { >+ QualifiedType s1 = ast.newQualifiedType(x, ast.newSimpleName("z")); //$NON-NLS-1$ >+ return s1; >+ } >+ public void unwrap() { >+ QualifiedType s1 = (QualifiedType) x.getParent(); >+ s1.setQualifier(ast.newSimpleType(ast.newSimpleName("z"))); //$NON-NLS-1$ >+ } >+ public ASTNode get() { >+ return x.getQualifier(); >+ } >+ public void set(ASTNode value) { >+ x.setQualifier((Type) value); >+ } >+ }); > >+ genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$ >+ public ASTNode sample(AST targetAst, boolean parented) { >+ SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$ >+ if (parented) { >+ targetAst.newExpressionStatement(result); >+ } >+ return result; >+ } >+ public ASTNode get() { >+ return x.getName(); >+ } >+ public void set(ASTNode value) { >+ x.setName((SimpleName) value); >+ } >+ }); > } > > public void testNullLiteral() { >@@ -1482,6 +1566,7 @@ > assertTrue(x.isSimpleType()); > assertTrue(!x.isArrayType()); > assertTrue(!x.isPrimitiveType()); >+ assertTrue(!x.isParameterizedType()); > assertTrue(x.getNodeType() == ASTNode.SIMPLE_TYPE); > // make sure that reading did not change modification count > assertTrue(ast.modificationCount() == previousCount); >@@ -1515,6 +1600,7 @@ > assertTrue(!x.isSimpleType()); > assertTrue(!x.isArrayType()); > assertTrue(x.isPrimitiveType()); >+ assertTrue(!x.isParameterizedType()); > assertTrue(x.getNodeType() == ASTNode.PRIMITIVE_TYPE); > // make sure that reading did not change modification count > assertTrue(ast.modificationCount() == previousCount); >@@ -1589,6 +1675,7 @@ > assertTrue(!x.isSimpleType()); > assertTrue(x.isArrayType()); > assertTrue(!x.isPrimitiveType()); >+ assertTrue(!x.isParameterizedType()); > assertTrue(x.getNodeType() == ASTNode.ARRAY_TYPE); > > assertTrue(x.getDimensions() == 1); >@@ -1626,6 +1713,61 @@ > assertTrue(x.getElementType().isPrimitiveType()); > } > >+ public void testParameterizedType() { >+ long previousCount = ast.modificationCount(); >+ final ParameterizedType x = ast.newParameterizedType(ast.newSimpleName("String")); //$NON-NLS-1$ >+ assertTrue(ast.modificationCount() > previousCount); >+ previousCount = ast.modificationCount(); >+ assertTrue(x instanceof Type); >+ assertTrue(x.getAST() == ast); >+ assertTrue(x.getParent() == null); >+ assertTrue(x.getName().getParent() == x); >+ assertTrue(!x.isSimpleType()); >+ assertTrue(!x.isArrayType()); >+ assertTrue(!x.isPrimitiveType()); >+ assertTrue(x.isParameterizedType()); >+ assertTrue(x.getNodeType() == ASTNode.PARAMETERIZED_TYPE); >+ assertTrue(x.typeArguments().size() == 0); >+ // make sure that reading did not change modification count >+ assertTrue(ast.modificationCount() == previousCount); >+ >+ genericPropertyTest(x, new Property("Name", true, Name.class) { //$NON-NLS-1$ >+ public ASTNode sample(AST targetAst, boolean parented) { >+ SimpleName result = targetAst.newSimpleName("a"); //$NON-NLS-1$ >+ if (parented) { >+ targetAst.newExpressionStatement(result); >+ } >+ return result; >+ } >+ public ASTNode get() { >+ return x.getName(); >+ } >+ public void set(ASTNode value) { >+ x.setName((Name) value); >+ } >+ }); >+ genericPropertyListTest(x, x.typeArguments(), >+ new Property("Arguments", true, Type.class) { //$NON-NLS-1$ >+ public ASTNode sample(AST targetAst, boolean parented) { >+ PrimitiveType result = targetAst.newPrimitiveType(PrimitiveType.INT); >+ if (parented) { >+ targetAst.newArrayType(result); >+ } >+ return result; >+ } >+ public ASTNode wrap() { >+ // return Type that embeds x >+ ParameterizedType s1 = ast.newParameterizedType(ast.newSimpleName("foo")); //$NON-NLS-1$ >+ s1.typeArguments().add(x); >+ return s1; >+ } >+ public void unwrap() { >+ ParameterizedType s1 = (ParameterizedType) x.getParent(); >+ s1.typeArguments().remove(x); >+ } >+ }); >+ } >+ > public void testPackageDeclaration() { > long previousCount = ast.modificationCount(); > final PackageDeclaration x = ast.newPackageDeclaration(); >@@ -1827,8 +1969,11 @@ > assertTrue(x.isInterface() == false); > assertTrue(x.getName().getParent() == x); > assertTrue(x.getName().isDeclaration() == true); >+ assertTrue(x.typeParameters().size() == 0); >+ assertTrue(x.getSuperclassType() == null); > assertTrue(x.getSuperclass() == null); > assertTrue(x.getJavadoc() == null); >+ assertTrue(x.superInterfaceTypes().size() == 0); > assertTrue(x.superInterfaces().size() == 0); > assertTrue(x.bodyDeclarations().size()== 0); > assertTrue(x.getNodeType() == ASTNode.TYPE_DECLARATION); >@@ -1871,33 +2016,93 @@ > } > }); > >- genericPropertyTest(x, new Property("Superclass", false, Name.class) { //$NON-NLS-1$ >+ genericPropertyListTest(x, x.typeParameters(), >+ new Property("TypeParameters", true, TypeParameter.class) { //$NON-NLS-1$ > public ASTNode sample(AST targetAst, boolean parented) { >- SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$ >+ TypeParameter result = targetAst.newTypeParameter(); > if (parented) { >- targetAst.newExpressionStatement(result); >+ targetAst.newMethodDeclaration().typeParameters().add(result); >+ } >+ return result; >+ } >+ }); >+ >+ genericPropertyTest(x, new Property("SuperclassType", false, Type.class) { //$NON-NLS-1$ >+ public ASTNode sample(AST targetAst, boolean parented) { >+ SimpleType result = targetAst.newSimpleType(targetAst.newSimpleName("foo")); //$NON-NLS-1$ >+ if (parented) { >+ targetAst.newArrayType(result); > } > return result; > } > public ASTNode get() { >- return x.getSuperclass(); >+ return x.getSuperclassType(); > } > public void set(ASTNode value) { >- x.setSuperclass((Name) value); >+ x.setSuperclassType((Type) value); > } > }); > >- genericPropertyListTest(x, x.superInterfaces(), >- new Property("SuperInterfaces", true, Name.class) { //$NON-NLS-1$ >+ // deprecated superclass name property >+ // ensure that changing the name affects the type, and conversely >+ x.setSuperclassType(null); >+ assertTrue(x.getSuperclassType() == null); >+ assertTrue(x.getSuperclass() == null); >+ Name n0 = ast.newSimpleName("n0"); >+ Type t0 = ast.newSimpleType(n0); >+ x.setSuperclassType(t0); >+ assertTrue(x.getSuperclassType() == t0); >+ assertTrue(x.getSuperclass() == n0); >+ Name n1 = ast.newSimpleName("n1"); >+ x.setSuperclass(n1); >+ assertTrue(x.getSuperclassType() == t0); >+ assertTrue(x.getSuperclass() == n1); >+ x.setSuperclass(null); >+ assertTrue(x.getSuperclassType() == null); >+ assertTrue(x.getSuperclass() == null); >+ >+ genericPropertyListTest(x, x.superInterfaceTypes(), >+ new Property("SuperInterfaceTypes", true, Type.class) { //$NON-NLS-1$ > public ASTNode sample(AST targetAst, boolean parented) { >- SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$ >+ SimpleType result = targetAst.newSimpleType(targetAst.newSimpleName("foo")); //$NON-NLS-1$ > if (parented) { >- targetAst.newExpressionStatement(result); >+ targetAst.newArrayType(result); > } > return result; > } > }); > >+ // deprecated superinterface names property >+ // ensure that changing the name affects the type, and conversely >+ x.superInterfaceTypes().clear(); >+ assertTrue(x.superInterfaceTypes().size() == 0); >+ assertTrue(x.superInterfaces().size() == 0); >+ n0 = ast.newSimpleName("n0"); >+ t0 = ast.newSimpleType(n0); >+ x.superInterfaceTypes().add(t0); >+ assertTrue(x.superInterfaceTypes().size() == 1); >+ assertTrue(x.superInterfaces().size() == 1); >+ assertTrue(x.superInterfaceTypes().get(0) == t0); >+ assertTrue(x.superInterfaces().get(0) == n0); >+ n1 = ast.newSimpleName("n1"); >+ x.superInterfaces().add(n1); >+ assertTrue(x.superInterfaceTypes().size() == 2); >+ assertTrue(x.superInterfaces().size() == 2); >+ assertTrue(x.superInterfaceTypes().get(0) == t0); >+ assertTrue(x.superInterfaces().get(0) == n0); >+ assertTrue(x.superInterfaces().get(1) == n1); >+ assertTrue(n1.getParent() instanceof SimpleType); >+ assertTrue(n1.getParent().getParent() == x); >+ x.superInterfaces().remove(n1); >+ assertTrue(x.superInterfaceTypes().size() == 1); >+ assertTrue(x.superInterfaces().size() == 1); >+ assertTrue(x.superInterfaceTypes().get(0) == t0); >+ assertTrue(x.superInterfaces().get(0) == n0); >+ assertTrue(n1.getParent() == null); >+ x.superInterfaces().remove(n0); >+ assertTrue(x.superInterfaceTypes().size() == 0); >+ assertTrue(x.superInterfaces().size() == 0); >+ > genericPropertyListTest(x, x.bodyDeclarations(), > new Property("BodyDeclarations", true, BodyDeclaration.class) { //$NON-NLS-1$ > public ASTNode sample(AST targetAst, boolean parented) { >@@ -1964,6 +2169,47 @@ > > } > >+ public void testTypeParameter() { >+ long previousCount = ast.modificationCount(); >+ final TypeParameter x = ast.newTypeParameter(); >+ assertTrue(ast.modificationCount() > previousCount); >+ previousCount = ast.modificationCount(); >+ assertTrue(x instanceof TypeParameter); >+ assertTrue(x.getAST() == ast); >+ assertTrue(x.getParent() == null); >+ assertTrue(x.getName().getParent() == x); >+ assertTrue(x.getNodeType() == ASTNode.TYPE_PARAMETER); >+ assertTrue(x.typeBounds().size() == 0); >+ // make sure that reading did not change modification count >+ assertTrue(ast.modificationCount() == previousCount); >+ >+ genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$ >+ public ASTNode sample(AST targetAst, boolean parented) { >+ SimpleName result = targetAst.newSimpleName("a"); //$NON-NLS-1$ >+ if (parented) { >+ targetAst.newExpressionStatement(result); >+ } >+ return result; >+ } >+ public ASTNode get() { >+ return x.getName(); >+ } >+ public void set(ASTNode value) { >+ x.setName((SimpleName) value); >+ } >+ }); >+ genericPropertyListTest(x, x.typeBounds(), >+ new Property("TypeBounds", true, Type.class) { //$NON-NLS-1$ >+ public ASTNode sample(AST targetAst, boolean parented) { >+ Type result = targetAst.newSimpleType(targetAst.newSimpleName("foo")); >+ if (parented) { >+ targetAst.newArrayType(result); >+ } >+ return result; >+ } >+ }); >+ } >+ > public void testSingleVariableDeclaration() { > long previousCount = ast.modificationCount(); > final SingleVariableDeclaration x = ast.newSingleVariableDeclaration(); >@@ -2153,6 +2399,7 @@ > assertTrue(x.getParent() == null); > assertTrue(x.getModifiers() == Modifier.NONE); > assertTrue(x.isConstructor() == false); >+ assertTrue(x.typeParameters().size() == 0); > assertTrue(x.getName().getParent() == x); > assertTrue(x.getName().isDeclaration() == true); > assertTrue(x.getReturnType().getParent() == x); >@@ -2202,6 +2449,17 @@ > > tJavadocComment(x); > >+ genericPropertyListTest(x, x.typeParameters(), >+ new Property("TypeParameters", true, TypeParameter.class) { //$NON-NLS-1$ >+ public ASTNode sample(AST targetAst, boolean parented) { >+ TypeParameter result = targetAst.newTypeParameter(); >+ if (parented) { >+ targetAst.newMethodDeclaration().typeParameters().add(result); >+ } >+ return result; >+ } >+ }); >+ > genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$ > public ASTNode sample(AST targetAst, boolean parented) { > SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$ >@@ -5605,7 +5863,9 @@ > assertTrue(x.getAST() == ast); > assertTrue(x.getParent() == null); > assertTrue(x.getExpression() == null); >- assertTrue(x.getName().getParent() == x); >+ assertTrue(x.getType().getParent() == x); >+ // test deprecated method too >+ assertTrue(x.getName().getParent() == x.getType()); > assertTrue(x.arguments().isEmpty()); > assertTrue(x.getAnonymousClassDeclaration() == null); > assertTrue(x.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION); >@@ -5638,21 +5898,33 @@ > } > }); > >- genericPropertyTest(x, new Property("Name", true, Name.class) { //$NON-NLS-1$ >+ genericPropertyTest(x, new Property("Type", true, Type.class) { //$NON-NLS-1$ > public ASTNode sample(AST targetAst, boolean parented) { >- SimpleName result = targetAst.newSimpleName("a"); //$NON-NLS-1$ >+ SimpleType result = targetAst.newSimpleType(targetAst.newSimpleName("foo")); //$NON-NLS-1$ > if (parented) { >- targetAst.newExpressionStatement(result); >+ targetAst.newArrayType(result); > } > return result; > } > public ASTNode get() { >- return x.getName(); >+ return x.getType(); > } > public void set(ASTNode value) { >- x.setName((Name) value); >+ x.setType((Type) value); > } > }); >+ >+ // deprecated name property >+ // ensure that changing the name affects the type, and conversely >+ Name n0 = ast.newSimpleName("n0"); >+ Type t0 = ast.newSimpleType(n0); >+ x.setType(t0); >+ assertTrue(x.getType() == t0); >+ assertTrue(x.getName() == n0); >+ Name n1 = ast.newSimpleName("n1"); >+ x.setName(n1); >+ assertTrue(x.getType() == t0); >+ assertTrue(x.getName() == n1); > > genericPropertyListTest(x, x.arguments(), > new Property("Arguments", true, Expression.class) { //$NON-NLS-1$ >Index: src/org/eclipse/jdt/core/tests/dom/ASTVisitorTest.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTVisitorTest.java,v >retrieving revision 1.8 >diff -u -r1.8 ASTVisitorTest.java >--- src/org/eclipse/jdt/core/tests/dom/ASTVisitorTest.java 11 Mar 2003 15:07:11 -0000 1.8 >+++ src/org/eclipse/jdt/core/tests/dom/ASTVisitorTest.java 10 Apr 2003 20:12:56 -0000 >@@ -44,6 +44,10 @@ > String E2S; > Type T1; > String T1S; >+ Type T2; >+ String T2S; >+ ParameterizedType PT1; >+ String PT1S; > Statement S1; > String S1S; > Statement S2; >@@ -78,6 +82,10 @@ > String JD2S; > AnonymousClassDeclaration ACD1; > String ACD1S; >+ TypeParameter TP1; >+ String TP1S; >+ TypeParameter TP2; >+ String TP2S; > > final StringBuffer b = new StringBuffer(); > >@@ -99,6 +107,10 @@ > E2S = "[(nSYYnS)]"; //$NON-NLS-1$ > T1 = ast.newSimpleType(ast.newSimpleName("Z")); //$NON-NLS-1$ > T1S = "[(tS[(nSZZnS)]tS)]"; //$NON-NLS-1$ >+ T2 = ast.newSimpleType(ast.newSimpleName("X")); //$NON-NLS-1$ >+ T2S = "[(tS[(nSXXnS)]tS)]"; //$NON-NLS-1$ >+ PT1 = ast.newParameterizedType(ast.newSimpleName("Z")); //$NON-NLS-1$ >+ PT1S = "[(tM[(nSZZnS)]tM)]"; //$NON-NLS-1$ > S1 = ast.newContinueStatement(); > S1S = "[(sCNsCN)]"; //$NON-NLS-1$ > S2 = ast.newBreakStatement(); >@@ -159,6 +171,14 @@ > JD2.setComment("/**Y*/"); //$NON-NLS-1$ > JD2S = "[(JD/**Y*//**Y*/JD)]"; //$NON-NLS-1$ > >+ TP1 = ast.newTypeParameter(); >+ TP1.setName(ast.newSimpleName("x")); //$NON-NLS-1$ >+ TP1S = "[(tTP[(nSxxnS)]tTP)]"; //$NON-NLS-1$ >+ >+ TP2 = ast.newTypeParameter(); >+ TP2.setName(ast.newSimpleName("y")); //$NON-NLS-1$ >+ TP2S = "[(tTP[(nSyynS)]tTP)]"; //$NON-NLS-1$ >+ > } > > protected void tearDown() { >@@ -221,6 +241,13 @@ > b.append(node.getPrimitiveTypeCode().toString()); > b.append("tP)"); //$NON-NLS-1$ > } >+ public boolean visit(QualifiedType node) { >+ b.append("(tQ"); //$NON-NLS-1$ >+ return isVisitingChildren(); >+ } >+ public void endVisit(QualifiedType node) { >+ b.append("tQ)"); //$NON-NLS-1$ >+ } > > // EXPRESSIONS and STATEMENTS > >@@ -326,7 +353,7 @@ > public void endVisit(ClassInstanceCreation node) { > b.append("eCI)"); //$NON-NLS-1$ > } >- >+ > public boolean visit(AnonymousClassDeclaration node) { > b.append("(ACD"); //$NON-NLS-1$ > return isVisitingChildren(); >@@ -517,6 +544,14 @@ > b.append("PD)"); //$NON-NLS-1$ > } > >+ public boolean visit(ParameterizedType node) { >+ b.append("(tM"); //$NON-NLS-1$ >+ return isVisitingChildren(); >+ } >+ public void endVisit(ParameterizedType node) { >+ b.append("tM)"); //$NON-NLS-1$ >+ } >+ > public boolean visit(ParenthesizedExpression node) { > b.append("(ePA"); //$NON-NLS-1$ > return isVisitingChildren(); >@@ -667,6 +702,14 @@ > b.append("eTL)"); //$NON-NLS-1$ > } > >+ public boolean visit(TypeParameter node) { >+ b.append("(tTP"); //$NON-NLS-1$ >+ return isVisitingChildren(); >+ } >+ public void endVisit(TypeParameter node) { >+ b.append("tTP)"); //$NON-NLS-1$ >+ } >+ > public boolean visit(VariableDeclarationExpression node) { > b.append("(eVD"); //$NON-NLS-1$ > return isVisitingChildren(); >@@ -757,6 +800,26 @@ > assertTrue("[(tA[(tPcharchartP)]tA)]".equals(result)); //$NON-NLS-1$ > } > >+ public void testParameterizedType() { >+ ParameterizedType x1 = ast.newParameterizedType(N1); >+ x1.typeArguments().add(T1); >+ x1.typeArguments().add(T2); >+ TestVisitor v1 = new TestVisitor(); >+ b.setLength(0); >+ x1.accept(v1); >+ String result = b.toString(); >+ assertTrue(result.equals("[(tM"+N1S+T1S+T2S+"tM)]")); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ public void testQualifiedType() { >+ QualifiedType x1 = ast.newQualifiedType(T1, N1); >+ TestVisitor v1 = new TestVisitor(); >+ b.setLength(0); >+ x1.accept(v1); >+ String result = b.toString(); >+ assertTrue(result.equals("[(tQ"+T1S+N1S+"tQ)]")); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ > // EXPRESSIONS and STATEMENTS > > public void testArrayAccess() { >@@ -878,13 +941,13 @@ > public void testClassInstanceCreation() { > ClassInstanceCreation x1 = ast.newClassInstanceCreation(); > x1.setExpression(E1); >- x1.setName(N1); >+ x1.setType(PT1); > x1.setAnonymousClassDeclaration(ACD1); > TestVisitor v1 = new TestVisitor(); > b.setLength(0); > x1.accept(v1); > String result = b.toString(); >- assertTrue(result.equals("[(eCI"+E1S+N1S+ACD1S+"eCI)]")); //$NON-NLS-1$ //$NON-NLS-2$ >+ assertTrue(result.equals("[(eCI"+E1S+PT1S+ACD1S+"eCI)]")); //$NON-NLS-1$ //$NON-NLS-2$ > } > public void testAnonymousClassDeclaration() { > AnonymousClassDeclaration x1 = ast.newAnonymousClassDeclaration(); >@@ -1083,6 +1146,7 @@ > public void testMethodDeclaration() { > MethodDeclaration x1 = ast.newMethodDeclaration(); > x1.setJavadoc(JD1); >+ x1.typeParameters().add(TP1); > x1.setReturnType(T1); > x1.setName(N1); > x1.parameters().add(V1); >@@ -1094,7 +1158,7 @@ > b.setLength(0); > x1.accept(v1); > String result = b.toString(); >- assertTrue(result.equals("[(MD"+JD1S+T1S+N1S+V1S+V2S+N2S+N3S+B1S+"MD)]")); //$NON-NLS-1$ //$NON-NLS-2$ >+ assertTrue(result.equals("[(MD"+JD1S+TP1S+T1S+N1S+V1S+V2S+N2S+N3S+B1S+"MD)]")); //$NON-NLS-1$ //$NON-NLS-2$ > } > public void testMethodInvocation() { > MethodInvocation x1 = ast.newMethodInvocation(); >@@ -1283,16 +1347,17 @@ > TypeDeclaration x1 = ast.newTypeDeclaration(); > x1.setJavadoc(JD1); > x1.setName(N1); >- x1.setSuperclass(N2); >- x1.superInterfaces().add(N3); >- x1.superInterfaces().add(ast.newSimpleName("J")); //$NON-NLS-1$ >+ x1.typeParameters().add(TP1); >+ x1.setSuperclassType(PT1); >+ x1.superInterfaceTypes().add(T1); >+ x1.superInterfaceTypes().add(T2); //$NON-NLS-1$ > x1.bodyDeclarations().add(FD1); > x1.bodyDeclarations().add(FD2); > TestVisitor v1 = new TestVisitor(); > b.setLength(0); > x1.accept(v1); > String result = b.toString(); >- assertTrue(result.equals("[(TD"+JD1S+N1S+N2S+N3S+"[(nSJJnS)]"+FD1S+FD2S+"TD)]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ assertTrue(result.equals("[(TD"+JD1S+N1S+TP1S+PT1S+T1S+T2S+FD1S+FD2S+"TD)]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > } > public void testTypeDeclarationStatement() { > TypeDeclarationStatement x1 = ast.newTypeDeclarationStatement(TD1); >@@ -1311,6 +1376,19 @@ > String result = b.toString(); > assertTrue(result.equals("[(eTL"+T1S+"eTL)]")); //$NON-NLS-1$ //$NON-NLS-2$ > } >+ public void testTypeParameter() { >+ TypeParameter x1 = ast.newTypeParameter(); >+ x1.setName(N1); >+ x1.typeBounds().add(PT1); >+ x1.typeBounds().add(T1); >+ x1.typeBounds().add(T2); >+ TestVisitor v1 = new TestVisitor(); >+ b.setLength(0); >+ x1.accept(v1); >+ String result = b.toString(); >+ assertTrue(result.equals("[(tTP"+N1S+PT1S+T1S+T2S+"tTP)]")); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ > public void testVariableDeclaration() { > SingleVariableDeclaration x1 = ast.newSingleVariableDeclaration(); > x1.setType(T1); >Index: src/org/eclipse/jdt/core/tests/dom/BindingsCollectorVisitor.java >=================================================================== >RCS file: /data/cvs/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/BindingsCollectorVisitor.java,v >retrieving revision 1.2 >diff -u -r1.2 BindingsCollectorVisitor.java >--- src/org/eclipse/jdt/core/tests/dom/BindingsCollectorVisitor.java 11 Mar 2003 15:07:11 -0000 1.2 >+++ src/org/eclipse/jdt/core/tests/dom/BindingsCollectorVisitor.java 10 Apr 2003 20:12:56 -0000 >@@ -303,6 +303,15 @@ > } > > /** >+ * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(ParameterizedType) >+ * @since 2.2 >+ */ >+ public void endVisit(ParameterizedType node) { >+ ITypeBinding typeBinding = node.resolveBinding(); >+ collectBindings(node, typeBinding); >+ } >+ >+ /** > * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(ParenthesizedExpression) > */ > public void endVisit(ParenthesizedExpression node) { >@@ -462,6 +471,13 @@ > public void endVisit(TypeLiteral node) { > ITypeBinding typeBinding = node.resolveTypeBinding(); > collectBindings(node, typeBinding); >+ } >+ >+ /** >+ * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(TypeParameter) >+ * @since 2.2 >+ */ >+ public void endVisit(TypeParameter node) { > } > > /**
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 36142
:
4579
| 4580 |
4581