@@ -688,15 +688,18 @@ public int getParseCodeEditor(List<FileObject> context) {
688688 methodSignatures .put (signature , editorPane .getText ());
689689 } catch (Exception e ) {
690690 try {
691-
692- CompilationUnit edCu = StaticJavaParser . parse ( editorPane . getText () );
693- edCu .findAll (ClassOrInterfaceDeclaration .class )
691+ CompilationUnit aiCu = StaticJavaParser . parse ( editorPane . getText ());
692+ int classesCount = aiCu . findAll ( ClassOrInterfaceDeclaration . class ). size ( );
693+ aiCu .findAll (ClassOrInterfaceDeclaration .class )
694694 .forEach (classDecl -> {
695695 classes .add (classDecl .getNameAsString ());
696- methodSignatures .put (classDecl .getNameAsString (), classDecl .toString ());
696+ if (classesCount == 1 ) {
697+ methodSignatures .put (classDecl .getNameAsString (), aiCu .toString ());
698+ } else {
699+ methodSignatures .put (classDecl .getNameAsString (), classDecl .toString ());
700+ }
697701 });
698- // CompilationUnit edCu = StaticJavaParser.parse("class Tmp {" + editorPane.getText() + "}");
699- List <MethodDeclaration > edMethods = edCu .findAll (MethodDeclaration .class );
702+ List <MethodDeclaration > edMethods = aiCu .findAll (MethodDeclaration .class );
700703 for (MethodDeclaration edMethod : edMethods ) {
701704 String signature = edMethod .getNameAsString () + "("
702705 + edMethod .getParameters ().stream ()
@@ -705,14 +708,18 @@ public int getParseCodeEditor(List<FileObject> context) {
705708 methodSignatures .put (signature , edMethod .toString ());
706709 }
707710 } catch (Exception e1 ) {
708- CompilationUnit edCu = StaticJavaParser .parse (editorPane .getText ());
709- edCu .findAll (ClassOrInterfaceDeclaration .class )
710- .forEach (classDecl -> {
711- classes .add (classDecl .getNameAsString ());
712- methodSignatures .put (classDecl .getNameAsString (), classDecl .toString ());
713- });
714- if (edCu .getTypes ().isNonEmpty ()) {
715- methodSignatures .put (edCu .getType (0 ).getNameAsString (), edCu .toString ());
711+ try {
712+ CompilationUnit aiCu = StaticJavaParser .parse (editorPane .getText ());
713+ aiCu .findAll (ClassOrInterfaceDeclaration .class )
714+ .forEach (classDecl -> {
715+ classes .add (classDecl .getNameAsString ());
716+ methodSignatures .put (classDecl .getNameAsString (), classDecl .toString ());
717+ });
718+ if (aiCu .getTypes ().isNonEmpty ()) {
719+ methodSignatures .put (aiCu .getType (0 ).getNameAsString (), aiCu .toString ());
720+ }
721+ } catch (Exception e2 ) {
722+ // ignore
716723 }
717724 }
718725 }
@@ -727,17 +734,20 @@ public int getParseCodeEditor(List<FileObject> context) {
727734 methodSignatures .put (signature , editorPane .getText ());
728735 } catch (Exception e ) {
729736 try {
730- // CompilationUnit edCu = StaticJavaParser.parse("class Tmp {" + editorPane.getText() + "}");
731- CompilationUnit edCu = StaticJavaParser .parse (editorPane .getText ());
732- List <MethodDeclaration > edMethods = edCu .findAll (MethodDeclaration .class );
737+ CompilationUnit aiCu = StaticJavaParser .parse (editorPane .getText ());
738+ List <MethodDeclaration > edMethods = aiCu .findAll (MethodDeclaration .class );
733739 for (MethodDeclaration edMethod : edMethods ) {
734740 String signature = edMethod .getNameAsString ();
735741 methodSignatures .put (signature , edMethod .toString ());
736742 }
737743 } catch (Exception e1 ) {
738- CompilationUnit edCu = StaticJavaParser .parse (editorPane .getText ());
739- if (edCu .getTypes ().isNonEmpty ()) {
740- methodSignatures .put (edCu .getType (0 ).getNameAsString (), edCu .toString ());
744+ try {
745+ CompilationUnit aiCu = StaticJavaParser .parse (editorPane .getText ());
746+ if (aiCu .getTypes ().isNonEmpty ()) {
747+ methodSignatures .put (aiCu .getType (0 ).getNameAsString (), aiCu .toString ());
748+ }
749+ } catch (Exception e2 ) {
750+ // ignore
741751 }
742752 }
743753 }
0 commit comments