Skip to content

Commit 107e49e

Browse files
Remove popup when switching environments (#204) + fix general refresh button
1 parent e3356b9 commit 107e49e

File tree

7 files changed

+13
-19
lines changed

7 files changed

+13
-19
lines changed

ide-common/src/main/java/org/digma/intellij/plugin/analytics/Environment.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.apache.commons.lang3.time.StopWatch;
66
import org.digma.intellij.plugin.common.Backgroundable;
77
import org.digma.intellij.plugin.log.Log;
8-
import org.digma.intellij.plugin.notifications.NotificationUtil;
98
import org.digma.intellij.plugin.persistence.PersistenceData;
109
import org.digma.intellij.plugin.settings.SettingsState;
1110
import org.digma.intellij.plugin.ui.model.environment.EnvironmentsSupplier;
@@ -248,7 +247,7 @@ private void notifyEnvironmentChanged(String oldEnv, String newEnv) {
248247
if (project.isDisposed()) {
249248
return;
250249
}
251-
NotificationUtil.notifyChangingEnvironment(project, oldEnv, newEnv);
250+
Log.log(LOGGER::info, "Digma: Changing environment " + oldEnv + " to " + newEnv);
252251
EnvironmentChanged publisher = project.getMessageBus().syncPublisher(EnvironmentChanged.ENVIRONMENT_CHANGED_TOPIC);
253252
publisher.environmentChanged(newEnv);
254253
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ public void update(@NotNull DocumentInfo documentInfo) {
6262
//maybe documentInfo already exists, override it anyway with a new one from analysis
6363
this.documentInfo = documentInfo;
6464

65-
loadAllInsightsForCurrentEnvironment();
65+
loadAllInsightsForCurrentDocument();
6666
}
6767

6868
public void refresh() {
6969
Log.log(LOGGER::debug, "Refreshing document backend data for {}: ", psiFile.getVirtualFile());
70-
loadAllInsightsForCurrentEnvironment();
70+
loadAllInsightsForCurrentDocument();
7171
}
7272

73-
public List<CodeObjectInsight> getMethodInsights(@NotNull MethodInfo methodInfo) {
73+
public List<CodeObjectInsight> getMethodInsightsFromCache(@NotNull MethodInfo methodInfo) {
7474
Log.log(LOGGER::debug, "Requesting insights for MethodInfo {}", methodInfo.getId());
7575

7676
return insights.stream().filter(codeObjectInsight -> {
@@ -82,8 +82,8 @@ public List<CodeObjectInsight> getMethodInsights(@NotNull MethodInfo methodInfo)
8282
}).collect(Collectors.toList());
8383
}
8484

85-
private void loadAllInsightsForCurrentEnvironment() {
86-
List<String> objectIds = getObjectIds();
85+
private void loadAllInsightsForCurrentDocument() {
86+
List<String> objectIds = getObjectIdsForCurrentDocument();
8787
try {
8888
Log.log(LOGGER::debug, "Requesting insights with ids {}", objectIds);
8989
insights = analyticsService.getInsights(objectIds);
@@ -108,7 +108,7 @@ private void loadAllInsightsForCurrentEnvironment() {
108108
}
109109
}
110110

111-
private List<String> getObjectIds() {
111+
private List<String> getObjectIdsForCurrentDocument() {
112112
return this.documentInfo.getMethods().values().stream().flatMap((Function<MethodInfo, Stream<String>>) methodInfo -> {
113113
var ids = new ArrayList<String>();
114114
ids.add(methodInfo.idWithType());

ide-common/src/main/java/org/digma/intellij/plugin/insights/InsightsProvider.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.apache.commons.lang3.time.StopWatch;
66
import org.digma.intellij.plugin.analytics.AnalyticsService;
77
import org.digma.intellij.plugin.analytics.AnalyticsServiceException;
8-
import org.digma.intellij.plugin.document.DocumentInfoContainer;
98
import org.digma.intellij.plugin.document.DocumentInfoService;
109
import org.digma.intellij.plugin.insights.view.BuildersHolder;
1110
import org.digma.intellij.plugin.insights.view.InsightsViewBuilder;
@@ -45,12 +44,8 @@ public InsightsListContainer getInsights(@NotNull MethodInfo methodInfo) {
4544
var stopWatch = StopWatch.createStarted();
4645

4746
try {
48-
DocumentInfoContainer documentInfoContainer = documentInfoService.getDocumentInfo(methodInfo.getContainingFileUri());
49-
List<? extends CodeObjectInsight> codeObjectInsights = new ArrayList<>();
50-
if (documentInfoContainer != null) {
51-
codeObjectInsights = documentInfoContainer.getMethodInsights(methodInfo);
52-
codeObjectInsights = filterUnmapped(codeObjectInsights);
53-
}
47+
List<? extends CodeObjectInsight> codeObjectInsights = analyticsService.getInsights(objectIds);
48+
codeObjectInsights = filterUnmapped(codeObjectInsights);
5449
Log.log(LOGGER::debug, "CodeObjectInsights for {}: {}", methodInfo.getId(), codeObjectInsights);
5550
final UsageStatusResult usageStatus = analyticsService.getUsageStatus(objectIds);
5651
InsightsViewBuilder insightsViewBuilder = new InsightsViewBuilder(buildersHolder);

ide-common/src/main/kotlin/org/digma/intellij/plugin/ui/service/InsightsViewService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class InsightsViewService(project: Project) : AbstractViewService(project) {
165165

166166
}
167167

168-
fun refreshInsights() {
168+
fun refreshAllInsights() {
169169
val scope = model.scope
170170
if (scope is MethodScope) {
171171
Backgroundable.ensureBackground(project, "Refresh insights list") {

java/src/main/java/org/digma/intellij/plugin/idea/psi/java/JavaSpanNavigationProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void buildSpanNavigation() {
8888
//for example is the IDE is closed when the cursor is on a method with Duration Breakdown that
8989
// has span links, then start the IDE again, the insights view is populted already, without this refresh
9090
// there will be no links.
91-
project.getService(InsightsViewService.class).refreshInsights();
91+
project.getService(InsightsViewService.class).refreshAllInsights();
9292
project.getService(ErrorsViewService.class).refreshErrors();
9393

9494
} finally {

src/main/kotlin/org/digma/intellij/plugin/ui/common/Panels.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private fun getGeneralRefreshButton(project: Project): JButton {
118118

119119
generalRefreshIconButton.addMouseListener(object : MouseAdapter() {
120120
override fun mouseClicked(e: MouseEvent?) {
121-
insightsActionListener.refreshInsights()
121+
insightsActionListener.refreshAllInsights()
122122
errorsActionListener.refreshErrors()
123123
}
124124
})

src/main/kotlin/org/digma/intellij/plugin/ui/list/insights/InsightsCommon.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ private fun getRefreshButton(insightPanel: DigmaResettablePanel, project: Projec
321321
val refreshAction = ActionLink(REFRESH)
322322
refreshAction.addActionListener {
323323
val actionListener: InsightsViewService = project.getService(InsightsViewService::class.java)
324-
actionListener.refreshInsights()
324+
actionListener.refreshAllInsights()
325325
rebuildInsightPanel(insightPanel)
326326
}
327327
refreshAction.border = empty()

0 commit comments

Comments
 (0)