Cleanups: more type-checked representation of LanguageId
This commit is contained in:
@@ -15,7 +15,6 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.eclipse.lsp4j.CompletionList;
|
||||
import org.eclipse.lsp4j.DiagnosticSeverity;
|
||||
import org.springframework.ide.vscode.commons.languageserver.LanguageIds;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.VscodeCompletionEngineAdapter;
|
||||
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfoProvider;
|
||||
import org.springframework.ide.vscode.commons.languageserver.hover.VscodeHoverEngineAdapter;
|
||||
@@ -26,6 +25,7 @@ import org.springframework.ide.vscode.commons.languageserver.util.DocumentSymbol
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
|
||||
import org.springframework.ide.vscode.commons.util.CollectionUtil;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
import org.springframework.ide.vscode.commons.yaml.ast.YamlASTProvider;
|
||||
import org.springframework.ide.vscode.commons.yaml.completion.SchemaBasedYamlAssistContextProvider;
|
||||
@@ -90,9 +90,9 @@ public class ConcourseLanguageServer extends SimpleLanguageServer {
|
||||
// SimpleWorkspaceService workspace = getWorkspaceService();
|
||||
documents.onDidChangeContent(params -> {
|
||||
TextDocument doc = params.getDocument();
|
||||
if (LanguageIds.CONCOURSE_PIPELINE.equals(doc.getLanguageId())) {
|
||||
if (LanguageId.CONCOURSE_PIPELINE.equals(doc.getLanguageId())) {
|
||||
validateWith(doc.getId(), forPipelines.reconcileEngine);
|
||||
} else if (LanguageIds.CONCOURSE_TASK.equals(doc.getLanguageId())) {
|
||||
} else if (LanguageId.CONCOURSE_TASK.equals(doc.getLanguageId())) {
|
||||
validateWith(doc.getId(), forTasks.reconcileEngine);
|
||||
} else {
|
||||
validateWith(doc.getId(), IReconcileEngine.NULL);
|
||||
@@ -113,9 +113,9 @@ public class ConcourseLanguageServer extends SimpleLanguageServer {
|
||||
documents.onCompletion(params -> {
|
||||
TextDocument doc = documents.get(params);
|
||||
if (doc!=null) {
|
||||
if (LanguageIds.CONCOURSE_PIPELINE.equals(doc.getLanguageId())) {
|
||||
if (LanguageId.CONCOURSE_PIPELINE.equals(doc.getLanguageId())) {
|
||||
return forPipelines.completionEngine.getCompletions(params);
|
||||
} else if (LanguageIds.CONCOURSE_TASK.equals(doc.getLanguageId())) {
|
||||
} else if (LanguageId.CONCOURSE_TASK.equals(doc.getLanguageId())) {
|
||||
return forTasks.completionEngine.getCompletions(params);
|
||||
}
|
||||
}
|
||||
@@ -129,9 +129,9 @@ public class ConcourseLanguageServer extends SimpleLanguageServer {
|
||||
documents.onHover(params -> {
|
||||
TextDocument doc = documents.get(params);
|
||||
if (doc!=null) {
|
||||
if (LanguageIds.CONCOURSE_PIPELINE.equals(doc.getLanguageId())) {
|
||||
if (LanguageId.CONCOURSE_PIPELINE.equals(doc.getLanguageId())) {
|
||||
return forPipelines.hoverEngine.getHover(params);
|
||||
} else if (LanguageIds.CONCOURSE_TASK.equals(doc.getLanguageId())) {
|
||||
} else if (LanguageId.CONCOURSE_TASK.equals(doc.getLanguageId())) {
|
||||
return forTasks.hoverEngine.getHover(params);
|
||||
}
|
||||
}
|
||||
@@ -142,9 +142,9 @@ public class ConcourseLanguageServer extends SimpleLanguageServer {
|
||||
DocumentSymbolHandler handler = DocumentSymbolHandler.NO_SYMBOLS;
|
||||
TextDocument doc = documents.getDocument(params.getTextDocument().getUri());
|
||||
if (doc!=null) {
|
||||
if (LanguageIds.CONCOURSE_PIPELINE.equals(doc.getLanguageId())) {
|
||||
if (LanguageId.CONCOURSE_PIPELINE.equals(doc.getLanguageId())) {
|
||||
handler = forPipelines.symbolHandler;
|
||||
} else if (LanguageIds.CONCOURSE_TASK.equals(doc.getLanguageId())) {
|
||||
} else if (LanguageId.CONCOURSE_TASK.equals(doc.getLanguageId())) {
|
||||
handler = forTasks.symbolHandler;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.ide.vscode.commons.languageserver.LanguageIds;
|
||||
import org.springframework.ide.vscode.commons.languageserver.reconcile.IProblemCollector;
|
||||
import org.springframework.ide.vscode.commons.util.MimeTypes;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
@@ -25,6 +24,7 @@ import org.springframework.ide.vscode.commons.util.ValueParseException;
|
||||
import org.springframework.ide.vscode.commons.util.ValueParser;
|
||||
import org.springframework.ide.vscode.commons.util.ValueParsers;
|
||||
import org.springframework.ide.vscode.commons.util.text.IDocument;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.commons.yaml.ast.NodeUtil;
|
||||
import org.springframework.ide.vscode.commons.yaml.ast.YamlFileAST;
|
||||
import org.springframework.ide.vscode.commons.yaml.path.YamlPath;
|
||||
@@ -241,8 +241,8 @@ public class PipelineYmlSchema implements YamlSchema {
|
||||
addProp(task, "run", t_command).isRequired(true);
|
||||
addProp(task, "params", t_string_params);
|
||||
task.require((dc) -> {
|
||||
String languageId = dc.getDocument().getLanguageId();
|
||||
if (LanguageIds.CONCOURSE_PIPELINE.equals(languageId)) {
|
||||
LanguageId languageId = dc.getDocument().getLanguageId();
|
||||
if (LanguageId.CONCOURSE_PIPELINE.equals(languageId)) {
|
||||
Node parentImageDef = models.getParentPropertyNode("image", dc);
|
||||
if (parentImageDef==null) {
|
||||
return Constraints.requireOneOf("image_resource", "image");
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.eclipse.lsp4j.DiagnosticSeverity;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.commons.languageserver.LanguageIds;
|
||||
import org.springframework.ide.vscode.commons.util.IOUtil;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.CodeAction;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
@@ -40,7 +40,7 @@ public class ConcourseEditorTest {
|
||||
return new ConcourseLanguageServer()
|
||||
.setMaxCompletions(100);
|
||||
},
|
||||
LanguageIds.CONCOURSE_PIPELINE
|
||||
LanguageId.CONCOURSE_PIPELINE
|
||||
);
|
||||
harness.intialize(null);
|
||||
}
|
||||
@@ -2492,12 +2492,12 @@ public class ConcourseEditorTest {
|
||||
@Test public void reconcileTaskFileToplevelProperties() throws Exception {
|
||||
Editor editor;
|
||||
|
||||
editor = harness.newEditor(LanguageIds.CONCOURSE_TASK,
|
||||
editor = harness.newEditor(LanguageId.CONCOURSE_TASK,
|
||||
"image: some-image"
|
||||
);
|
||||
editor.assertProblems("image: some-image|[platform, run] are required");
|
||||
|
||||
editor = harness.newEditor(LanguageIds.CONCOURSE_TASK,
|
||||
editor = harness.newEditor(LanguageId.CONCOURSE_TASK,
|
||||
"platform: a-platform\n" +
|
||||
"image_resource:\n" +
|
||||
" name: should-not-be-here\n" +
|
||||
@@ -2526,6 +2526,10 @@ public class ConcourseEditorTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void reconcileTaskFileMissingToplevelProperties() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Test public void contentAssistTaskFileToplevelProperties() throws Exception {
|
||||
assertTaskCompletions(
|
||||
"<*>"
|
||||
@@ -2560,7 +2564,7 @@ public class ConcourseEditorTest {
|
||||
}
|
||||
|
||||
@Test public void hoversForTaskFileToplevelProperties() throws Exception {
|
||||
Editor editor = harness.newEditor(LanguageIds.CONCOURSE_TASK,
|
||||
Editor editor = harness.newEditor(LanguageId.CONCOURSE_TASK,
|
||||
"image: some-image\n" +
|
||||
"image_resource:\n" +
|
||||
" type: docker-image\n" +
|
||||
@@ -2624,7 +2628,7 @@ public class ConcourseEditorTest {
|
||||
@Test public void taskRunPropertiesValidationAndHovers() throws Exception {
|
||||
Editor editor;
|
||||
|
||||
editor = harness.newEditor(LanguageIds.CONCOURSE_TASK,
|
||||
editor = harness.newEditor(LanguageId.CONCOURSE_TASK,
|
||||
"inputs:\n" +
|
||||
"- name: sts4\n" +
|
||||
"outputs:\n" +
|
||||
@@ -2651,7 +2655,7 @@ public class ConcourseEditorTest {
|
||||
editor.assertHoverContains("dir", "A directory, relative to the initial working directory, to set as the working directory");
|
||||
editor.assertHoverContains("user", "Explicitly set the user to run as");
|
||||
|
||||
editor = harness.newEditor(LanguageIds.CONCOURSE_TASK,
|
||||
editor = harness.newEditor(LanguageId.CONCOURSE_TASK,
|
||||
"inputs:\n" +
|
||||
"- name: sts4\n" +
|
||||
"outputs:\n" +
|
||||
@@ -2668,7 +2672,7 @@ public class ConcourseEditorTest {
|
||||
}
|
||||
|
||||
@Test public void nameAndPathHoversInTaskInputsAndOutputs() throws Exception {
|
||||
Editor editor = harness.newEditor(LanguageIds.CONCOURSE_TASK,
|
||||
Editor editor = harness.newEditor(LanguageId.CONCOURSE_TASK,
|
||||
"inputs:\n" +
|
||||
"- name: sts4\n" +
|
||||
" path: botk\n" +
|
||||
@@ -2798,7 +2802,7 @@ public class ConcourseEditorTest {
|
||||
}
|
||||
|
||||
@Test public void resourceInTaskConfigFileNotRequired() throws Exception {
|
||||
Editor editor = harness.newEditor(LanguageIds.CONCOURSE_TASK,
|
||||
Editor editor = harness.newEditor(LanguageId.CONCOURSE_TASK,
|
||||
"inputs:\n" +
|
||||
"- name: commons-git\n" +
|
||||
"platform: linux\n" +
|
||||
@@ -3120,7 +3124,7 @@ public class ConcourseEditorTest {
|
||||
}
|
||||
|
||||
private void assertTaskCompletions(String textBefore, String... textAfter) throws Exception {
|
||||
Editor editor = harness.newEditor(LanguageIds.CONCOURSE_TASK, textBefore);
|
||||
Editor editor = harness.newEditor(LanguageId.CONCOURSE_TASK, textBefore);
|
||||
editor.assertCompletions(textAfter);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user