-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge the changes from the main branch.
Signed-off-by: Paul Gooderham <turkeyonmarblerye@gmail.com>
- Loading branch information
Showing
53 changed files
with
1,453 additions
and
493 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
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
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
44 changes: 44 additions & 0 deletions
44
src/main/java/io/openliberty/tools/intellij/liberty/lsp/LibertyCustomConfigListener.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,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); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/io/openliberty/tools/intellij/liberty/lsp/LibertyCustomConfigManager.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,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); | ||
} | ||
} |
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
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
Oops, something went wrong.