use of com.github._1c_syntax.bsl.languageserver.context.ServerContext in project sonar-bsl-plugin-community by 1c-syntax.
the class BSLCoreSensor method processFile.
private void processFile(InputFile inputFile, ServerContext bslServerContext) {
URI uri = inputFile.uri();
String content;
try {
content = IOUtils.toString(inputFile.inputStream(), StandardCharsets.UTF_8);
} catch (IOException e) {
LOGGER.warn("Can't read content of file " + uri, e);
content = "";
}
DocumentContext documentContext = bslServerContext.addDocument(uri, content, 1);
if (langServerEnabled) {
documentContext.getDiagnostics().forEach(diagnostic -> issuesLoader.createIssue(inputFile, diagnostic));
}
saveCpd(inputFile, documentContext);
highlighter.saveHighlighting(inputFile, documentContext);
saveMeasures(inputFile, documentContext);
documentContext.clearSecondaryData();
}
use of com.github._1c_syntax.bsl.languageserver.context.ServerContext in project bsl-language-server by 1c-syntax.
the class DiagnosticsTest method testCompatibilityMode.
@Test
void testCompatibilityMode() {
// given
documentContext = spy(TestUtils.getDocumentContext(""));
var serverContext = spy(context);
var bslConfiguration = spy(serverContext.getConfiguration());
doReturn(serverContext).when(documentContext).getServerContext();
doReturn(bslConfiguration).when(serverContext).getConfiguration();
configuration.getDiagnosticsOptions().setMode(Mode.ON);
// when-then pairs
doReturn(new CompatibilityMode(3, 10)).when(bslConfiguration).getCompatibilityMode();
assertThat(diagnosticsConfiguration.diagnostics(documentContext)).anyMatch(diagnostic -> diagnostic instanceof DeprecatedFindDiagnostic);
doReturn(new CompatibilityMode(3, 6)).when(bslConfiguration).getCompatibilityMode();
assertThat(diagnosticsConfiguration.diagnostics(documentContext)).anyMatch(diagnostic -> diagnostic instanceof DeprecatedFindDiagnostic);
doReturn(new CompatibilityMode(2, 16)).when(bslConfiguration).getCompatibilityMode();
assertThat(diagnosticsConfiguration.diagnostics(documentContext)).noneMatch(diagnostic -> diagnostic instanceof DeprecatedFindDiagnostic);
}
Aggregations