use of com.github._1c_syntax.bsl.languageserver.jsonrpc.Diagnostics in project bsl-language-server by 1c-syntax.
the class BSLTextDocumentService method diagnostics.
@Override
public CompletableFuture<Diagnostics> diagnostics(DiagnosticParams params) {
DocumentContext documentContext = context.getDocument(params.getTextDocument().getUri());
if (documentContext == null) {
return CompletableFuture.completedFuture(Diagnostics.EMPTY);
}
return CompletableFuture.supplyAsync(() -> {
var diagnostics = documentContext.getDiagnostics();
var range = params.getRange();
if (range != null) {
diagnostics = diagnostics.stream().filter(diagnostic -> Ranges.containsRange(range, diagnostic.getRange())).collect(Collectors.toList());
}
return new Diagnostics(diagnostics, documentContext.getVersion());
});
}
use of com.github._1c_syntax.bsl.languageserver.jsonrpc.Diagnostics in project bsl-language-server by 1c-syntax.
the class CompilationDirectiveLostDiagnosticTest method testFormModule.
@Test
void testFormModule() {
DocumentContext documentContext = getDocumentContext();
List<Diagnostic> diagnostics = getDiagnostics(documentContext);
assertThat(diagnostics).hasSize(1);
assertThat(diagnostics, true).hasRange(9, 8, 9, 16);
}
use of com.github._1c_syntax.bsl.languageserver.jsonrpc.Diagnostics in project bsl-language-server by 1c-syntax.
the class CommonModuleAssignDiagnosticTest method test.
@SneakyThrows
@Test
void test() {
Path path = Absolute.path(PATH_TO_METADATA);
initServerContext(path);
Path testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath();
DocumentContext documentContext = TestUtils.getDocumentContext(testFile.toUri(), FileUtils.readFileToString(testFile.toFile(), StandardCharsets.UTF_8), context);
List<Diagnostic> diagnostics = diagnosticInstance.getDiagnostics(documentContext);
assertThat(diagnostics).hasSize(1);
assertThat(diagnostics, true).hasRange(3, 0, 3, 17);
}
use of com.github._1c_syntax.bsl.languageserver.jsonrpc.Diagnostics in project bsl-language-server by 1c-syntax.
the class CanonicalSpellingKeywordsDiagnosticTest method testQuickFix.
@Test
void testQuickFix() {
final DocumentContext documentContext = getDocumentContext();
List<Diagnostic> diagnostics = getDiagnostics();
final Diagnostic firstDiagnostic = diagnostics.get(0);
List<CodeAction> quickFixes = getQuickFixes(firstDiagnostic);
assertThat(quickFixes).hasSize(1);
final CodeAction quickFix = quickFixes.get(0);
assertThat(quickFix).of(diagnosticInstance).in(documentContext).fixes(firstDiagnostic);
assertThat(quickFix).in(documentContext).hasChanges(1);
}
use of com.github._1c_syntax.bsl.languageserver.jsonrpc.Diagnostics in project bsl-language-server by 1c-syntax.
the class EmptyRegionDiagnosticTest method testQuickFix.
@Test
void testQuickFix() {
final DocumentContext documentContext = getDocumentContext();
List<Diagnostic> diagnostics = getDiagnostics();
final Diagnostic externalRegionDiagnostic = diagnostics.get(2);
final Diagnostic internalRegionDiagnostic = diagnostics.get(1);
List<CodeAction> quickFixes = getQuickFixes(externalRegionDiagnostic);
assertThat(quickFixes).hasSize(1);
final CodeAction quickFix = quickFixes.get(0);
assertThat(quickFix).of(diagnosticInstance).in(documentContext).fixes(externalRegionDiagnostic);
assertThat(quickFix).of(diagnosticInstance).in(documentContext).fixes(internalRegionDiagnostic);
assertThat(quickFix).in(documentContext).hasChanges(1).hasNewText("");
}
Aggregations