Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » CaseInsensitiv Scoping - how to do it?
CaseInsensitiv Scoping - how to do it? [message #1822110] Thu, 27 February 2020 12:46 Go to next message
Max Weißböck is currently offline Max WeißböckFriend
Messages: 4
Registered: February 2020
Junior Member
Sorry if this is obvious, but I spent more than a day on this without finding the solution.

How building a case insenstive language (we need it, our backend is PL/SQL) ist done is clear to me so far, I use as documentetd this in the workflow

scopeProvider = {
ignoreCase = true // Case Insensitive
}

parserGenerator = {
options = {
ignoreCase = true // Case Insensitive Keywords
}
}

Trouble starts as soon as I implement Scoping. This is the Scoping we have to implement

/*
* calculate the Scope for Symbol References
*/
def protected IScope scopeForSymbolRef(EObject context) {
val container = context.eContainer
return switch (container) {
Process: {
// FIXME Scoping Probmels with case insensitivity
var EList<EObject> symbolList = new BasicEList()
symbolList.addAll(container.variables)
symbolList.addAll(container.parameter)
Scopes.scopeFor(symbolList)
IScope.NULLSCOPE

}
default: scopeForSymbolRef(container)
}
}

As soon as I use this, case insensitivity does not work any longer.

Now I found some posts on this, like https://www.eclipse.org/forums/index.php/t/304413/ or this https://www.eclipse.org/forums/index.php?t=msg&th=238781/
But in xtext version 2.20 all this solutions seem not to work, as I can find nither Scopes.scope for method with ignoreCase parameter nor SimpleScope at all.

So how do I tell the Scopes to be case insensitiv?

Thanks, Max




Re: CaseInsensitiv Scoping - how to do it? [message #1822115 is a reply to message #1822110] Thu, 27 February 2020 14:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
just have a look what the scopeFor methods do
org.eclipse.xtext.scoping.Scopes.scopeFor(Iterable<? extends EObject>)
and create your own ones with
calling
public SimpleScope(IScope parent, Iterable<IEObjectDescription> descriptions, boolean ignoreCase) {
with true for ignorecase

is you neither find the SimpleScope class not the Scopes class
i assume there is something wrong with your classapth or imports


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: CaseInsensitiv Scoping - how to do it? [message #1822130 is a reply to message #1822115] Thu, 27 February 2020 16:47 Go to previous messageGo to next message
Max Weißböck is currently offline Max WeißböckFriend
Messages: 4
Registered: February 2020
Junior Member
Thanks, now I got it.

As it was a little tricky for me (and others had problems with this to) here is the pragmatic way I resolved it

- make a copy of Class org.eclipse.xtext.scoping.Scopes and name it <yourpackage>.scoping.IgnoreCaseScopes
- inside yor copied Class replace every occurence of new SimpleScope(...) with new SimpleScope(..., true)
- in your code replace every occurence of Scopes.scopeFor with IgnoreCaseScopes.scopeFor

I'm shure this is not the most elegant way to do it, but it (mostly) worked for me. I still have one problem, see next post.

[Updated on: Tue, 03 March 2020 08:35]

Report message to a moderator

Re: CaseInsensitiv Scoping - how to do it? [message #1822285 is a reply to message #1822130] Tue, 03 March 2020 08:51 Go to previous messageGo to next message
Max Weißböck is currently offline Max WeißböckFriend
Messages: 4
Registered: February 2020
Junior Member
As mentioned above, I still have one problem with case insensitivity I do not know how to solve the correct way

I now can write (we have a PL/SQL based DSL)

var i number
I := 5


So far so good. But I still can write

var i number
var I number
I := 5


I should get an error now, as i or I is declared twice now.

What do I miss, what did I wrong?
Re: CaseInsensitiv Scoping - how to do it? [message #1822293 is a reply to message #1822285] Tue, 03 March 2020 10:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
you need to implement this validation. scoping will pick the first matching element

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: CaseInsensitiv Scoping - how to do it? [message #1822307 is a reply to message #1822293] Tue, 03 March 2020 17:00 Go to previous message
Max Weißböck is currently offline Max WeißböckFriend
Messages: 4
Registered: February 2020
Junior Member
Thanks, solved it

Now I understand why in the Xtext doc regarding case insensitivity you are talking from broken shift key :-) ... support in Xtext for this is not out of the box.

I'm no fan of case insensitivity either, but as we have to generate PL/SQL it is a must for the DSL.
Previous Topic:Xtext / Xtend 2.21 Release
Next Topic:xtext grammar
Goto Forum:
  


Current Time: Sat Apr 20 04:29:19 GMT 2024

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

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

Back to the top