33import com .intellij .openapi .diagnostic .Logger ;
44import com .intellij .openapi .project .Project ;
55import com .intellij .psi .PsiFile ;
6+ import org .apache .commons .lang3 .StringUtils ;
67import org .digma .intellij .plugin .log .Log ;
78import org .digma .intellij .plugin .model .InsightImportance ;
89import org .digma .intellij .plugin .model .lens .CodeLens ;
@@ -35,19 +36,21 @@ public List<CodeLens> provideCodeLens(@NotNull PsiFile psiFile) {
3536 }
3637
3738 var codeLens = buildCodeLens (documentInfo , false );
38- Log .log (LOGGER ::debug , "Got code lens for {}, {}" , psiFile .getVirtualFile (),codeLens );
39+ Log .log (LOGGER ::debug , "Got code lens for {}, {}" , psiFile .getVirtualFile (), codeLens );
3940 return codeLens ;
4041 }
4142
4243 private List <CodeLens > buildCodeLens (
43- @ NotNull DocumentInfoContainer documentInfo ,
44+ @ NotNull DocumentInfoContainer documentInfoContainer ,
4445 boolean environmentPrefix
4546 ) {
4647 List <CodeLens > codeLensList = new ArrayList <>();
4748
48- List <CodeObjectInsight > insightsList = documentInfo .getAllInsights ();
49+ List <CodeObjectInsight > methodInsightsList = documentInfoContainer .getDocumentInfo ().getMethods ().values ().stream ()
50+ .flatMap (methodInfo -> documentInfoService .getCachedMethodInsights (methodInfo ).stream ())
51+ .toList ();
4952
50- insightsList .forEach (insight -> {
53+ methodInsightsList .forEach (insight -> {
5154 if (insight .getDecorators () != null && insight .getDecorators ().size () > 0 ) {
5255 for (CodeObjectDecorator decorator : insight .getDecorators ()) {
5356 String envComponent = "" ;
@@ -62,7 +65,7 @@ private List<CodeLens> buildCodeLens(
6265
6366 String title = priorityEmoji + decorator .getTitle () + " " + envComponent ;
6467
65- CodeLens codeLen = new CodeLens (insight . getCodeObjectId ( ), title , insight .getImportance ());
68+ CodeLens codeLen = new CodeLens (getMethodCodeObjectId ( insight ), title , insight .getImportance ());
6669 codeLen .setLensDescription (decorator .getDescription ());
6770 codeLen .setLensMoreText ("Go to " + title );
6871 codeLen .setAnchor ("Top" );
@@ -75,6 +78,14 @@ private List<CodeLens> buildCodeLens(
7578 return codeLensList ;
7679 }
7780
81+ private String getMethodCodeObjectId (CodeObjectInsight insight ) {
82+ if (StringUtils .isNotEmpty (insight .getPrefixedCodeObjectId ())) {
83+ return insight .getPrefixedCodeObjectId ().replace ("method:" , "" );
84+ } else {
85+ return insight .getCodeObjectId ();
86+ }
87+ }
88+
7889 private boolean isImportant (Integer importanceLevel ) {
7990 return importanceLevel <= InsightImportance .HighlyImportant .getPriority () &&
8091 importanceLevel >= InsightImportance .ShowStopper .getPriority ();
0 commit comments