Including custom models for default imports [message #722358] |
Mon, 05 September 2011 13:45 |
amey.par Messages: 17 Registered: July 2011 |
Junior Member |
|
|
I have a grammar which has support for builtin types (like Int, Bool, String etc.). I initially implemented these with
type=[Type] | basicType=BasicType
but decided to change this to the cleaner approach of defining those types in a different dsl. However, I don't want to force users to import this dsl manually, so I followed the second approach outlined in Xtext cross references and scoping an overview (Part 3).
My grammar already uses Imported Namespaces thanks to a rule:
ClassDecl:
'class' name=Word
( 'extends' importedNamespace=[ClassDecl] )?
( classParams += ClassParam )*
SEMICOLON;
so I followed the second approach in the above guide, ending up with:
public class UnrealscriptImportedNamespaceAwareLocalScopeProvider extends
ImportedNamespaceAwareLocalScopeProvider
{
@Override
protected List<ImportNormalizer> getImplicitImports(boolean ignoreCase)
{
System.out.println("getImplicitImports called");
List<ImportNormalizer> temp = new ArrayList<ImportNormalizer>();
temp.add(new ImportNormalizer(
QualifiedName.create("array"),
true, ignoreCase));
return temp;
}
}
Now, I have a file "builtins.uc", with the following content:
class array;
struct byte
{
};
struct int
{
};
struct float
{
};
struct string
{
};
struct bool
{
};
struct name
{
};
and I can't quite figure out where I should embed this file so that the scope provider is able to locate it but it doesn't appear in the user's workspace.
[Updated on: Mon, 05 September 2011 13:46] Report message to a moderator
|
|
|
|
Re: Including custom models for default imports [message #722364 is a reply to message #722362] |
Mon, 05 September 2011 14:04 |
amey.par Messages: 17 Registered: July 2011 |
Junior Member |
|
|
Hi Alex,
Thanks for the prompt reply. Like I said, the blog post is the one I followed (couldn't link to it since I haven't posted five messages yet). I was under the impression that classpaths are applicable only to imported URIs and not to imported namespaces. Does setting a classpath work with imported namespaces too?
~Amey
[Updated on: Mon, 05 September 2011 14:04] Report message to a moderator
|
|
|
|
|
Re: Including custom models for default imports [message #722439 is a reply to message #722371] |
Mon, 05 September 2011 19:13 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Amey,
you could try to load the builtin.uc by means of a URI of the form
"platform:/plugin/your.plugin/model/builtin.uc" into your resource set.
This could by done in your scope provider implementation. This way, no
dependency is necessary. Unfortunately you'll have to provide the list
of builtin types explicitly because they won't be indexed.
Please note also, that platform:/plugin is unlikely to work in a
standalone environment.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
On 05.09.11 16:39, amey.par wrote:
> Hi Alex,
>
> Forgive me, for this'll probably sound like a stupid question, but what
> do you mean by "the plugin containing your models"?
>
> I thought there was only one plugin, the one that contains builtins.uc,
> and the models were contained inside a project. And since it's not a
> Java project, I can't set the classpath for it.
>
> Thanks,
> ~Amey
|
|
|
|
Powered by
FUDForum. Page generated in 0.03401 seconds