Skip to content

Commit dde3d8f

Browse files
committed
cleanup
1 parent 046995c commit dde3d8f

File tree

2 files changed

+46
-54
lines changed

2 files changed

+46
-54
lines changed

jetbrains/.run/Run Plugin in IDE.run.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<component name="ProjectRunConfigurationManager">
2-
<configuration default="false" name="Run Plugin in IDE" type="GradleRunConfiguration" factoryName="Gradle" show_console_on_std_err="true" show_console_on_std_out="true">
2+
<configuration default="false" name="Run Plugin in IDE" type="GradleRunConfiguration" factoryName="Gradle">
33
<log_file alias="IDE logs" path="$PROJECT_DIR$/build/idea-sandbox/*/log/idea.log" show_all="true" />
44
<ExternalSystemSettings>
55
<option name="env">
66
<map>
77
<entry key="JETBRAINS_PROJECT_DIR" value="$PROJECT_DIR$" />
8-
<!-- <entry key="VSCODE_DEBUG_MODE" value="true" />-->
8+
<entry key="VSCODE_DEBUG_MODE" value="true" />
99
</map>
1010
</option>
1111
<option name="executionName" />
@@ -20,7 +20,6 @@
2020
<option value="runIde" />
2121
</list>
2222
</option>
23-
<option name="vmOptions" value="-Didea.log.console.stdout.level=DEBUG -Didea.log.debug.categories=#com.boundaryml.jetbrains_ext.BamlLanguageClient" />
2423
</ExternalSystemSettings>
2524
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
2625
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>

jetbrains/src/main/kotlin/com/boundaryml/jetbrains_ext/BamlLanguageClient.kt

Lines changed: 44 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class BamlLanguageClient(project: Project) :
5252
// Phase 2: Full version switching notification processing
5353
@JsonNotification("baml_src_generator_version")
5454
fun generatorVersionNotification(payload: GeneratorVersionPayload) {
55-
log.info("🔄 PROCESSING generator version notification: ${payload.version} for ${payload.root_path}")
55+
log.info("🔄 language server requested that we run a different version: $payload")
5656

5757
// Process in background to avoid blocking LSP communication
5858
ApplicationManager.getApplication().executeOnPooledThread {
@@ -61,63 +61,56 @@ class BamlLanguageClient(project: Project) :
6161
}
6262

6363
private fun processVersionSwitchRequest(payload: GeneratorVersionPayload) {
64-
try {
65-
log.info("Processing version switch request: ${payload.version}")
66-
67-
if (BamlIdeConfig.shouldIgnoreLanguageServerDynamicVersioning()) {
68-
log.warn("Debug mode detected - skipping version switching to preserve existing debug logic")
69-
return
70-
}
71-
72-
// 1. Validate notification is for current project (equivalent to VSCode's isPathWithinParent)
73-
if (!isNotificationForCurrentProject(payload.root_path)) {
74-
log.debug("Ignoring version notification for different project: ${payload.root_path}")
75-
return
76-
}
64+
if (BamlIdeConfig.shouldIgnoreLanguageServerDynamicVersioning()) {
65+
log.info("Running in development mode, ignoring version switch request")
66+
return
67+
}
7768

78-
// 2. Check if restart already in progress (equivalent to VSCode's isRestarting flag)
79-
if (languageServerService.isCurrentlyRestarting()) {
80-
log.info("Language server restart already in progress, ignoring request")
81-
return
82-
}
69+
// 1. Validate notification is for current project (equivalent to VSCode's isPathWithinParent)
70+
if (!isNotificationForCurrentProject(payload.root_path)) {
71+
log.debug("Ignoring version notification for different project: ${payload.root_path}")
72+
return
73+
}
8374

84-
// 3. Validate semantic version (equivalent to VSCode's semver.valid check)
85-
if (!isValidSemanticVersion(payload.version)) {
86-
log.warn("Invalid semantic version received: ${payload.version}")
87-
return
88-
}
75+
// 2. Check if restart already in progress (equivalent to VSCode's isRestarting flag)
76+
if (languageServerService.isCurrentlyRestarting()) {
77+
log.info("Language server restart already in progress, ignoring request")
78+
return
79+
}
8980

90-
// 4. Check minimum version requirement (equivalent to VSCode's >= 0.86.0 check)
91-
if (!isMinimumVersionSupported(payload.version)) {
92-
log.warn("Ignoring version ${payload.version} - below minimum supported version")
93-
return
94-
}
81+
// 3. Validate semantic version (equivalent to VSCode's semver.valid check)
82+
if (!isValidSemanticVersion(payload.version)) {
83+
log.warn("Invalid semantic version received: ${payload.version}")
84+
return
85+
}
9586

96-
// 5. Resolve target CLI path (equivalent to VSCode's resolveCliPath call)
97-
runBlocking {
98-
// 6. Check if restart is needed (equivalent to VSCode's path comparison)
99-
if (languageServerService.getCurrentCliVersion() != payload.version) {
100-
// Update version tracking even if no restart needed
101-
languageServerService.updateCurrentServer(payload.version)
102-
// 7. Execute restart (equivalent to VSCode's executeLanguageServerRestart)
103-
log.info("Restarting language server with new version")
104-
service<BamlLanguageServerService>().setRestartingFlag(true)
105-
// https://github.com/redhat-developer/lsp4ij/blob/main/docs/DeveloperGuide.md#install-language-server
106-
// Stops the language server if it is currently starting or already started.
107-
//Resets the installer's internal state.
108-
//Executes the installation via checkInstallation(context).
109-
//If the server was previously running, it restarts it once the installation completes.
110-
val context = ServerInstallationContext()
111-
.setForceInstall(true)
112-
LanguageServerManager.getInstance(project)
113-
.install("baml-language-server", context)
114-
}
115-
log.info("Already using correct CLI version, no restart needed")
87+
// 4. Check minimum version requirement (equivalent to VSCode's >= 0.86.0 check)
88+
if (!isMinimumVersionSupported(payload.version)) {
89+
log.warn("Ignoring version ${payload.version} - below minimum supported version")
90+
return
91+
}
11692

93+
// 5. Resolve target CLI path (equivalent to VSCode's resolveCliPath call)
94+
runBlocking {
95+
// 6. Check if restart is needed (equivalent to VSCode's path comparison)
96+
if (languageServerService.getCurrentCliVersion() != payload.version) {
97+
// Update version tracking even if no restart needed
98+
languageServerService.updateCurrentServer(payload.version)
99+
// 7. Execute restart (equivalent to VSCode's executeLanguageServerRestart)
100+
log.info("Restarting language server with new version")
101+
service<BamlLanguageServerService>().setRestartingFlag(true)
102+
// https://github.com/redhat-developer/lsp4ij/blob/main/docs/DeveloperGuide.md#install-language-server
103+
// Stops the language server if it is currently starting or already started.
104+
//Resets the installer's internal state.
105+
//Executes the installation via checkInstallation(context).
106+
//If the server was previously running, it restarts it once the installation completes.
107+
val context = ServerInstallationContext()
108+
.setForceInstall(true)
109+
LanguageServerManager.getInstance(project)
110+
.install("baml-language-server", context)
117111
}
112+
log.info("Already using correct CLI version, no restart needed")
118113

119-
} catch (e: Exception) {
120-
log.error("Error processing version switch request", e)
121114
}
122115
}
123116

0 commit comments

Comments
 (0)