Lines 330-335
Link Here
|
330 |
} |
330 |
} |
331 |
|
331 |
|
332 |
/** |
332 |
/** |
|
|
333 |
* @see org.eclipse.jdt.core.dom.ASTMatcher#match(ParameterizedType, Object) |
334 |
* @since 2.2 |
335 |
*/ |
336 |
public boolean match(ParameterizedType node, Object other) { |
337 |
checkPositions(node, other); |
338 |
return super.match(node, other); |
339 |
} |
340 |
|
341 |
/** |
333 |
* @see org.eclipse.jdt.core.dom.ASTMatcher#match(ParenthesizedExpression, Object) |
342 |
* @see org.eclipse.jdt.core.dom.ASTMatcher#match(ParenthesizedExpression, Object) |
334 |
*/ |
343 |
*/ |
335 |
public boolean match(ParenthesizedExpression node, Object other) { |
344 |
public boolean match(ParenthesizedExpression node, Object other) { |
Lines 370-375
Link Here
|
370 |
} |
379 |
} |
371 |
|
380 |
|
372 |
/** |
381 |
/** |
|
|
382 |
* @see org.eclipse.jdt.core.dom.ASTMatcher#match(QualifiedType, Object) |
383 |
*/ |
384 |
public boolean match(QualifiedType node, Object other) { |
385 |
checkPositions(node, other); |
386 |
return super.match(node, other); |
387 |
} |
388 |
|
389 |
/** |
373 |
* @see org.eclipse.jdt.core.dom.ASTMatcher#match(ReturnStatement, Object) |
390 |
* @see org.eclipse.jdt.core.dom.ASTMatcher#match(ReturnStatement, Object) |
374 |
*/ |
391 |
*/ |
375 |
public boolean match(ReturnStatement node, Object other) { |
392 |
public boolean match(ReturnStatement node, Object other) { |
Lines 506-511
Link Here
|
506 |
} |
523 |
} |
507 |
|
524 |
|
508 |
/** |
525 |
/** |
|
|
526 |
* @see org.eclipse.jdt.core.dom.ASTMatcher#match(TypeParameter, Object) |
527 |
* @since 2.2 |
528 |
*/ |
529 |
public boolean match(TypeParameter node, Object other) { |
530 |
checkPositions(node, other); |
531 |
return super.match(node, other); |
532 |
} |
533 |
|
534 |
/** |
509 |
* @see org.eclipse.jdt.core.dom.ASTMatcher#match(VariableDeclarationExpression, Object) |
535 |
* @see org.eclipse.jdt.core.dom.ASTMatcher#match(VariableDeclarationExpression, Object) |
510 |
*/ |
536 |
*/ |
511 |
public boolean match(VariableDeclarationExpression node, Object other) { |
537 |
public boolean match(VariableDeclarationExpression node, Object other) { |
Lines 1138-1144
Link Here
|
1138 |
assertTrue(x.isDeclaration() == true); |
1164 |
assertTrue(x.isDeclaration() == true); |
1139 |
fd.setName(ast.newSimpleName("b")); //$NON-NLS-1$ |
1165 |
fd.setName(ast.newSimpleName("b")); //$NON-NLS-1$ |
1140 |
assertTrue(x.isDeclaration() == false); |
1166 |
assertTrue(x.isDeclaration() == false); |
1141 |
|
|
|
1142 |
} |
1167 |
} |
1143 |
|
1168 |
|
1144 |
public void testQualifiedName() { |
1169 |
public void testQualifiedName() { |
Lines 1199-1205
Link Here
|
1199 |
x.setName((SimpleName) value); |
1224 |
x.setName((SimpleName) value); |
1200 |
} |
1225 |
} |
1201 |
}); |
1226 |
}); |
|
|
1227 |
} |
1228 |
|
1229 |
public void testQualifiedType() { |
1230 |
long previousCount = ast.modificationCount(); |
1231 |
final QualifiedType x = ast.newQualifiedType( |
1232 |
ast.newSimpleType(ast.newSimpleName("q")), //$NON-NLS-1$ |
1233 |
ast.newSimpleName("i")); //$NON-NLS-1$ |
1234 |
assertTrue(ast.modificationCount() > previousCount); |
1235 |
previousCount = ast.modificationCount(); |
1236 |
assertTrue(x instanceof Type); |
1237 |
assertTrue(x.getAST() == ast); |
1238 |
assertTrue(x.getParent() == null); |
1239 |
assertTrue(x.getQualifier().getParent() == x); |
1240 |
assertTrue(x.getName().getParent() == x); |
1241 |
assertTrue(x.getName().isDeclaration() == false); |
1242 |
assertTrue(x.getNodeType() == ASTNode.QUALIFIED_TYPE); |
1243 |
// make sure that reading did not change modification count |
1244 |
assertTrue(ast.modificationCount() == previousCount); |
1245 |
|
1246 |
genericPropertyTest(x, new Property("Qualifier", true, Type.class) { //$NON-NLS-1$ |
1247 |
public ASTNode sample(AST targetAst, boolean parented) { |
1248 |
SimpleType result = |
1249 |
targetAst.newSimpleType( |
1250 |
targetAst.newSimpleName("a")); //$NON-NLS-1$ |
1251 |
if (parented) { |
1252 |
targetAst.newArrayType(result); |
1253 |
} |
1254 |
return result; |
1255 |
} |
1256 |
public ASTNode wrap() { |
1257 |
QualifiedType s1 = ast.newQualifiedType(x, ast.newSimpleName("z")); //$NON-NLS-1$ |
1258 |
return s1; |
1259 |
} |
1260 |
public void unwrap() { |
1261 |
QualifiedType s1 = (QualifiedType) x.getParent(); |
1262 |
s1.setQualifier(ast.newSimpleType(ast.newSimpleName("z"))); //$NON-NLS-1$ |
1263 |
} |
1264 |
public ASTNode get() { |
1265 |
return x.getQualifier(); |
1266 |
} |
1267 |
public void set(ASTNode value) { |
1268 |
x.setQualifier((Type) value); |
1269 |
} |
1270 |
}); |
1202 |
|
1271 |
|
|
|
1272 |
genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$ |
1273 |
public ASTNode sample(AST targetAst, boolean parented) { |
1274 |
SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$ |
1275 |
if (parented) { |
1276 |
targetAst.newExpressionStatement(result); |
1277 |
} |
1278 |
return result; |
1279 |
} |
1280 |
public ASTNode get() { |
1281 |
return x.getName(); |
1282 |
} |
1283 |
public void set(ASTNode value) { |
1284 |
x.setName((SimpleName) value); |
1285 |
} |
1286 |
}); |
1203 |
} |
1287 |
} |
1204 |
|
1288 |
|
1205 |
public void testNullLiteral() { |
1289 |
public void testNullLiteral() { |
Lines 1482-1487
Link Here
|
1482 |
assertTrue(x.isSimpleType()); |
1566 |
assertTrue(x.isSimpleType()); |
1483 |
assertTrue(!x.isArrayType()); |
1567 |
assertTrue(!x.isArrayType()); |
1484 |
assertTrue(!x.isPrimitiveType()); |
1568 |
assertTrue(!x.isPrimitiveType()); |
|
|
1569 |
assertTrue(!x.isParameterizedType()); |
1485 |
assertTrue(x.getNodeType() == ASTNode.SIMPLE_TYPE); |
1570 |
assertTrue(x.getNodeType() == ASTNode.SIMPLE_TYPE); |
1486 |
// make sure that reading did not change modification count |
1571 |
// make sure that reading did not change modification count |
1487 |
assertTrue(ast.modificationCount() == previousCount); |
1572 |
assertTrue(ast.modificationCount() == previousCount); |
Lines 1515-1520
Link Here
|
1515 |
assertTrue(!x.isSimpleType()); |
1600 |
assertTrue(!x.isSimpleType()); |
1516 |
assertTrue(!x.isArrayType()); |
1601 |
assertTrue(!x.isArrayType()); |
1517 |
assertTrue(x.isPrimitiveType()); |
1602 |
assertTrue(x.isPrimitiveType()); |
|
|
1603 |
assertTrue(!x.isParameterizedType()); |
1518 |
assertTrue(x.getNodeType() == ASTNode.PRIMITIVE_TYPE); |
1604 |
assertTrue(x.getNodeType() == ASTNode.PRIMITIVE_TYPE); |
1519 |
// make sure that reading did not change modification count |
1605 |
// make sure that reading did not change modification count |
1520 |
assertTrue(ast.modificationCount() == previousCount); |
1606 |
assertTrue(ast.modificationCount() == previousCount); |
Lines 1589-1594
Link Here
|
1589 |
assertTrue(!x.isSimpleType()); |
1675 |
assertTrue(!x.isSimpleType()); |
1590 |
assertTrue(x.isArrayType()); |
1676 |
assertTrue(x.isArrayType()); |
1591 |
assertTrue(!x.isPrimitiveType()); |
1677 |
assertTrue(!x.isPrimitiveType()); |
|
|
1678 |
assertTrue(!x.isParameterizedType()); |
1592 |
assertTrue(x.getNodeType() == ASTNode.ARRAY_TYPE); |
1679 |
assertTrue(x.getNodeType() == ASTNode.ARRAY_TYPE); |
1593 |
|
1680 |
|
1594 |
assertTrue(x.getDimensions() == 1); |
1681 |
assertTrue(x.getDimensions() == 1); |
Lines 1626-1631
Link Here
|
1626 |
assertTrue(x.getElementType().isPrimitiveType()); |
1713 |
assertTrue(x.getElementType().isPrimitiveType()); |
1627 |
} |
1714 |
} |
1628 |
|
1715 |
|
|
|
1716 |
public void testParameterizedType() { |
1717 |
long previousCount = ast.modificationCount(); |
1718 |
final ParameterizedType x = ast.newParameterizedType(ast.newSimpleName("String")); //$NON-NLS-1$ |
1719 |
assertTrue(ast.modificationCount() > previousCount); |
1720 |
previousCount = ast.modificationCount(); |
1721 |
assertTrue(x instanceof Type); |
1722 |
assertTrue(x.getAST() == ast); |
1723 |
assertTrue(x.getParent() == null); |
1724 |
assertTrue(x.getName().getParent() == x); |
1725 |
assertTrue(!x.isSimpleType()); |
1726 |
assertTrue(!x.isArrayType()); |
1727 |
assertTrue(!x.isPrimitiveType()); |
1728 |
assertTrue(x.isParameterizedType()); |
1729 |
assertTrue(x.getNodeType() == ASTNode.PARAMETERIZED_TYPE); |
1730 |
assertTrue(x.typeArguments().size() == 0); |
1731 |
// make sure that reading did not change modification count |
1732 |
assertTrue(ast.modificationCount() == previousCount); |
1733 |
|
1734 |
genericPropertyTest(x, new Property("Name", true, Name.class) { //$NON-NLS-1$ |
1735 |
public ASTNode sample(AST targetAst, boolean parented) { |
1736 |
SimpleName result = targetAst.newSimpleName("a"); //$NON-NLS-1$ |
1737 |
if (parented) { |
1738 |
targetAst.newExpressionStatement(result); |
1739 |
} |
1740 |
return result; |
1741 |
} |
1742 |
public ASTNode get() { |
1743 |
return x.getName(); |
1744 |
} |
1745 |
public void set(ASTNode value) { |
1746 |
x.setName((Name) value); |
1747 |
} |
1748 |
}); |
1749 |
genericPropertyListTest(x, x.typeArguments(), |
1750 |
new Property("Arguments", true, Type.class) { //$NON-NLS-1$ |
1751 |
public ASTNode sample(AST targetAst, boolean parented) { |
1752 |
PrimitiveType result = targetAst.newPrimitiveType(PrimitiveType.INT); |
1753 |
if (parented) { |
1754 |
targetAst.newArrayType(result); |
1755 |
} |
1756 |
return result; |
1757 |
} |
1758 |
public ASTNode wrap() { |
1759 |
// return Type that embeds x |
1760 |
ParameterizedType s1 = ast.newParameterizedType(ast.newSimpleName("foo")); //$NON-NLS-1$ |
1761 |
s1.typeArguments().add(x); |
1762 |
return s1; |
1763 |
} |
1764 |
public void unwrap() { |
1765 |
ParameterizedType s1 = (ParameterizedType) x.getParent(); |
1766 |
s1.typeArguments().remove(x); |
1767 |
} |
1768 |
}); |
1769 |
} |
1770 |
|
1629 |
public void testPackageDeclaration() { |
1771 |
public void testPackageDeclaration() { |
1630 |
long previousCount = ast.modificationCount(); |
1772 |
long previousCount = ast.modificationCount(); |
1631 |
final PackageDeclaration x = ast.newPackageDeclaration(); |
1773 |
final PackageDeclaration x = ast.newPackageDeclaration(); |
Lines 1827-1834
Link Here
|
1827 |
assertTrue(x.isInterface() == false); |
1969 |
assertTrue(x.isInterface() == false); |
1828 |
assertTrue(x.getName().getParent() == x); |
1970 |
assertTrue(x.getName().getParent() == x); |
1829 |
assertTrue(x.getName().isDeclaration() == true); |
1971 |
assertTrue(x.getName().isDeclaration() == true); |
|
|
1972 |
assertTrue(x.typeParameters().size() == 0); |
1973 |
assertTrue(x.getSuperclassType() == null); |
1830 |
assertTrue(x.getSuperclass() == null); |
1974 |
assertTrue(x.getSuperclass() == null); |
1831 |
assertTrue(x.getJavadoc() == null); |
1975 |
assertTrue(x.getJavadoc() == null); |
|
|
1976 |
assertTrue(x.superInterfaceTypes().size() == 0); |
1832 |
assertTrue(x.superInterfaces().size() == 0); |
1977 |
assertTrue(x.superInterfaces().size() == 0); |
1833 |
assertTrue(x.bodyDeclarations().size()== 0); |
1978 |
assertTrue(x.bodyDeclarations().size()== 0); |
1834 |
assertTrue(x.getNodeType() == ASTNode.TYPE_DECLARATION); |
1979 |
assertTrue(x.getNodeType() == ASTNode.TYPE_DECLARATION); |
Lines 1871-1903
Link Here
|
1871 |
} |
2016 |
} |
1872 |
}); |
2017 |
}); |
1873 |
|
2018 |
|
1874 |
genericPropertyTest(x, new Property("Superclass", false, Name.class) { //$NON-NLS-1$ |
2019 |
genericPropertyListTest(x, x.typeParameters(), |
|
|
2020 |
new Property("TypeParameters", true, TypeParameter.class) { //$NON-NLS-1$ |
1875 |
public ASTNode sample(AST targetAst, boolean parented) { |
2021 |
public ASTNode sample(AST targetAst, boolean parented) { |
1876 |
SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$ |
2022 |
TypeParameter result = targetAst.newTypeParameter(); |
1877 |
if (parented) { |
2023 |
if (parented) { |
1878 |
targetAst.newExpressionStatement(result); |
2024 |
targetAst.newMethodDeclaration().typeParameters().add(result); |
|
|
2025 |
} |
2026 |
return result; |
2027 |
} |
2028 |
}); |
2029 |
|
2030 |
genericPropertyTest(x, new Property("SuperclassType", false, Type.class) { //$NON-NLS-1$ |
2031 |
public ASTNode sample(AST targetAst, boolean parented) { |
2032 |
SimpleType result = targetAst.newSimpleType(targetAst.newSimpleName("foo")); //$NON-NLS-1$ |
2033 |
if (parented) { |
2034 |
targetAst.newArrayType(result); |
1879 |
} |
2035 |
} |
1880 |
return result; |
2036 |
return result; |
1881 |
} |
2037 |
} |
1882 |
public ASTNode get() { |
2038 |
public ASTNode get() { |
1883 |
return x.getSuperclass(); |
2039 |
return x.getSuperclassType(); |
1884 |
} |
2040 |
} |
1885 |
public void set(ASTNode value) { |
2041 |
public void set(ASTNode value) { |
1886 |
x.setSuperclass((Name) value); |
2042 |
x.setSuperclassType((Type) value); |
1887 |
} |
2043 |
} |
1888 |
}); |
2044 |
}); |
1889 |
|
2045 |
|
1890 |
genericPropertyListTest(x, x.superInterfaces(), |
2046 |
// deprecated superclass name property |
1891 |
new Property("SuperInterfaces", true, Name.class) { //$NON-NLS-1$ |
2047 |
// ensure that changing the name affects the type, and conversely |
|
|
2048 |
x.setSuperclassType(null); |
2049 |
assertTrue(x.getSuperclassType() == null); |
2050 |
assertTrue(x.getSuperclass() == null); |
2051 |
Name n0 = ast.newSimpleName("n0"); |
2052 |
Type t0 = ast.newSimpleType(n0); |
2053 |
x.setSuperclassType(t0); |
2054 |
assertTrue(x.getSuperclassType() == t0); |
2055 |
assertTrue(x.getSuperclass() == n0); |
2056 |
Name n1 = ast.newSimpleName("n1"); |
2057 |
x.setSuperclass(n1); |
2058 |
assertTrue(x.getSuperclassType() == t0); |
2059 |
assertTrue(x.getSuperclass() == n1); |
2060 |
x.setSuperclass(null); |
2061 |
assertTrue(x.getSuperclassType() == null); |
2062 |
assertTrue(x.getSuperclass() == null); |
2063 |
|
2064 |
genericPropertyListTest(x, x.superInterfaceTypes(), |
2065 |
new Property("SuperInterfaceTypes", true, Type.class) { //$NON-NLS-1$ |
1892 |
public ASTNode sample(AST targetAst, boolean parented) { |
2066 |
public ASTNode sample(AST targetAst, boolean parented) { |
1893 |
SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$ |
2067 |
SimpleType result = targetAst.newSimpleType(targetAst.newSimpleName("foo")); //$NON-NLS-1$ |
1894 |
if (parented) { |
2068 |
if (parented) { |
1895 |
targetAst.newExpressionStatement(result); |
2069 |
targetAst.newArrayType(result); |
1896 |
} |
2070 |
} |
1897 |
return result; |
2071 |
return result; |
1898 |
} |
2072 |
} |
1899 |
}); |
2073 |
}); |
1900 |
|
2074 |
|
|
|
2075 |
// deprecated superinterface names property |
2076 |
// ensure that changing the name affects the type, and conversely |
2077 |
x.superInterfaceTypes().clear(); |
2078 |
assertTrue(x.superInterfaceTypes().size() == 0); |
2079 |
assertTrue(x.superInterfaces().size() == 0); |
2080 |
n0 = ast.newSimpleName("n0"); |
2081 |
t0 = ast.newSimpleType(n0); |
2082 |
x.superInterfaceTypes().add(t0); |
2083 |
assertTrue(x.superInterfaceTypes().size() == 1); |
2084 |
assertTrue(x.superInterfaces().size() == 1); |
2085 |
assertTrue(x.superInterfaceTypes().get(0) == t0); |
2086 |
assertTrue(x.superInterfaces().get(0) == n0); |
2087 |
n1 = ast.newSimpleName("n1"); |
2088 |
x.superInterfaces().add(n1); |
2089 |
assertTrue(x.superInterfaceTypes().size() == 2); |
2090 |
assertTrue(x.superInterfaces().size() == 2); |
2091 |
assertTrue(x.superInterfaceTypes().get(0) == t0); |
2092 |
assertTrue(x.superInterfaces().get(0) == n0); |
2093 |
assertTrue(x.superInterfaces().get(1) == n1); |
2094 |
assertTrue(n1.getParent() instanceof SimpleType); |
2095 |
assertTrue(n1.getParent().getParent() == x); |
2096 |
x.superInterfaces().remove(n1); |
2097 |
assertTrue(x.superInterfaceTypes().size() == 1); |
2098 |
assertTrue(x.superInterfaces().size() == 1); |
2099 |
assertTrue(x.superInterfaceTypes().get(0) == t0); |
2100 |
assertTrue(x.superInterfaces().get(0) == n0); |
2101 |
assertTrue(n1.getParent() == null); |
2102 |
x.superInterfaces().remove(n0); |
2103 |
assertTrue(x.superInterfaceTypes().size() == 0); |
2104 |
assertTrue(x.superInterfaces().size() == 0); |
2105 |
|
1901 |
genericPropertyListTest(x, x.bodyDeclarations(), |
2106 |
genericPropertyListTest(x, x.bodyDeclarations(), |
1902 |
new Property("BodyDeclarations", true, BodyDeclaration.class) { //$NON-NLS-1$ |
2107 |
new Property("BodyDeclarations", true, BodyDeclaration.class) { //$NON-NLS-1$ |
1903 |
public ASTNode sample(AST targetAst, boolean parented) { |
2108 |
public ASTNode sample(AST targetAst, boolean parented) { |
Lines 1964-1969
Link Here
|
1964 |
|
2169 |
|
1965 |
} |
2170 |
} |
1966 |
|
2171 |
|
|
|
2172 |
public void testTypeParameter() { |
2173 |
long previousCount = ast.modificationCount(); |
2174 |
final TypeParameter x = ast.newTypeParameter(); |
2175 |
assertTrue(ast.modificationCount() > previousCount); |
2176 |
previousCount = ast.modificationCount(); |
2177 |
assertTrue(x instanceof TypeParameter); |
2178 |
assertTrue(x.getAST() == ast); |
2179 |
assertTrue(x.getParent() == null); |
2180 |
assertTrue(x.getName().getParent() == x); |
2181 |
assertTrue(x.getNodeType() == ASTNode.TYPE_PARAMETER); |
2182 |
assertTrue(x.typeBounds().size() == 0); |
2183 |
// make sure that reading did not change modification count |
2184 |
assertTrue(ast.modificationCount() == previousCount); |
2185 |
|
2186 |
genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$ |
2187 |
public ASTNode sample(AST targetAst, boolean parented) { |
2188 |
SimpleName result = targetAst.newSimpleName("a"); //$NON-NLS-1$ |
2189 |
if (parented) { |
2190 |
targetAst.newExpressionStatement(result); |
2191 |
} |
2192 |
return result; |
2193 |
} |
2194 |
public ASTNode get() { |
2195 |
return x.getName(); |
2196 |
} |
2197 |
public void set(ASTNode value) { |
2198 |
x.setName((SimpleName) value); |
2199 |
} |
2200 |
}); |
2201 |
genericPropertyListTest(x, x.typeBounds(), |
2202 |
new Property("TypeBounds", true, Type.class) { //$NON-NLS-1$ |
2203 |
public ASTNode sample(AST targetAst, boolean parented) { |
2204 |
Type result = targetAst.newSimpleType(targetAst.newSimpleName("foo")); |
2205 |
if (parented) { |
2206 |
targetAst.newArrayType(result); |
2207 |
} |
2208 |
return result; |
2209 |
} |
2210 |
}); |
2211 |
} |
2212 |
|
1967 |
public void testSingleVariableDeclaration() { |
2213 |
public void testSingleVariableDeclaration() { |
1968 |
long previousCount = ast.modificationCount(); |
2214 |
long previousCount = ast.modificationCount(); |
1969 |
final SingleVariableDeclaration x = ast.newSingleVariableDeclaration(); |
2215 |
final SingleVariableDeclaration x = ast.newSingleVariableDeclaration(); |
Lines 2153-2158
Link Here
|
2153 |
assertTrue(x.getParent() == null); |
2399 |
assertTrue(x.getParent() == null); |
2154 |
assertTrue(x.getModifiers() == Modifier.NONE); |
2400 |
assertTrue(x.getModifiers() == Modifier.NONE); |
2155 |
assertTrue(x.isConstructor() == false); |
2401 |
assertTrue(x.isConstructor() == false); |
|
|
2402 |
assertTrue(x.typeParameters().size() == 0); |
2156 |
assertTrue(x.getName().getParent() == x); |
2403 |
assertTrue(x.getName().getParent() == x); |
2157 |
assertTrue(x.getName().isDeclaration() == true); |
2404 |
assertTrue(x.getName().isDeclaration() == true); |
2158 |
assertTrue(x.getReturnType().getParent() == x); |
2405 |
assertTrue(x.getReturnType().getParent() == x); |
Lines 2202-2207
Link Here
|
2202 |
|
2449 |
|
2203 |
tJavadocComment(x); |
2450 |
tJavadocComment(x); |
2204 |
|
2451 |
|
|
|
2452 |
genericPropertyListTest(x, x.typeParameters(), |
2453 |
new Property("TypeParameters", true, TypeParameter.class) { //$NON-NLS-1$ |
2454 |
public ASTNode sample(AST targetAst, boolean parented) { |
2455 |
TypeParameter result = targetAst.newTypeParameter(); |
2456 |
if (parented) { |
2457 |
targetAst.newMethodDeclaration().typeParameters().add(result); |
2458 |
} |
2459 |
return result; |
2460 |
} |
2461 |
}); |
2462 |
|
2205 |
genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$ |
2463 |
genericPropertyTest(x, new Property("Name", true, SimpleName.class) { //$NON-NLS-1$ |
2206 |
public ASTNode sample(AST targetAst, boolean parented) { |
2464 |
public ASTNode sample(AST targetAst, boolean parented) { |
2207 |
SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$ |
2465 |
SimpleName result = targetAst.newSimpleName("foo"); //$NON-NLS-1$ |
Lines 5605-5611
Link Here
|
5605 |
assertTrue(x.getAST() == ast); |
5863 |
assertTrue(x.getAST() == ast); |
5606 |
assertTrue(x.getParent() == null); |
5864 |
assertTrue(x.getParent() == null); |
5607 |
assertTrue(x.getExpression() == null); |
5865 |
assertTrue(x.getExpression() == null); |
5608 |
assertTrue(x.getName().getParent() == x); |
5866 |
assertTrue(x.getType().getParent() == x); |
|
|
5867 |
// test deprecated method too |
5868 |
assertTrue(x.getName().getParent() == x.getType()); |
5609 |
assertTrue(x.arguments().isEmpty()); |
5869 |
assertTrue(x.arguments().isEmpty()); |
5610 |
assertTrue(x.getAnonymousClassDeclaration() == null); |
5870 |
assertTrue(x.getAnonymousClassDeclaration() == null); |
5611 |
assertTrue(x.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION); |
5871 |
assertTrue(x.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION); |
Lines 5638-5658
Link Here
|
5638 |
} |
5898 |
} |
5639 |
}); |
5899 |
}); |
5640 |
|
5900 |
|
5641 |
genericPropertyTest(x, new Property("Name", true, Name.class) { //$NON-NLS-1$ |
5901 |
genericPropertyTest(x, new Property("Type", true, Type.class) { //$NON-NLS-1$ |
5642 |
public ASTNode sample(AST targetAst, boolean parented) { |
5902 |
public ASTNode sample(AST targetAst, boolean parented) { |
5643 |
SimpleName result = targetAst.newSimpleName("a"); //$NON-NLS-1$ |
5903 |
SimpleType result = targetAst.newSimpleType(targetAst.newSimpleName("foo")); //$NON-NLS-1$ |
5644 |
if (parented) { |
5904 |
if (parented) { |
5645 |
targetAst.newExpressionStatement(result); |
5905 |
targetAst.newArrayType(result); |
5646 |
} |
5906 |
} |
5647 |
return result; |
5907 |
return result; |
5648 |
} |
5908 |
} |
5649 |
public ASTNode get() { |
5909 |
public ASTNode get() { |
5650 |
return x.getName(); |
5910 |
return x.getType(); |
5651 |
} |
5911 |
} |
5652 |
public void set(ASTNode value) { |
5912 |
public void set(ASTNode value) { |
5653 |
x.setName((Name) value); |
5913 |
x.setType((Type) value); |
5654 |
} |
5914 |
} |
5655 |
}); |
5915 |
}); |
|
|
5916 |
|
5917 |
// deprecated name property |
5918 |
// ensure that changing the name affects the type, and conversely |
5919 |
Name n0 = ast.newSimpleName("n0"); |
5920 |
Type t0 = ast.newSimpleType(n0); |
5921 |
x.setType(t0); |
5922 |
assertTrue(x.getType() == t0); |
5923 |
assertTrue(x.getName() == n0); |
5924 |
Name n1 = ast.newSimpleName("n1"); |
5925 |
x.setName(n1); |
5926 |
assertTrue(x.getType() == t0); |
5927 |
assertTrue(x.getName() == n1); |
5656 |
|
5928 |
|
5657 |
genericPropertyListTest(x, x.arguments(), |
5929 |
genericPropertyListTest(x, x.arguments(), |
5658 |
new Property("Arguments", true, Expression.class) { //$NON-NLS-1$ |
5930 |
new Property("Arguments", true, Expression.class) { //$NON-NLS-1$ |