Skip to content

Commit 3ab5f96

Browse files
committed
Динамическое определение файла bsl language server
1 parent fbe0587 commit 3ab5f96

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/main/java/org/github/_1c_syntax/intellij/bsl/BSLPreloadingActivity.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@
2323

2424
import com.github.gtache.lsp.client.languageserver.serverdefinition.ExeLanguageServerDefinition;
2525
import com.github.gtache.lsp.client.languageserver.serverdefinition.LanguageServerDefinition;
26-
import com.github.gtache.lsp.client.languageserver.serverdefinition.LanguageServerDefinition$;
26+
import com.intellij.notification.Notification;
27+
import com.intellij.notification.NotificationType;
28+
import com.intellij.notification.Notifications;
2729
import com.intellij.openapi.application.PathManager;
2830
import com.intellij.openapi.application.PreloadingActivity;
2931
import com.intellij.openapi.components.ServiceManager;
3032
import com.intellij.openapi.progress.ProgressIndicator;
3133
import org.github._1c_syntax.intellij.bsl.files.BSLFileType;
3234
import org.github._1c_syntax.intellij.bsl.files.OSFileType;
33-
import org.github._1c_syntax.intellij.bsl.psi.BSLFile;
3435
import org.github._1c_syntax.intellij.bsl.settings.LanguageServerSettingsState;
3536
import org.jetbrains.annotations.NotNull;
3637

38+
import java.io.File;
3739
import java.nio.file.Path;
3840
import java.nio.file.Paths;
3941
import java.util.ArrayList;
@@ -51,7 +53,23 @@ public void preload(@NotNull ProgressIndicator indicator) {
5153
}
5254

5355
String pluginsPath = PathManager.getPluginsPath();
54-
Path languageServer = Paths.get(pluginsPath, "Language 1C (BSL)", "lib", "bsl-language-server-0.1.0.jar");
56+
57+
File libDir = Paths.get(pluginsPath, "Language 1C (BSL)", "lib").toFile();
58+
File[] files = libDir.listFiles(
59+
(File dir, String name) -> name.startsWith("bsl-language-server-") && name.endsWith(".jar")
60+
);
61+
if (files == null || files.length == 0) {
62+
Notification notification = new Notification(
63+
"Language 1C (BSL)",
64+
"BSL Language server is not found",
65+
String.format("Check %s dir. Is plugin installed correctly?", libDir.getAbsolutePath()),
66+
NotificationType.ERROR
67+
);
68+
Notifications.Bus.notify(notification);
69+
return;
70+
}
71+
72+
Path languageServer = files[0].toPath().toAbsolutePath();
5573

5674
List<String> args = new ArrayList<>();
5775
args.add("-jar");

0 commit comments

Comments
 (0)