Rename YamlLanguageServer to ApplicationYamlLanguageServer

This commit is contained in:
Kris De Volder
2016-10-17 12:57:19 -07:00
parent b3d85501a2
commit 3f9f21d09d
6 changed files with 23 additions and 26 deletions

View File

@@ -20,14 +20,14 @@ import io.typefox.lsapi.services.WindowService;
/**
* Abstract base class to implement LanguageServer. Bits and pieces copied from
* the 'JavaLanguageServer' example which seem generally useful / reusable end up in
* here so we can try to keep the subclass itself more 'clutter free' and focus on
* the 'JavaLanguageServer' example which seem generally useful / reusable end up in
* here so we can try to keep the subclass itself more 'clutter free' and focus on
* what its really doing and not the 'wiring and plumbing'.
*/
public abstract class SimpleLanguageServer implements LanguageServer {
private static final Logger LOG = Logger.getLogger(SimpleLanguageServer.class.getName());
private Consumer<MessageParams> showMessage = m -> {};
private Path workspaceRoot;
@@ -35,16 +35,16 @@ public abstract class SimpleLanguageServer implements LanguageServer {
private SimpleTextDocumentService tds;
private SimpleWorkspaceService workspace;
@Override
public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
LOG.info("Initializing");
// LOG.info("Initializing");
String rootPath = params.getRootPath();
if (rootPath==null) {
LOG.warning("workspaceRoot NOT SET");
// LOG.warning("workspaceRoot NOT SET");
} else {
this.workspaceRoot= Paths.get(rootPath).toAbsolutePath().normalize();
LOG.info("workspaceRoot = "+workspaceRoot);
// LOG.info("workspaceRoot = "+workspaceRoot);
}
InitializeResultImpl result = new InitializeResultImpl();
@@ -74,13 +74,13 @@ public abstract class SimpleLanguageServer implements LanguageServer {
}
};
}
public void onError(String message, Throwable error) {
if (error instanceof ShowMessageException)
showMessage.accept(((ShowMessageException) error).message);
else {
LOG.log(Level.SEVERE, message, error);
MessageParamsImpl m = new MessageParamsImpl();
m.setMessage(message);
@@ -91,7 +91,7 @@ public abstract class SimpleLanguageServer implements LanguageServer {
}
protected abstract ServerCapabilitiesImpl getServerCapabilities();
@Override
public void shutdown() {
}
@@ -128,7 +128,7 @@ public abstract class SimpleLanguageServer implements LanguageServer {
}
return workspace;
}
@Override
public void onTelemetryEvent(Consumer<Object> callback) {
//TODO: not sure what this is for exactly. We just stub it and do nothing for now.

View File

@@ -20,9 +20,7 @@ import com.google.common.collect.ImmutableList;
import io.typefox.lsapi.CompletionItem;
import io.typefox.lsapi.CompletionItemKind;
import io.typefox.lsapi.CompletionList;
import io.typefox.lsapi.Diagnostic;
import io.typefox.lsapi.DiagnosticSeverity;
import io.typefox.lsapi.ServerCapabilities;
import io.typefox.lsapi.TextDocumentSyncKind;
import io.typefox.lsapi.impl.CompletionItemImpl;
import io.typefox.lsapi.impl.CompletionListImpl;
@@ -32,15 +30,14 @@ import io.typefox.lsapi.impl.PositionImpl;
import io.typefox.lsapi.impl.RangeImpl;
import io.typefox.lsapi.impl.ServerCapabilitiesImpl;
public class YamlLanguageServer extends SimpleLanguageServer {
public class ApplicationYamlLanguageServer extends SimpleLanguageServer {
private Yaml yaml = new Yaml();
public YamlLanguageServer() {
public ApplicationYamlLanguageServer() {
SimpleTextDocumentService documents = getTextDocumentService();
// SimpleWorkspaceService workspace = getWorkspaceService();
documents.onDidChangeContent(params -> {
System.out.println("Document changed: "+params);
TextDocument doc = params.getDocument();
validateDocument(documents, doc);
});

View File

@@ -79,7 +79,7 @@ public class Main {
* When the request stream is closed, wait for 5s for all outstanding responses to compute, then return.
*/
public static void run(Connection connection) {
YamlLanguageServer server = new YamlLanguageServer();
ApplicationYamlLanguageServer server = new ApplicationYamlLanguageServer();
LoggingJsonAdapter jsonServer = new LoggingJsonAdapter(server);
jsonServer.setMessageLog(new PrintWriter(System.out));

View File

@@ -30,7 +30,7 @@ public class AbstractPropsEditorTest {
@Before
public void setup() throws Exception {
md = new PropertyIndexHarness();
harness = new LanguageServerHarness(YamlLanguageServer::new);
harness = new LanguageServerHarness(ApplicationYamlLanguageServer::new);
harness.intialize(null);
}

View File

@@ -40,7 +40,7 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
////////////////////////////////////////////////////////////////////////////////////////
@Test public void linterRunsOnDocumentOpenAndChange() throws Exception {
LanguageServerHarness harness = new LanguageServerHarness(YamlLanguageServer::new);
LanguageServerHarness harness = new LanguageServerHarness(ApplicationYamlLanguageServer::new);
harness.intialize(null);
Editor editor = newEditor(
@@ -252,7 +252,7 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
System.out.println("<<< testHyperlinkTargets");
}
@Ignore @Test public void testReconcile() throws Exception {
@Test public void testReconcile() throws Exception {
defaultTestData();
Editor editor = newEditor(
"server:\n" +

View File

@@ -10,7 +10,7 @@ import java.util.List;
import org.junit.Test;
import org.springframework.ide.vscode.testharness.LanguageServerHarness;
import org.springframework.ide.vscode.testharness.TextDocumentInfo;
import org.springframework.ide.vscode.yaml.YamlLanguageServer;
import org.springframework.ide.vscode.yaml.ApplicationYamlLanguageServer;
import io.typefox.lsapi.CompletionItem;
import io.typefox.lsapi.CompletionList;
@@ -18,15 +18,15 @@ import io.typefox.lsapi.InitializeResult;
import io.typefox.lsapi.ServerCapabilities;
import io.typefox.lsapi.TextDocumentSyncKind;
public class YamlLanguageServerTests {
public class ApplicationYamlLanguageServerTests {
public static File getTestResource(String name) throws URISyntaxException {
return Paths.get(YamlLanguageServerTests.class.getResource(name).toURI()).toFile();
return Paths.get(ApplicationYamlLanguageServerTests.class.getResource(name).toURI()).toFile();
}
@Test
public void createAndInitializeServerWithWorkspace() throws Exception {
LanguageServerHarness harness = new LanguageServerHarness(YamlLanguageServer::new);
LanguageServerHarness harness = new LanguageServerHarness(ApplicationYamlLanguageServer::new);
File workspaceRoot = getTestResource("/workspace/");
assertExpectedInitResult(harness.intialize(workspaceRoot));
}
@@ -34,7 +34,7 @@ public class YamlLanguageServerTests {
@Test
public void createAndInitializeServerWithoutWorkspace() throws Exception {
File workspaceRoot = null;
LanguageServerHarness harness = new LanguageServerHarness(YamlLanguageServer::new);
LanguageServerHarness harness = new LanguageServerHarness(ApplicationYamlLanguageServer::new);
assertExpectedInitResult(harness.intialize(workspaceRoot));
}