Skip to content

Commit

Permalink
Merge the changes from the main branch.
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Gooderham <turkeyonmarblerye@gmail.com>
  • Loading branch information
turkeylurkey committed Oct 24, 2023
2 parents cf80996 + 076a924 commit 8443170
Show file tree
Hide file tree
Showing 53 changed files with 1,453 additions and 493 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: '**'
pull_request:
branches: [ main ]
branches: [ main, code-action-unification ]

jobs:
build:
Expand Down Expand Up @@ -62,4 +62,4 @@ jobs:
./**/*liberty-tools-intellij*.zip
./**/libs/*liberty-tools-intellij*.jar
if-no-files-found: warn
retention-days: 7
retention-days: 7
23 changes: 14 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,16 @@ configurations {
}

dependencies {
// LSP4IJ dependencies
implementation 'org.microshed:lsp4ij:0.0.5'
implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j:0.15.0'
implementation 'org.microshed:lsp4ij:0.0.5' // includes org.eclipse.lsp4j
implementation ('org.eclipse.lsp4mp:org.eclipse.lsp4mp.ls:0.6.0') {
exclude group: 'org.eclipse.lsp4j'
}
// implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j:0.15.0'
implementation ('org.eclipse.lemminx:org.eclipse.lemminx:0.25.0') {
exclude group: 'org.eclipse.lsp4j'
}
implementation 'io.openliberty.tools:liberty-langserver-lemminx:2.0'
implementation ('io.openliberty.tools:liberty-langserver:2.0') {
implementation 'io.openliberty.tools:liberty-langserver-lemminx:2.1-SNAPSHOT'
implementation ('io.openliberty.tools:liberty-langserver:2.1-SNAPSHOT') {
exclude group: 'org.eclipse.lsp4j'
}
implementation ('org.eclipse.lsp4jakarta:org.eclipse.lsp4jakarta.ls:0.1.1') {
Expand All @@ -92,7 +91,7 @@ dependencies {
testImplementation 'com.intellij.remoterobot:remote-robot:' + remoteRobotVersion
testImplementation 'com.intellij.remoterobot:remote-fixtures:' + remoteRobotVersion
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
testImplementation('com.jetbrains.intellij.maven:maven-test-framework:231.9011.34') {
testImplementation('com.jetbrains.intellij.maven:maven-test-framework:232.10072.27') {
transitive = false
}
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
Expand All @@ -105,16 +104,17 @@ dependencies {
// Test: Video Recording.
testImplementation 'com.automation-remarks:video-recorder-junit5:2.0'

// define jars to grab locally (if falling back to mavenLocal() repo)
lsp('org.eclipse.lsp4mp:org.eclipse.lsp4mp.ls:0.6.0:uber') {
transitive = false
}
lsp('org.eclipse.lemminx:org.eclipse.lemminx:0.25.0:uber') {
transitive = false
}
lsp('io.openliberty.tools:liberty-langserver-lemminx:2.0:jar-with-dependencies') {
lsp('io.openliberty.tools:liberty-langserver-lemminx:2.1-SNAPSHOT: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 All @@ -137,7 +137,7 @@ runIde {

intellij {
// For a full list of IntelliJ IDEA releases please see https://www.jetbrains.com/intellij-repository/releases
version = '2023.1.2'
version = '2023.2.3'

plugins = ['java', 'maven', 'gradle-java', 'properties', 'terminal', 'org.jetbrains.idea.maven', 'com.intellij.gradle']
updateSinceUntilBuild = false
Expand Down Expand Up @@ -166,6 +166,11 @@ test {
showStandardStreams = true
exceptionFormat = 'full'
}

filter {
// disable lsp4jakarta integration tests until listener leak issue is resolved: https://github.com/OpenLiberty/liberty-tools-intellij/issues/541
excludeTestsMatching "io.openliberty.tools.intellij.lsp4jakarta.it.*"
}
}

tasks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,43 @@
******************************************************************************/
package io.openliberty.tools.intellij.liberty.lsp;

import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.vfs.VirtualFile;
import io.openliberty.tools.intellij.lsp4mp.MicroProfileProjectService;
import org.microshed.lsp4ij.LanguageClientImpl;
import org.apache.commons.lang3.tuple.Pair;
import java.util.List;
import org.eclipse.lsp4j.DidChangeWatchedFilesParams;
import org.eclipse.lsp4j.FileChangeType;
import org.eclipse.lsp4j.FileEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import com.intellij.openapi.project.Project;
import com.intellij.util.messages.MessageBusConnection;
import org.microshed.lsp4ij.LanguageClientImpl;
import org.microshed.lsp4ij.LanguageServerWrapper;

/**
* Client for Liberty language server
* Adapted from https://github.com/redhat-developer/intellij-quarkus/blob/2585eb422beeb69631076d2c39196d6eca2f5f2e/src/main/java/com/redhat/devtools/intellij/quarkus/lsp/QuarkusLanguageClient.java
*/
public class LibertyConfigLanguageClient extends LanguageClientImpl implements MicroProfileProjectService.Listener {
public class LibertyConfigLanguageClient extends LanguageClientImpl implements LibertyCustomConfigManager.Listener {

private static final Logger LOGGER = LoggerFactory.getLogger(LibertyConfigLanguageClient.class);

private final MessageBusConnection connection;

public LibertyConfigLanguageClient(Project project) {
super(project);
connection = project.getMessageBus().connect(project);
connection.subscribe(LibertyCustomConfigManager.TOPIC, this);
LibertyCustomConfigManager.getInstance(project);
}

@Override
public void libraryUpdated(Library library) {
// not needed for Liberty LS
}

@Override
public void sourceUpdated(List<Pair<Module, VirtualFile>> sources) {
// not needed for Liberty LS
public void processConfigXml(List<String> uris) {
LanguageServerWrapper wrapper = getLanguageServerWrapper();
if (wrapper != null) {
List<FileEvent> fileEvents = uris.stream()
.map(uri -> new FileEvent(uri, FileChangeType.Changed)).toList();
DidChangeWatchedFilesParams params = new DidChangeWatchedFilesParams();
params.setChanges(fileEvents);
wrapper.getInitializedServer().thenAccept(ls -> ls.getWorkspaceService().didChangeWatchedFiles(params));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.openapi.extensions.PluginId;
import org.microshed.lsp4ij.server.ProcessStreamConnectionProvider;
import io.openliberty.tools.intellij.util.JavaVersionUtil;
import io.openliberty.tools.intellij.util.Constants;
import org.microshed.lsp4ij.server.ProcessStreamConnectionProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.net.URI;
import java.util.ArrayList;
Expand All @@ -32,18 +32,10 @@ public class LibertyConfigLanguageServer extends ProcessStreamConnectionProvider
private static final Logger LOGGER = LoggerFactory.getLogger(LibertyConfigLanguageServer.class);

public LibertyConfigLanguageServer() {
String javaHome = System.getProperty("java.home");
IdeaPluginDescriptor descriptor = PluginManagerCore.getPlugin(PluginId.getId("open-liberty.intellij"));
File libertyServerPath = new File(descriptor.getPluginPath().toFile(), "lib/server/liberty-langserver-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");
return;
}
if (!checkJavaVersion(javaHome, Constants.REQUIRED_JAVA_VERSION)) {
LOGGER.error("Unable to launch the Liberty language server." +
" Java " + Constants.REQUIRED_JAVA_VERSION + " or more recent is required to run 'Liberty Tools for IntelliJ'." +
" Change the boot Java runtime of the IDE as documented here:" +
" https://www.jetbrains.com/help/idea/switching-boot-jdk.html");
if(!JavaVersionUtil.isJavaHomeValid(javaHome, Constants.LIBERTY_CONFIG_SERVER)){
return;
}
if (libertyServerPath.exists()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright (c) 2023 IBM Corporation.
*
* 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.
*
* SPDX-License-Identifier: EPL-2.0
******************************************************************************/
package io.openliberty.tools.intellij.liberty.lsp;

import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
import io.openliberty.tools.intellij.lsp4mp.lsp4ij.LSPIJUtils;

import org.jetbrains.annotations.NotNull;

import java.util.List;

public class LibertyCustomConfigListener implements BulkFileListener {
private final static Logger LOGGER = Logger.getInstance(LibertyCustomConfigListener.class);

private final LibertyCustomConfigManager manager;
public static final String LIBERTY_PLUGIN_CONFIG_XML = "liberty-plugin-config.xml";

public LibertyCustomConfigListener(LibertyCustomConfigManager manager) {
this.manager = manager;
}

@Override
public void after(@NotNull List<? extends VFileEvent> events) {
// filter file events to only liberty-plugin-config.xml
List<String> pluginConfigList = events.stream()
.map(event -> LSPIJUtils.toUri(event.getFile()).toString())
.filter(this::isPluginConfigXml)
.toList();
manager.handleProcessConfigXml(pluginConfigList);
}

private boolean isPluginConfigXml(String uri) {
return uri.endsWith(LIBERTY_PLUGIN_CONFIG_XML);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright (c) 2023 IBM Corporation.
*
* 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.
*
* SPDX-License-Identifier: EPL-2.0
******************************************************************************/
package io.openliberty.tools.intellij.liberty.lsp;

import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;

import java.util.List;

public class LibertyCustomConfigManager implements LibraryTable.Listener, Disposable {

private final static Logger LOGGER = Logger.getInstance(LibertyCustomConfigManager.class);

private final Project project;
private final MessageBusConnection appConnection;
private final LibertyCustomConfigListener listener;

@Override
public void dispose() {
this.appConnection.disconnect();
}

public interface Listener {
void processConfigXml(List<String> uris);
}

public static LibertyCustomConfigManager getInstance(@NotNull Project project) {
return project.getService(LibertyCustomConfigManager.class);
}

public static final Topic<Listener> TOPIC = Topic.create(LibertyCustomConfigManager.class.getName(), Listener.class);


public LibertyCustomConfigManager(Project project) {
this.project = project;
listener = new LibertyCustomConfigListener(this);
appConnection = ApplicationManager.getApplication().getMessageBus().connect(project);
appConnection.subscribe(VirtualFileManager.VFS_CHANGES, listener);
}

protected void handleProcessConfigXml(List<String> uris) {
project.getMessageBus().syncPublisher(TOPIC).processConfigXml(uris);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.openapi.extensions.PluginId;
import org.microshed.lsp4ij.server.ProcessStreamConnectionProvider;
import io.openliberty.tools.intellij.util.JavaVersionUtil;
import io.openliberty.tools.intellij.util.Constants;
import org.microshed.lsp4ij.server.ProcessStreamConnectionProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -32,19 +33,11 @@ public class LibertyXmlServer extends ProcessStreamConnectionProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(LibertyXmlServer.class);

public LibertyXmlServer() {
String javaHome = System.getProperty("java.home");
IdeaPluginDescriptor descriptor = PluginManagerCore.getPlugin(PluginId.getId("open-liberty.intellij"));
File lemminxServerPath = new File(descriptor.getPluginPath().toFile(), "lib/server/org.eclipse.lemminx-uber.jar");
File libertyServerPath = new File(descriptor.getPluginPath().toFile(), "lib/server/liberty-langserver-lemminx-jar-with-dependencies.jar");
String javaHome = System.getProperty("java.home");
if (javaHome == null) {
LOGGER.error("Unable to launch the LemMinX language server. Could not resolve the java home system property");
return;
}
if (!checkJavaVersion(javaHome, Constants.REQUIRED_JAVA_VERSION)) {
LOGGER.error("Unable to launch the LemMinX language server." +
" Java " + Constants.REQUIRED_JAVA_VERSION + " or more recent is required to run 'Liberty Tools for IntelliJ'." +
" Change the boot Java runtime of the IDE as documented here:" +
" https://www.jetbrains.com/help/idea/switching-boot-jdk.html");
if(!JavaVersionUtil.isJavaHomeValid(javaHome, Constants.LIBERTY_XML_SERVER)){
return;
}
if (lemminxServerPath.exists() && libertyServerPath.exists()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022 IBM Corporation.
* Copyright (c) 2022, 2023 IBM Corporation.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -9,11 +9,6 @@
*******************************************************************************/
package io.openliberty.tools.intellij.liberty.lsp;

import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;

import javax.swing.Icon;

import com.intellij.openapi.fileTypes.PlainTextLanguage;
Expand All @@ -27,8 +22,6 @@

import io.openliberty.tools.intellij.LibertyPluginIcons;

import static io.openliberty.tools.intellij.util.Constants.SERVER_ENV_GLOB_PATTERN;

/**
* Custom file type for server.env files
*/
Expand All @@ -43,9 +36,7 @@ private ServerEnvFileType() {

@Override
public boolean isMyFileType(@NotNull VirtualFile file) {
Path path = Paths.get(file.getPath());
final PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + SERVER_ENV_GLOB_PATTERN);
return matcher.matches(path);
return file.getPath().endsWith(".env");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;

import static io.openliberty.tools.intellij.util.Constants.SERVER_ENV_GLOB_PATTERN;

/**
* Language Substitutor for Liberty server.env files
* To re-use the IntelliJ parsing for Properties files on server.env files, categorize server.env files that are in a recognized
Expand All @@ -47,8 +40,6 @@ public class ServerEnvSubstitutor extends LanguageSubstitutor {
}

private boolean isLibertyServerEnvFile(VirtualFile file) {
Path path = Paths.get(file.getPath());
final PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + SERVER_ENV_GLOB_PATTERN);
return matcher.matches(path);
return file.getPath().endsWith(".env");
}
}
Loading

0 comments on commit 8443170

Please sign in to comment.