Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failed cast to TypeDeclaration in file paste event #3239

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

hopehadfield
Copy link
Contributor

Fixes issues pasting text with implicitly declared classes into the file explorer.

@rgrunber
Copy link
Contributor

rgrunber commented Aug 13, 2024

Thanks. For those interested, the error :

!ENTRY org.eclipse.jdt.ls.core 4 2 2024-08-13 16:03:50.652
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ls.core".
!STACK 0
java.lang.ClassCastException: class org.eclipse.jdt.core.dom.ImplicitTypeDeclaration cannot be cast to class org.eclipse.jdt.core.dom.TypeDeclaration (org.eclipse.jdt.core.dom.ImplicitTypeDeclaration and org.eclipse.jdt.core.dom.TypeDeclaration are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @644648f7)
	at org.eclipse.jdt.ls.core.internal.handlers.PasteEventHandler.handleFilePasteEvent(PasteEventHandler.java:371)
	at org.eclipse.jdt.ls.core.internal.JDTDelegateCommandHandler.executeCommand(JDTDelegateCommandHandler.java:217)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:230)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:220)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:606)
	at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)

from pasting something as simple as public void test () {} or anything that lacks a proper type declaration.

@rgrunber rgrunber added the bug label Aug 13, 2024
Copy link
Contributor

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I like that it only generates the Untitled file when there is "something" substantial, like an actual method declaration.

@rgrunber rgrunber merged commit 949a9a2 into eclipse-jdtls:master Aug 13, 2024
6 checks passed
@hopehadfield hopehadfield deleted the fix-paste-feature branch August 15, 2024 19:17
@rgrunber rgrunber added this to the End August 2024 milestone Aug 27, 2024
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