Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 353969 - Follow hyperlink to wrong location
Summary: Follow hyperlink to wrong location
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: SR2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-05 03:14 EDT by Peter Feiler CLA
Modified: 2017-09-19 17:20 EDT (History)
3 users (show)

See Also:
sebastian.zarnekow: indigo+


Attachments
the buggy grammar (1.22 KB, text/plain)
2011-08-05 03:17 EDT, Peter Feiler CLA
no flags Details
the mwe2 file for the grammar (4.60 KB, application/octet-stream)
2011-08-05 03:17 EDT, Peter Feiler CLA
no flags Details
Sample model to illustrate the problem (118 bytes, text/plain)
2011-08-05 03:18 EDT, Peter Feiler CLA
no flags Details
Revised grammar with ignored Hyperlink reference (1.62 KB, text/plain)
2011-08-07 09:33 EDT, Peter Feiler CLA
no flags Details
Example model for revised grammar (137 bytes, text/plain)
2011-08-07 09:33 EDT, Peter Feiler CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Feiler CLA 2011-08-05 03:14:27 EDT
Build Identifier: Build id: 20110615-0604 Xtext 2.0.1

I have a grammar with components that contain state machines. The transitions reference the states (modes). When I follow the hyperlink the editor goes to the enclosing component instead of the mode state.
This is due to the fact that I have a rule that defines the common backend part of different components once, while the frontends of the components differ.

In a different variant [Repeated backend] of the grammar the hyperlink works ok. In that case I repeat the definition of the state machine rules for each ocmponent tpye. 
(In my actual grammar I have a larger number of components and a larger set of common backend).

Reproducible: Always

Steps to Reproduce:
1. Generate the editor from the attached grammar.
2. Examine the attached model and follow the hyperlink of the source or destination of one of the transitions. It will jump to the enclsoing processor instead of the mode.
3. The repeated backed variant of the grammar is included in comments.
Comment 1 Peter Feiler CLA 2011-08-05 03:17:10 EDT
Created attachment 200956 [details]
the buggy grammar

This is the grammar with the buggy hyperlink. The unfodled version of the grammar [repeated backend] is included as comment - the hyperlink works for it.
Comment 2 Peter Feiler CLA 2011-08-05 03:17:42 EDT
Created attachment 200957 [details]
the mwe2 file for the grammar
Comment 3 Peter Feiler CLA 2011-08-05 03:18:52 EDT
Created attachment 200958 [details]
Sample model to illustrate the problem

The sample model can be used on both variants of the grammar
Comment 4 Christian Dietrich CLA 2011-08-06 17:19:15 EDT
The Problem is actually the (Bus | Processor) that is not assigned (busorproc=(Bus | Processor))
Comment 5 Peter Feiler CLA 2011-08-07 09:28:57 EDT
My actual grammar is against an existing Ecore model so I cannot assign Bus/Processor as an element of Component.
I have 40+ component types, each varying in the first set of elements, but all allowing the same remaing elements. This is enforced in the Ecore model by a class for each component type with the appropriate elements present or missing.

As a result I have 40 grammar rules for which the front end differs but the backend is the same. So I wanted to define the backend once rather than copying and pasting it into each specific component rule.

The produced model is exactly what I wanted. The Processor and Bus model model instances get assigned the modes and transition.

The issue seems to be with mapping the location of the reference from the text into the model. The Node representing the reference is not contained in a Node with a pointer to the model element for the transition but to the component.

I have attached another variant of the grammar that is closer to my real grammar. In that case the editor thinks that the link to the mode in the flow is not a hyperlink. The Node with a reference into the model is the package, which does not allow such an EReference.
Comment 6 Peter Feiler CLA 2011-08-07 09:33:04 EDT
Created attachment 201042 [details]
Revised grammar with ignored Hyperlink reference

This is a revised version of the grammar showing an ignored hyperlink in addition to going to the wrong location. It can be used with the original mwe2 file.
Comment 7 Peter Feiler CLA 2011-08-07 09:33:41 EDT
Created attachment 201043 [details]
Example model for revised grammar
Comment 8 Peter Feiler CLA 2011-08-07 09:37:37 EDT
To summarize: the grammar I have and the flattened grammar (enclosed in comments in the grammar file) produce the same model, i.e., a model in which the Processor instance has all the elements (flows, modes, and transitions).
Comment 9 Peter Feiler CLA 2011-08-23 22:43:42 EDT
Hallo Christian,

ich habe noch mal in der Dokumentation nachgesehen. Unter "unassigned Rule Calls" steht:
As AbstractToken could possibly return an instance of TokenA, TokenB or TokenC its type must be a super type for all these types. Since the return value of the called rule becomes the result of the current rule, it is possible to further change the state of the AST element by assigning additional features. 

Example: 


AbstractToken :
  ( TokenA |
    TokenB |
    TokenC ) (cardinality=('?'|'+'|'*'))?
;


Das ist genau was ich mit der Component Regel mache.
	Component :
		(Bus | Processor)
	   (=> 'flows'
	   ((flow+=Flow)+ | (noFlows?='none' ';')))?
		('modes' (mode+=Mode |
			transition+=Transition)+
		)?
		'end' ';'
	;

I noticed that when the hyperlink code walks up the INode hierarchy it does not find a composite node with a pointer into the model until it gets to the processor in the case of the mode reference in the transition, and until it gets to the package in the case of the mode reference in the Flow (in this case resulting in the reference not being recognized as a hyperlink at all). In the case of the flow the reference is an optional element of the rule.

I am stuck as I am moving our implementation of the SAE AADL standard into Xtext until this is resolved. My alternate route was the falttened grammar. In that case the grammar it is large enough that I get the "Too many constants" error despite using "fieldsPerClass" and avoiding backtrack (see bug 354101).

Sincerely

Peter Feiler, Software Engineering Institute
Comment 10 Sebastian Zarnekow CLA 2011-08-27 09:51:53 EDT
Pushed to master.

Workaround: Override the ILocationInFileProvider
Comment 11 Karsten Thoms CLA 2017-09-19 17:09:02 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 12 Karsten Thoms CLA 2017-09-19 17:20:51 EDT
Closing all bugs that were set to RESOLVED before Neon.0