Skip to content

Refactor: extract HandlerHelper, fix duplication, add superclass traversal#12

Merged
unknowIfGuestInDream merged 3 commits intomasterfrom
copilot/refactor-project-code
Feb 28, 2026
Merged

Refactor: extract HandlerHelper, fix duplication, add superclass traversal#12
unknowIfGuestInDream merged 3 commits intomasterfrom
copilot/refactor-project-code

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

All 4 handler classes duplicated ~80% of their code (editor extraction, AST parsing, indentation, VariableFinder, document insertion). Several bugs and anti-patterns present.

Structural

  • Extract HandlerHelper utility class with shared logic, reducing handler LOC from ~500 to ~190
  • Unify three divergent VariableFinder implementations into one (with VariableDeclarationStatement fallback)
  • Use Java 17 record for EditorContext

Bug fixes / correctness

  • Activator: move plugin = this from constructor to start() — constructor runs before OSGi lifecycle
  • e.printStackTrace() → null-safe ILog-based logging
  • Remove unused StringBuilder sb built but never read in 3 handlers
  • Remove unreachable lines.isEmpty() in converter handler (list always has ≥2 entries)
  • propName.length() == 0propName.isEmpty()
  • indent += c in loop → StringBuilder

Functional improvement

  • collectSetters() / collectGetters() now traverse the superclass hierarchy via getSuperclass(), stopping at java.lang.Object. Previously only getDeclaredMethods() was called, missing inherited methods.
// Before: only direct methods
for (IMethodBinding m : type.getDeclaredMethods()) { ... }

// After: walks up the class hierarchy
ITypeBinding current = type;
while (current != null && !"java.lang.Object".equals(current.getQualifiedName())) {
    for (IMethodBinding m : current.getDeclaredMethods()) { ... }
    current = current.getSuperclass();
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • mirrors.aliyun.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.12/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.12/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.12 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.12/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/eclipse-generateAllSetter/eclipse-generateAllSetter org.codehaus.plexus.classworlds.launcher.Launcher clean verify (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…improve logging and inherited method support

Co-authored-by: unknowIfGuestInDream <57802425+unknowIfGuestInDream@users.noreply.github.com>
@unknowIfGuestInDream unknowIfGuestInDream marked this pull request as ready for review February 28, 2026 03:14
… logging, fix record accessor calls

Co-authored-by: unknowIfGuestInDream <57802425+unknowIfGuestInDream@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor project code for optimization Refactor: extract HandlerHelper, fix duplication, add superclass traversal Feb 28, 2026
@unknowIfGuestInDream unknowIfGuestInDream merged commit cad63e2 into master Feb 28, 2026
7 checks passed
@unknowIfGuestInDream unknowIfGuestInDream deleted the copilot/refactor-project-code branch February 28, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants