Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2012-02-23 23:32:18 +0000
committerStephan Herrmann2012-02-23 23:32:18 +0000
commitc6dd181becd3f159023ab3daa44ede9d6be39755 (patch)
tree859bb201b91f408497e77ca59e2ee031bbe0d1c1
parent74ba1aaf17fd4359457f6b520c6b318aa8f5b66b (diff)
downloadorg.eclipse.objectteams-c6dd181becd3f159023ab3daa44ede9d6be39755.tar.gz
org.eclipse.objectteams-c6dd181becd3f159023ab3daa44ede9d6be39755.tar.xz
org.eclipse.objectteams-c6dd181becd3f159023ab3daa44ede9d6be39755.zip
Test & fix for Bug 372433 - [refactoring][dom] extract method in a
callin with tunneled base result throws NPE
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/AstGenerator.java4
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java7
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseCallMessageSendTest.java9
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/basecall/teampkg/Team1.java1
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/basecall/teampkg/Team2.java2
5 files changed, 21 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/AstGenerator.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/AstGenerator.java
index 0419c6a6b..b671de68f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/AstGenerator.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/AstGenerator.java
@@ -139,7 +139,9 @@ public class AstGenerator extends AstFactory {
}
public SingleNameReference singleNameReference(char[] name) {
- return new SingleNameReference(name, this.pos);
+ SingleNameReference ref = new SingleNameReference(name, this.pos);
+ ref.bits |= ASTNode.IsGenerated;
+ return ref;
}
public QualifiedNameReference qualifiedNameReference(char[][] tokens) {
long[] poss = new long[tokens.length];
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 b303876fc..c2aa0cd84 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
@@ -2617,6 +2617,13 @@ class ASTConverter {
final ReturnStatement returnStatement = new ReturnStatement(this.ast);
returnStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
if (statement.expression != null) {
+//{ObjectTeams: don't convert synthetic _OT$result in return statement:
+ org.eclipse.jdt.internal.compiler.ast.Expression expr = statement.expression;
+ if (expr.isGenerated() && expr instanceof SingleNameReference) {
+ if (CharOperation.equals(((SingleNameReference)expr).token, IOTConstants.OT_RESULT))
+ return returnStatement;
+ }
+// SH}
returnStatement.setExpression(convert(statement.expression));
}
return returnStatement;
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseCallMessageSendTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseCallMessageSendTest.java
index 2ff830de4..ccd3c672c 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseCallMessageSendTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseCallMessageSendTest.java
@@ -41,6 +41,7 @@ import org.eclipse.jdt.core.dom.ExpressionStatement;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.IfStatement;
import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.ReturnStatement;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
@@ -302,4 +303,12 @@ public class BaseCallMessageSendTest extends FileBasedDOMTest
expected, actual);
}
+ // see http://bugs.eclipse.org/372433 - [refactoring][dom] extract method in a callin with tunneled base result throws NPE
+ public void testReturnWithHiddenExpression1() {
+ MethodDeclaration method = _role.getMethods()[1];
+ ReturnStatement returnStatement = (ReturnStatement) method.getBody().statements().get(1);
+
+ assertNull("Return should not show hidden expression: "+returnStatement.getExpression(),
+ returnStatement.getExpression());
+ }
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/basecall/teampkg/Team1.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/basecall/teampkg/Team1.java
index a96bdebc6..67e3c1182 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/basecall/teampkg/Team1.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/basecall/teampkg/Team1.java
@@ -14,6 +14,7 @@ public team class Team1
callin void roleMethod1()
{
base.roleMethod1();
+ return; // for testReturnWithHiddenExpression1()
}
callin int roleMethod2()
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/basecall/teampkg/Team2.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/basecall/teampkg/Team2.java
index 5af50f584..b765dd998 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/basecall/teampkg/Team2.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/basecall/teampkg/Team2.java
@@ -2,7 +2,7 @@ package basecall.teampkg;
import basecall.basepkg.MyClass;
-public team class Team1
+public team class Team2
{
public class Role1<S,T> playedBy MissingBaseclass
{

Back to the top