Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2012-08-10 15:31:38 +0000
committerStephan Herrmann2012-08-10 15:32:11 +0000
commit4fdf5e13c36e2e98613ffbc019c2e262849070b6 (patch)
tree358608a47f5ce504455b8d5ed80960b6c52eddfb /testplugins
parent96b559b649b3359bd40bdfe646aafacb0476499b (diff)
downloadorg.eclipse.objectteams-4fdf5e13c36e2e98613ffbc019c2e262849070b6.tar.gz
org.eclipse.objectteams-4fdf5e13c36e2e98613ffbc019c2e262849070b6.tar.xz
org.eclipse.objectteams-4fdf5e13c36e2e98613ffbc019c2e262849070b6.zip
Bug 386704 - Requesting AST throws NPE if base class is unresolved
Diffstat (limited to 'testplugins')
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/DOMRegressionTests.java28
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/regression/basecall/B.java4
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/regression/basecall/T.java17
3 files changed, 49 insertions, 0 deletions
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/DOMRegressionTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/DOMRegressionTests.java
index 1eb2a3b11..05aa63b8d 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/DOMRegressionTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/DOMRegressionTests.java
@@ -24,7 +24,10 @@ import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTParser;
+import org.eclipse.jdt.core.dom.BaseCallMessageSend;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.IfStatement;
+import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.objectteams.otdt.ui.tests.dom.FileBasedDOMTest;
@@ -95,4 +98,29 @@ public class DOMRegressionTests extends FileBasedDOMTest {
assertEquals("No fields expected",nestedTeam.getFields().length, 0);
}
+ // Bug 386704 - Requesting AST throws NPE if base class is unresolved
+ // request resolved AST despite syntax error (missing ';')
+ public void testBug386704() throws JavaModelException {
+ ICompilationUnit teamClass = getCompilationUnit(
+ getTestProjectDir(),
+ "src",
+ "regression.basecall",
+ "T.java");
+ ASTParser parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
+ parser.setProject(getJavaProject(TEST_PROJECT));
+ parser.setSource(teamClass);
+ parser.setStatementsRecovery(true);
+ parser.setResolveBindings(true);
+
+ ASTNode root = parser.createAST( new NullProgressMonitor() );
+ CompilationUnit compUnit = (CompilationUnit) root;
+ TypeDeclaration topTeam = (TypeDeclaration) compUnit.types().get(0);
+ TypeDeclaration role = (TypeDeclaration) topTeam.getTypes()[0];
+ MethodDeclaration method = (MethodDeclaration) role.bodyDeclarations().get(1);
+ IfStatement ifStat = (IfStatement) method.getBody().statements().get(0);
+ BaseCallMessageSend basecall = (BaseCallMessageSend) ifStat.getExpression();
+ // note: the bug was related to mistakenly converted generated fields.
+ assertEquals("Call to foo expected", "foo", basecall.getName().getIdentifier());
+ }
+
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/regression/basecall/B.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/regression/basecall/B.java
new file mode 100644
index 000000000..02d1fe9f2
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/regression/basecall/B.java
@@ -0,0 +1,4 @@
+package regression.basecall;
+public class B {
+ boolean getFlag(String i) { return false; }
+} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/regression/basecall/T.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/regression/basecall/T.java
new file mode 100644
index 000000000..4c1df7743
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/regression/basecall/T.java
@@ -0,0 +1,17 @@
+package regression.basecall;
+public team class T {
+ protected class R playedBy B {
+ boolean foo(String i) <- replace boolean getFlag(String i);
+ callin boolean foo(String i) {
+ if (base.foo(i)) return true;
+ int l = i.length();
+ switch (l) {
+ case 1 :
+ if (i.equals("OK"))
+ return true;
+ return false;
+ default return
+ }
+ }
+ }
+} \ No newline at end of file

Back to the top