Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Case-insensitive linking with customised ScopeProvider
Case-insensitive linking with customised ScopeProvider [message #814222] Tue, 06 March 2012 07:20 Go to next message
William Brodie-Tyrrell is currently offline William Brodie-TyrrellFriend
Messages: 4
Registered: March 2012
Junior Member
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 07:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
have a look into the source code of the Scopes.scope for method and
you will see what to do.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Case-insensitive linking with customised ScopeProvider [message #815026 is a reply to message #814233] Wed, 07 March 2012 06:10 Go to previous messageGo to next message
William Brodie-Tyrrell is currently offline William Brodie-TyrrellFriend
Messages: 4
Registered: March 2012
Junior Member
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 18:27 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

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

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Xtend 2 - NoSuchElementException while generating without eclipse
Next Topic:Formatting Text with Tabulators
Goto Forum:
  


Current Time: Thu Apr 18 21:15:02 GMT 2024

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

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

Back to the top