Bug 582198 - Body of blockless within statement has invalid sourceStart
+ similarly for expressionStatement holding a base ctor invocation
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
index 5ede4bd..6264749 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
@@ -3398,7 +3398,9 @@
//{ObjectTeams: handle BaseConstructorMessageSend. Note: might be unresolvable, i.e. incomplete rhs!
if (statement instanceof org.eclipse.objectteams.otdt.internal.core.compiler.ast.BaseAllocationExpression) {
BaseConstructorInvocation invocation = convert((org.eclipse.objectteams.otdt.internal.core.compiler.ast.BaseAllocationExpression) statement);
- return this.ast.newExpressionStatement(invocation);
+ ExpressionStatement expressionStatement = this.ast.newExpressionStatement(invocation);
+ expressionStatement.setSourceRange(invocation.getStartPosition(), invocation.getLength());
+ return expressionStatement;
}
//carp}
if (statement instanceof org.eclipse.jdt.internal.compiler.ast.Block) {
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseConstructorInvocationTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseConstructorInvocationTest.java
index bbe3382..27123b5 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseConstructorInvocationTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseConstructorInvocationTest.java
@@ -52,7 +52,7 @@
public class BaseConstructorInvocationTest extends FileBasedDOMTest
{
public static final String TEST_PROJECT = "DOM_AST";
- private static final int JAVA_LANGUAGE_SPEC_LEVEL = AST.JLS14;
+ private static final int JAVA_LANGUAGE_SPEC_LEVEL = AST.JLS20;
private TypeDeclaration _typeDecl;
private TypeDeclaration _role;
@@ -236,4 +236,14 @@
assertNotNull(actual);
assertEquals(expected, actual);
}
+
+ public void testSourceRange() {
+ RoleTypeDeclaration role = _typeDecl.getRoles()[0];
+ MethodDeclaration constructor = role.getMethods()[1];
+
+ _testObj = getBaseConstructorInvocation(constructor);
+ ExpressionStatement stm = (ExpressionStatement) _testObj.getParent();
+ assertEquals("expected source position", 270, stm.getStartPosition());
+ assertEquals("expected source length", 4, stm.getLength());
+ }
}