Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problem related to scope provider
Problem related to scope provider [message #1255056] Mon, 24 February 2014 03:42
Ashwini Nayak is currently offline Ashwini NayakFriend
Messages: 19
Registered: July 2013
Junior Member
Hi,

My problem is regarding scope provider in xtend.

XText editor contents
---------------------------
arrays {
uses A1[5]
}

My xcore metamodel is as below:
-------------------------------------------
class Arrays {
contains ArrayLink[] arraylink
}

class ArrayLink {
contains resolving A
}

And XText grammar is as below:
-----------------------------------------
Arrays:
{Arrays}
"arrays"
("{"
(usedArrays += ArrayLink)*
"}")
;

ArrayLink:
"uses" ref=Reference
;

Reference is a rule which accepts Characters with arrays. Eg: A[5], B[3] etc.

When arrays are used in the editor, I want the array to be expanded in the generator.
Considering the above example, A1[5] should be expanded as A1, A2, A3, A4 and A5

since array has the value '5'.

I have an XTend class which has methods for expanding the arrays.
I have injected a Scope provider in the class.
i.e : @Inject
IScopeProvider scopeProvider

expand(arrays, )
{
expandArrays(arrays, replacements)
}

expandArrays(Arrays arrays, Map<EObject, ArrayList<? extends

EObject>>replacements)
{
//This method expands the array.
i.e, A[5] will be expanded as A1, A2, A3, A4 and A5 and the expanded items will be

added to the map 'replacements'
i.e, The key, 'A1[5]' will have values 'A1, A2, A3, A4 ,A5'
}

Inside the 'expandArrays' method, after the expansion, val scope =

scopeProvider.getScope(..) method returns the scope of the IArrayReference Object.
scope.allElements(...) returns all the expanded items. ie, A1, A2, A3, A4, A5. The

expanded items are added to the 'arrays'.
But, when control is out of the method, the scope is lost.
The contents of arrays will not have the expanded items.

Is there a way to store the elements permanently?

Thanks in advance




Previous Topic:NullPointerException while invoking JvmModelInferrer/Generator for code generation from a Java Proje
Next Topic:Running MWE2 Workflow from ANT buildfile causes ANTLR Error
Goto Forum:
  


Current Time: Tue Apr 16 06:00:49 GMT 2024

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

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

Back to the top