eclipse-jdt / eclipse.jdt.ui

Eclipse Public License 2.0
35 stars 86 forks source link

Fix for pasting snippet with main method to Package Explorer #1416

Closed iloveeclipse closed 3 months ago

iloveeclipse commented 3 months ago

After introducing implicit types via https://github.com/eclipse-jdt/eclipse.jdt.core/pull/2066 the snippet that contains only main() method is recognized as ImplicitTypeDeclaration that does not inherit AbstractTypeDeclaration but common super class AbstractUnnamedTypeDeclaration.

Make sure we don't fail with CCE and don't generate extra main method that wraps around pasted main method.

Fixes https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/1414

trancexpress commented 3 months ago

Seems to work. Personally I don't miss randomly pasting code into the Package Explorer (its always a mistake when I do this, I forgot to select a package to paste into), but I guess the exception is bad and should be fixed.