mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
Merge pull request #1404 from eclipse/cd_lsp4jDiag
[#1244] adapted to changes in Diagnostic.code in LSP4j
This commit is contained in:
commit
624515c21c
6 changed files with 26 additions and 24 deletions
|
@ -32,7 +32,7 @@ class ValidatorTest extends AbstractTestLangLanguageServerTest {
|
|||
assertEquals("problems found:\n" + problems.join("\n"), 1, problems.size)
|
||||
val problem = problems.head
|
||||
assertEquals("Test Validation to mark the whole type", problem.message)
|
||||
assertEquals(TestLanguageValidator.MULTILINE_PROBLEM, problem.code)
|
||||
assertEquals(TestLanguageValidator.MULTILINE_PROBLEM, problem.code.get)
|
||||
val range = problem.range
|
||||
assertEquals(0, range.start.line)
|
||||
assertEquals(0, range.start.character)
|
||||
|
@ -50,7 +50,7 @@ class ValidatorTest extends AbstractTestLangLanguageServerTest {
|
|||
assertEquals("problems found:\n" + problems.join("\n"), 1, problems.size)
|
||||
val problem = problems.head
|
||||
assertEquals("Test Validation to mark the whole type", problem.message)
|
||||
assertEquals(TestLanguageValidator.MULTILINE_PROBLEM, problem.code)
|
||||
assertEquals(TestLanguageValidator.MULTILINE_PROBLEM, problem.code.get)
|
||||
val range = problem.range
|
||||
assertEquals(0, range.start.line)
|
||||
assertEquals(0, range.start.character)
|
||||
|
@ -70,7 +70,7 @@ class ValidatorTest extends AbstractTestLangLanguageServerTest {
|
|||
assertEquals("problems found:\n" + problems.join("\n"), 1, problems.size)
|
||||
val problem = problems.head
|
||||
assertEquals("Name should start with a capital", problem.message)
|
||||
assertEquals(TestLanguageValidator.INVALID_NAME, problem.code)
|
||||
assertEquals(TestLanguageValidator.INVALID_NAME, problem.code.get)
|
||||
val range = problem.range
|
||||
assertEquals(0, range.start.line)
|
||||
assertEquals(5, range.start.character)
|
||||
|
@ -90,7 +90,7 @@ class ValidatorTest extends AbstractTestLangLanguageServerTest {
|
|||
assertEquals("problems found:\n" + problems.join("\n"), 1, problems.size)
|
||||
val problem = problems.head
|
||||
assertEquals("mismatched input '<EOF>' expecting RULE_ID", problem.message)
|
||||
assertEquals(Diagnostic.SYNTAX_DIAGNOSTIC, problem.code)
|
||||
assertEquals(Diagnostic.SYNTAX_DIAGNOSTIC, problem.code.get)
|
||||
val range = problem.range
|
||||
assertEquals(0, range.start.line)
|
||||
assertEquals(4, range.start.character)
|
||||
|
|
|
@ -38,7 +38,7 @@ class CodeActionService implements ICodeActionService2 {
|
|||
override getCodeActions(Options options) {
|
||||
val actions = newArrayList
|
||||
for (d : options.codeActionParams.context.diagnostics) {
|
||||
switch d.code {
|
||||
switch d.code.get {
|
||||
case INVALID_NAME: actions += Either.forLeft(d.fixInvalidName(options))
|
||||
case UNSORTED_MEMBERS: actions += Either.forRight(d.fixUnsortedMembers(options))
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class ValidatorTest extends AbstractTestLangLanguageServerTest {
|
|||
Assert.assertEquals(_plus, 1, problems.size());
|
||||
final Diagnostic problem = IterableExtensions.<Diagnostic>head(problems);
|
||||
this.assertEquals("Test Validation to mark the whole type", problem.getMessage());
|
||||
this.assertEquals(TestLanguageValidator.MULTILINE_PROBLEM, problem.getCode());
|
||||
Assert.assertEquals(TestLanguageValidator.MULTILINE_PROBLEM, problem.getCode().get());
|
||||
final Range range = problem.getRange();
|
||||
Assert.assertEquals(0, range.getStart().getLine());
|
||||
Assert.assertEquals(0, range.getStart().getCharacter());
|
||||
|
@ -63,7 +63,7 @@ public class ValidatorTest extends AbstractTestLangLanguageServerTest {
|
|||
Assert.assertEquals(_plus, 1, problems.size());
|
||||
final Diagnostic problem = IterableExtensions.<Diagnostic>head(problems);
|
||||
this.assertEquals("Test Validation to mark the whole type", problem.getMessage());
|
||||
this.assertEquals(TestLanguageValidator.MULTILINE_PROBLEM, problem.getCode());
|
||||
Assert.assertEquals(TestLanguageValidator.MULTILINE_PROBLEM, problem.getCode().get());
|
||||
final Range range = problem.getRange();
|
||||
Assert.assertEquals(0, range.getStart().getLine());
|
||||
Assert.assertEquals(0, range.getStart().getCharacter());
|
||||
|
@ -88,7 +88,7 @@ public class ValidatorTest extends AbstractTestLangLanguageServerTest {
|
|||
Assert.assertEquals(_plus, 1, problems.size());
|
||||
final Diagnostic problem = IterableExtensions.<Diagnostic>head(problems);
|
||||
this.assertEquals("Name should start with a capital", problem.getMessage());
|
||||
this.assertEquals(TestLanguageValidator.INVALID_NAME, problem.getCode());
|
||||
Assert.assertEquals(TestLanguageValidator.INVALID_NAME, problem.getCode().get());
|
||||
final Range range = problem.getRange();
|
||||
Assert.assertEquals(0, range.getStart().getLine());
|
||||
Assert.assertEquals(5, range.getStart().getCharacter());
|
||||
|
@ -109,7 +109,7 @@ public class ValidatorTest extends AbstractTestLangLanguageServerTest {
|
|||
Assert.assertEquals(_plus, 1, problems.size());
|
||||
final Diagnostic problem = IterableExtensions.<Diagnostic>head(problems);
|
||||
this.assertEquals("mismatched input \'<EOF>\' expecting RULE_ID", problem.getMessage());
|
||||
this.assertEquals(org.eclipse.xtext.diagnostics.Diagnostic.SYNTAX_DIAGNOSTIC, problem.getCode());
|
||||
Assert.assertEquals(org.eclipse.xtext.diagnostics.Diagnostic.SYNTAX_DIAGNOSTIC, problem.getCode().get());
|
||||
final Range range = problem.getRange();
|
||||
Assert.assertEquals(0, range.getStart().getLine());
|
||||
Assert.assertEquals(4, range.getStart().getCharacter());
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
package org.eclipse.xtext.ide.tests.testlanguage.ide.server;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
|
@ -57,17 +58,18 @@ public class CodeActionService implements ICodeActionService2 {
|
|||
final ArrayList<Either<Command, CodeAction>> actions = CollectionLiterals.<Either<Command, CodeAction>>newArrayList();
|
||||
List<Diagnostic> _diagnostics = options.getCodeActionParams().getContext().getDiagnostics();
|
||||
for (final Diagnostic d : _diagnostics) {
|
||||
String _code = d.getCode();
|
||||
if (_code != null) {
|
||||
switch (_code) {
|
||||
case TestLanguageValidator.INVALID_NAME:
|
||||
Either<Command, CodeAction> _forLeft = Either.<Command, CodeAction>forLeft(this.fixInvalidName(d, options));
|
||||
actions.add(_forLeft);
|
||||
break;
|
||||
case TestLanguageValidator.UNSORTED_MEMBERS:
|
||||
Either<Command, CodeAction> _forRight = Either.<Command, CodeAction>forRight(this.fixUnsortedMembers(d, options));
|
||||
actions.add(_forRight);
|
||||
break;
|
||||
Object _get = d.getCode().get();
|
||||
boolean _matched = false;
|
||||
if (Objects.equal(_get, TestLanguageValidator.INVALID_NAME)) {
|
||||
_matched=true;
|
||||
Either<Command, CodeAction> _forLeft = Either.<Command, CodeAction>forLeft(this.fixInvalidName(d, options));
|
||||
actions.add(_forLeft);
|
||||
}
|
||||
if (!_matched) {
|
||||
if (Objects.equal(_get, TestLanguageValidator.UNSORTED_MEMBERS)) {
|
||||
_matched=true;
|
||||
Either<Command, CodeAction> _forRight = Either.<Command, CodeAction>forRight(this.fixUnsortedMembers(d, options));
|
||||
actions.add(_forRight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -477,7 +477,7 @@ abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
title : «title»
|
||||
kind : «kind»
|
||||
command : «command»
|
||||
«IF !diagnostics.nullOrEmpty»codes : «diagnostics.map[code].join(',')»«ENDIF»
|
||||
«IF !diagnostics.nullOrEmpty»codes : «diagnostics.map[code.get].join(',')»«ENDIF»
|
||||
edit : «edit.toExpectation»
|
||||
'''
|
||||
|
||||
|
|
|
@ -1024,10 +1024,10 @@ public abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
boolean _not = (!_isNullOrEmpty);
|
||||
if (_not) {
|
||||
_builder.append("codes : ");
|
||||
final Function1<Diagnostic, String> _function = (Diagnostic it_1) -> {
|
||||
return it_1.getCode();
|
||||
final Function1<Diagnostic, Object> _function = (Diagnostic it_1) -> {
|
||||
return it_1.getCode().get();
|
||||
};
|
||||
String _join = IterableExtensions.join(ListExtensions.<Diagnostic, String>map(it.getDiagnostics(), _function), ",");
|
||||
String _join = IterableExtensions.join(ListExtensions.<Diagnostic, Object>map(it.getDiagnostics(), _function), ",");
|
||||
_builder.append(_join);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue