diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/PasteEventHandler.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/PasteEventHandler.java index e9b0663ecc..810f194cd0 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/PasteEventHandler.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/PasteEventHandler.java @@ -367,7 +367,7 @@ public static String handleFilePasteEvent(String path, String content, IProgress } String possibleFileName = "Untitled"; - if (!root.types().isEmpty()) { + if (!root.types().isEmpty() && root.types().get(0) instanceof TypeDeclaration) { possibleFileName = ((TypeDeclaration) root.types().get(0)).getName().getIdentifier(); } if (Files.exists(Paths.get(desiredPath, possibleFileName + ".java"))) {