createReferenceUpdate failed in rename/refactor [message #1002586] |
Fri, 18 January 2013 17:19  |
Eclipse User |
|
|
|
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 #1004166 is a reply to message #1003727] |
Tue, 22 January 2013 13:01   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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 #1004321 is a reply to message #1004241] |
Tue, 22 January 2013 20:14   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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] | ...;
|
|
|
Powered by
FUDForum. Page generated in 0.05552 seconds