- This topic has 5 replies, 2 voices, and was last updated 13 years, 4 months ago by support-swapna.
-
AuthorPosts
-
andersflodellMemberHello!
I have stumbled on a annoying problem with MyEclipse when copy paste a line of code containing a reference to a private static class.
Lets say i have this code in a simple main args java class:
private static class Global{ static final String ISSUE_YEAR = "2001"; }
And also another similar main args java class but with a different value in the parameter:
public class Mainargsclass { .... private static class Global{ static final String ISSUE_YEAR = "2002"; } .... }
Then, when copying another line of code from the first main args class, lets say:
if(Global.ISSUE_YEAR != null && !Global.ISSUE_YEAR.equals("")){ ...... }
into the other main args class myeclipse is automatically generating a new import statement line in the class getting the new pasted code:
import my.own.package.Mainargsclass.Global;
And it generates an compilation error for the class getting the pasted code.
Any input on this issue would be great.
It is not critical, as long as i now of the problem i can remove the extra import statement manually.Im currently using ME 8.6.
With Kind Regards
Anders
support-swapnaModeratorandersflodell ,
When you are copying the statement
if(Global.ISSUE_YEAR != null && !Global.ISSUE_YEAR.equals(“”)){ }
it copies the reference for the outer class too. The reference is Mainargsclass.Global. So when you paste it in the second java class, it automatically adds an import statement for this reference. As the second class also has Mainargsclass.Global in this case even though the names are the same the references are different, it throws a compilation error. This behavior is not a bug.
Let us know if you have any other issues.
andersflodellMembercould there be a feature request that adds “paste without references” or “paste as plain text” in MyEclipse?! Or maybe in Eclipse?!
support-swapnaModeratorandersflodell,
Go to Window > Preferences > Java > Typing and uncheck the Update Imports option to stop updating the imports.
Let us know how it works for you.
andersflodellMemberYes it worked. Thanks!
And the setting was located under Window > Preferences > Java > Editor >Typing.
However im not sure if this is a solution for me since most of the time i would like the support of auto-inserted import statements when copy-paste. It was just this time, using private class inside of the main class that things got weird when copy-paste.
But now i know how to disable it when needed.Anders
support-swapnaModeratorandersflodell ,
Glad that it is working.
Do let us know if you have any other issues. -
AuthorPosts