0


I used the newly introduced great feature of xtext 2.8.3, the synthetic tokens, but what I'm facing is

  1. a lag with the proposals
  2. a validation error

Couldn't resolve reference to EStructuralFeature 'name'.

the problem is that the proposal didn't show up unless I typed the first character. I've overridden the method below but does not work very well

complete_BEGIN(EObject model, RuleCall ruleCall, ContentAssistContext context,
        ICompletionProposalAcceptor acceptor) 

and my scope

override getScope(EObject context, EReference reference) {
    if (reference.name == "eType") {
        val elements = Lists.newArrayList(EcoreUtil2.getRootContainer(context).eAllContents.filter(EClassifier))
        return Scopes::scopeFor(elements)
    } else if (reference.name == "feature" && context.eContainer instanceof Instance) {
        var eClass = (context.eContainer as Instance).getEType()
        Scopes::scopeFor((eClass as EClass).EStructuralFeatures)
    }
    super.getScope(context, reference)
}

and my grammar that uses them is

InstaceFeature:
feature+=[ecore::EStructuralFeature] value=ValueLiteral;
//
Instance returns ecore::EClass:
    {Instance}
    name=ID '=' 'new' eType=[ecore::EClass]
    (BEGIN
    features+=InstaceFeature*
    END)?;

what I want to perform is the feature in InstanceFeature would contain the list of the structured features of the eType=[ecore::EClass] in the Instance object.

unique_ptr
  • 586
  • 1
  • 8
  • 22
  • This line is probably the reason for your lag: `val elements = Lists.newArrayList(EcoreUtil2.getRootContainer(context).eAllContents.filter(EClassifier))`. If, for example, your EClassifiers can only be at the root of your model you wouldn't have to traverse the whole using `eAllContents` – Franz Becker Jul 01 '15 at 05:59
  • Thanks Franz, your right, but I have basically my eclassifiers contained in an epackge, but I think this is not the issue, I think that I'm doing something wrong with my grammar, may be I should have defined my Instance in another way ? – unique_ptr Jul 01 '15 at 22:19
  • Sorry but I don't understand what you're trying to accomplish here. Could you provide a self contained example (i.e. minimal grammar that I can copy&paste into my Eclipse and a snippet of your desired target DSL)? – Franz Becker Jul 02 '15 at 21:54

0 Answers0