aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-02-03 17:11:38 (EST)
committersefftinge2009-02-03 17:11:38 (EST)
commitb4b6ff7d2404c43cc2727a30efa5ae0a05297d6b (patch)
tree68a44d02ab4d0773ffebf644bee53efdd1b41096
parentcd3152c0122c54b6e53b26e38d03f73b742612b7 (diff)
downloadorg.eclipse.xtext-b4b6ff7d2404c43cc2727a30efa5ae0a05297d6b.zip
org.eclipse.xtext-b4b6ff7d2404c43cc2727a30efa5ae0a05297d6b.tar.gz
org.eclipse.xtext-b4b6ff7d2404c43cc2727a30efa5ae0a05297d6b.tar.bz2
Several fixes: ClasspathURIResolution more robust
Applied patch from Knut Wannheden
-rw-r--r--plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/util/JdtClasspathUriResolver.java3
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammarinheritance/ToEcoreTrafoTest.java9
2 files changed, 10 insertions, 2 deletions
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/util/JdtClasspathUriResolver.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/util/JdtClasspathUriResolver.java
index 525af3e..a2bc962 100644
--- a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/util/JdtClasspathUriResolver.java
+++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/util/JdtClasspathUriResolver.java
@@ -49,6 +49,9 @@ public class JdtClasspathUriResolver implements IClasspathUriResolver {
if (javaProject.exists()) {
IPackageFragmentRoot[] allPackageFragmentRoots = javaProject.getAllPackageFragmentRoots();
for (IPackageFragmentRoot packageFragmentRoot : allPackageFragmentRoots) {
+ // prevents MalFormedURIException after executing the NewXtextProjectWizard
+ if (!packageFragmentRoot.isOpen())
+ packageFragmentRoot.open(null);
IResource correspondingResource = packageFragmentRoot.getCorrespondingResource();
if ((correspondingResource != null && correspondingResource instanceof IFile)
|| packageFragmentRoot instanceof JarPackageFragmentRoot) {
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammarinheritance/ToEcoreTrafoTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammarinheritance/ToEcoreTrafoTest.java
index 80507f2..f8176b5 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammarinheritance/ToEcoreTrafoTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammarinheritance/ToEcoreTrafoTest.java
@@ -11,6 +11,8 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource.Diagnostic;
+import org.eclipse.xtext.AbstractMetamodelDeclaration;
+import org.eclipse.xtext.GeneratedMetamodel;
import org.eclipse.xtext.Grammar;
import org.eclipse.xtext.GrammarUtil;
import org.eclipse.xtext.LexerRule;
@@ -19,6 +21,8 @@ import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.resource.metamodel.Xtext2EcoreTransformer;
import org.eclipse.xtext.tests.AbstractGeneratorTest;
+import org.eclipse.xtext.util.CollectionUtils;
+import org.eclipse.xtext.util.Filter;
public class ToEcoreTrafoTest extends AbstractGeneratorTest {
private static final Logger logger = Logger.getLogger(ToEcoreTrafoTest.class);
@@ -70,11 +74,12 @@ public class ToEcoreTrafoTest extends AbstractGeneratorTest {
assertNotNull(feature.getEType());
}
- @SuppressWarnings("unchecked")
public void testConcreteLanguageToMetamodel1() throws Exception {
XtextResource r = getResource("classpath:/" + ConcreteTestLanguage.class.getName().replace('.', '/') + ".xtext");
EObject element = r.getParseResult().getRootASTElement();
- List<EPackage> mms = (List<EPackage>) invokeWithXtend("getGeneratedEPackages(this)", element);
+ Grammar g = (Grammar) element;
+ List<AbstractMetamodelDeclaration> mms = CollectionUtils.list(
+ CollectionUtils.filter(g.getMetamodelDeclarations(), Filter.Util.<AbstractMetamodelDeclaration>instanceOf(GeneratedMetamodel.class)));
assertNotNull(mms);
assertEquals(1, mms.size());
}