Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Xtext Display line numbers
Xtext Display line numbers [message #1727819] Mon, 28 March 2016 02:21 Go to next message
Eclipse UserFriend
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 03:44] by Moderator

Re: Xtext Display line numbers [message #1727823 is a reply to message #1727819] Mon, 28 March 2016 03:08 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Xtext Display line numbers [message #1727824 is a reply to message #1727823] Mon, 28 March 2016 03:23 Go to previous messageGo to next message
Eclipse UserFriend
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 03:31 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Xtext Display line numbers [message #1727827 is a reply to message #1727825] Mon, 28 March 2016 03:45 Go to previous messageGo to next message
Eclipse UserFriend
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 03:47 Go to previous message
Eclipse UserFriend
xtext uses e.g.

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

or

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

for calculating the line number
Previous Topic:Can't get scoping to work
Next Topic:Alternative cross-reference with JVM types
Goto Forum:
  


Current Time: Wed Jul 23 22:04:31 EDT 2025

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

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

Back to the top