Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Remove the hierarchy from the name of cross reference
Remove the hierarchy from the name of cross reference [message #1863271] Mon, 22 January 2024 08:29 Go to next message
Loredana Hozan is currently offline Loredana HozanFriend
Messages: 34
Registered: January 2019
Member
I have 2 simple languages. One defines tables with fields, and in the other one i define which tables and fields are being used like this :
Language A:
model hello1-1.0.0 {
	table newTable {
		field field1
		field field11
	} 
	 
	table newTable2 {
		field field2
	}
}


Language B:
 
model2 hello2-1.0.0 !
import hello1-1.0.0

used-tables { 
	newUsedTable is using hello1-1.0.0.newTable {
		//what works :
		hello1-1.0.0.newTable.field1
		
		//What i want :
		field1
	}
}


How can I remove the hierarchy from the name when i am using a certain table's fields? i have implemented a ScopeProvider, when i use the eclipse runtime and do a Ctrl+Space i get the right name (field1) but once i select it, it gives me an error with : "Could not resolve reference."

In the grammar i have defined the reference like :
UsedField:
	referenced=[model::Field|FIELD_FQN];
FIELD_FQN:
    CTXT_FQN'.'ID'.'ID;

I have tried to remove the FIELD_FQN and leave just the reference, i have also tried to just put ID instead of it, and it still can not find the reference.
I have tried to implement a ValueConverter for the terminal, but it still does not work.

I have also tried to implement a qualifiedNameProvider with teh following code :
List<INode> nodes = NodeModelUtils.findNodesForFeature(((UsedField)obj).getReferenced(), MyDslPackage.Literals.FIELD__NAME);
return QualifiedName.create(nodes.get(0).getText());
//	    return QualifiedName.create((((UsedField)obj).getReferenced().getName());

and the list of nodes is empty.

I have attached a zip with the code.
Re: Remove the hierarchy from the name of cross reference [message #1863281 is a reply to message #1863271] Mon, 22 January 2024 19:58 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
Without looking into details

NodeModelUtils.findNodesForFeature(obj, MyDslPackage.Literals.used_field__referenced)

Besides that: how does your ImportedNamspacewareLocalScopeProvider customization look like
There you need to create wildcard normalizers for hello1-1.0.0.*


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Previous Topic:Language server seems to trigger build twice during initialization
Next Topic:Different indentation level in the same file
Goto Forum:
  


Current Time: Wed Dec 04 15:55:38 GMT 2024

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

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

Back to the top