Search code examples
xtext

Current Model in Proposal Provider


I try to check the spelling and make dynamic proposals based on previous inputs.

For checking the spelling I use the Validator and code like this.

@Check
def checkUniqueDeclarations(Model model) {
    for (decl : model.declarations) {
        if (decl instanceof Device) {
           for(input : decl.input)
         ...

In this code I have a Model which does exactly what I want. But for making dynamic proposal I need to use the proposal provider in the ui project. Can someone explain me how to get the same Model in the proposal provider as in the Validator? So I can use a similar code there.

Thank you


Solution

  • The model can be obtained from the given ContentAssistContext. You may need to navigate to the eContainer of the correct type. Please try to use EcoreUtil2.getContainerOfType for that purpose.