Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problem with validation / linking
Problem with validation / linking [message #672926] Sun, 22 May 2011 12:53
Simon Stratmann is currently offline Simon StratmannFriend
Messages: 27
Registered: February 2011
Junior Member
Hi,

I have a weird problem with my outline and my linking.

When I start the XText project and open the outline, which at some point invokes the labelProvider which tries to get the FQN of some objects, and then change something in my file (thus making it "dirty"), the linker won't find some of the cross references (although it finds references to the same referrable at another position in the file). The outline will show some of the names, but not all (the names of the elements that the linker was able to find).
If I start the project, first change something (starting the validation) and then open the outline it works fine.

As example:

I have an element that looks something like this:
Process:
name=ID ":" "process" "(" list=List ")" ";"
List:
NAMES+=name ("," NAMES+=name)*;


The label for "process (a, b, c)" should look like this: "Process a, b, c" (the names in my real grammar are a bit different):

	String text(process_statement ps) {
		StringBuilder sb = new StringBuilder("process");
		if (ps.getName() != null) {
			sb.append(" ");
			sb.append(ps.getName());
		}
		String slText = getText(ps.getList());
		if (slText.length() > 0) {
			sb.append(": ");

			sb.append(slText);
		}
		return sb.toString();
	}

	String text(refToSimpleName ref) {
		String lastSegment = provider.getFullyQualifiedName(ref.getRefersTo()).getLastSegment();
		return lastSegment;
	}


"text(refToSimpleName ref)" is called to find out the name of the "a, b, c" after process, which in my grammar is a List of Names which can be, among others, a "refToSimpleName". For this the QualifiedNameProvider is asked for the simple name of the element. This is what disturbs the linking. Removing this part and replacing it with return "null" makes the problem go away.

As example. I have:

A: process (x,y);
B: process (o,p);
C: process (x,y);


Then I start the project with this file opened, open the outline and the outline will show:

process A
process B
process C


When I change something in the file now the outline will show something like:
process A
process B
process C : x, y


So the linker found the references to x and y in one case and not the other. Changing something in the file again will change this, for example x and y wouldn't be found this time but o and p instead.

When I remove one of the parameters from a process line with the ouline open the problem happens, too, because apparently the outline is refreshed before the validation is started. Collapsing the outline node containing the processes before removing the parameter solves the problem.

In conclusion, invoking the FQN provider before the validation seems to be the problem. Invoking the XText validation before opening the outline will solve it.

I tried starting the validation programmatically (using Diagnostic diagnostic = Diagnostician.INSTANCE.validate(myModel)Wink, but it didn't work. My guess is that the change in a language file starts another XText validation than this code does.

Any ideas? I would be really grateful.

Thanks,

Simon



PS: Has anybody had problem with posting new topics before? This's been the third time I lost a long new post I'd written because the forum software redirected me to the wrong page without posting anything.
Previous Topic:Programmatically start validation/linking?
Next Topic:Scope of Xtext
Goto Forum:
  


Current Time: Fri Mar 29 04:40:34 GMT 2024

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

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

Back to the top