Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » cross reference between two resources
cross reference between two resources [message #1820807] Wed, 29 January 2020 12:25 Go to next message
Nagashree KN is currently offline Nagashree KNFriend
Messages: 32
Registered: September 2018
Member
Hi all,

I am using Autosar model in my xtext grammar.
My use case is I will have arxml file with some configuration, for one element in the arxml file i need to open xtext editor.
My problem here is element has cross reference to another element, which will be present in autosar resource not in xtext resource.
How i will show that element in content assist.


Any help would be much appreciated!

Thanks!!
Re: cross reference between two resources [message #1820812 is a reply to message #1820807] Wed, 29 January 2020 13:41 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 157
Registered: February 2016
Senior Member
You can take a look at the followig blog post:
https://blogs.itemis.com/en/combining-emf-models-with-xtext-dsls
Re: cross reference between two resources [message #1820815 is a reply to message #1820812] Wed, 29 January 2020 14:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
for autosar (i assume you use artop) you have to come up with a manual scoping solution

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: cross reference between two resources [message #1820845 is a reply to message #1820812] Thu, 30 January 2020 09:55 Go to previous messageGo to next message
Nagashree KN is currently offline Nagashree KNFriend
Messages: 32
Registered: September 2018
Member
Hi,

Thanks for the quick replay.

I tried to implement the same way as it is there in this link - https://blogs.itemis.com/en/combining-emf-models-with-xtext-dsls.

I am getting error "Couldn't resolve reference to Node 'Root'".

I have attatched the files.
can any one please tell where i am doing wrong.

Thanks!!
  • Attachment: Result.png
    (Size: 19.67KB, Downloaded 58 times)
  • Attachment: MyDsl.7z
    (Size: 1.45MB, Downloaded 36 times)
Re: cross reference between two resources [message #1820852 is a reply to message #1820845] Thu, 30 January 2020 12:15 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 157
Registered: February 2016
Senior Member
Hi,

could you create a branch with the name forum/thread1102196 on the https://github.com/itemis/xtext-issues GitHub repository and upload your project there?
Please also update your TestProject.

Tamás
Re: cross reference between two resources [message #1820882 is a reply to message #1820852] Fri, 31 January 2020 05:18 Go to previous messageGo to next message
Nagashree KN is currently offline Nagashree KNFriend
Messages: 32
Registered: September 2018
Member
Hi Tamas ,

I create File1.xtree (Image i have attatched). I deleted that file soon.

From then after Cross references errors are not coming.
Its working fine now.
  • Attachment: Image.png
    (Size: 15.82KB, Downloaded 38 times)
Re: cross reference between two resources [message #1820897 is a reply to message #1820882] Fri, 31 January 2020 09:16 Go to previous messageGo to next message
Nagashree KN is currently offline Nagashree KNFriend
Messages: 32
Registered: September 2018
Member
Hi,

I have another problem now. The same thing i did for AUTOSAR model, In content assist element to be referred is being shown as proxy object.
Why element is becoming proxy, how i can resolve.
Re: cross reference between two resources [message #1820899 is a reply to message #1820897] Fri, 31 January 2020 09:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
you give no details what you implement. e.g. nameprovider for arxml.
how shall we help then


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: cross reference between two resources [message #1820902 is a reply to message #1820899] Fri, 31 January 2020 10:08 Go to previous messageGo to next message
Nagashree KN is currently offline Nagashree KNFriend
Messages: 32
Registered: September 2018
Member
Xtext grammar-

// automatically generated by Xtext
grammar org.xtext.example.xtext.MyDsl with org.eclipse.xtext.common.Terminals

import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "platform:/resource/org.artop.aal.autosar446/model/autosar446.ecore#//swcomponent/composition"
import "platform:/resource/org.artop.aal.autosar446/model/autosar446.ecore#//swcomponent/datatype/datatypes"

CompositionSwComponentType:
{CompositionSwComponentType}
'CompositionSwComponentType{'
('ShortName:' shortName=String0)?
('DataTypeMappings:'dataTypeMappings+=[DataTypeMappingSet|String0] (','dataTypeMappings+=[DataTypeMappingSet|String0])*)?
(checksum=String0)?
(category=String0)?
(uuid=String0)?
(shortNamePattern=String0)?
'}';
String0 returns ecore::EString:
ID* & INT* & '-'*
;
Work flow-

module org.xtext.example.xtext.GenerateMyDsl

import org.eclipse.xtext.xtext.generator.*
import org.eclipse.xtext.xtext.generator.model.project.*

var rootPath = ".."

Workflow {

component = XtextGenerator {
configuration = {
project = StandardProjectConfig {
baseName = "org.xtext.example.xtext"
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.xtext.MyDsl"
fileExtensions = "arxml"
referencedResource = "platform:/resource/org.artop.aal.autosar446/model/autosar446.genmodel"

fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment2 auto-inject {}
parserGenerator = {
antlrParam = "-Xmaxinlinedfastates" antlrParam = "100000"
antlrParam = "-Xmaxswitchcaselabels" antlrParam = "30000"
antlrParam = "-Xminswitchalts" antlrParam="1"
options = {
backtrack = true
classSplitting = true
fieldsPerClass = "2000"
methodsPerClass = "2000"
}
// antlrParam = "-Xconversiontimeout"
// antlrParam = "5000"
// options = {
// memoize = true
// }
}
formatter = {
generateStub = true
}

serializer = {
generateStub = false
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
// Generates checks for @Deprecated grammar annotations, an IssueProvider and a corresponding PropertyPage
generateDeprecationValidation = true
}
junitSupport = {
junitVersion = "5"
}
}
}
}
Name provider-

public class GrammarReferenceNameProvider extends DefaultDeclarativeQualifiedNameProvider {

QualifiedName qualifiedName(EObject element) {
QualifiedName local_qualifiedName = null;
if(element instanceof CompositionSwComponentType) {
local_qualifiedName = QualifiedName.create(((CompositionSwComponentType) element).getShortName());
}
else if(element instanceof DataTypeMappingSet) {
local_qualifiedName = QualifiedName.create(((DataTypeMappingSet) element).getShortName());
}
return local_qualifiedName;
}
}
  • Attachment: Projects.7z
    (Size: 1.45MB, Downloaded 35 times)
Re: cross reference between two resources [message #1820904 is a reply to message #1820902] Fri, 31 January 2020 10:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
where is your autosarnameprovider. autosar stuff has no "name" afaik but hierarchical IDS.
also where does the metamodel come from you are using?
if you use artop the approach wont work
you have to use sphinx to load the models and
put it into scope manually


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sat, 01 February 2020 15:28]

Report message to a moderator

Re: cross reference between two resources [message #1820954 is a reply to message #1820904] Mon, 03 February 2020 09:54 Go to previous messageGo to next message
Nagashree KN is currently offline Nagashree KNFriend
Messages: 32
Registered: September 2018
Member
I am not using artop. I am using only AUTOSAR model from artop and I am using sphinx to load the model. can you please tell how to put model into scope manually.
Re: cross reference between two resources [message #1820956 is a reply to message #1820954] Mon, 03 February 2020 11:15 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
see Scopes.scopeFor methods. simply pass your object and nameprovider there

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Recommended terminal value for auto-completion
Next Topic:Auto-completion for text value
Goto Forum:
  


Current Time: Thu Mar 28 16:29:18 GMT 2024

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

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

Back to the top