Home » Language IDEs » Java Development Tools (JDT) » getting the newly created field's reference after renaming of an existing IField
getting the newly created field's reference after renaming of an existing IField [message #166551] |
Wed, 30 June 2004 09:01  |
Eclipse User |
|
|
|
Originally posted by: sunay.yaldiz.gentleware.com
I have a field for example,
IField field = ...;
field.rename(newName,false, null);
I realized, after rename method executes, the reference to field is no
more useful, because a new field with the newName is actually created
instead of manipulating the existing field reference. So, my question is
at this point, whether I can get the reference for the newly created
field, and if yes, how? (Of course I can also getType of this field and
then search in this type for the newly created field but I wonder if
there is a shorter way).
Thanks in advance for answering,
Regards,
Sunay
|
|
|
Re: getting the newly created field's reference after renaming of an existing IField [message #166566 is a reply to message #166551] |
Wed, 30 June 2004 09:03   |
Eclipse User |
|
|
|
The easiest way to get a handle on the new field is:
field.getDeclaringType().getField(newName)
Jerome
"Sunay Yaldiz" <sunay.yaldiz@gentleware.com> wrote in message
news:cbudg5$t3k$1@eclipse.org...
> I have a field for example,
>
> IField field = ...;
> field.rename(newName,false, null);
>
> I realized, after rename method executes, the reference to field is no
> more useful, because a new field with the newName is actually created
> instead of manipulating the existing field reference. So, my question is
> at this point, whether I can get the reference for the newly created
> field, and if yes, how? (Of course I can also getType of this field and
> then search in this type for the newly created field but I wonder if
> there is a shorter way).
>
> Thanks in advance for answering,
> Regards,
> Sunay
|
|
|
Re: getting the newly created field's reference after renaming of an existing IField [message #166619 is a reply to message #166566] |
Wed, 30 June 2004 10:28   |
Eclipse User |
|
|
|
Originally posted by: sunay.yaldiz.gentleware.com
Thank you Jerome.
So, there is no real direct way to get it, am I right? My IField case
was just actually as an example for renaming by
ISourceManipulation.rename(..). I thought maybe somehow I can directly
get the newly created java elements. In case of package fragments or
types(and maybe more), it is not so straightforward to get the new
element's reference. For an IType for example, I have to check whether
it is top-level(if it is toplevel also the compilation unit gets
renamed...),if not getDeclaringType().getType(newName) is enough, but if
it is toplevel, I should ask the owning package fragment to get the
newly created Compilation unit, and then get the newly created type.
Regards,
Sunay
Jerome Lanneluc wrote:
> The easiest way to get a handle on the new field is:
> field.getDeclaringType().getField(newName)
>
> Jerome
>
> "Sunay Yaldiz" <sunay.yaldiz@gentleware.com> wrote in message
> news:cbudg5$t3k$1@eclipse.org...
>
>>I have a field for example,
>>
>>IField field = ...;
>>field.rename(newName,false, null);
>>
>>I realized, after rename method executes, the reference to field is no
>>more useful, because a new field with the newName is actually created
>>instead of manipulating the existing field reference. So, my question is
>> at this point, whether I can get the reference for the newly created
>>field, and if yes, how? (Of course I can also getType of this field and
>>then search in this type for the newly created field but I wonder if
>>there is a shorter way).
>>
>>Thanks in advance for answering,
>>Regards,
>>Sunay
>
>
>
|
|
|
Re: getting the newly created field's reference after renaming of an existing IField [message #166626 is a reply to message #166619] |
Wed, 30 June 2004 10:32  |
Eclipse User |
|
|
|
Unfortunately there is no other way to get the element created by the rename
operation. Feel free to enter a feature request.
Jerome
"Sunay Yaldiz" <sunay.yaldiz@gentleware.com> wrote in message
news:cbuijd$as2$1@eclipse.org...
> Thank you Jerome.
>
> So, there is no real direct way to get it, am I right? My IField case
> was just actually as an example for renaming by
> ISourceManipulation.rename(..). I thought maybe somehow I can directly
> get the newly created java elements. In case of package fragments or
> types(and maybe more), it is not so straightforward to get the new
> element's reference. For an IType for example, I have to check whether
> it is top-level(if it is toplevel also the compilation unit gets
> renamed...),if not getDeclaringType().getType(newName) is enough, but if
> it is toplevel, I should ask the owning package fragment to get the
> newly created Compilation unit, and then get the newly created type.
>
> Regards,
> Sunay
>
>
> Jerome Lanneluc wrote:
> > The easiest way to get a handle on the new field is:
> > field.getDeclaringType().getField(newName)
> >
> > Jerome
> >
> > "Sunay Yaldiz" <sunay.yaldiz@gentleware.com> wrote in message
> > news:cbudg5$t3k$1@eclipse.org...
> >
> >>I have a field for example,
> >>
> >>IField field = ...;
> >>field.rename(newName,false, null);
> >>
> >>I realized, after rename method executes, the reference to field is no
> >>more useful, because a new field with the newName is actually created
> >>instead of manipulating the existing field reference. So, my question is
> >> at this point, whether I can get the reference for the newly created
> >>field, and if yes, how? (Of course I can also getType of this field and
> >>then search in this type for the newly created field but I wonder if
> >>there is a shorter way).
> >>
> >>Thanks in advance for answering,
> >>Regards,
> >>Sunay
> >
> >
> >
|
|
|
Goto Forum:
Current Time: Tue May 13 07:18:21 EDT 2025
Powered by FUDForum. Page generated in 0.03336 seconds
|