Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Case-insensitive linking with customised ScopeProvider
Case-insensitive linking with customised ScopeProvider [message #814222] Tue, 06 March 2012 02:20 Go to next message
Eclipse UserFriend
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 #814233 is a reply to message #814222] Tue, 06 March 2012 02:36 Go to previous messageGo to next message
Eclipse UserFriend
have a look into the source code of the Scopes.scope for method and
you will see what to do.
Re: Case-insensitive linking with customised ScopeProvider [message #815026 is a reply to message #814233] Wed, 07 March 2012 01:10 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Case-insensitive linking with customised ScopeProvider [message #815487 is a reply to message #815026] Wed, 07 March 2012 13:27 Go to previous message
Eclipse UserFriend
Hi,

is is just a utility/convenience class so it is not injected Wink

~Christian
Previous Topic:Xtend 2 - NoSuchElementException while generating without eclipse
Next Topic:Formatting Text with Tabulators
Goto Forum:
  


Current Time: Tue Jul 22 19:37:19 EDT 2025

Powered by FUDForum. Page generated in 0.03680 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top