Refactoring for java non-assert version to assert version

Hi,
I have a project source which uses 'assert' as name of methods, this was developed using jdk 1.3. Now when I am using java 5.0, Idea complains of the syntax.
What steps I should take to refactor the exisiting code so that jdk 5.0 compiler passes the code.
I tried using the "Change Signature" option of Refactor on the method named 'assert', but Idea complains this - Cannot perform refactoring. The caret should be positioned at the name of the method or class to be refactored.

Thanks to all.

4 comments
Comment actions Permalink

Don't know if this is the best/easiest method, but I would do this:

First change the language level for the project to 1.3 (Settings -> Modules -> Language Level) (IDEA will reload the project)

Then refactor all methods with the name assert (Shift-F6 rename or Ctrl-F6 Change signature).

Last change the language level back to 5.0

Bart

0
Comment actions Permalink

Use the "'assert' used as identifier" inspection. It should find all of the places that "assert" is used as something's name (there's a similar inspection for 'enum'). Go through the list, navigate to the items, and rename the objects. You'll need to have your language level set to 1.3.

--Dave Griffith

0
Comment actions Permalink

Thanks Bart for detailed steps, it helped.

0
Comment actions Permalink

hi Dave,
I followed one of our community member's idea which needs us only to update things which were declared as 'assert', and let idea change the references to such declared items accordingly.
here it is:
First change the language level for the project to 1.3 (Settings -> Modules -> Language Level) (IDEA will reload the project)

Then refactor all methods with the name assert (Shift-F6 rename or Ctrl-F6 Change signature).

Last change the language level back to 5.0


Thanks bro.

0

Please sign in to leave a comment.