Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Different hovers for same data type rule(is it possible to have different hovers for the same datatype rule? )
Different hovers for same data type rule [message #1715138] Thu, 19 November 2015 14:23 Go to next message
Mohsin waqas is currently offline Mohsin waqasFriend
Messages: 33
Registered: June 2015
Member
I have a small example grammar for explaining my question:
grammar org.xtext.example.hoverCheck.Hov with org.eclipse.xtext.common.Terminals

generate hov "http://www.xtext.org/example/hoverCheck/Hov"

Model:
	declaration+=Declaration*
	contents+=Content*;

Declaration:
	'set' Socket  decInt = INT ';'
;	
Content:
	'add' Socket (Socket | INT | OFFSET) ';'
;

Socket:
	('S0'|'S1'|'S2')
;
terminal OFFSET:'OS'('0'|'1');


the language looks like

set S0 0; // set S0 equal to 0
set S1 1; // set S1 equal to 1
set S2 2; // set S2 equal to 2

add S0 S1; // here hover on S0 should show 0 and on S1 should show 1
add S0 S2; // here hover on S0 should show 1 and on S1 should show 2
add S0 OS1; // here hover on S0 should show 1
add S0 OS1; // here hover on S0 should show null because in last command add function was not computed because we dont know value of OS1


I know how to implement hover using MyDslEObjectHoverProvider.
but the problem is whenever i implement hover e:g on S0, it will show the same hover on S0 for the whole code. Is there a way to implement different hover on different lines of the code but on the same datatype rule of the grammar?
Thanks

[Updated on: Thu, 19 November 2015 14:34]

Report message to a moderator

Re: Different hovers for same data type rule [message #1715243 is a reply to message #1715138] Fri, 20 November 2015 13:54 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi,

your grammar does not make much sense. it lacks of assignments.
then you have no names and no cross references.

maybe you want to do actually something like

Model:
	declaration+=Declaration*
	contents+=Content*;

Declaration:
	'set' name=Socket  decInt = INT ';'
;	
Content:
	'add' decl1=[Declaration|Socket] (decl2=[Declaration|Socket] | INT | OFFSET) ';'
;

Socket:
	('S0'|'S1'|'S2')
;
terminal OFFSET:'OS'('0'|'1');


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:How to generate and package xmi file with maven and xtext 2.9
Next Topic:Enrich Xbase expression programatically in Inferrer
Goto Forum:
  


Current Time: Tue Sep 24 10:51:03 GMT 2024

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

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

Back to the top