|
|
|
|
|
|
|
Re: cross-reference with modified name [message #1799599 is a reply to message #1799584] |
Mon, 10 December 2018 21:18 |
|
this is a different problem.
Xtext creates objects lazy (usually)
that means "after" the first assignment
in your grammar you have
Use2:
'use2' name=UseRef ;
UseRef:
name=[langA::Definition]
;
=> the context may be a Use2 or even a Model (depending on situation), that is expected behaviour.
=> you have to consider that in your scoping impl.
you can otherwise mitigate it by changing the grammar (depends on the situation if this is possible)
Use2:
name=UseRef ;
UseRef:
{UseRef}'use2' name=[langA::Definition]
;
the label in the completion is done there:org.eclipse.xtext.resource.impl.AliasedEObjectDescription.getQualifiedName()
called by org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider.getStyledDisplayString(IEObjectDescription)
you might custoize that in your proposal provider
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: cross-reference with modified name [message #1799605 is a reply to message #1799599] |
Tue, 11 December 2018 00:47 |
Ravi Nallappan Messages: 12 Registered: September 2014 |
Junior Member |
|
|
Thanks Christian, that explained it.
In my case, since context does not have to be fixed - I able just to skip the check. i.e this works.
class LangBScopeProvider extends AbstractLangBScopeProvider {
override getScope(EObject context, EReference reference) {
if (context instanceof Use1) {
if (reference == LangBPackage.Literals.USE1__NAME) {
val scope = super.getScope(context, reference)
println("USE1__NAME")
val defs = scope.allElements.map([ d |
new AliasedEObjectDescription(QualifiedName.create(d.name.firstSegment.toUpperCase), d)
]).map([d|d as IEObjectDescription])
return new SimpleScope(defs)
}
}
// if (context instanceof UseRef) {
// if (reference == LangBPackage.Literals.USE_REF__NAME) {
// val scope = super.getScope(context, reference)
// println("USE_REF__NAME")
// val defs = scope.allElements.map([ d |
// new AliasedEObjectDescription(QualifiedName.create(d.name.firstSegment.toUpperCase), d)
// ]).map([d|d as IEObjectDescription])
// return new SimpleScope(defs)
// }
// }
if (reference == LangBPackage.Literals.USE_REF__NAME) {
val scope = super.getScope(context, reference)
println("none UseRef USE_REF__NAME")
val defs = scope.allElements.map([ d |
new AliasedEObjectDescription(QualifiedName.create(d.name.firstSegment.toUpperCase), d)
]).map([d|d as IEObjectDescription])
return new SimpleScope(defs)
}
super.getScope(context, reference)
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.04100 seconds