use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.
the class CommonModuleNameFullAccessDiagnosticTest method getDocumentContextFromFile.
@SneakyThrows
void getDocumentContextFromFile() {
Path path = Absolute.path(PATH_TO_METADATA);
Path testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath();
initServerContext(path);
var configuration = context.getConfiguration();
documentContext = spy(TestUtils.getDocumentContext(testFile.toUri(), FileUtils.readFileToString(testFile.toFile(), StandardCharsets.UTF_8), context));
module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri()));
}
use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.
the class CommonModuleNameGlobalClientDiagnosticTest method getDocumentContextFromFile.
@SneakyThrows
void getDocumentContextFromFile() {
Path path = Absolute.path(PATH_TO_METADATA);
Path testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath();
initServerContext(path);
var configuration = context.getConfiguration();
documentContext = spy(TestUtils.getDocumentContext(testFile.toUri(), FileUtils.readFileToString(testFile.toFile(), StandardCharsets.UTF_8), context));
module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri()));
}
use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.
the class CommonModuleNameWordsDiagnosticTest method getDocumentContextFromFile.
@SneakyThrows
void getDocumentContextFromFile() {
Path path = Absolute.path(PATH_TO_METADATA);
Path testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath();
initServerContext(path);
var configuration = context.getConfiguration();
documentContext = spy(TestUtils.getDocumentContext(testFile.toUri(), FileUtils.readFileToString(testFile.toFile(), StandardCharsets.UTF_8), context));
module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri()));
}
use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.
the class CommonModuleNameClientDiagnosticTest method getDocumentContextFromFile.
@SneakyThrows
void getDocumentContextFromFile() {
Path path = Absolute.path(PATH_TO_METADATA);
Path testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath();
initServerContext(path);
var configuration = context.getConfiguration();
documentContext = spy(TestUtils.getDocumentContext(testFile.toUri(), FileUtils.readFileToString(testFile.toFile(), StandardCharsets.UTF_8), context));
module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri()));
}
use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.
the class CodeActionProviderTest method testGetCodeActions.
@Test
void testGetCodeActions() {
// given
DiagnosticInfo diagnosticInfo = new DiagnosticInfo(CanonicalSpellingKeywordsDiagnostic.class, configuration);
DiagnosticCode diagnosticCode = diagnosticInfo.getCode();
List<Diagnostic> diagnostics = documentContext.getDiagnostics().stream().filter(diagnostic -> diagnostic.getCode().equals(diagnosticCode)).peek(diagnostic -> diagnostic.setTags(null)).collect(Collectors.toList());
CodeActionParams params = new CodeActionParams();
TextDocumentIdentifier textDocumentIdentifier = new TextDocumentIdentifier(documentContext.getUri().toString());
CodeActionContext codeActionContext = new CodeActionContext();
codeActionContext.setDiagnostics(diagnostics);
params.setRange(new Range());
params.setTextDocument(textDocumentIdentifier);
params.setContext(codeActionContext);
// when
List<Either<Command, CodeAction>> codeActions = codeActionProvider.getCodeActions(params, documentContext);
// then
assertThat(codeActions).extracting(Either::getRight).hasSizeGreaterThanOrEqualTo(3).anyMatch(codeAction -> codeAction.getDiagnostics().contains(diagnostics.get(0))).anyMatch(codeAction -> codeAction.getDiagnostics().contains(diagnostics.get(1))).anyMatch(codeAction -> codeAction.getKind().equals(CodeActionKind.QuickFix)).allMatch(codeAction -> (codeAction.getDiagnostics().size() == 1) == toBoolean(codeAction.getIsPreferred()));
}
Aggregations