Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
evie-lau committed Sep 12, 2023
1 parent 36b0831 commit e3549c6
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ repositories {
maven {
url = "https://cache-redirector.jetbrains.com/download-pgp-verifier"
}

mavenLocal() // TODO remove once Liberty LS is publicly available
}

Expand All @@ -68,7 +67,7 @@ dependencies {
implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j:0.15.0'
implementation 'org.eclipse.lemminx:org.eclipse.lemminx:0.25.0'
implementation 'io.openliberty.tools:liberty-langserver-lemminx:2.0'
implementation 'io.openliberty.tools:liberty-langserver:2.0'
implementation 'io.openliberty.tools:liberty-langserver:2.1-SNAPSHOT'
implementation 'org.eclipse.lsp4jakarta:org.eclipse.lsp4jakarta.ls:0.1.1'
//required by lsp4j as the version from IJ is incompatible
implementation 'com.google.code.gson:gson:2.8.9'
Expand Down Expand Up @@ -104,7 +103,7 @@ dependencies {
lsp('io.openliberty.tools:liberty-langserver-lemminx:2.0:jar-with-dependencies') {
transitive = false
}
lsp('io.openliberty.tools:liberty-langserver:2.0:jar-with-dependencies') {
lsp('io.openliberty.tools:liberty-langserver:2.1-SNAPSHOT:jar-with-dependencies') {
transitive = false
}
lsp('org.eclipse.lsp4jakarta:org.eclipse.lsp4jakarta.ls:0.1.1:jar-with-dependencies') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class LibertyConfigLanguageServer extends ProcessStreamConnectionProvider

public LibertyConfigLanguageServer() {
IdeaPluginDescriptor descriptor = PluginManagerCore.getPlugin(PluginId.getId("open-liberty.intellij"));
File libertyServerPath = new File(descriptor.getPluginPath().toFile(), "lib/server/liberty-langserver-2.0-jar-with-dependencies.jar");
File libertyServerPath = new File(descriptor.getPluginPath().toFile(), "lib/server/liberty-langserver-2.1-SNAPSHOT-jar-with-dependencies.jar");
String javaHome = System.getProperty("java.home");
if (javaHome == null) {
LOGGER.error("Unable to launch the Liberty language server. Could not resolve the java home system property");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.openliberty.tools.intellij.liberty.lsp;

import java.net.URI;
import java.util.List;
import java.util.stream.Collectors;

import org.jetbrains.annotations.NotNull;

import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;

import io.openliberty.tools.intellij.lsp4mp.lsp4ij.LSPIJUtils;

public class LibertyCustomConfigFileWatcher implements BulkFileListener {

@Override
public void after(@NotNull List<? extends VFileEvent> events) {
// handle the events
List<URI> pluginConfigList = events.stream().map(event -> LSPIJUtils.toUri(event.getFile()))
.filter(file -> isPluginConfigXml(file))
.collect(Collectors.toList());

pluginConfigList.forEach(fileURI -> processLibertyPluginConfigXml(fileURI));
}

private boolean isPluginConfigXml(URI uri) {
if (uri.getPath().endsWith("liberty-plugin-config.xml")) {
return true;
}
return false;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/lsp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
clientImpl="io.openliberty.tools.intellij.liberty.lsp.LibertyConfigLanguageClient"
serverInterface="org.eclipse.lsp4mp.ls.api.MicroProfileLanguageServerAPI"/>
<languageMapping language="Properties" serverId="libertyls"
filePattern="**/{src/main/liberty/config,usr/servers/**}/{bootstrap.properties,server.env}"/>
filePattern="**/{*.properties,*.env}"/>

<!-- Jakarta LS -->
<server id="jakartals" class="io.openliberty.tools.intellij.lsp4jakarta.lsp.JakartaLanguageServer"
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
beanClass="io.openliberty.tools.intellij.lsp4mp4ij.psi.core.java.validators.annotations.AnnotationRuleExtensionPointBean"/>
<extensionPoint name="javaCodeActionParticipant"
beanClass="io.openliberty.tools.intellij.lsp4mp4ij.psi.internal.core.java.codeaction.JavaCodeActionDefinition"/>
<extensionPoint name="customConfigWatcher"
beanClass=""/>
</extensionPoints>

<extensions defaultExtensionNs="open-liberty.intellij">
Expand Down Expand Up @@ -182,8 +184,14 @@
<attribute name="jitter" range="0"/> <!-- x >=0 -->
<attribute name="maxRetries" range="-1"/> <!-- x >=0 -->
</javaASTValidator.annotationValidator>
<customConfigWatcher></customConfigWatcher>
</extensions>

<applicationListeners>
<listener class="io.openliberty.tools.intellij.liberty.lsp.LibertyCustomConfigFileWatcher"
topic="com.intellij.openapi.vfs.newvfs.BulkFileListener"/>
</applicationListeners>

<projectListeners>
<listener class="io.openliberty.tools.intellij.runConfiguration.LibertyRunManagerListener"
topic="com.intellij.execution.RunManagerListener"/>
Expand Down

0 comments on commit e3549c6

Please sign in to comment.