-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Several improvements to the way remote language servers may be configured through workspace configuration #9387
Changes from all commits
4714d6f
9d7baa9
6acf544
a57a218
f3a88e7
86698e5
b5b26f4
9273f88
49e3fbd
0e745b2
6f397ec
ee1c680
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
|
||
import java.util.List; | ||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
import org.eclipse.che.api.core.jsonrpc.commons.RequestHandlerManager; | ||
import org.slf4j.Logger; | ||
|
||
|
@@ -58,4 +59,13 @@ public void withFunction(Function<String, List<R>> function) { | |
|
||
handlerManager.registerNoneToMany(method, rClass, function); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is never called. Remove! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Meaningless comment. |
||
/** | ||
* Define a supplier to be applied | ||
* | ||
* @param supplier supplier | ||
*/ | ||
public void withSupplier(Supplier<List<R>> supplier) { | ||
withFunction(s -> supplier.get()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
import org.eclipse.che.api.core.jsonrpc.commons.RequestHandlerManager; | ||
import org.slf4j.Logger; | ||
|
||
|
@@ -56,4 +57,13 @@ public void withFunction(Function<String, R> function) { | |
|
||
handlerManager.registerNoneToOne(method, rClass, function); | ||
} | ||
|
||
/** | ||
* Define a supplier to be applied | ||
* | ||
* @param supplier supplier | ||
*/ | ||
public void withSupplier(Supplier<R> supplier) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this method is ever called. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree |
||
withFunction(s -> supplier.get()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,18 @@ public class FileType { | |
|
||
private String namePattern; | ||
|
||
public void setImage(SVGResource image) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are never called. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
this.image = image; | ||
} | ||
|
||
public void setExtension(String extension) { | ||
this.extension = extension; | ||
} | ||
|
||
public void setNamePattern(String namePattern) { | ||
this.namePattern = namePattern; | ||
} | ||
|
||
public FileType(SVGResource image, String extension) { | ||
this(image, extension, null); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,5 +56,5 @@ public interface FileTypeRegistry { | |
* @return file type or default file type if no file type's name pattern matches the given file | ||
* name | ||
*/ | ||
FileType getFileTypeByNamePattern(String name); | ||
FileType getFileTypeByFileName(String name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gratuitous rename, if anything should have fixed the javadoc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Javadoc is correct, method name was inappropriate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So it's not a pattern? |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.plugin.camel.server.languageserver; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import com.google.common.collect.ImmutableSet; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
import org.eclipse.che.api.languageserver.DefaultInstanceProvider; | ||
import org.eclipse.che.api.languageserver.LanguageServerConfig; | ||
import org.eclipse.che.api.languageserver.ProcessCommunicationProvider; | ||
import org.eclipse.che.plugin.camel.server.inject.CamelModule; | ||
|
||
/** Launcher for Apache Camel Language Server */ | ||
@Singleton | ||
public class CamelLanguageServerConfig implements LanguageServerConfig { | ||
private static final String REGEX = ".*\\.(xml)"; | ||
|
||
private final Path launchScript; | ||
|
||
@Inject | ||
public CamelLanguageServerConfig() { | ||
|
||
this.launchScript = Paths.get(System.getenv("HOME"), "che/ls-camel/launch.sh"); | ||
} | ||
|
||
@Override | ||
public RegexProvider getRegexpProvider() { | ||
return new RegexProvider() { | ||
@Override | ||
public Map<String, String> getLanguageRegexes() { | ||
return ImmutableMap.of(CamelModule.LANGUAGE_ID, REGEX); | ||
} | ||
|
||
@Override | ||
public Set<String> getFileWatchPatterns() { | ||
return ImmutableSet.of(); | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public CommunicationProvider getCommunicationProvider() { | ||
ProcessBuilder processBuilder = new ProcessBuilder(launchScript.toString()); | ||
processBuilder.redirectInput(ProcessBuilder.Redirect.PIPE); | ||
processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE); | ||
|
||
return new ProcessCommunicationProvider(processBuilder, CamelModule.LANGUAGE_ID); | ||
} | ||
|
||
@Override | ||
public InstanceProvider getInstanceProvider() { | ||
return DefaultInstanceProvider.getInstance(); | ||
} | ||
|
||
@Override | ||
public InstallerStatusProvider getInstallerStatusProvider() { | ||
return new InstallerStatusProvider() { | ||
@Override | ||
public boolean isSuccessfullyInstalled() { | ||
return launchScript.toFile().exists(); | ||
} | ||
|
||
@Override | ||
public String getCause() { | ||
return isSuccessfullyInstalled() ? null : "Launch script file does not exist"; | ||
} | ||
}; | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree