Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Description for the Content Assist of File Cross-References
Description for the Content Assist of File Cross-References [message #1860111] Tue, 18 July 2023 12:20 Go to next message
Atul Krishnan is currently offline Atul KrishnanFriend
Messages: 8
Registered: July 2023
Junior Member
Hello,

I was wanting to know whether it is possible to have a description for the content assist of references. For example in the simple grammar below:

Model:
greetings+=Greeting*;

Greeting:
'Hello' name=ID '!';

References:
'ref' greeting=[Greeting];

And I have a file A:
Hello World1 !

And in file B:
Hello World2 !

Is it possible to have the content assist display a description like World1 :File A and World2 :File B for Reference?

Thank you,
Atul
Re: Description for the Content Assist of File Cross-References [message #1860114 is a reply to message #1860111] Tue, 18 July 2023 13:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14738
Registered: July 2009
Senior Member
starting point

public class MyDslProposalProvider extends AbstractMyDslProposalProvider {
	
	protected StyledString getStyledDisplayString(IEObjectDescription description) {
		StyledString styledDisplayString = getStyledDisplayString(description.getEObjectOrProxy(),
			getQualifiedNameConverter().toString(description.getQualifiedName()),
			getQualifiedNameConverter().toString(description.getName()));
		StyledString append = styledDisplayString.append(" - " + description.getEObjectURI().trimFragment());
		return append;
	}
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Description for the Content Assist of File Cross-References [message #1860140 is a reply to message #1860114] Wed, 19 July 2023 11:54 Go to previous messageGo to next message
Atul Krishnan is currently offline Atul KrishnanFriend
Messages: 8
Registered: July 2023
Junior Member
Thank you so much, that works perfectly
Re: Description for the Content Assist of File Cross-References [message #1860296 is a reply to message #1860114] Thu, 27 July 2023 08:51 Go to previous messageGo to next message
Atul Krishnan is currently offline Atul KrishnanFriend
Messages: 8
Registered: July 2023
Junior Member
Hello,

For the same example grammar,
If file A contains:
Hello World1 !

And File B contains:
Hello World1 !

Is it possible that if I refer it from file A, can the qualified names in the content assist come as World1 which refers to file A and fileB.World1 which refers to file B?

Thank you,
Atul
Re: Description for the Content Assist of File Cross-References [message #1860302 is a reply to message #1860296] Thu, 27 July 2023 13:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14738
Registered: July 2009
Senior Member
HI,
i did not understand your question. can you please elaborate


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Description for the Content Assist of File Cross-References [message #1860312 is a reply to message #1860302] Fri, 28 July 2023 03:20 Go to previous messageGo to next message
Atul Krishnan is currently offline Atul KrishnanFriend
Messages: 8
Registered: July 2023
Junior Member
Hello,

If there are two references with the same name in different files, the default scope takes only the first reference. Is there a way to provide a qualified name to the other reference similar to <filename>.<reference>?

If File A contains:
Hello World1 !

And File B also contains:
Hello World1 !

So if i do ref, I should get World1 and FileB.World1 as the possible references instead of just World1.

Thank you,
Atul
Re: Description for the Content Assist of File Cross-References [message #1860319 is a reply to message #1860312] Fri, 28 July 2023 08:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14738
Registered: July 2009
Senior Member
you can adapt IQualifiedNameProvider to encode file name into elements name.
but then you also need to allow file names in the reference

SomeObject: ref=[SomeType|FQN];

FQN: ID ("." ID)*;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Fri, 28 July 2023 08:31]

Report message to a moderator

Re: Description for the Content Assist of File Cross-References [message #1860321 is a reply to message #1860319] Fri, 28 July 2023 09:10 Go to previous messageGo to next message
Atul Krishnan is currently offline Atul KrishnanFriend
Messages: 8
Registered: July 2023
Junior Member
Hello,

Yes. But how do i encode the file name only for the duplicate elements and not all the elements?
Re: Description for the Content Assist of File Cross-References [message #1860322 is a reply to message #1860321] Fri, 28 July 2023 10:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14738
Registered: July 2009
Senior Member
this would be more compilated.
you would need to query the scope for all elements and transform it.

unfortunately there is not ootb example


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Description for the Content Assist of File Cross-References [message #1860325 is a reply to message #1860322] Fri, 28 July 2023 12:37 Go to previous message
Atul Krishnan is currently offline Atul KrishnanFriend
Messages: 8
Registered: July 2023
Junior Member
Okay! no issues
Thank you for the help!
Previous Topic:Arithmetic defined in xtext
Next Topic:Xtext 2.32.0.M2 is out
Goto Forum:
  


Current Time: Thu Dec 26 13:07:31 GMT 2024

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

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

Back to the top