Skip to content

Commit

Permalink
JBIDE-29058: fix build after TP update (#236)
Browse files Browse the repository at this point in the history
* JBIDE-29058: fix build after TP update

Signed-off-by: Stephane Bouchet <[email protected]>

* JBIDE-29058: fix after reviews.

Signed-off-by: Stephane Bouchet <[email protected]>

* JBIDE-29058: fix after reviews.

Signed-off-by: Stephane Bouchet <[email protected]>

* JBIDE-29058: fix after reviews - removed singleton client.

Signed-off-by: Stephane Bouchet <[email protected]>

* fix SchemaRegistry for YAML

Signed-off-by: Stephane Bouchet <[email protected]>

* fix YAML properties schema registration

Signed-off-by: Stephane Bouchet <[email protected]>

* JBIDE-29058: fix build after TP update (quarkus-ls 0.17)

Signed-off-by: Stephane Bouchet <[email protected]>

---------

Signed-off-by: Stephane Bouchet <[email protected]>
  • Loading branch information
sbouchet authored Oct 10, 2023
1 parent 16a0d4b commit da40850
Show file tree
Hide file tree
Showing 44 changed files with 220 additions and 261 deletions.
2 changes: 1 addition & 1 deletion features/org.jboss.tools.quarkus.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.jboss.tools.quarkus.feature"
label="Quarkus Tools"
version="1.10.0.qualifier">
version="1.10.100.qualifier">

<description>
The Eclipse plugins in this feature provide tooling for the Quarkus
Expand Down
2 changes: 1 addition & 1 deletion features/org.jboss.tools.quarkus.feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.jboss.tools.quarkus</groupId>
<artifactId>features</artifactId>
<version>1.10.0-SNAPSHOT</version>
<version>1.10.100-SNAPSHOT</version>
</parent>

<groupId>org.jboss.tools.quarkus.features</groupId>
Expand Down
2 changes: 1 addition & 1 deletion features/org.jboss.tools.quarkus.test.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.jboss.tools.quarkus.test.feature"
label="Quarkus Tools Test"
version="1.10.0.qualifier">
version="1.10.100.qualifier">

<description>
The Eclipse plugins in this feature provide tooling for the Quarkus
Expand Down
2 changes: 1 addition & 1 deletion features/org.jboss.tools.quarkus.test.feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.jboss.tools.quarkus</groupId>
<artifactId>features</artifactId>
<version>1.10.0-SNAPSHOT</version>
<version>1.10.100-SNAPSHOT</version>
</parent>

<groupId>org.jboss.tools.quarkus.features</groupId>
Expand Down
2 changes: 1 addition & 1 deletion features/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.jboss.tools</groupId>
<artifactId>quarkus</artifactId>
<version>1.10.0-SNAPSHOT</version>
<version>1.10.100-SNAPSHOT</version>
</parent>

<groupId>org.jboss.tools.quarkus</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Quarkus Integration Tests
Bundle-SymbolicName: org.jboss.tools.quarkus.integration.tests;singleton:=true
Bundle-Version: 1.10.0.qualifier
Bundle-Version: 1.10.100.qualifier
Require-Bundle: org.eclipse.reddeer.go,
org.jboss.tools.quarkus.reddeer,
org.eclipse.m2e.editor.lemminx,
Expand Down
2 changes: 1 addition & 1 deletion itests/org.jboss.tools.quarkus.integration.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.jboss.tools.quarkus</groupId>
<artifactId>itests</artifactId>
<version>1.10.0-SNAPSHOT</version>
<version>1.10.100-SNAPSHOT</version>
</parent>

<groupId>org.jboss.tools.quarkus.itests</groupId>
Expand Down
2 changes: 1 addition & 1 deletion itests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.jboss.tools</groupId>
<artifactId>quarkus</artifactId>
<version>1.10.0-SNAPSHOT</version>
<version>1.10.100-SNAPSHOT</version>
</parent>

<groupId>org.jboss.tools.quarkus</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundle-Copyright: Copyright (c) 2019 Red Hat, Inc.
Bundle-ManifestVersion: 2
Bundle-Name: Quarkus Eclipse Cheatsheet Plugin
Bundle-SymbolicName: org.jboss.tools.quarkus.cheatsheet;singleton:=true
Bundle-Version: 1.10.0.qualifier
Bundle-Version: 1.10.100.qualifier
Automatic-Module-Name: org.jboss.tools.quarkus.cheatsheet
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.jboss.tools.quarkus.ui,
Expand Down
2 changes: 1 addition & 1 deletion plugins/org.jboss.tools.quarkus.cheatsheet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.jboss.tools.quarkus</groupId>
<artifactId>plugins</artifactId>
<version>1.10.0-SNAPSHOT</version>
<version>1.10.100-SNAPSHOT</version>
</parent>

<groupId>org.jboss.tools.quarkus.plugins</groupId>
Expand Down
2 changes: 1 addition & 1 deletion plugins/org.jboss.tools.quarkus.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundle-Copyright: Copyright (c) 2019 Red Hat, Inc.
Bundle-ManifestVersion: 2
Bundle-Name: Quarkus Eclipse Core Plugin
Bundle-SymbolicName: org.jboss.tools.quarkus.core;singleton:=true
Bundle-Version: 1.10.0.qualifier
Bundle-Version: 1.10.100.qualifier
Automatic-Module-Name: org.jboss.tools.quarkus.core
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.jboss.tools.quarkus.runtime,
Expand Down
2 changes: 1 addition & 1 deletion plugins/org.jboss.tools.quarkus.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.jboss.tools.quarkus</groupId>
<artifactId>plugins</artifactId>
<version>1.10.0-SNAPSHOT</version>
<version>1.10.100-SNAPSHOT</version>
</parent>

<groupId>org.jboss.tools.quarkus.plugins</groupId>
Expand Down
2 changes: 1 addition & 1 deletion plugins/org.jboss.tools.quarkus.lsp4e/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-SymbolicName: org.jboss.tools.quarkus.lsp4e;singleton:=true
Bundle-Version: 1.10.0.qualifier
Bundle-Version: 1.10.100.qualifier
Require-Bundle: org.eclipse.lsp4e,
org.eclipse.core.runtime,
org.eclipse.jface.text,
Expand Down
2 changes: 1 addition & 1 deletion plugins/org.jboss.tools.quarkus.lsp4e/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.jboss.tools.quarkus</groupId>
<artifactId>plugins</artifactId>
<version>1.10.0-SNAPSHOT</version>
<version>1.10.100-SNAPSHOT</version>
</parent>

<groupId>org.jboss.tools.quarkus.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,11 @@
*/
public class QuarkusLanguageClient extends LanguageClientImpl implements MicroProfileLanguageClientAPI {

private static IMicroProfilePropertiesChangedListener SINGLETON_LISTENER;

private IMicroProfilePropertiesChangedListener listener = event -> {
((MicroProfileLanguageServerAPI) getLanguageServer()).propertiesChanged(event);
};

public QuarkusLanguageClient() {
// FIXME : how to remove the listener????
// The listener should be removed when language server is shutdown, how to
// manage that????
if (SINGLETON_LISTENER != null) {
MicroProfileCorePlugin.getDefault().removeMicroProfilePropertiesChangedListener(SINGLETON_LISTENER);
}
SINGLETON_LISTENER = listener;
MicroProfileCorePlugin.getDefault().addMicroProfilePropertiesChangedListener(listener);
}

Expand Down Expand Up @@ -298,4 +289,10 @@ public CompletableFuture<String> getPropertyDocumentation(MicroProfilePropertyDo

});
}

@Override
public void dispose() {
MicroProfileCorePlugin.getDefault().removeMicroProfilePropertiesChangedListener(listener);
super.dispose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.lsp4e.LanguageServerWrapper;
import org.eclipse.lsp4e.LanguageServers;
import org.eclipse.lsp4e.LanguageServiceAccessor;
import org.eclipse.lsp4e.command.LSPCommandHandler;
import org.eclipse.lsp4j.Command;
Expand All @@ -46,7 +48,7 @@ public class GenerateTemplateFileHandler extends LSPCommandHandler {

//TODO refactor to use QuteServerCommandConstants class in future versions
private static final String QUTE_COMMAND_GENERATE_TEMPLATE_CONTENT = "qute.command.generate.template.content"; //$NON-NLS-1$

@Override
public Object execute(ExecutionEvent event, @NonNull Command command, IPath sourcePath) {
URI uri;
Expand All @@ -55,10 +57,10 @@ public Object execute(ExecutionEvent event, @NonNull Command command, IPath sour
ExecuteCommandParams params = new ExecuteCommandParams();
params.setCommand(QUTE_COMMAND_GENERATE_TEMPLATE_CONTENT);
params.setArguments(command.getArguments());
LanguageServer server = getServer();
LanguageServerWrapper server = getServer();
if (server != null) {
// use LangageServer to generate file content for qute template, with given command arguments
server.getWorkspaceService().executeCommand(params).thenApply(content -> {
server.execute(ls -> ls.getWorkspaceService().executeCommand(params)).thenApply(content -> {
try {
Path path = Path.of(uri);
if (!Files.exists(path)) {
Expand Down Expand Up @@ -93,11 +95,11 @@ public Object execute(ExecutionEvent event, @NonNull Command command, IPath sour
return null;
}

private LanguageServer getServer() {
List<LanguageServer> servers = LanguageServiceAccessor.getActiveLanguageServers(cap -> {
private LanguageServerWrapper getServer() {
List<LanguageServerWrapper> servers = LanguageServiceAccessor.getStartedWrappers( ResourcesPlugin.getWorkspace().getRoot().getProject(), cap -> {
ExecuteCommandOptions provider = cap.getExecuteCommandProvider();
return provider != null && provider.getCommands().contains(QUTE_COMMAND_GENERATE_TEMPLATE_CONTENT);
});
}, true);
return servers.isEmpty() ? null : servers.get(0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package org.jboss.tools.quarkus.lsp4e.internal.ls.qute;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -70,61 +71,45 @@
* @author Red Hat Developers
*
*/
public class QuteLanguageClient extends LanguageClientImpl implements QuteLanguageClientAPI, IPreferenceChangeListener, INodeChangeListener {
public class QuteLanguageClient extends LanguageClientImpl
implements QuteLanguageClientAPI, IPreferenceChangeListener, INodeChangeListener {

private static IJavaDataModelChangedListener SINGLETON_LISTENER;

private static QuteLanguageClient SINGLETON_CLIENT;

private IJavaDataModelChangedListener listener = event -> {
((QuteLanguageServerAPI) getLanguageServer()).dataModelChanged(event);
};

private List<IEclipsePreferences> preferencesNodes = new ArrayList<>();

/**
*
*/

public QuteLanguageClient() {
// FIXME : how to remove the listener????
// The listener should be removed when language server is shutdown, how to
// manage that????
if (SINGLETON_LISTENER != null) {
QutePlugin.getDefault().removeJavaDataModelChangedListener(SINGLETON_LISTENER);
}
if (SINGLETON_CLIENT != null) {
SINGLETON_CLIENT.dispose();
}
SINGLETON_LISTENER = listener;
SINGLETON_CLIENT = this;
QutePlugin.getDefault().addJavaDataModelChangedListener(listener);
listenForPreferences();
}

/**
*
*/
private void dispose() {
@Override
public void dispose() {
InstanceScope.INSTANCE.getNode(QuarkusLSPPlugin.PREFERENCES_QUALIFIER).removePreferenceChangeListener(this);
((IEclipsePreferences) Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE)).removeNodeChangeListener(this);
((IEclipsePreferences) Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE))
.removeNodeChangeListener(this);
preferencesNodes.forEach(node -> node.removePreferenceChangeListener(this));
QutePlugin.getDefault().removeJavaDataModelChangedListener(listener);
super.dispose();
}

/**
* In order to send configuration change notification, we should detect changes on Qute configuration. To do so,
* we listen on:
* - general Qute configuration
* - new nodes on project node (new projects being added)
* - for each project listen on the Qute prefences
* In order to send configuration change notification, we should detect changes
* on Qute configuration. To do so, we listen on: - general Qute configuration -
* new nodes on project node (new projects being added) - for each project
* listen on the Qute prefences
*
* #see {@link #dispose()}
* #see {@link #dispose()}
*/
private void listenForPreferences() {
InstanceScope.INSTANCE.getNode(QuarkusLSPPlugin.PREFERENCES_QUALIFIER).addPreferenceChangeListener(this);
((IEclipsePreferences) Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE)).addNodeChangeListener(this);
((IEclipsePreferences) Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE))
.addNodeChangeListener(this);
try {
Platform.getPreferencesService().getRootNode().accept(node -> {
if (node.parent() != null && node.parent().absolutePath().equals("/"+ ProjectScope.SCOPE)) {
if (node.parent() != null && node.parent().absolutePath().equals("/" + ProjectScope.SCOPE)) {
Preferences child = node.node(QuarkusLSPPlugin.PREFERENCES_QUALIFIER);
((IEclipsePreferences) child).addPreferenceChangeListener(this);
preferencesNodes.add((IEclipsePreferences) child);
Expand All @@ -142,9 +127,9 @@ public CompletableFuture<ProjectInfo> getProjectInfo(QuteProjectParams params) {
return CompletableFutures.computeAsync((cancelChecker) -> {
IProgressMonitor monitor = getProgressMonitor(cancelChecker);
return QuteSupportForTemplate.getInstance().getProjectInfo(params, JDTUtilsImpl.getInstance(), monitor);
});
});
}

@Override
public CompletableFuture<DataModelProject<DataModelTemplate<DataModelParameter>>> getDataModelProject(
QuteDataModelProjectParams params) {
Expand Down Expand Up @@ -184,7 +169,7 @@ public CompletableFuture<ResolvedJavaTypeInfo> getResolvedJavaType(QuteResolvedJ
QuarkusLSPPlugin.logException(e.getLocalizedMessage(), e);
return null;
}
});
});
}

@Override
Expand All @@ -200,7 +185,7 @@ public CompletableFuture<Location> getJavaDefinition(QuteJavaDefinitionParams pa
}
});
}

@Override
public CompletableFuture<List<? extends CodeLens>> getJavaCodelens(QuteJavaCodeLensParams javaParams) {
return CompletableFutures.computeAsync((cancelChecker) -> {
Expand Down Expand Up @@ -237,29 +222,31 @@ public CompletableFuture<List<UserTagInfo>> getUserTags(QuteUserTagParams params
}
});
}

@Override
public CompletableFuture<String> getJavadoc(QuteJavadocParams params) {
return CompletableFutures.computeAsync((cancelChecker) -> {
IProgressMonitor monitor = getProgressMonitor(cancelChecker);
return QuteSupportForTemplate.getInstance().getJavadoc(params, JDTUtilsImpl.getInstance(), monitor);
});
}

@Override
public CompletableFuture<WorkspaceEdit> generateMissingJavaMember(GenerateMissingJavaMemberParams params) {
return CompletableFutures.computeAsync((cancelChecker) -> {
IProgressMonitor monitor = getProgressMonitor(cancelChecker);
return QuteSupportForTemplate.getInstance().generateMissingJavaMember(params, JDTUtilsImpl.getInstance(), monitor);
return QuteSupportForTemplate.getInstance().generateMissingJavaMember(params, JDTUtilsImpl.getInstance(),
monitor);
});
}

private static IProgressMonitor getProgressMonitor(CancelChecker cancelChecker) {
IProgressMonitor monitor = new NullProgressMonitor() {
@Override
public boolean isCanceled() {
cancelChecker.checkCanceled();
return false;
};
}
};
return monitor;
}
Expand All @@ -275,11 +262,20 @@ public void added(NodeChangeEvent event) {
public void removed(NodeChangeEvent event) {
Preferences child = event.getChild().node(QuarkusLSPPlugin.PREFERENCES_QUALIFIER);
((IEclipsePreferences) child).removePreferenceChangeListener(this);
preferencesNodes.remove((IEclipsePreferences) child);
preferencesNodes.remove(child);
}

@Override
public void preferenceChange(PreferenceChangeEvent event) {
getLanguageServer().getWorkspaceService().didChangeConfiguration(new DidChangeConfigurationParams(QuteUtils.getQuteSettings()));
getLanguageServer().getWorkspaceService()
.didChangeConfiguration(new DidChangeConfigurationParams(QuteUtils.getQuteSettings()));
}

@Override
public CompletableFuture<Collection<ProjectInfo>> getProjects() {
return CompletableFutures.computeAsync((cancelChecker) -> {
IProgressMonitor monitor = getProgressMonitor(cancelChecker);
return QuteSupportForTemplate.getInstance().getProjects(JDTUtilsImpl.getInstance(), monitor);
});
}
}
Loading

0 comments on commit da40850

Please sign in to comment.