use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.
the class ServerContext method computeConfigurationMetadata.
private Configuration computeConfigurationMetadata() {
if (configurationRoot == null) {
return Configuration.create();
}
Configuration configuration;
ForkJoinPool customThreadPool = new ForkJoinPool();
try {
configuration = customThreadPool.submit(() -> Configuration.create(configurationRoot)).fork().join();
} catch (RuntimeException e) {
LOGGER.error("Can't parse configuration metadata. Execution exception.", e);
configuration = Configuration.create();
}
return configuration;
}
use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.
the class CommentedCodeDiagnostic method configure.
@Override
public void configure(Map<String, Object> configuration) {
threshold = ((Number) configuration.getOrDefault("threshold", threshold)).floatValue();
codeRecognizer = new CodeRecognizer(threshold, new BSLFootprint());
}
use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.
the class CodeActionProviderTest method testOnly.
@Test
void testOnly() {
// given
CodeActionParams params = new CodeActionParams();
TextDocumentIdentifier textDocumentIdentifier = new TextDocumentIdentifier(documentContext.getUri().toString());
DiagnosticInfo diagnosticInfo = new DiagnosticInfo(CanonicalSpellingKeywordsDiagnostic.class, configuration);
DiagnosticCode diagnosticCode = diagnosticInfo.getCode();
List<Diagnostic> diagnostics = documentContext.getDiagnostics().stream().filter(diagnostic -> diagnostic.getCode().equals(diagnosticCode)).collect(Collectors.toList());
CodeActionContext codeActionContext = new CodeActionContext();
codeActionContext.setOnly(List.of(CodeActionKind.Refactor));
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).extracting(CodeAction::getKind).containsOnly(CodeActionKind.Refactor);
}
use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.
the class UsingModalWindowsDiagnosticTest method testUseWithForce.
@Test
void testUseWithForce() {
DocumentContext documentContext = getDocumentContextWithUseFlag(UseMode.USE);
Map<String, Object> configuration = diagnosticInstance.getInfo().getDefaultConfiguration();
configuration.put("forceModalityMode", true);
diagnosticInstance.configure(configuration);
List<Diagnostic> diagnostics = getDiagnostics(documentContext);
assertDiagnosticList(diagnostics);
}
use of com.github._1c_syntax.mdclasses.Configuration in project bsl-language-server by 1c-syntax.
the class ServerContextTest method testErrorConfigurationMetadata.
@Test
void testErrorConfigurationMetadata() {
Path path = Absolute.path(Paths.get(PATH_TO_METADATA, "test"));
serverContext.setConfigurationRoot(path);
Configuration configurationMetadata = serverContext.getConfiguration();
assertThat(configurationMetadata).isNotNull();
assertThat(configurationMetadata.getModulesByType()).isEmpty();
}
Aggregations