ImportUriGlobalScopeProvider can not find resource [message #724019] |
Sat, 10 September 2011 11:19 |
eecolor Messages: 36 Registered: September 2011 |
Member |
|
|
I have the following simplified language:
grammar ee.xtext.test.Test with org.eclipse.xtext.common.Terminals
generate test "http://www.xtext.ee/test/Test"
File:
(classes+=Class)*
(references+=ClassReference)*
;
Class:
'class' name=ID
'{'
'}'
;
ClassReference:
reference=[Class]
;
In the mew2 file I have the following (relevant) lines:
// scoping and exporting API
fragment = scoping.ImportURIScopingFragment {}
fragment = exporting.SimpleNamesFragment {}
// scoping and exporting API
//fragment = scoping.ImportNamespacesScopingFragment {}
//fragment = exporting.QualifiedNamesFragment {}
//fragment = builder.BuilderIntegrationFragment {}
// provides the necessary bindings for java types integration
//fragment = types.TypesGeneratorFragment {}
// generates the required bindings only if the grammar inherits from Xbase
//fragment = xbase.XbaseGeneratorFragment {}
My module looks like this:
public class TestRuntimeModule extends ee.xtext.test.AbstractTestRuntimeModule {
@Override
public Class<? extends IGlobalScopeProvider> bindIGlobalScopeProvider() {
return TestImportUriGlobalScopeProvider.class;
}
}
My custom ImportUriGlobalScopeProvider looks like this:
public class TestImportUriGlobalScopeProvider extends
ImportUriGlobalScopeProvider {
@Override
protected LinkedHashSet<URI> getImportedUris(Resource resource) {
System.out.println("resource exists: " + (getClass().getClassLoader().getResource("test2.test") != null));
LinkedHashSet<URI> temp = super.getImportedUris(resource);
temp.add(URI.createURI("classpath:/test2.test"));
return temp;
}
}
I have created a separate plugin with the 'test2.test' file in it. Both the test project and the test.ui project have a dependency on that plugin.
I am using this text file:
class Test1
{
}
Test1
Test2
When I test the above configuration I get the following output:
resource exists: true
ERROR org.eclipse.xtext.linking.lazy.LazyLinkingResource - resolution of uriFragment 'xtextLink_::0.1.0::0::/1' failed.
org.eclipse.xtext.resource.ClasspathUriResolutionException: java.lang.IllegalStateException: Couldn't find resource on classpath. URI was 'classpath:/test2.test'
...
It seems this is caused by the ClassloaderClasspathUriResolver using another class loader. The resolve method is called without a context, this causes the Thread.currentThread().getContextClassLoader() to be used:
public URI resolve(Object context, URI classpathUri) {
Object myContext = context;
if (myContext == null) {
myContext = Thread.currentThread().getContextClassLoader();
}
...
}
I have no clue on how to solve this problem, any help would be greatly appreciated.
[Updated on: Sat, 10 September 2011 11:19] Report message to a moderator
|
|
|
|
|
Re: ImportUriGlobalScopeProvider can not find resource [message #725446 is a reply to message #725439] |
Wed, 14 September 2011 19:59 |
|
Hi,
how are you actually executing this:
(1) create a new project with your dsl and importuri customization (changed to classpath:/test/test2.mydsl)
(2) create a pluginproject with the libary file (hanged the file to be in a package test and exported this in the manifest)
(3) start a runtime, create a pluginproject, add the lib project to the path, create the model file - i can ref stuff from the lib project
or
(1) create a new project with your dsl and importuri customization (code changed to platform:/plugin/lib/test2.mydsl)
(2) create a pluginproject with the libary (made file be part of the build in build.properties)
(3) start runtime, create any project and ref stuff
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02547 seconds