aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-03-10 07:16:13 (EDT)
committersefftinge2009-03-10 07:16:13 (EDT)
commitf1c676b35d4e2c501fe54061854f93fbd0d78388 (patch)
tree2069079a513c28918a92cb5ab9c597daefc2fea6
parentbee67a74b4187a88f721a81d147fbaaf366d76e7 (diff)
downloadorg.eclipse.xtext-f1c676b35d4e2c501fe54061854f93fbd0d78388.zip
org.eclipse.xtext-f1c676b35d4e2c501fe54061854f93fbd0d78388.tar.gz
org.eclipse.xtext-f1c676b35d4e2c501fe54061854f93fbd0d78388.tar.bz2
Fix: Another infinite loop in XtextDamagerRepairer
Refactoring: AdaptingIterable existed already as MappingIterator - Collections.map(..) Fix: Exception when importing a generated metamodel Feature: error markers when referencing a metamodel twice
-rw-r--r--plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextDamagerRepairer.java2
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/metamodelreferencing/tests/ExceptionTest.java34
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/metamodelreferencing/tests/MetamodelRefTest.java3
3 files changed, 36 insertions, 3 deletions
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextDamagerRepairer.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextDamagerRepairer.java
index e26df64..e4acfc7 100644
--- a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextDamagerRepairer.java
+++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextDamagerRepairer.java
@@ -78,6 +78,8 @@ public class XtextDamagerRepairer extends DefaultDamagerRepairer {
if (node.getTotalLength() + node.getTotalOffset() >= endOffset) {
while(end == null) {
if (node instanceof CompositeNode) {
+ if (((CompositeNode) node).getChildren().isEmpty())
+ break;
for(int i = ((CompositeNode) node).getChildren().size() - 1; i >= 0; i--) {
AbstractNode child = ((CompositeNode) node).getChildren().get(i);
if (child.getTotalOffset() + child.getTotalLength() >= endOffset && child.getTotalOffset() <= endOffset) {
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/metamodelreferencing/tests/ExceptionTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/metamodelreferencing/tests/ExceptionTest.java
new file mode 100644
index 0000000..a869ebe
--- /dev/null
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/metamodelreferencing/tests/ExceptionTest.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2009 itemis AG (http://www.itemis.eu) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.xtext.metamodelreferencing.tests;
+
+import org.eclipse.xtext.XtextStandaloneSetup;
+import org.eclipse.xtext.junit.AbstractXtextTests;
+import org.eclipse.xtext.resource.XtextResource;
+
+/**
+ * @author Sebastian Zarnekow - Initial contribution and API
+ */
+public class ExceptionTest extends AbstractXtextTests {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ with(XtextStandaloneSetup.class);
+ }
+
+ public void testExceptionOnRegenerate() throws Exception {
+ String model = "grammar org.eclipse.xtext.ExceptionTest with org.eclipse.xtext.common.Terminals\n" +
+ "generate existing 'http://www.eclipse.org/xtext/tests/grammarinheritance'\n" +
+ "import 'classpath:/org/eclipse/xtext/grammarinheritance/ametamodel.ecore' as existing\n" +
+ "AType : name=ID;";
+ XtextResource resource = getResourceFromString(model);
+ assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
+ }
+
+}
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/metamodelreferencing/tests/MetamodelRefTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/metamodelreferencing/tests/MetamodelRefTest.java
index 4b17f92..574eb2e 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/metamodelreferencing/tests/MetamodelRefTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/metamodelreferencing/tests/MetamodelRefTest.java
@@ -8,16 +8,13 @@
*******************************************************************************/
package org.eclipse.xtext.metamodelreferencing.tests;
-import org.eclipse.xtext.XtextStandaloneSetup;
import org.eclipse.xtext.tests.AbstractGeneratorTest;
public class MetamodelRefTest extends AbstractGeneratorTest {
-
@Override
protected void setUp() throws Exception {
super.setUp();
- with(new XtextStandaloneSetup());
with(new MetamodelRefTestLanguageStandaloneSetup());
}