use of com.github._1c_syntax.bsl.languageserver.configuration.diagnostics.DiagnosticsOptions in project bsl-language-server by 1c-syntax.
the class LanguageServerConfigurationTest method createFromFile.
@Test
void createFromFile() {
// given
File configurationFile = new File(PATH_TO_CONFIGURATION_FILE);
// when
configuration.update(configurationFile);
// then
DiagnosticsOptions diagnosticsOptions = configuration.getDiagnosticsOptions();
Language language = configuration.getLanguage();
Map<String, Either<Boolean, Map<String, Object>>> parameters = diagnosticsOptions.getParameters();
assertThat(language).isEqualTo(Language.EN);
assertThat(parameters).hasSize(2);
Either<Boolean, Map<String, Object>> lineLength = parameters.get("LineLength");
assertThat(lineLength.isRight()).isTrue();
assertThat(lineLength.getRight()).isInstanceOfAny(Map.class);
assertThat(lineLength.getRight()).extracting(stringObjectMap -> stringObjectMap.get("maxLineLength")).isEqualTo(140);
Either<Boolean, Map<String, Object>> methodSize = parameters.get("MethodSize");
assertThat(methodSize.isLeft()).isTrue();
assertThat(methodSize.getLeft()).isFalse();
Path configurationRoot = configuration.getConfigurationRoot();
assertThat(configurationRoot).isNotNull();
assertThat(configuration.isUseDevSite()).isTrue();
assertThat(configuration.getDiagnosticsOptions().isOrdinaryAppSupport()).isFalse();
}
use of com.github._1c_syntax.bsl.languageserver.configuration.diagnostics.DiagnosticsOptions in project bsl-language-server by 1c-syntax.
the class LanguageServerConfigurationTest method testPartialInitialization.
@Test
void testPartialInitialization() {
// given
File configurationFile = new File(PATH_TO_PARTIAL_CONFIGURATION_FILE);
configuration.update(configurationFile);
// when
CodeLensOptions codeLensOptions = configuration.getCodeLensOptions();
DiagnosticsOptions diagnosticsOptions = configuration.getDiagnosticsOptions();
// then
assertThat(codeLensOptions.isShowCognitiveComplexity()).isTrue();
assertThat(codeLensOptions.isShowCyclomaticComplexity()).isFalse();
assertThat(configuration.getLanguage()).isEqualTo(DEFAULT_LANGUAGE);
assertThat(diagnosticsOptions.getMode()).isEqualTo(Mode.ON);
assertThat(diagnosticsOptions.getSkipSupport()).isEqualTo(SkipSupport.NEVER);
assertThat(diagnosticsOptions.getParameters()).isEmpty();
}
use of com.github._1c_syntax.bsl.languageserver.configuration.diagnostics.DiagnosticsOptions in project bsl-language-server by 1c-syntax.
the class DiagnosticsConfiguration method diagnostics.
@Bean
@Scope("prototype")
public List<BSLDiagnostic> diagnostics(DocumentContext documentContext) {
Collection<DiagnosticInfo> diagnosticInfos = diagnosticInfos();
DiagnosticsOptions diagnosticsOptions = configuration.getDiagnosticsOptions();
if (needToComputeDiagnostics(documentContext, diagnosticsOptions)) {
FileType fileType = documentContext.getFileType();
CompatibilityMode compatibilityMode = documentContext.getServerContext().getConfiguration().getCompatibilityMode();
ModuleType moduleType = documentContext.getModuleType();
return diagnosticInfos.stream().filter(diagnosticInfo -> isEnabled(diagnosticInfo, diagnosticsOptions)).filter(info -> inScope(info, fileType)).filter(info -> correctModuleType(info, moduleType, fileType)).filter(info -> passedCompatibilityMode(info, compatibilityMode)).map(DiagnosticInfo::getDiagnosticClass).map(diagnosticObjectProvider::get).collect(Collectors.toList());
} else {
return Collections.emptyList();
}
}
use of com.github._1c_syntax.bsl.languageserver.configuration.diagnostics.DiagnosticsOptions in project bsl-language-server by 1c-syntax.
the class LanguageServerConfigurationTest method createFromEmptyFile.
@Test
void createFromEmptyFile() {
// given
File configurationFile = new File(PATH_TO_EMPTY_CONFIGURATION_FILE);
// when
configuration.update(configurationFile);
// then
DiagnosticsOptions diagnosticsOptions = configuration.getDiagnosticsOptions();
Language language = configuration.getLanguage();
Map<String, Either<Boolean, Map<String, Object>>> parameters = diagnosticsOptions.getParameters();
assertThat(language).isEqualTo(DEFAULT_LANGUAGE);
assertThat(parameters).isEmpty();
}
Aggregations