Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into #167_customStart-pr…
Browse files Browse the repository at this point in the history
…ojectOptions
  • Loading branch information
Rahul-Biju committed Nov 2, 2023
2 parents 781b524 + 14c7fcc commit 7f861b5
Show file tree
Hide file tree
Showing 100 changed files with 1,532 additions and 7,354 deletions.
32 changes: 20 additions & 12 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 All @@ -31,6 +31,11 @@ jobs:
minimum-size: 8GB
maximum-size: 10GB
disk-root: "C:"
- name: 'Checkout lsp4ij'
uses: actions/checkout@v3
with:
repository: MicroShed/lsp4ij
path: lsp4ij
- name: 'Checkout liberty-tools-intellij'
uses: actions/checkout@v3
with:
Expand All @@ -40,16 +45,9 @@ jobs:
- name: 'Install required integration test software'
working-directory: ./liberty-tools-intellij
run: bash ./src/test/resources/ci/scripts/setup.sh
- name: 'Run UI integration tests'
working-directory: ./liberty-tools-intellij
run: bash ./src/test/resources/ci/scripts/run.sh
- name: 'Archive Test logs and reports'
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.reportName }}
path: |
liberty-tools-intellij/build/reports/
- name: 'Build lsp4ij jar and publish to local Maven repository'
working-directory: ./lsp4ij
run: bash ./gradlew publishToMavenLocal
- name: 'Build Liberty-Tools-Intellij'
working-directory: ./liberty-tools-intellij
run: bash ./gradlew buildPlugin
Expand All @@ -62,4 +60,14 @@ jobs:
./**/*liberty-tools-intellij*.zip
./**/libs/*liberty-tools-intellij*.jar
if-no-files-found: warn
retention-days: 7
retention-days: 7
- name: 'Run UI integration tests'
working-directory: ./liberty-tools-intellij
run: bash ./src/test/resources/ci/scripts/run.sh
- name: 'Archive Test logs and reports'
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.reportName }}
path: |
liberty-tools-intellij/build/reports/
5 changes: 4 additions & 1 deletion DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

This extension is built using the [gradle-intellij-plugin](https://github.com/JetBrains/gradle-intellij-plugin/).

1. Clone this repository: `git clone [email protected]:OpenLiberty/liberty-tools-intellij.git && cd liberty-tools-intellij`
1. Clone this repository: `git clone [email protected]:OpenLiberty/liberty-tools-intellij.git`
2. Clone the lsp4ij repository: `git clone [email protected]:MicroShed/lsp4ij.git`
3. Build lsp4ij: `./gradlew jar`
4. Save it in your local Maven repository: `./gradlew publishToMavenLocal` (this also runs the `jar` task)
2. Import this repository as a Gradle project in IntelliJ IDEA
3. Run `./gradlew runIde --stacktrace`. A new IntelliJ IDEA window will launch with the Liberty Tools plugin installed to it. You can connect the IntelliJ IDEA debugger to this process to debug the plugin.

Expand Down
38 changes: 24 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group 'io.openliberty.tools'
version '23.0.7-SNAPSHOT'
version '23.0.12-SNAPSHOT'

sourceCompatibility = 17
targetCompatibility = 17
Expand Down Expand Up @@ -63,17 +63,26 @@ configurations {
}

dependencies {
// LSP4IJ dependencies
implementation 'org.eclipse.lsp4mp:org.eclipse.lsp4mp.ls:0.6.0'
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 'org.eclipse.lsp4jakarta:org.eclipse.lsp4jakarta.ls:0.1.1'
implementation 'org.microshed:lsp4ij:0.0.1' // includes org.eclipse.lsp4j
implementation ('org.eclipse.lsp4mp:org.eclipse.lsp4mp.ls:0.6.0') {
exclude group: 'org.eclipse.lsp4j'
}
implementation ('org.eclipse.lemminx:org.eclipse.lemminx:0.25.0') {
exclude group: 'org.eclipse.lsp4j'
}
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') {
exclude group: 'org.eclipse.lsp4mp'
exclude group: 'org.eclipse.lsp4j'
}
//required by lsp4j as the version from IJ is incompatible
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'com.vladsch.flexmark:flexmark:0.50.50'
implementation 'org.jsoup:jsoup:1.15.3'
// implementation 'com.google.code.gson:gson:2.8.9'
// implementation 'com.vladsch.flexmark:flexmark:0.50.50'
// implementation 'org.jsoup:jsoup:1.15.3'
//Add junit dependency back when tests are added
//testImplementation group: 'junit', name: 'junit', version: '4.13.1'
implementation 'org.apache.maven:maven-artifact:3.6.3'
Expand All @@ -82,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 @@ -95,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 @@ -127,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
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ protected void executeLibertyAction(LibertyModule libertyModule) {
String startCmd;
try {
startCmd = projectType.equals(Constants.LIBERTY_MAVEN_PROJECT) ? LibertyMavenUtil.getMavenSettingsCmd(project) + Constants.LIBERTY_MAVEN_START_CONTAINER_CMD : LibertyGradleUtil.getGradleSettingsCmd(project) + Constants.LIBERTY_GRADLE_START_CONTAINER_CMD;
startCmd += libertyModule.getCustomStartParams();
} catch (LibertyException ex) {
// in this case, the settings specified to mvn or gradle are invalid and an error was launched by getMavenSettingsCmd or getGradleSettingsCmd
LOGGER.warn(ex.getMessage()); // Logger.error creates an entry on "IDE Internal Errors", which we do not want
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 io.openliberty.tools.intellij.lsp4mp.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,8 +13,9 @@
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.openapi.extensions.PluginId;
import io.openliberty.tools.intellij.lsp4mp.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;
Expand All @@ -34,7 +35,7 @@ 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");
if(!isJavaHomeValid(javaHome, Constants.LIBERTY_CONFIG_SERVER)){
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 org.jetbrains.annotations.NotNull;
import org.microshed.lsp4ij.LSPIJUtils;

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 @@ -15,7 +15,7 @@
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.vfs.VirtualFile;
import io.openliberty.tools.intellij.lsp4mp.MicroProfileProjectService;
import io.openliberty.tools.intellij.lsp4mp.lsp4ij.LanguageClientImpl;
import org.microshed.lsp4ij.LanguageClientImpl;
import org.apache.commons.lang3.tuple.Pair;
import org.eclipse.lemminx.customservice.XMLLanguageClientAPI;
import org.slf4j.Logger;
Expand Down
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 io.openliberty.tools.intellij.lsp4mp.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 @@ -36,7 +37,7 @@ public LibertyXmlServer() {
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");
if(!isJavaHomeValid(javaHome, Constants.LIBERTY_XML_SERVER)){
if(!JavaVersionUtil.isJavaHomeValid(javaHome, Constants.LIBERTY_XML_SERVER)){
return;
}
if (lemminxServerPath.exists() && libertyServerPath.exists()) {
Expand Down
Loading

0 comments on commit 7f861b5

Please sign in to comment.