Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Quickfix for syntactical errors
Quickfix for syntactical errors [message #1741766] Mon, 29 August 2016 11:12 Go to next message
Jonathan L. is currently offline Jonathan L.Friend
Messages: 24
Registered: May 2016
Junior Member
Hi,

I have customized the generated error messages for my language via ISyntaxErrorMessageProvider by the following:
public static val INVALID_VAR_IDENTIFIER = "INVALID_VAR_IDENTIFIER"

override getSyntaxErrorMessage(IParserErrorContext context) {
	val unexpectedText = context?.recognitionException?.token?.text
	if ( !(GrammarUtil::getAllAlternatives(grammarAccess.getGrammar()).contains(unexpectedText))) {
		if (context.currentContext.eClass.name == "Dcl_var") {
			return new SyntaxErrorMessage(
				"Identifiers for variables have to start with a lower case!",
				INVALID_VAR_IDENTIFIER
			)
		}
}

Now I want to add a quickfix for this, but I'm getting the error "The annotation @Fix is disallowed for this location."
@Fix(CeuSyntaxErrorMessageProvider.INVALID_VAR_IDENTIFIER) { }

how can I now add a quickfix for this IssueCode if this is not working? I haven't found any help on the documentation..
Re: Quickfix for syntactical errors [message #1741767 is a reply to message #1741766] Mon, 29 August 2016 11:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
where did you put the @Fix(CeuSyntaxErrorMessageProvider.INVALID_VAR_IDENTIFIER) at

id expect it at a method in the quickfixprovider


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Quickfix for syntactical errors [message #1741768 is a reply to message #1741767] Mon, 29 August 2016 11:19 Go to previous messageGo to next message
Jonathan L. is currently offline Jonathan L.Friend
Messages: 24
Registered: May 2016
Junior Member
It's within the QuickfixProvider class
class CeuQuickfixProvider extends DefaultQuickfixProvider {
	@Fix(CeuSyntaxErrorMessageProvider.INVALID_VAR_IDENTIFIER) {
		
	}
}
Re: Quickfix for syntactical errors [message #1741770 is a reply to message #1741768] Mon, 29 August 2016 11:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13885
Registered: July 2009
Senior Member
bit there is no method ?!?

@Fix(MyDslValidator.INVALID_NAME)
def capitalizeName(Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, 'Capitalize name', 'Capitalize the name.', 'upcase.png') [
context |
val xtextDocument = context.xtextDocument
val firstLetter = xtextDocument.get(issue.offset, 1)
xtextDocument.replace(issue.offset, 1, firstLetter.toUpperCase)
]
}


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Quickfix for syntactical errors [message #1741771 is a reply to message #1741768] Mon, 29 August 2016 11:23 Go to previous message
Jonathan L. is currently offline Jonathan L.Friend
Messages: 24
Registered: May 2016
Junior Member
Oh.. ok sorry. I've overlooked that a method declaration have to come after that.
Previous Topic:xtext GenModelSupport error
Next Topic:No elements in the index when doing Project Clean
Goto Forum:
  


Current Time: Mon Apr 19 01:24:17 GMT 2021

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

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

Back to the top