Skip to main content



      Home
Home » Modeling » TMF (Xtext) » cross reference between two resources
cross reference between two resources [message #1820807] Wed, 29 January 2020 07:25 Go to next message
Eclipse UserFriend
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 08:41 Go to previous messageGo to next message
Eclipse UserFriend
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 09:34 Go to previous messageGo to next message
Eclipse UserFriend
for autosar (i assume you use artop) you have to come up with a manual scoping solution
Re: cross reference between two resources [message #1820845 is a reply to message #1820812] Thu, 30 January 2020 04:55 Go to previous messageGo to next message
Eclipse UserFriend
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 87 times)
  • Attachment: MyDsl.7z
    (Size: 1.45MB, Downloaded 58 times)
Re: cross reference between two resources [message #1820852 is a reply to message #1820845] Thu, 30 January 2020 07:15 Go to previous messageGo to next message
Eclipse UserFriend
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 00:18 Go to previous messageGo to next message
Eclipse UserFriend
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 69 times)
Re: cross reference between two resources [message #1820897 is a reply to message #1820882] Fri, 31 January 2020 04:16 Go to previous messageGo to next message
Eclipse UserFriend
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 04:39 Go to previous messageGo to next message
Eclipse UserFriend
you give no details what you implement. e.g. nameprovider for arxml.
how shall we help then
Re: cross reference between two resources [message #1820902 is a reply to message #1820899] Fri, 31 January 2020 05:08 Go to previous messageGo to next message
Eclipse UserFriend
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 63 times)
Re: cross reference between two resources [message #1820904 is a reply to message #1820902] Fri, 31 January 2020 05:30 Go to previous messageGo to next message
Eclipse UserFriend
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

[Updated on: Sat, 01 February 2020 10:28] by Moderator

Re: cross reference between two resources [message #1820954 is a reply to message #1820904] Mon, 03 February 2020 04:54 Go to previous messageGo to next message
Eclipse UserFriend
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 06:15 Go to previous message
Eclipse UserFriend
see Scopes.scopeFor methods. simply pass your object and nameprovider there
Previous Topic:Recommended terminal value for auto-completion
Next Topic:Auto-completion for text value
Goto Forum:
  


Current Time: Sat Jul 05 03:56:03 EDT 2025

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

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

Back to the top