Search code examples
javaeclipseeclipse-pluginxtextmetamodel

Xtext: Cannot resolve reference


I have the following Xtext grammar:

grammar dsl.miniproject.Question2.EclipsePluginLanguage with org.eclipse.xtext.common.Terminals

import "platform:/resource/Question2/model/EclipsePluginModel.ecore" 
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

Plugin:
    {Plugin}
    'Plugin' Name = EntityName
    '{'             
        (documentation = Documentation)?
        (functions += Functionality)*
        manifest = Manifest
    '}'
;

Documentation:
    {Documentation}
    'description =' documentation = STRING
;

Manifest:
    {Manifest}
    'manifest'
    '{'
        (dependencies += Dependency)*
        (extensionPoints += ExtensionPoint)*    
        (extensions += Extension)*
    '}'
;

Functionality:
    {Functionality}
    'function' Name = EntityName ';'
;

Dependency:
    {Dependency}
    Name = EntityName '=>' depends = [Plugin|EntityName]
;

Extension:
    {Extension}
    Name = EntityName '->' extends = [ExtensionPoint|EntityName]
;

ExtensionPoint:
    {ExtensionPoint}
    'ExtensionPoint' Name = EntityName 
    '{'
        'ref' functions += [Functionality|EntityName] ';'       
    '}'
;

EntityName:
    ID ('.' ID)*
;

However when writing a sample script ex:

    Plugin x{
        description = "test"

        function f;
        function f2;

        manifest{

            dep1 => x

            ExtensionPoint ep.ep1{
                ref f;
            }

            ext1 -> ep.ep1
        }    
}

I get the following error:

Couldn't resolve reference to Plugin 'x'. Couldn't resolve reference to Functionality 'f'. ... etc

This is my first attempt at xtext and I cannot figure out what I'm doing wrong

Thanks in advance for any help!!


Solution

  • hi you should name you elements name attribute name and NOT Name and you have to make sure the (actual) qualified names in the scope at the place you use it match the terminal or datatype rule you use (in your case EntityName) alternatively you can change IQualifiedNameProvider