strange completion [message #844060] |
Fri, 13 April 2012 16:39 |
Michal S Messages: 74 Registered: July 2011 |
Member |
|
|
Hello,
I have little problem, when completion is "too late"...
My grammar:
Model:
elements += Elements*
;
Elements:
EntityA|FinalEntity
;
EntityA:
'A' name=ID '{'
entityCs+=EntityC+
'}'
;
EntityC:
'C' name=ID '{'
entityDs+=EntityD+
'}'
;
EntityD:
'D' name=ID
;
FinalEntity:
'X' a=[EntityA] '{'
assignments += Assignments+
'}'
;
Assignments:
AssignmentA|AssignmentB
;
AssignmentA:
c=[EntityC] refs=DRef? '=' v=INT
;
AssignmentB:
c=[EntityC] refs=DRef? '==' v=INT
;
DRef:
'.' d=[EntityD]
;
My scope functions:
IScope scope_Assignments_c(FinalEntity fe, EReference reference){
return Scopes.scopeFor(fe.getA().getEntityCs());
}
IScope scope_Assignments_c(Assignments asgn, EReference reference){
EntityA a = EcoreUtil2.getContainerOfType(asgn, FinalEntity.class).getA();
return Scopes.scopeFor(a.getEntityCs());
}
IScope scope_DRef_d(DRef dref, EReference reference){
EntityC c = EcoreUtil2.getContainerOfType(dref, Assignments.class).getC();
return Scopes.scopeFor(c.getEntityDs());
}
IScope scope_DRef_d(Assignments asgn, EReference reference){
DRef refs = asgn.getRefs();
if(refs!=null){
DRef dref = (DRef) refs;
EntityC c = EcoreUtil2.getContainerOfType(dref, Assignments.class).getC();
return Scopes.scopeFor(c.getEntityDs());
}
return IScope.NULLSCOPE;
}
My model:
A aa {
C cc {
D dd
}
}
X aa {
cc.dd = 5
}
Everything works perfect, there is a problem only when I try to complete "dd" in DRef. If I write "." and Ctrl+Space, no completion is offered. If I write one more letter, it offers the completion very well.
What am I doing wrong?
Thank you,
Michal
[Updated on: Fri, 13 April 2012 16:41] Report message to a moderator
|
|
|
Re: strange completion [message #844112 is a reply to message #844060] |
Fri, 13 April 2012 17:51 |
|
Hi,
the problem is that the model is invalid until there is at least one letter after the .
=> the context is an FinalEntity in this case since neither a AssignmentA nor a AssignmentB can be created
i do not know how to solve this besides chaning the grammar e.g.
Assignments:
c=[EntityC] refs=DRef? (a?="="|b?="==") v=INT
;
DRef:
'.' d=[EntityD]
;
IScope scope_DRef_d(DRef dref, EReference reference){
EntityC c = EcoreUtil2.getContainerOfType(dref, Assignments.class).getC();
return Scopes.scopeFor(c.getEntityDs());
}
IScope scope_DRef_d(Assignments asn, EReference reference){
if(asn.getC()!=null){
return Scopes.scopeFor(asn.getC().getEntityDs());
}
return IScope.NULLSCOPE;
}
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: strange completion [message #844406 is a reply to message #844112] |
Sat, 14 April 2012 01:00 |
Michal S Messages: 74 Registered: July 2011 |
Member |
|
|
Hello Christian,
thank you for your answer.
I was afraid that you give me this solution... It forces me to make changes in the validator, generator, etc., but I will manage
Additional question: I understand, why the context is an FinalEntity. But: Why does it not recognize '.' as it does with normal keyword? (Basically, when any entity is being defined, the model is invalid, isn't it? -> but completion works... There is no other alternative for '.' starting rule in the grammar available at this place.)
Thank you & Best regards,
Michal
|
|
|
Re: strange completion [message #844727 is a reply to message #844406] |
Sat, 14 April 2012 09:32 |
|
I dont know this. you would have to debug the ui parser to see what actually happens. but as said before: you get only contexts that are actually instantiated - and at this point nothing can be instantiated or the already instantiated stuff has to be thrown away.
maybe you could try another solution that may keep a metamodel that is more like your old one:
Refable : EntityC|EntityD;
AssignmentA:
cordd=[Refable] '=' v=INT
;
AssignmentB:
cordd=[Refable] '==' v=INT
;
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Powered by
FUDForum. Page generated in 0.03000 seconds