summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhbehrens2009-04-01 10:11:19 (EDT)
committer sefftinge2009-04-01 10:11:19 (EDT)
commit3ca543850bdb601c0faf4fc998bf61b9c6c2b975 (patch)
treeb37b1a665538b73bf356066827a381660d37ea63
parent91b8c1febce4eb39febd02563837e406e38fc7fd (diff)
downloadorg.eclipse.xtext-3ca543850bdb601c0faf4fc998bf61b9c6c2b975.zip
org.eclipse.xtext-3ca543850bdb601c0faf4fc998bf61b9c6c2b975.tar.gz
org.eclipse.xtext-3ca543850bdb601c0faf4fc998bf61b9c6c2b975.tar.bz2
* fix: MweReader now propagates errors from all resources of the resourceSet
* feature: Message text of mwe issues displays resource URI and line number
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/MweReaderTest.java24
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/MweReaderTestLoadingResourceWithError.xtext8
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/MweReaderTestResourceWithError.xtext6
3 files changed, 36 insertions, 2 deletions
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/MweReaderTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/MweReaderTest.java
index 23d32a4..28df067 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/MweReaderTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/MweReaderTest.java
@@ -8,14 +8,15 @@
*******************************************************************************/
package org.eclipse.xtext;
+import junit.framework.TestCase;
+
import org.eclipse.emf.mwe.core.WorkflowContextDefaultImpl;
import org.eclipse.emf.mwe.core.issues.IssuesImpl;
import org.eclipse.emf.mwe.core.monitor.NullProgressMonitor;
-import junit.framework.TestCase;
-
/**
* @author Sven Efftinge - Initial contribution and API
+ * @author Heiko Behrens
*
*/
public class MweReaderTest extends TestCase {
@@ -50,4 +51,23 @@ public class MweReaderTest extends TestCase {
reader.checkConfiguration(issues);
assertTrue(issues.hasErrors());
}
+
+ public void testIssuesInOtherResource() throws Exception {
+ MweReader reader = new MweReader();
+ reader.setRegister(new XtextStandaloneSetup());
+ final String errorURI = "classpath:/"+(getClass().getName()+"ResourceWithError").replace('.', '/')+".xtext";
+ final String loadingURI = "classpath:/"+(getClass().getName()+"LoadingResourceWithError").replace('.', '/')+".xtext";
+ reader.setUri(loadingURI);
+ WorkflowContextDefaultImpl ctx = new WorkflowContextDefaultImpl();
+ IssuesImpl issues = new IssuesImpl();
+ reader.checkConfiguration(issues);
+ assertFalse(issues.hasErrors());
+ reader.invoke(ctx, new NullProgressMonitor(), issues);
+ assertTrue(ctx.get(MweReader.DEFAULT_OUTPUT_SLOT) instanceof Grammar);
+
+ assertEquals(1, issues.getErrors().length);
+ final String errorString = issues.getErrors()[0].toString();
+ assertFalse(errorString.startsWith("[ERROR]: " + loadingURI));
+ assertTrue(errorString.startsWith("[ERROR]: " + errorURI));
+ }
}
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/MweReaderTestLoadingResourceWithError.xtext b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/MweReaderTestLoadingResourceWithError.xtext
new file mode 100644
index 0000000..e3798ae
--- /dev/null
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/MweReaderTestLoadingResourceWithError.xtext
@@ -0,0 +1,8 @@
+grammar org.eclipse.xtext.MweReaderTestLoadingResourceWithError
+ with org.eclipse.xtext.MweReaderTestResourceWithError
+// with org.eclipse.xtext.common.Terminals
+
+generate Model "model/model"
+
+Model:
+ value = InvalidMain; \ No newline at end of file
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/MweReaderTestResourceWithError.xtext b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/MweReaderTestResourceWithError.xtext
new file mode 100644
index 0000000..35681fe
--- /dev/null
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/MweReaderTestResourceWithError.xtext
@@ -0,0 +1,6 @@
+grammar org.eclipse.xtext.MweReaderTestResourceWithError
+ with org.eclipse.xtext.common.Terminals
+
+generate foo "http://foo/bar"
+
+InvalidMain : \ No newline at end of file