Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » createReferenceUpdate failed in rename/refactor(crossreference return null in createReferenceUpdate)
createReferenceUpdate failed in rename/refactor [message #1002586] Fri, 18 January 2013 17:19 Go to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I used createReferenceUpdate method in DefaultReferenceUpdater for the purpose of rename/refactor variables in my language.

I expected this reference update would be able to provide cross reference updates when I changed a variable name in semantic model.

However, the crossReference variable in the method of createReerenceUpdate always return null. I looked into and found childNode.getGrammarElement() always return RuleCallImpl class instead of CrossReference class.

With null value for crossReference, the createReferenceUpdate method would not work.

Re: createReferenceUpdate failed in rename/refactor [message #1003727 is a reply to message #1002586] Mon, 21 January 2013 17:14 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian Zarnekow
Messages: 2809
Registered: July 2009
Senior Member
Am 18.01.13 23:19, schrieb Hao Xie:
> I used createReferenceUpdate method in DefaultReferenceUpdater for the
> purpose of rename/refactor variables in my language.
>
> I expected this reference update would be able to provide cross
> reference updates when I changed a variable name in semantic model.
>
> However, the crossReference variable in the method of
> createReerenceUpdate always return null. I looked into and found
> childNode.getGrammarElement() always return RuleCallImpl class instead
> of CrossReference class.
>
> With null value for crossReference, the createReferenceUpdate method
> would not work.
>

Please provide some code that illustrates what you actually tried to do.
Otherwise it's hard to guess what's going wrong. Also note that the
DefaultReferenceUpdater is not intended to be used manually.

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: createReferenceUpdate failed in rename/refactor [message #1004166 is a reply to message #1003727] Tue, 22 January 2013 13:01 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
Thank you for replying, Sebastian.

Actually the problem I have is the following: I have my language WRESL, which for example have the following code:

goal test1{abc>1.0}
goal test2{abc<2.0}
goal test3{abc>1.5}
goal test4{abc<1.8}
goal test5{abc<1.6}

I would like to modify "abc" in the second line and the "abc" in all other lines automatically changes concurrently with my modification. After reviewing online posts, I found out maybe I missed the definition of cross reference in my xtext grammar to link those lines. I probablly need name and "[]" to define the cross references so that the createReferenceUpdate method would not return null.

Actually the concurent modification of "abc" is not my highest priority for now in my case, since it also has some scope issue in my case. Because in my language, the "define" statement for "abc" can be from another file, which makes it very hard for creating cross reference. That is why I plan to hold on this implementation.

My highest priority problem is that after I modified the "abc" in the second line to "ab", my code changed to:

goal test1{ab>1.0}
goal test2{aab2.0}
goal test3{abab5}
goal test4{abc<ab}
goal test5{abc<1ab

I used DefaultRenameStratege. It seems that after the first modification, my code shift for one character but the originalTextRegion in DefaultRenameStratege sticks to the text region before the modification without update. Then from the second modifications onwards, the modifications shift from my expectation.

I am going to create another thread since it has become a different issue. But I would like to hear your suggestions. Thanks again.
Re: createReferenceUpdate failed in rename/refactor [message #1004204 is a reply to message #1004166] Tue, 22 January 2013 14:46 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan Koehnlein
Messages: 655
Registered: July 2009
Senior Member
If your language defines the element named 'abc' somewhere else, even in
another file, and the listing you provided shows cross-references to
this element only, rename refactoring should work out of the box. It
shouldn't even matter whether you trigger it on a cross-ref or on the
definition itself.

I don't know of what type your 'abc' is, but lets assume it is 'Foo'. So
your grammar should read similar to

Foo:
name=ID ...
....
Goal:
'goal' name=ID '{' ref=[Foo] ... '}'

If that's what you're already using, make sure the cross-references are
properly linked, e.g. by navigating them with F3 in the editor. You say
you have scoping problems, so it'd be a good idea to solve them first.

If this doesn't help, please post the relevant sections of your grammar.


Am 22.01.13 19:01, schrieb Hao Xie:
> Thank you for replying, Sebastian.
>
> Actually the problem I have is the following: I have my language WRESL,
> which for example have the following code:
>
> goal test1{abc>1.0}
> goal test2{abc<2.0}
> goal test3{abc>1.5}
> goal test4{abc<1.8}
> goal test5{abc<1.6}
>
> I would like to modify "abc" in the second line and the "abc" in all
> other lines automatically changes concurrently with my modification.
> After reviewing online posts, I found out maybe I missed the definition
> of cross reference in my xtext grammar to link those lines. I probablly
> need name and "[]" to define the cross references so that the
> createReferenceUpdate method would not return null.
>
> Actually the concurent modification of "abc" is not my highest priority
> for now in my case, since it also has some scope issue in my case.
> Because in my language, the "define" statement for "abc" can be from
> another file, which makes it very hard for creating cross reference.
> That is why I plan to hold on this implementation.
>
> My highest priority problem is that after I modified the "abc" in the
> second line to "ab", my code changed to:
>
> goal test1{ab>1.0}
> goal test2{aab2.0}
> goal test3{abab5}
> goal test4{abc<ab}
> goal test5{abc<1ab
>
> I used DefaultRenameStratege. It seems that after the first
> modification, my code shift for one character but the originalTextRegion
> in DefaultRenameStratege sticks to the text region before the
> modification without update. Then from the second modifications onwards,
> the modifications shift from my expectation.
>
> I am going to create another thread since it has become a different
> issue. But I would like to hear your suggestions. Thanks again.


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: createReferenceUpdate failed in rename/refactor [message #1004241 is a reply to message #1004204] Tue, 22 January 2013 16:23 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
Thank you, Jan. I will try.

Also do you have any idea on my second issue? Why my rename always shifts from my expectation. Is that due to failure on update originalTextRegion in DefaultRenameStrategy. You also can find my question at the following post:

http://www.eclipse.org/forums/index.php/t/451328/
Re: createReferenceUpdate failed in rename/refactor [message #1004321 is a reply to message #1004241] Tue, 22 January 2013 20:14 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I got the following errors after implementing cross reference. It seems xtext doesn't allow me have multiple cross references. I attached my grammar with this reply.

warning(200): ../gov.ca.dwr.wresl.xtext.editor.ui/src-gen/gov/ca/dwr/wresl/xtext/editor/ui/contentassist/antlr/internal/InternalWreslEditor.g:4704:1: Decision can match input such as "RULE_ID" using multiple alternatives: 1, 2, 3, 4, 5
As a result, alternative(s) 2,3,4,5 were disabled for that input
error(201): ../gov.ca.dwr.wresl.xtext.editor.ui/src-gen/gov/ca/dwr/wresl/xtext/editor/ui/contentassist/antlr/internal/InternalWreslEditor.g:4704:1: The following alternatives can never be matched: 2,3,4,5

Re: createReferenceUpdate failed in rename/refactor [message #1004751 is a reply to message #1004321] Wed, 23 January 2013 15:01 Go to previous message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
After I create the cross reference correctly, my second problem disappear. The refactor/rename functions are well designed in xtext and I hardly need customize the default class used.

The problem I encountered in my previous reply can be solved be introducing a new term as follows:


Pattern:
Variable | ...;

Variable:
Define | SvarDef | DvarDef | ConstDef;

Define:
('define' | 'DEFINE') ('[' local?=('local' | 'LOCAL') ']')? name=ID '{' definition=(DVar | SVar | DVarInteger |
External)
'}';

SvarDef:
('svar' | 'SVAR' | 'Svar') ('[' local?=('local' | 'LOCAL') ']')? name=ID '{' definition=SVar '}';

DvarDef:
('dvar' | 'DVAR' | 'Dvar') ('[' local?=('local' | 'LOCAL') ']')? name=ID '{' definition=(DVar|DVarInteger) '}';

ConstDef:
('const' | 'CONST' | 'Const') ('[' local?=('local' | 'LOCAL') ']')? name=ID '{' definition=Number '}';

Term:
ref=[Variable] | ...;
Previous Topic:Problem running xtext workflow in Plugin Environment
Next Topic:Unordered Groups & Custom Checks
Goto Forum:
  


Current Time: Fri Jul 25 03:05:16 EDT 2014

Powered by FUDForum. Page generated in 0.01778 seconds