Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext Display line numbers
Xtext Display line numbers [message #1727819] Mon, 28 March 2016 06:21 Go to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
I want to display the line number where the error has occurred.

For example, if I have the grammar:
Quote:

Model:
defs += myTestMethod*
;

myTestMethod:
'test' name=ID ';'
;


In my config file, I have the following configuration in test.mak:
Quote:

test start;
test sleep;
test wakeup;


In my testValidator.xtend:
class testValidator {
def checkTest()
{
   if (name == "wakeup")
       print.error("wakeup is not supported.");
}
}


In my error message, I want to display the file name and line number where the "wakeup" is configured.
I am looking for something like this:
"ERROR: test.mak, line 3: no name configured.

I am looking for ways to display the filename and line number (in bold).

[Updated on: Mon, 28 March 2016 07:44]

Report message to a moderator

Re: Xtext Display line numbers [message #1727823 is a reply to message #1727819] Mon, 28 March 2016 07:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Can you please give more context.
Are you talking about the editor or a standalone app or ...

The error view in eclipse should already contain the line number


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Display line numbers [message #1727824 is a reply to message #1727823] Mon, 28 March 2016 07:23 Go to previous messageGo to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
I am referring to a standalone JAR file.

I generate the JAR file and run it via command line. In my implementation, I process the configurations and check their validity. I don't use the validator class that comes with Xtext since I create my own. The error message is printed out via System.out.println().
Re: Xtext Display line numbers [message #1727825 is a reply to message #1727824] Mon, 28 March 2016 07:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
can you please file a complete reproducable grammar. and your impl of a validator.
i get the syntax error message on line 1 which is correct


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Display line numbers [message #1727827 is a reply to message #1727825] Mon, 28 March 2016 07:45 Go to previous messageGo to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
Hi Christian,
i have updated my entry and added more information.
Re: Xtext Display line numbers [message #1727828 is a reply to message #1727827] Mon, 28 March 2016 07:47 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
xtext uses e.g.

org.eclipse.xtext.validation.DiagnosticConverterImpl.getLocationData(Diagnostic)

or

org.eclipse.xtext.diagnostics.AbstractDiagnostic.getLine()

for calculating the line number


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Can't get scoping to work
Next Topic:Alternative cross-reference with JVM types
Goto Forum:
  


Current Time: Sat Apr 20 04:27:28 GMT 2024

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

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

Back to the top