diff --git a/src/main/java/io/github/jeddict/ai/components/AssistantTopComponent.java b/src/main/java/io/github/jeddict/ai/components/AssistantTopComponent.java index a262680..03b855a 100644 --- a/src/main/java/io/github/jeddict/ai/components/AssistantTopComponent.java +++ b/src/main/java/io/github/jeddict/ai/components/AssistantTopComponent.java @@ -18,6 +18,8 @@ */ package io.github.jeddict.ai.components; +import com.github.javaparser.ParserConfiguration; +import com.github.javaparser.ParserConfiguration.LanguageLevel; import com.github.javaparser.ast.CompilationUnit; import static io.github.jeddict.ai.util.EditorUtil.getExtension; import static io.github.jeddict.ai.util.EditorUtil.isSuitableForWebAppDirectory; @@ -64,10 +66,8 @@ import javax.lang.model.element.Name; import java.io.IOException; import java.io.InputStream; -import java.io.Reader; import java.io.StringReader; import java.util.ArrayList; -import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.SwingUtilities; import javax.swing.text.BadLocationException; @@ -86,7 +86,6 @@ import org.openide.loaders.DataObject; import org.openide.loaders.DataObjectNotFoundException; import org.openide.windows.TopComponent; -import javax.swing.filechooser.FileSystemView; import javax.swing.text.JTextComponent; import javax.swing.text.StyledDocument; import org.netbeans.api.editor.EditorRegistry; @@ -388,6 +387,7 @@ public int getAllCodeEditorCount() { } public int getParseCodeEditor(List fileObjects) { + StaticJavaParser.getParserConfiguration().setLanguageLevel(ParserConfiguration.LanguageLevel.JAVA_21); Map> editorMethodSignCache = new HashMap<>(); Map> editorMethodCache = new HashMap<>(); for (FileObject fileObject : fileObjects) { diff --git a/src/main/java/io/github/jeddict/ai/util/SourceUtil.java b/src/main/java/io/github/jeddict/ai/util/SourceUtil.java index e0ad0aa..6971ff8 100644 --- a/src/main/java/io/github/jeddict/ai/util/SourceUtil.java +++ b/src/main/java/io/github/jeddict/ai/util/SourceUtil.java @@ -18,6 +18,8 @@ */ package io.github.jeddict.ai.util; +import com.github.javaparser.ParserConfiguration; +import com.github.javaparser.StaticJavaParser; import com.sun.source.tree.ClassTree; import com.sun.source.tree.CompilationUnitTree; import com.sun.source.tree.ImportTree; @@ -26,11 +28,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.List; -import javax.swing.text.BadLocationException; import org.json.JSONArray; import org.netbeans.api.java.source.JavaSource; import org.netbeans.api.java.source.TreeMaker; @@ -44,8 +42,8 @@ */ public class SourceUtil { - public static void fixImports(FileObject fileObject) { - // TODO + static { + StaticJavaParser.getParserConfiguration().setLanguageLevel(ParserConfiguration.LanguageLevel.JAVA_21); } public static void printSource(FileObject fileObject) {