Skip to content

Commit 1e2e6e3

Browse files
Merge pull request #11182 from srnagar/misc-fixes
Fix maven report background thread exception and update logs
2 parents 49d50c6 + 56cc9bb commit 1e2e6e3

File tree

6 files changed

+65
-42
lines changed

6 files changed

+65
-42
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ All notable changes to "Azure Toolkit for IntelliJ IDEA" will be documented in t
119119
- [3.0.6](#306)
120120

121121
## 3.96.0
122+
- Configure Azure MCP server for GitHub Copilot
122123
- Integrate azd to Azure Explorer
123-
- Fix some known issues.
124+
- Fix some known issues
124125

125126
## 3.95.0
126127
- Update function cdn uri

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-azuremcp/src/main/java/com/microsoft/azure/toolkit/intellij/azuremcp/AzureMcpPackageManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public synchronized File getAzureMcpExecutable() {
7777
}
7878
}
7979
} catch (final IOException e) {
80-
System.err.println("Error reading Azure MCP Server version: " + e.getMessage());
80+
log.error("Error getting Azure MCP executable: " + e.getMessage());
81+
AzureMcpUtils.logErrorTelemetryEvent("azmcp-get-executable", e);
8182
}
8283
return null;
8384
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.microsoft.azure.toolkit.intellij.azuremcp;
2+
3+
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
4+
import com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemeter;
5+
import com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemetry;
6+
import org.apache.commons.lang3.exception.ExceptionUtils;
7+
8+
import java.util.Map;
9+
10+
public final class AzureMcpUtils {
11+
12+
private static final String GHCP_MCP_INITIALIZER = "GHCP_MCP_INITIALIZER";
13+
14+
private AzureMcpUtils() {
15+
}
16+
17+
public static void logTelemetryEvent(String eventName) {
18+
Map<String, String> properties = Map.of(
19+
AzureTelemeter.OP_NAME, eventName,
20+
AzureTelemeter.OP_PARENT_ID, GHCP_MCP_INITIALIZER,
21+
AzureTelemeter.OPERATION_NAME, eventName, // what's the difference between OP_NAME and OPERATION_NAME?
22+
AzureTelemeter.SERVICE_NAME, GHCP_MCP_INITIALIZER
23+
);
24+
AzureTaskManager.getInstance().runLater(() -> {
25+
AzureTelemeter.log(AzureTelemetry.Type.INFO, properties);
26+
});
27+
}
28+
29+
public static void logErrorTelemetryEvent(String eventName, Exception ex) {
30+
Map<String, String> properties = Map.of(
31+
AzureTelemeter.OP_NAME, eventName,
32+
AzureTelemeter.OP_PARENT_ID, GHCP_MCP_INITIALIZER,
33+
AzureTelemeter.OPERATION_NAME, eventName, // what's the difference between OP_NAME and OPERATION_NAME?
34+
AzureTelemeter.SERVICE_NAME, GHCP_MCP_INITIALIZER,
35+
AzureTelemeter.ERROR_STACKTRACE, ExceptionUtils.getStackTrace(ex)
36+
);
37+
AzureTaskManager.getInstance().runLater(() -> {
38+
AzureTelemeter.log(AzureTelemetry.Type.ERROR, properties);
39+
});
40+
}
41+
}

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-azuremcp/src/main/java/com/microsoft/azure/toolkit/intellij/azuremcp/GithubCopilotMcpInitializer.java

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@
1313
import com.intellij.openapi.startup.ProjectActivity;
1414
import com.intellij.openapi.util.SystemInfo;
1515
import com.intellij.openapi.util.registry.Registry;
16-
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
17-
import com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemeter;
18-
import com.microsoft.azure.toolkit.lib.common.telemetry.AzureTelemetry;
1916
import kotlin.Unit;
2017
import kotlin.coroutines.Continuation;
2118
import lombok.extern.slf4j.Slf4j;
22-
import org.apache.commons.lang3.exception.ExceptionUtils;
2319
import org.apache.maven.artifact.versioning.ComparableVersion;
2420
import org.jetbrains.annotations.NotNull;
2521

@@ -30,6 +26,9 @@
3026
import java.util.HashMap;
3127
import java.util.Map;
3228

29+
import static com.microsoft.azure.toolkit.intellij.azuremcp.AzureMcpUtils.logErrorTelemetryEvent;
30+
import static com.microsoft.azure.toolkit.intellij.azuremcp.AzureMcpUtils.logTelemetryEvent;
31+
3332
@Slf4j
3433
public class GithubCopilotMcpInitializer implements ProjectActivity, DumbAware, ProjectManagerListener {
3534
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()
@@ -39,7 +38,6 @@ public class GithubCopilotMcpInitializer implements ProjectActivity, DumbAware,
3938
.enable(SerializationFeature.INDENT_OUTPUT);
4039

4140
private static final ComparableVersion LOWEST_SUPPORTED_COPILOT_VERSION = new ComparableVersion("1.5.50");
42-
private static final String GHCP_MCP_INITIALIZER = "GitHubCopilotMcpInitializer";
4341
private static final String COPILOT_PLUGIN_ID = "com.github.copilot";
4442
private final AzureMcpPackageManager azureMcpPackageManager;
4543

@@ -71,7 +69,7 @@ public Object execute(@NotNull Project project, @NotNull Continuation<? super Un
7169
private boolean isCopilotMcpSupported() {
7270
// Get all installed plugins
7371
final IdeaPluginDescriptor[] installedPlugins = PluginManagerCore.getPlugins();
74-
boolean copilotMcpSupported = Arrays.stream(installedPlugins)
72+
final boolean copilotMcpSupported = Arrays.stream(installedPlugins)
7573
.anyMatch(plugin -> {
7674
final boolean copilotPluginInstalled = COPILOT_PLUGIN_ID.equals(plugin.getPluginId().getIdString());
7775
return copilotPluginInstalled && isMcpSupported(plugin.getVersion());
@@ -115,7 +113,10 @@ private void configureMcpServer(File azMcpExe) throws Exception {
115113
final McpServer azureMcpServer = new McpServer();
116114
azureMcpServer.setCommand(azMcpExe.getAbsolutePath());
117115
azureMcpServer.setArgs(Arrays.asList("server", "start"));
118-
servers.put("Azure MCP Server", azureMcpServer);
116+
if (servers.containsKey("Azure MCP Server")) {
117+
servers.remove("Azure MCP Server");
118+
}
119+
servers.put("Azure MCP Server IntelliJ", azureMcpServer);
119120
Files.writeString(mcpConfigPath, OBJECT_MAPPER.writeValueAsString(mcpConfig));
120121
logTelemetryEvent("azmcp-copilot-initialization-success");
121122
}
@@ -156,29 +157,4 @@ private File getConfigPath() {
156157
}
157158
return configPath;
158159
}
159-
160-
public static void logTelemetryEvent(String eventName) {
161-
Map<String, String> properties = Map.of(
162-
AzureTelemeter.OP_NAME, eventName,
163-
AzureTelemeter.OP_PARENT_ID, GHCP_MCP_INITIALIZER,
164-
AzureTelemeter.OPERATION_NAME, eventName, // what's the difference between OP_NAME and OPERATION_NAME?
165-
AzureTelemeter.SERVICE_NAME, GHCP_MCP_INITIALIZER
166-
);
167-
AzureTaskManager.getInstance().runLater(() -> {
168-
AzureTelemeter.log(AzureTelemetry.Type.INFO, properties);
169-
});
170-
}
171-
172-
public static void logErrorTelemetryEvent(String eventName, Exception ex) {
173-
Map<String, String> properties = Map.of(
174-
AzureTelemeter.OP_NAME, eventName,
175-
AzureTelemeter.OP_PARENT_ID, GHCP_MCP_INITIALIZER,
176-
AzureTelemeter.OPERATION_NAME, eventName, // what's the difference between OP_NAME and OPERATION_NAME?
177-
AzureTelemeter.SERVICE_NAME, GHCP_MCP_INITIALIZER,
178-
AzureTelemeter.ERROR_STACKTRACE, ExceptionUtils.getStackTrace(ex)
179-
);
180-
AzureTaskManager.getInstance().runLater(() -> {
181-
AzureTelemeter.log(AzureTelemetry.Type.ERROR, properties);
182-
});
183-
}
184160
}

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-java-sdk/src/main/java/com/microsoft/azure/toolkit/intellij/java/sdk/MavenProjectReportGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public MavenProjectReportGenerator() {
8383
@Nullable
8484
@Override
8585
public Object execute(@Nonnull Project project, @Nonnull Continuation<? super Unit> continuation) {
86-
scheduledExecutor.schedule(() -> generateReport(project), INITIAL_DELAY_IN_MINUTES, TimeUnit.MINUTES);
86+
scheduledExecutor.schedule(() -> ApplicationManager.getApplication().runReadAction(() -> generateReport(project)),
87+
INITIAL_DELAY_IN_MINUTES, TimeUnit.MINUTES);
8788
return null;
8889
}
8990

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-lib/src/main/java/com/microsoft/azure/toolkit/intellij/common/component/TreeUtils.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,17 @@ public void mouseMoved(MouseEvent e) {
126126
final MouseAdapter popupHandler = new MouseAdapter() {
127127
@Override
128128
public void mouseClicked(MouseEvent e) {
129-
final Object n = tree.getLastSelectedPathComponent();
130-
if (n instanceof Tree.TreeNode) {
131-
final Tree.TreeNode<?> node = (Tree.TreeNode<?>) n;
132-
clickNode(e, node);
133-
} else if (n instanceof Tree.LoadMoreNode && SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
134-
((Tree.LoadMoreNode) n).load();
129+
final TreePath pathForLocation = tree.getPathForLocation(e.getX(), e.getY());
130+
if (pathForLocation != null) {
131+
final Object n = pathForLocation.getLastPathComponent();
132+
if (n instanceof Tree.TreeNode) {
133+
final Tree.TreeNode<?> node = (Tree.TreeNode<?>) n;
134+
clickNode(e, node);
135+
} else if (n instanceof Tree.LoadMoreNode && SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
136+
((Tree.LoadMoreNode) n).load();
137+
}
138+
super.mouseClicked(e);
135139
}
136-
super.mouseClicked(e);
137140
}
138141

139142
@AzureOperation(name = "user/$resource.click_node.resource", params = {"node.inner.getValue()"}, source = "node.inner.getValue()")

0 commit comments

Comments
 (0)