Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » quick fix in xtext
quick fix in xtext [message #1073875] Thu, 25 July 2013 17:24 Go to next message
Yueming Hong is currently offline Yueming HongFriend
Messages: 87
Registered: April 2013
Member
Hi,
How can we pass data (from validator)to quick fix ?

for instance,
I use the error() to issue the error INVALID_NAME
and @fix handles the error. how can we handle the error with data passed from error?

sincerely
Re: quick fix in xtext [message #1073879 is a reply to message #1073875] Thu, 25 July 2013 17:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

i am not quite sure what you are targeting with this question
the error methods in the validator have a String... varargs
param that allows you to pass data.

These will be available via org.eclipse.xtext.validation.Issue.getData()
in the quickfix provider


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: quick fix in xtext [message #1073883 is a reply to message #1073879] Thu, 25 July 2013 17:44 Go to previous messageGo to next message
Yueming Hong is currently offline Yueming HongFriend
Messages: 87
Registered: April 2013
Member
Ok thanks Christ.
I once use the quickfix in java, but now the xtext changes the source file into xtend and it seems that the syntax which works in java no longer works in xtend: the new ISemanticModification{} is not recognized.
can you give the equivalent codes to these:

acceptor.accept(issue, 'tag error', 'no tagsdfs', '', new ISemanticModification{
public void apply(final EObject element, IModificationContext context) {
createDefaultValue((KeyValuePair) element, "a");
}
})

Thanks.

[Updated on: Thu, 25 July 2013 17:45]

Report message to a moderator

Re: quick fix in xtext [message #1073889 is a reply to message #1073883] Thu, 25 July 2013 17:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,
anonymous inner classes a not a feature of xtend. you can use a closure instead

acceptor.accept(issue, 'tag error', 'no tagsdfs',[object, context|createDefaultValue((KeyValuePair) element, "a")]);


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: quick fix in xtext [message #1073890 is a reply to message #1073889] Thu, 25 July 2013 17:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,
anonymous inner classes a not a feature of xtend. you can use a closure instead

acceptor.accept(issue, 'tag error', 'no tagsdfs',[object, context|createDefaultValue((KeyValuePair) element, "a")]);


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: quick fix in xtext [message #1073893 is a reply to message #1073890] Thu, 25 July 2013 18:04 Go to previous messageGo to next message
Yueming Hong is currently offline Yueming HongFriend
Messages: 87
Registered: April 2013
Member
HI, then where can i find the tutorial/example for this new syntax ?
Xtext 2.4.2 Documentation seems a little old-fashion~

Thx
Re: quick fix in xtext [message #1073896 is a reply to message #1073893] Thu, 25 July 2013 18:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

you are not forced to use xtend. you can configure the workflow to use java (though it may not work for all cases)

...
var generateXtendStub = false

Workflow {
...



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: quick fix in xtext [message #1073898 is a reply to message #1073896] Thu, 25 July 2013 18:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
and
xtend is here: xtend-lang.org


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: quick fix in xtext [message #1073905 is a reply to message #1073896] Thu, 25 July 2013 18:25 Go to previous messageGo to next message
Yueming Hong is currently offline Yueming HongFriend
Messages: 87
Registered: April 2013
Member
So when i set
generateXtendStub = false

I switch to edit java code in xtend-gen folder, right?
Re: quick fix in xtext [message #1073910 is a reply to message #1073905] Thu, 25 July 2013 18:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
No,

simply delete the xtend class, rerun the workflow and you should get a new java class in the src folder


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: quick fix in xtext [message #1073953 is a reply to message #1073910] Thu, 25 July 2013 20:46 Go to previous messageGo to next message
Yueming Hong is currently offline Yueming HongFriend
Messages: 87
Registered: April 2013
Member
It seems that content assist and validation are still in xtend.
Re: quick fix in xtext [message #1073961 is a reply to message #1073953] Thu, 25 July 2013 20:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
jepp,

this is what i meant with "it may not work for all cases"
you have to replace the fragments with
- org.eclipse.xtext.generator.validation.JavaValidatorFragment
- org.eclipse.xtext.ui.generator.contentAssist.JavaBasedContentAssistFragment


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: quick fix in xtext [message #1074006 is a reply to message #1073961] Thu, 25 July 2013 23:28 Go to previous message
Yueming Hong is currently offline Yueming HongFriend
Messages: 87
Registered: April 2013
Member
anyway, i will try to get used to xtend.

Thanks Christ
Previous Topic:automatic tweaking lexer for semantic predicates
Next Topic:XbaseScopeProvider in Xtext 2.4
Goto Forum:
  


Current Time: Fri Mar 29 04:33:45 GMT 2024

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

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

Back to the top