Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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] by 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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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: Tue Jul 22 17:46:39 EDT 2025

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

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

Back to the top