Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Facing problem in cross references
Facing problem in cross references [message #1819208] Fri, 10 January 2020 05:03 Go to next message
Nagashree KN is currently offline Nagashree KNFriend
Messages: 32
Registered: September 2018
Member
Hi,

I have one existing model named as mydsl, and i am importing to my grammar like this-

grammar org.xtext.example.mydsl1 with org.eclipse.xtext.common.Terminals

import "http://www.xtext.org/example/mydsl " as mydsl
generate mydsl1 "http://www.xtext.org/example/mydsl1"

I have added referencedResource in mwe2 workflow.

In my grammar i am referring mydsl like -
('Package:' packages+=[mydsl::EPackage|STRING] (packages+=[mydsl::EPackage|STRING])*)?

Here my problem is in Xtext editor if add instances of epackage i am getting error " Couldn't resolve reference to epackage "

So if anyone has any suggestions, what I should check or fix or use, please let me know.
Re: Facing problem in cross references [message #1819213 is a reply to message #1819208] Fri, 10 January 2020 06:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13628
Registered: July 2009
Senior Member
does the project with the metamodel have Xtext nature and is added to the dependencies of the mydsl project?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Facing problem in cross references [message #1819227 is a reply to message #1819213] Fri, 10 January 2020 09:09 Go to previous messageGo to next message
Nagashree KN is currently offline Nagashree KNFriend
Messages: 32
Registered: September 2018
Member
Yes, the project with the metamodel have Xtext nature. In dependency also i have added.
Re: Facing problem in cross references [message #1819231 is a reply to message #1819227] Fri, 10 January 2020 09:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13628
Registered: July 2009
Senior Member
could you provide a small reproducing example?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Facing problem in cross references [message #1819553 is a reply to message #1819231] Fri, 17 January 2020 09:15 Go to previous messageGo to next message
Nagashree KN is currently offline Nagashree KNFriend
Messages: 32
Registered: September 2018
Member
Hi,

This is my mydsl grammar-

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
packages+=EPackage*;

EPackage:
{EPackage}
'EPackage{'
('PackageName:' packageName=String0)?
'}';

String0 returns ecore::EString:
ID* & INT* & '-'*
;

And mydsl1 grammar-

grammar org.xtext.example.mydsl1.MyDsl1 with org.eclipse.xtext.common.Terminals

import "http://www.xtext.org/example/mydsl/MyDsl" as myDsl
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
generate myDsl1 "http://www.xtext.org/example/mydsl1/MyDsl1"

ModelClass:
classes+=Class*;

Class:
{Class}
'Class{'
('ClassName:' className=String0)?
('Package:' packages+=[myDsl::EPackage|String0])?
'}'
;
String0 returns ecore::EString:
ID* & INT* & '-'*
;
Work flow -
Workflow {
component = XtextGenerator {
configuration = {
project = StandardProjectConfig {
baseName = "org.xtext.example.mydsl1"
rootPath = rootPath
runtimeTest = {
enabled = true
}
eclipsePlugin = {
enabled = true
}
eclipsePluginTest = {
enabled = true
}
createEclipseMetaData = true
}
code = {
encoding = "windows-1252"
lineDelimiter = "\r\n"
fileHeader = "/*\n * generated by Xtext \${version}\n */"
}
}
language = StandardLanguage {
name = "org.xtext.example.mydsl1.MyDsl1"
fileExtensions = "mydsl1"
referencedResource = "platform:/resource/org.xtext.example.mydsl/model/generated/MyDsl.genmodel"
serializer = {
generateStub = false
}
parserGenerator = {
antlrParam = "-Xmaxinlinedfastates" antlrParam = "100000"
antlrParam = "-Xmaxswitchcaselabels" antlrParam = "30000"
antlrParam = "-Xminswitchalts" antlrParam="1"
options = {
backtrack = true
classSplitting = true
fieldsPerClass = "2000"
methodsPerClass = "2000"
}
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
// Generates checks for @Deprecated grammar annotations, an IssueProvider and a corresponding PropertyPage
generateDeprecationValidation = true
}
junitSupport = {
junitVersion = "5"
}
}
}
}

So if i am trying to refer the package in mydsl1 from mydsl, i am getting "Couldn't resolve reference to EPackage"
I have attached the Runtime xtext editor image.
Re: Facing problem in cross references [message #1819558 is a reply to message #1819553] Fri, 17 January 2020 10:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13628
Registered: July 2009
Senior Member
EPackage:
{EPackage}
'EPackage{'
('PackageName:' packageName=String0)?
'}';

how does your qualified name provider look like


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Facing problem in cross references [message #1819567 is a reply to message #1819558] Fri, 17 January 2020 11:59 Go to previous messageGo to next message
Nagashree KN is currently offline Nagashree KNFriend
Messages: 32
Registered: September 2018
Member
I have not implemented any qualified name provider.
Re: Facing problem in cross references [message #1819570 is a reply to message #1819567] Fri, 17 January 2020 12:24 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13628
Registered: July 2009
Senior Member
xtext ill give only things a name that have an attribute name. yours does not. see https://www.dietrich-it.de/xtext/2011/07/16/iqualifiednameproviders-in-xtext-2-0.html

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Custom coloring for block of code
Next Topic:Orion Web Editor: xtext-web functions are not available
Goto Forum:
  


Current Time: Tue Oct 20 03:09:07 GMT 2020

Powered by FUDForum. Page generated in 0.01749 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top