Lines 46-52
Link Here
|
46 |
} |
46 |
} |
47 |
|
47 |
|
48 |
static { |
48 |
static { |
49 |
// TESTS_NUMBERS = new int[] { 239 }; |
49 |
// TESTS_NUMBERS = new int[] { 323 }; |
50 |
// TESTS_RANGE = new int[] { 308, -1 }; |
50 |
// TESTS_RANGE = new int[] { 308, -1 }; |
51 |
// TESTS_NAMES = new String[] {"test0204"}; |
51 |
// TESTS_NAMES = new String[] {"test0204"}; |
52 |
} |
52 |
} |
Lines 10229-10232
Link Here
|
10229 |
IMemberValuePairBinding pairBinding = memberValuePairBindings[0]; |
10229 |
IMemberValuePairBinding pairBinding = memberValuePairBindings[0]; |
10230 |
assertNull("Got a value", pairBinding.getValue()); |
10230 |
assertNull("Got a value", pairBinding.getValue()); |
10231 |
} |
10231 |
} |
|
|
10232 |
|
10233 |
public void test0323() throws JavaModelException { |
10234 |
String contents = "package test0323;\n" |
10235 |
+ "public class X {\n" |
10236 |
+ " public void someMethod() {\n" |
10237 |
+ " int i = /*start*/(new Integer(getId())).intValue()/*end*/;\n" |
10238 |
+ " }\n" |
10239 |
+ " public String getId() {\n" |
10240 |
+ " return null;\n" |
10241 |
+ " }\n" |
10242 |
+ "}"; |
10243 |
this.workingCopy = getWorkingCopy("/Converter15/src/test0323/X.java", contents, true/*resolve*/ |
10244 |
); |
10245 |
MethodInvocation methodCall = (MethodInvocation) buildAST(contents, workingCopy, false, true, true); |
10246 |
ParenthesizedExpression intValueReceiver = (ParenthesizedExpression) methodCall.getExpression(); |
10247 |
ParenthesizedExpression newParenthesizedExpression = (ParenthesizedExpression) ASTNode.copySubtree( |
10248 |
intValueReceiver.getAST(), intValueReceiver); |
10249 |
replaceNodeInParent(methodCall, newParenthesizedExpression); |
10250 |
ClassInstanceCreation constructorCall = (ClassInstanceCreation) newParenthesizedExpression.getExpression(); |
10251 |
constructorCall.resolveTypeBinding(); // This should not throw a NPE |
10252 |
IMethodBinding constructorBinding = constructorCall.resolveConstructorBinding(); |
10253 |
assertNull("Not null constructor binding", constructorBinding); |
10254 |
constructorCall = (ClassInstanceCreation) intValueReceiver.getExpression(); |
10255 |
constructorCall.resolveTypeBinding(); // This should not throw a NPE |
10256 |
constructorBinding = constructorCall.resolveConstructorBinding(); |
10257 |
assertNotNull("Null constructor binding", constructorBinding); |
10258 |
} |
10259 |
|
10260 |
// Utility method to replace "node" by "replacement" |
10261 |
private static void replaceNodeInParent(Expression node, Expression replacement) { |
10262 |
StructuralPropertyDescriptor loc = node.getLocationInParent(); |
10263 |
if (loc.isChildProperty()) { |
10264 |
node.getParent().setStructuralProperty(loc, replacement); |
10265 |
} |
10266 |
else { |
10267 |
List l = (List) node.getParent().getStructuralProperty(loc); |
10268 |
for (int i = 0; i < l.size(); i++) { |
10269 |
if (node.equals(l.get(i))) { |
10270 |
l.set(i, replacement); |
10271 |
break; |
10272 |
} |
10273 |
} |
10274 |
} |
10275 |
} |
10232 |
} |
10276 |
} |