Search in sources :

Example 1 with Configuration

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;
}
Also used : Configuration(com.github._1c_syntax.mdclasses.Configuration) ForkJoinPool(java.util.concurrent.ForkJoinPool)

Example 2 with 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());
}
Also used : CodeRecognizer(com.github._1c_syntax.bsl.languageserver.recognizer.CodeRecognizer) BSLFootprint(com.github._1c_syntax.bsl.languageserver.recognizer.BSLFootprint)

Example 3 with Configuration

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);
}
Also used : CodeActionParams(org.eclipse.lsp4j.CodeActionParams) DiagnosticInfo(com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticInfo) CodeAction(org.eclipse.lsp4j.CodeAction) BeforeEach(org.junit.jupiter.api.BeforeEach) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Autowired(org.springframework.beans.factory.annotation.Autowired) Diagnostic(org.eclipse.lsp4j.Diagnostic) Range(org.eclipse.lsp4j.Range) DocumentContext(com.github._1c_syntax.bsl.languageserver.context.DocumentContext) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) CodeActionContext(org.eclipse.lsp4j.CodeActionContext) Collectors(java.util.stream.Collectors) CanonicalSpellingKeywordsDiagnostic(com.github._1c_syntax.bsl.languageserver.diagnostics.CanonicalSpellingKeywordsDiagnostic) Test(org.junit.jupiter.api.Test) CodeActionParams(org.eclipse.lsp4j.CodeActionParams) List(java.util.List) LanguageServerConfiguration(com.github._1c_syntax.bsl.languageserver.configuration.LanguageServerConfiguration) Command(org.eclipse.lsp4j.Command) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) CodeActionKind(org.eclipse.lsp4j.CodeActionKind) Either(org.eclipse.lsp4j.jsonrpc.messages.Either) TestUtils(com.github._1c_syntax.bsl.languageserver.util.TestUtils) CheckForNull(javax.annotation.CheckForNull) Collections(java.util.Collections) DiagnosticCode(com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticCode) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) CodeActionContext(org.eclipse.lsp4j.CodeActionContext) DiagnosticInfo(com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticInfo) Diagnostic(org.eclipse.lsp4j.Diagnostic) CanonicalSpellingKeywordsDiagnostic(com.github._1c_syntax.bsl.languageserver.diagnostics.CanonicalSpellingKeywordsDiagnostic) Either(org.eclipse.lsp4j.jsonrpc.messages.Either) DiagnosticCode(com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticCode) Range(org.eclipse.lsp4j.Range) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with Configuration

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);
}
Also used : Diagnostic(org.eclipse.lsp4j.Diagnostic) DocumentContext(com.github._1c_syntax.bsl.languageserver.context.DocumentContext) Test(org.junit.jupiter.api.Test)

Example 5 with Configuration

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();
}
Also used : Path(java.nio.file.Path) Configuration(com.github._1c_syntax.mdclasses.Configuration) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Path (java.nio.file.Path)20 Test (org.junit.jupiter.api.Test)17 Configuration (com.github._1c_syntax.mdclasses.Configuration)14 File (java.io.File)12 MDCommonModule (com.github._1c_syntax.mdclasses.mdo.MDCommonModule)10 SneakyThrows (lombok.SneakyThrows)10 CompatibilityMode (com.github._1c_syntax.mdclasses.common.CompatibilityMode)9 Collectors (java.util.stream.Collectors)8 ModuleType (com.github._1c_syntax.mdclasses.mdo.support.ModuleType)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7 ConfigurationExtension (com.github._1c_syntax.mdclasses.ConfigurationExtension)6 MDOType (com.github._1c_syntax.mdclasses.mdo.support.MDOType)6 ScriptVariant (com.github._1c_syntax.mdclasses.mdo.support.ScriptVariant)6 Absolute (com.github._1c_syntax.utils.Absolute)6 Set (java.util.Set)6 ConfigurationSource (com.github._1c_syntax.mdclasses.common.ConfigurationSource)5 AbstractMDOForm (com.github._1c_syntax.mdclasses.mdo.AbstractMDOForm)5 AbstractMDObjectBase (com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase)5 MDCommonForm (com.github._1c_syntax.mdclasses.mdo.MDCommonForm)5 Form (com.github._1c_syntax.mdclasses.mdo.children.Form)5