Case-insensitive linking with customised ScopeProvider [message #814222] |
Tue, 06 March 2012 02:20  |
Eclipse User |
|
|
|
Another linking question. My DSL is case-insensitive and I've got 90% of it working case-insensitively by setting the appropriate ignoreCase flags in the MWE2 file.
The problem occurs when resolving a symbol from a scope that was generated by my subclass of AbstractDeclarativeScopeProvider. I've written some methods that look a bit like this:
public IScope scope_Field_Operand_fieldname(EObject context, EReference reference)
{
// walk up and across the syntax tree looking for a particular structure
Iterable<Field> fg=findParentFieldgroup(context);
if(fg != null){
return Scopes.scopeFor(fg);
}
return IScope.NULLSCOPE;
}
All other scopes (the ones generated by the ImportedNamespaceAwareLocalScopeProvider to which the work is eventually delegated) respect the case insensitivity.
It seems that the IScope produced by Scopes.scopeFor() is ignoring the ignoreCase binding:
binder.bindConstant().annotatedWith(org.eclipse.xtext.scoping.IgnoreCaseLinking.class).to(true);
Is there a helper method similar to Scopes.scopeFor() that will give me the behaviour I want?
thanks...
|
|
|
|
Re: Case-insensitive linking with customised ScopeProvider [message #815026 is a reply to message #814233] |
Wed, 07 March 2012 01:10   |
Eclipse User |
|
|
|
Ah, SimpleScope constructor with an ignoreCase parameter. Works now, thanks.
public static IScope scopeFor(Iterable<? extends EObject> iter, boolean ignoreCase)
{
return new SimpleScope(IScope.NULLSCOPE,
Scopes.scopedElementsFor(iter, QualifiedName.wrapper(SimpleAttributeResolver.NAME_RESOLVER)),
ignoreCase);
}
Can I suggest that something similar to the above be inserted as an overload in Scopes? Or better yet, that Scopes.scopeFor be made Guice-aware so that it notices the IgnoreCaseLinking binding?
You'd not believe how much time I spent pondering making a toLowerCase Function<String,String> adapter to put between SimpleAttributeResolver.NAME_RESOLVER and QualifiedName.wrapper(). It wouldn't work of course because it'd only mangle names on the way into the table, not test them case-insensitively.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03680 seconds