-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Provide UI settings for Language Servers (#843)
Fixes #843 Signed-off-by: azerr <[email protected]>
- Loading branch information
1 parent
39fb795
commit fbc7788
Showing
14 changed files
with
662 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/com/redhat/devtools/intellij/quarkus/lsp4ij/LanguageServerBundle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Red Hat Inc. and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
* which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package com.redhat.devtools.intellij.quarkus.lsp4ij; | ||
|
||
import com.intellij.DynamicBundle; | ||
import com.intellij.json.JsonBundle; | ||
import org.jetbrains.annotations.Nls; | ||
import org.jetbrains.annotations.NonNls; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.PropertyKey; | ||
|
||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Language server messages bundle. | ||
*/ | ||
public final class LanguageServerBundle extends DynamicBundle { | ||
|
||
@NonNls public static final String BUNDLE = "messages.LanguageServerBundle"; | ||
private static final LanguageServerBundle INSTANCE = new LanguageServerBundle(); | ||
|
||
private LanguageServerBundle() { | ||
super(BUNDLE); | ||
} | ||
|
||
@NotNull | ||
public static @Nls String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) { | ||
return INSTANCE.getMessage(key, params); | ||
} | ||
|
||
@NotNull | ||
public static Supplier<@Nls String> messagePointer(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) { | ||
return INSTANCE.getLazyMessage(key, params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...in/java/com/redhat/devtools/intellij/quarkus/lsp4ij/server/JavaProcessCommandBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Red Hat, Inc. | ||
* Distributed under license by Red Hat, Inc. All rights reserved. | ||
* This program is made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, | ||
* and is available at https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package com.redhat.devtools.intellij.quarkus.lsp4ij.server; | ||
|
||
import com.redhat.devtools.intellij.quarkus.lsp4ij.settings.LanguageServerSettingsState; | ||
|
||
import java.io.File; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.regex.Pattern; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* A builder to create Java process command. | ||
*/ | ||
public class JavaProcessCommandBuilder { | ||
|
||
private final String languageId; | ||
|
||
private String javaPath; | ||
|
||
private String debugPort; | ||
|
||
private boolean debugSuspend; | ||
private String jar; | ||
|
||
private String cp; | ||
|
||
public JavaProcessCommandBuilder(String languageId) { | ||
this.languageId = languageId; | ||
setJavaPath(computeJavaPath()); | ||
LanguageServerSettingsState.LanguageServerDefinitionSettings settings = LanguageServerSettingsState.getInstance().getLanguageServerSettings(languageId); | ||
if (settings != null) { | ||
setDebugPort(settings.getDebugPort()); | ||
setDebugSuspend(settings.isDebugSuspend()); | ||
} | ||
} | ||
|
||
public JavaProcessCommandBuilder setJavaPath(String javaPath) { | ||
this.javaPath = javaPath; | ||
return this; | ||
} | ||
|
||
public JavaProcessCommandBuilder setDebugPort(String debugPort) { | ||
this.debugPort = debugPort; | ||
return this; | ||
} | ||
|
||
public JavaProcessCommandBuilder setDebugSuspend(boolean debugSuspend) { | ||
this.debugSuspend = debugSuspend; | ||
return this; | ||
} | ||
|
||
public JavaProcessCommandBuilder setJar(String jar) { | ||
this.jar = jar; | ||
return this; | ||
} | ||
|
||
public JavaProcessCommandBuilder setCp(String cp) { | ||
this.cp = cp; | ||
return this; | ||
} | ||
|
||
public List<String> create() { | ||
List<String> commands = new ArrayList<>(); | ||
commands.add(computeJavaPath()); | ||
if (debugPort != null && !debugPort.isEmpty()) { | ||
String suspend = debugSuspend ? "y" : "n"; | ||
commands.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=" + suspend + ",address=" + debugPort); | ||
} | ||
if(jar != null) { | ||
commands.add("-jar"); | ||
commands.add(jar); | ||
} | ||
if(cp != null) { | ||
commands.add("-cp"); | ||
commands.add(cp); | ||
} | ||
return commands; | ||
} | ||
|
||
private static String computeJavaPath() { | ||
String javaPath = "java"; | ||
boolean existsInPath = Stream.of(System.getenv("PATH").split(Pattern.quote(File.pathSeparator))).map(Paths::get) | ||
.anyMatch(path -> Files.exists(path.resolve("java"))); | ||
if (!existsInPath) { | ||
File f = new File(System.getProperty("java.home"), | ||
"bin/java" + (OS.current() == OS.WINDOWS ? ".exe" : "")); | ||
javaPath = f.getAbsolutePath(); | ||
} | ||
return javaPath; | ||
} | ||
} |
43 changes: 0 additions & 43 deletions
43
...m/redhat/devtools/intellij/quarkus/lsp4ij/server/JavaProcessStreamConnectionProvider.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.