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 13:24 Go to next message
Yueming Hong is currently offline Yueming Hong
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 13:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6143
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
Re: quick fix in xtext [message #1073883 is a reply to message #1073879] Thu, 25 July 2013 13:44 Go to previous messageGo to next message
Yueming Hong is currently offline Yueming Hong
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 13:45]

Report message to a moderator

Re: quick fix in xtext [message #1073889 is a reply to message #1073883] Thu, 25 July 2013 13:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6143
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")]);
Re: quick fix in xtext [message #1073890 is a reply to message #1073889] Thu, 25 July 2013 13:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6143
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")]);
Re: quick fix in xtext [message #1073893 is a reply to message #1073890] Thu, 25 July 2013 14:04 Go to previous messageGo to next message
Yueming Hong is currently offline Yueming Hong
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 14:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6143
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 {
...

Re: quick fix in xtext [message #1073898 is a reply to message #1073896] Thu, 25 July 2013 14:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6143
Registered: July 2009
Senior Member
and
xtend is here: xtend-lang.org
Re: quick fix in xtext [message #1073905 is a reply to message #1073896] Thu, 25 July 2013 14:25 Go to previous messageGo to next message
Yueming Hong is currently offline Yueming Hong
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 14:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6143
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
Re: quick fix in xtext [message #1073953 is a reply to message #1073910] Thu, 25 July 2013 16:46 Go to previous messageGo to next message
Yueming Hong is currently offline Yueming Hong
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 16:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6143
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
Re: quick fix in xtext [message #1074006 is a reply to message #1073961] Thu, 25 July 2013 19:28 Go to previous message
Yueming Hong is currently offline Yueming Hong
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: Wed Jul 30 07:14:48 EDT 2014

Powered by FUDForum. Page generated in 0.06061 seconds