Skip to content

Commit f605796

Browse files
Fixed CodeLens displaying for Java project #455
1 parent 88bef0c commit f605796

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

ide-common/src/main/java/org/digma/intellij/plugin/document/CodeLensProvider.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.intellij.openapi.diagnostic.Logger;
44
import com.intellij.openapi.project.Project;
55
import com.intellij.psi.PsiFile;
6+
import org.apache.commons.lang3.StringUtils;
67
import org.digma.intellij.plugin.log.Log;
78
import org.digma.intellij.plugin.model.InsightImportance;
89
import 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

Comments
 (0)