0

I am currently working on my project which requires me to implement extract method refactoring using the eclipse jdt and ltk. I am new to this topic, can anyone point me to some walkthrough example?

I have tried to search for guides but there is not much.

  • Please provide enough code so others can better understand or reproduce the problem. – Community Mar 09 '23 at 13:09
  • Why do you want implement just another extract method refactoring? What's wrong with the original? Why don't you look at the code of the original? Should this be an Eclipse plugin or a standalone Java application not based on Eclipse? See also documentation (in Eclipse: _Help > Help Contents_): https://help.eclipse.org/latest/topic/org.eclipse.jdt.doc.isv/guide/jdt_int_core.htm – howlger Mar 09 '23 at 13:13
  • The main idea is for me to learn how to implement a refactoring plugin by calling the apis of eclipse. – Bridget Nyirongo Mar 09 '23 at 14:02
  • 1
    Extract method is very complex. The core part of the code is `org.eclipse.jdt.internal.corext.refactoring.code.ExtractMethodRefactoring` which is 1391 lines, but relies on a lot of things set up by the classes that call it. Most of these classes are internal so are not part of the official APIs. – greg-449 Mar 09 '23 at 14:20
  • You might look into the code of a clean-up which is an auto refactoring which can also be applied as so-called _Save Action_. For example, this is the code of a very simply refactoring which replaces `String.strip().isEmpty()` with `String.isBlank()` (which is shorter and faster): https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/180067 – howlger Mar 09 '23 at 17:26

0 Answers0