diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 76edfa61db8..1b6a3b2913c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1 +1,38 @@ -{"image":"mcr.microsoft.com/devcontainers/universal:2"} \ No newline at end of file +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/java +{ + "name": "Java", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/java:1-17-bookworm", + + "features": { + "ghcr.io/devcontainers/features/java:1": { + "version": "none", + "installMaven": "false", + "installGradle": "true" + }, + "ghcr.io/devcontainers/features/python:1": {} + }, + "customizations": { + "vscode": { + "extensions": [ + "vscjava.vscode-gradle", + "GitHub.vscode-github-actions", + "astrizhachuk.1c-extension-pack", + "zhuangtongfa.Material-theme" + ] + } + } + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "java -version", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7687c759aff..cd99e05a5b4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,7 +9,15 @@ updates: directory: "/" # Location of package manifests schedule: interval: "daily" + groups: + freefair: + patterns: + - "io.freefair.*" - package-ecosystem: "github-actions" directory: "/" schedule: interval: "daily" + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index a151fc26bd9..24f4b47c2d6 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -29,16 +29,17 @@ jobs: uses: actions/checkout@v3 - name: Setup JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 17 distribution: 'temurin' + cache: gradle - name: Build with Gradle run: ./gradlew bootJar - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.7" diff --git a/.github/workflows/check-package.yml b/.github/workflows/check-package.yml index b7850fa9785..0aafe4335dd 100644 --- a/.github/workflows/check-package.yml +++ b/.github/workflows/check-package.yml @@ -31,13 +31,14 @@ jobs: steps: - name: Checkout source - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: - java-version: 20 + java-version: 21 distribution: 'temurin' + cache: gradle - name: Build bootJar with Gradle run: ./gradlew check build diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4a201535b01..eede133d6de 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -23,21 +23,22 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # We must fetch at least the immediate parents so that if this is # a pull request then we can checkout the head. fetch-depth: 2 - - name: Set up JDK 11 - uses: actions/setup-java@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v4 with: java-version: 17 distribution: 'temurin' + cache: gradle # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 # Override language selection by uncommenting this and choosing your languages with: languages: java @@ -52,4 +53,4 @@ jobs: - run: ./gradlew jar - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 50423a636b0..e37def7222c 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -17,19 +17,20 @@ jobs: build-deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 17 distribution: 'temurin' + cache: gradle - name: Build javadoc run: ./gradlew --no-daemon javadoc - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.7.15' architecture: 'x64' @@ -145,7 +146,7 @@ jobs: cp -R temp/site/. public/dev/en - name: Deploy - uses: peaceiris/actions-gh-pages@v3.9.3 + uses: peaceiris/actions-gh-pages@v4.0.0 with: deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} publish_branch: gh-pages diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index d64c2a2cbd3..5d3c2e361f2 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -18,20 +18,21 @@ jobs: strategy: fail-fast: false matrix: - java_version: ['17', '20'] + java_version: ['17', '21'] os: [ubuntu-latest, windows-latest, macOS-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK ${{ matrix.java_version }} - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: ${{ matrix.java_version }} distribution: 'temurin' + cache: gradle - name: Build with Gradle run: ./gradlew check --stacktrace - name: Archive test results if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: junit_report_${{ matrix.os }}_${{ matrix.java_version }} path: build/reports/tests/test diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml index 6c28e6b491d..391052f8d68 100644 --- a/.github/workflows/javadoc.yml +++ b/.github/workflows/javadoc.yml @@ -17,11 +17,12 @@ jobs: needs: gatekeeper runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 17 distribution: 'temurin' + cache: gradle - name: Check javadoc build run: ./gradlew javadoc --stacktrace diff --git a/.github/workflows/pre-qa.yml b/.github/workflows/pre-qa.yml index bc9564dc609..5c9485192e5 100644 --- a/.github/workflows/pre-qa.yml +++ b/.github/workflows/pre-qa.yml @@ -21,7 +21,7 @@ jobs: run: echo ${{ github.event.number }} > PR_NUMBER.txt - name: Archive PR number if: github.event_name == 'pull_request' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: PR_NUMBER path: PR_NUMBER.txt diff --git a/.github/workflows/publish-to-sonatype.yml b/.github/workflows/publish-to-sonatype.yml index 8db838b6f4e..8dd8c892fa0 100644 --- a/.github/workflows/publish-to-sonatype.yml +++ b/.github/workflows/publish-to-sonatype.yml @@ -12,12 +12,13 @@ jobs: publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 17 distribution: 'temurin' + cache: gradle - name: Publish to Sonatype run: ./gradlew publishMavenPublicationToSonatypeRepository -PsimplifyVersion env: diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index c6d82bb0b10..d3fa9fe8363 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Download PR number artifact if: github.event.workflow_run.event == 'pull_request' - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v5 with: workflow: ${{ github.event.workflow_run.name }} run_id: ${{ github.event.workflow_run.id }} @@ -34,7 +34,7 @@ jobs: full_name: ${{ github.event.repository.full_name }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ github.event.workflow_run.head_repository.full_name }} ref: ${{ github.event.workflow_run.head_branch }} @@ -48,10 +48,11 @@ jobs: git checkout ${{ github.event.workflow_run.head_branch }} git clean -ffdx && git reset --hard HEAD - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 17 distribution: 'temurin' + cache: gradle - name: SonarCloud Scan on PR if: github.event.workflow_run.event == 'pull_request' run: ./gradlew check sonar -Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} -Dsonar.pullrequest.key=${{ fromJson(steps.get_pr_data.outputs.data).number }} -Dsonar.pullrequest.branch=${{ fromJson(steps.get_pr_data.outputs.data).head.ref }} -Dsonar.pullrequest.base=${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} diff --git a/.github/workflows/qodana.yml b/.github/workflows/qodana.yml index b66887e84a0..dc40d3d41fb 100644 --- a/.github/workflows/qodana.yml +++ b/.github/workflows/qodana.yml @@ -10,7 +10,7 @@ on: jobs: gatekeeper: runs-on: ubuntu-latest - if: github.event_name == 'pull_request' && startsWith(github.head_ref, 'translations_') == false || github.event_name == 'push' + if: github.event_name == 'pull_request' && startsWith(github.head_ref, 'translations_') == false || github.event_name == 'push' || github.event_name == 'workflow_dispatch' steps: - run: echo 'Open the Golden Gate' @@ -18,19 +18,19 @@ jobs: needs: gatekeeper runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 'Qodana Scan' - uses: JetBrains/qodana-action@v2023.2.1 + uses: JetBrains/qodana-action@v2024.1.5 env: QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} with: linter: jetbrains/qodana-jvm-community - - uses: github/codeql-action/upload-sarif@v2 + - uses: github/codeql-action/upload-sarif@v3 with: sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json - name: Deploy to GitHub Pages if: github.event_name == 'push' - uses: peaceiris/actions-gh-pages@v3.9.3 + uses: peaceiris/actions-gh-pages@v4.0.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ${{ runner.temp }}/qodana/results/report diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml index 4e1a59c9938..c06a1bcdf2e 100644 --- a/.github/workflows/rebase.yml +++ b/.github/workflows/rebase.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the latest code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: token: ${{ secrets.GITHUB_TOKEN }} fetch-depth: 0 # otherwise, you will fail to push refs to dest repo diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9e6e4fd2816..783c4057b71 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,13 +28,14 @@ jobs: steps: - name: Checkout source - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: - java-version: 20 + java-version: 21 distribution: 'temurin' + cache: gradle - name: Build bootJar with Gradle run: ./gradlew check bootJar @@ -43,13 +44,13 @@ jobs: run: python .github/scripts/build-jpackage.py ${{ matrix.prefix }} ${{ matrix.app-image }} - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: bsl-language-server_${{ matrix.prefix }}.zip path: ./${{ matrix.app-image }} - name: Upload assets to release - uses: AButler/upload-release-assets@v2.0 + uses: AButler/upload-release-assets@v3.0 with: files: './bsl-language-server_${{ matrix.prefix }}.zip' repo-token: ${{ secrets.GITHUB_TOKEN }} @@ -60,7 +61,7 @@ jobs: - name: Upload jar to release if: matrix.prefix == 'nix' - uses: AButler/upload-release-assets@v2.0 + uses: AButler/upload-release-assets@v3.0 with: files: './build/libs/*.jar' repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/sentry.yml b/.github/workflows/sentry.yml index c435c5b8af7..5ed0d5a5622 100644 --- a/.github/workflows/sentry.yml +++ b/.github/workflows/sentry.yml @@ -2,14 +2,15 @@ name: Sentry on: push: branches-ignore: - - "translations_*" + - "translations_**" + - "dependabot/**" jobs: sentry: name: Sentry runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Create Sentry release uses: getsentry/action-release@v1 env: diff --git a/.github/workflows/update-gradle.yml b/.github/workflows/update-gradle.yml new file mode 100644 index 00000000000..82ef2caa042 --- /dev/null +++ b/.github/workflows/update-gradle.yml @@ -0,0 +1,26 @@ +name: Update Gradle Wrapper + +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * 0" + +jobs: + update-gradle-wrapper: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + cache: gradle + + - name: Update Gradle Wrapper + uses: gradle-update/update-gradle-wrapper-action@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + set-distribution-checksum: false diff --git a/.gitignore b/.gitignore index 317b6dd3d8d..09ec85e6fc1 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,6 @@ public/ bsl-language-server/ bsl-language-server_*.zip /.idea/misc.xml +*.log +*.hprof +/.idea/material_theme_project_new.xml diff --git a/build.gradle.kts b/build.gradle.kts index 7ff85d46ccc..5a70f42f60f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,8 @@ +import gradlegitproperties.org.ajoberstar.grgit.Grgit import me.qoomon.gitversioning.commons.GitRefType import org.apache.tools.ant.filters.EscapeUnicode import java.util.* +import java.text.SimpleDateFormat plugins { `java-library` @@ -8,28 +10,28 @@ plugins { jacoco signing id("org.cadixdev.licenser") version "0.6.1" - id("org.sonarqube") version "4.3.0.3225" - id("io.freefair.lombok") version "8.1.0" - id("io.freefair.javadoc-links") version "8.1.0" - id("io.freefair.javadoc-utf-8") version "8.1.0" - id("io.freefair.aspectj.post-compile-weaving") version "8.1.0" - id("io.freefair.maven-central.validate-poms") version "8.1.0" - id("me.qoomon.git-versioning") version "6.4.2" - id("com.github.ben-manes.versions") version "0.47.0" - id("org.springframework.boot") version "3.1.2" - id("io.spring.dependency-management") version "1.1.2" - id("io.github.1c-syntax.bslls-dev-tools") version "0.7.3" - id("ru.vyarus.pom") version "2.2.2" - id("com.gorylenko.gradle-git-properties") version "2.4.1" + id("org.sonarqube") version "5.0.0.4638" + id("io.freefair.lombok") version "8.6" + id("io.freefair.javadoc-links") version "8.6" + id("io.freefair.javadoc-utf-8") version "8.6" + id("io.freefair.aspectj.post-compile-weaving") version "8.6" + id("io.freefair.maven-central.validate-poms") version "8.6" + id("me.qoomon.git-versioning") version "6.4.3" + id("com.github.ben-manes.versions") version "0.51.0" + id("org.springframework.boot") version "3.2.5" + id("io.spring.dependency-management") version "1.1.5" + id("io.github.1c-syntax.bslls-dev-tools") version "0.8.0" + id("ru.vyarus.pom") version "3.0.0" + id("com.gorylenko.gradle-git-properties") version "2.4.2" id("io.codearte.nexus-staging") version "0.30.0" - id("me.champeau.jmh") version "0.7.1" + id("me.champeau.jmh") version "0.7.2" } repositories { mavenLocal() mavenCentral() maven(url = "https://jitpack.io") - maven(url = "https://projectlombok.org/edge-releases") + maven(url = "https://projectlombok.org/edge-releases") } group = "io.github.1c-syntax" @@ -50,13 +52,17 @@ gitVersioning.apply { } } +gitProperties { + customProperty("git.build.time", buildTime()) +} + val isSnapshot = gitVersioning.gitVersionDetails.refType != GitRefType.TAG -val languageToolVersion = "6.1" +val languageToolVersion = "6.4" dependencyManagement { imports { - mavenBom("io.sentry:sentry-bom:6.27.0") + mavenBom("io.sentry:sentry-bom:7.9.0") } } @@ -67,25 +73,25 @@ dependencies { // spring api("org.springframework.boot:spring-boot-starter") api("org.springframework.boot:spring-boot-starter-websocket") - api("info.picocli:picocli-spring-boot-starter:4.7.4") + api("info.picocli:picocli-spring-boot-starter:4.7.6") // lsp4j core - api("org.eclipse.lsp4j", "org.eclipse.lsp4j", "0.21.0") - api("org.eclipse.lsp4j", "org.eclipse.lsp4j.websocket.jakarta", "0.21.0") + api("org.eclipse.lsp4j", "org.eclipse.lsp4j", "0.23.1") + api("org.eclipse.lsp4j", "org.eclipse.lsp4j.websocket.jakarta", "0.23.1") // 1c-syntax - api("com.github.1c-syntax", "bsl-parser", "0.22.1") { + api("io.github.1c-syntax", "bsl-parser", "0.24.0") { exclude("com.tunnelvisionlabs", "antlr4-annotations") exclude("com.ibm.icu", "*") exclude("org.antlr", "ST4") exclude("org.abego.treelayout", "org.abego.treelayout.core") exclude("org.antlr", "antlr-runtime") - exclude("org.glassfish", "javax.json") } - api("com.github.1c-syntax", "utils", "0.5.1") - api("com.github.1c-syntax", "mdclasses", "0.10.3") - api("io.github.1c-syntax", "bsl-common-library", "0.3.0") - api("io.github.1c-syntax", "supportconf", "0.1.1") + api("io.github.1c-syntax", "utils", "0.6.1") + api("io.github.1c-syntax", "mdclasses", "0.13.0") + api("io.github.1c-syntax", "bsl-common-library", "0.6.0") + api("io.github.1c-syntax", "supportconf", "0.14.0") + api("io.github.1c-syntax", "bsl-parser-core", "0.1.0") // JLanguageTool implementation("org.languagetool", "languagetool-core", languageToolVersion){ @@ -95,19 +101,19 @@ dependencies { implementation("org.languagetool", "language-ru", languageToolVersion) // AOP - implementation("org.aspectj", "aspectjrt", "1.9.19") + implementation("org.aspectj", "aspectjrt", "1.9.22.1") // commons utils - implementation("commons-io", "commons-io", "2.13.0") - implementation("org.apache.commons", "commons-lang3", "3.12.0") + implementation("commons-io", "commons-io", "2.16.1") + implementation("org.apache.commons", "commons-lang3", "3.14.0") implementation("commons-beanutils", "commons-beanutils", "1.9.4"){ exclude("commons-logging", "commons-logging") } implementation("org.apache.commons", "commons-collections4", "4.4") - implementation("org.apache.commons", "commons-exec", "1.3") + implementation("org.apache.commons", "commons-exec", "1.4.0") // progress bar - implementation("me.tongfei", "progressbar", "0.9.5") + implementation("me.tongfei", "progressbar", "0.10.1") // (de)serialization implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310") @@ -120,18 +126,18 @@ dependencies { implementation("com.contrastsecurity", "java-sarif", "2.0") // Sentry - implementation("io.sentry:sentry-spring-boot-starter") + implementation("io.sentry:sentry-spring-boot-starter-jakarta") implementation("io.sentry:sentry-logback") // CONSTRAINTS implementation("com.google.guava:guava") { version { - strictly("32.0.1-jre") + strictly("33.2.1-jre") } } // COMPILE - compileOnly("com.github.spotbugs:spotbugs-annotations:4.7.3") + compileOnly("com.github.spotbugs:spotbugs-annotations:4.8.5") // TEST @@ -142,11 +148,11 @@ dependencies { // test utils testImplementation("org.jmockit", "jmockit", "1.49") - testImplementation("org.awaitility", "awaitility", "4.2.0") + testImplementation("org.awaitility", "awaitility", "4.2.1") } lombok { - version.set("edge-SNAPSHOT") + version.set("1.18.32") } jacoco { @@ -385,3 +391,9 @@ nexusStaging { tasks.withType { enabled = false } + +fun buildTime(): String { + val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") + formatter.timeZone = TimeZone.getTimeZone("UTC") + return formatter.format(Date()) +} diff --git a/docs/contributing/DiagnosticStructure.md b/docs/contributing/DiagnosticStructure.md index a312a01d2a2..f98512c41f9 100644 --- a/docs/contributing/DiagnosticStructure.md +++ b/docs/contributing/DiagnosticStructure.md @@ -45,11 +45,13 @@ - Тип диагностики `type` и ее важность `severity`, для каждой диагностики обязательно их определение. Для того, чтобы правильно выбрать тип и важность диагностики, можно обратиться к [статье](DiagnosticTypeAndSeverity.md). - Время на исправление замечания `minutesToFix` (по умолчанию 0). Данное значение используется при расчете общего техдолга проекта в трудозатрах на исправление всех замечаний (сумма времени на исправление по всем обнаруженным замечаниям). Стоит указывать время, максимально реалистичное, которое разработчик должен потратить на исправление. +- С помощью параметра `extraMinForComplexity` можно динамически увеличивать время на исправление замечания для диагностик, в которых учитывается несколько нарушающих правило мест, например при расчете сложности метода. - Набор тэгов `tag` диагностики, указывающих группы, к котором она относится. Подробнее о тэга в [статье](DiagnosticTag.md). - Границы применимости `scope` (по умолчанию `ALL`, т.е. без ограничения). BSL LS поддерживает несколько языков (oscript и bsl) и диагностики могут применяться как к одному конкретному языку, так и ко всем сразу. - Активность правила по-умолчанию `activatedByDefault` (по умолчанию `Истина`). При разработке экспериментальных, спорных либо не применимых в большинстве проектов, стоит по умолчанию отключать диагностику, активацию выполнит конечный пользователь решения. - Режим совместимости `compatibilityMode`, по которому фильтруются диагностики при использовании метаданных. По умолчанию `UNDEFINED`. - +- Список типов модулей `modules` для возможности ограничить анализируемую диагностикой область +- Признак возможности установить замечания на весь проект `canLocateOnProject`. Используется для диагностик не связанных с модулем исходного кода. На данный момент опция воспринимается только SonarQube, остальные инструменты игнорируют. Последние два могут быть опущены. Пример аннотации @@ -64,8 +66,14 @@ compatibilityMode = DiagnosticCompatibilityMode.COMPATIBILITY_MODE_8_3_3, // Режим проверки совместимости с 8.3.3 tags = { DiagnosticTag.STANDARD // Относится к диагностикам нарушения стандарта 1С - } + }, + modules = { + ModuleType.CommonModule // Анализируются только общие модули + }, + canLocateOnProject = false, // Замечание будет размещено только в привязке к модулю + extraMinForComplexity = 1 // За каждую дополнительную позицию замечания (`DiagnosticRelatedInformation`) будет добавлено по одной минуте ) + ``` Класс должен реализовывать интерфейс `BSLDiagnostic`. Если диагностика основывается на AST дереве, то класс реализации должен быть унаследован от одного из классов ниже, реализующих `BSLDiagnostic`: diff --git a/docs/diagnostics/CanonicalSpellingKeywords.md b/docs/diagnostics/CanonicalSpellingKeywords.md index dd96d369be8..11307483692 100644 --- a/docs/diagnostics/CanonicalSpellingKeywords.md +++ b/docs/diagnostics/CanonicalSpellingKeywords.md @@ -32,7 +32,7 @@ | Неопределено | Undefined | | Перейти | Goto | | Перем | Var | -| По | For | +| По | To | | Пока | WHile | | Попытка | Try | | Процедура | Procedure | diff --git a/docs/diagnostics/CognitiveComplexity.md b/docs/diagnostics/CognitiveComplexity.md index 0ffca8e0984..8604ddeff30 100644 --- a/docs/diagnostics/CognitiveComplexity.md +++ b/docs/diagnostics/CognitiveComplexity.md @@ -123,7 +123,7 @@ И НЕ Символы.Экспортный() Тогда // +1, логическая операция, вложенность не учитывается Если МожноПереопределить(Символ) Тогда // +3, вложенное условие, вложенность 2 - Переопредялемость = ПроверитьПереопределяемость(Символ, ТипКласса); + Переопределяемость = ПроверитьПереопределяемость(Символ, ТипКласса); Если Переопределяемость = Неопределено Тогда // +4, вложенное условие, вложенность 3 Если НЕ НеизвестностьНайдена Тогда // +5, вложенное условие, вложенность 4 НеизвестностьНайдена = Истина; diff --git a/docs/diagnostics/DenyIncompleteValues.md b/docs/diagnostics/DenyIncompleteValues.md index bd69b8cc1fe..9c2a9bc3864 100644 --- a/docs/diagnostics/DenyIncompleteValues.md +++ b/docs/diagnostics/DenyIncompleteValues.md @@ -1,4 +1,4 @@ -# Запрет незаполненных значений (DenyIncompleteValues) +# Запрет незаполненных значений у измерений регистров (DenyIncompleteValues) ## Описание диагностики diff --git a/docs/diagnostics/DisableSafeMode.md b/docs/diagnostics/DisableSafeMode.md new file mode 100644 index 00000000000..31a74a35a8e --- /dev/null +++ b/docs/diagnostics/DisableSafeMode.md @@ -0,0 +1,45 @@ +# Отключение безопасного режима (DisableSafeMode) + + +## Описание диагностики + +Помимо программного кода конфигурации, в прикладном решении может исполняться сторонний программный код, который может быть подключен с помощью внешних отчетов, внешних обработок, расширений конфигурации, внешних компонент или другими способами, например, с помощью стороннего (по отношению к конфигурации) программного кода, надежность которого разработчик гарантировать не может (далее – внешний код). При этом злоумышленник может предусмотреть в нем различные деструктивные действия (как в самом внешнем коде, так и опосредовано, через запуск внешних приложений, внешних компонент, COM-объектов), которые могут нанести вред компьютерам пользователей, серверным компьютерам, а также данным в программе. + +Перечисленные проблемы безопасности особенно критичны при работе конфигураций в модели сервиса. Например, получив доступ к сервису, вредоносный код может получить доступ сразу ко всем приложениям всех пользователей сервиса. + +Поэтому важно контролировать выполнение подобного внешнего кода в безопасном режиме, в исключительных случаях точечно разрешая выполнять код в небезопасном режиме после верификации кода. + +Правило диагностирует вызовы методов ` УстановитьБезопасныйРежим` и `УстановитьОтключениеБезопасногоРежима` в режиме отключения контроля безопасного режима +- вызов `УстановитьБезопасныйРежим (Истина)` игнорируется +- вызов `УстановитьОтключениеБезопасногоРежима(Ложь)` игнорируется + +## Примеры + +``` + УстановитьБезопасныйРежим (Ложь); // есть замечание + + Значение = Ложь; + УстановитьБезопасныйРежим (Значение); // есть замечание + + УстановитьБезопасныйРежим (Истина); // нет замечания + + УстановитьОтключениеБезопасногоРежима(Истина); // есть замечание + + Значение = Истина; + УстановитьОтключениеБезопасногоРежима(Значение); // есть замечание + + УстановитьОтключениеБезопасногоРежима(Ложь); // нет замечания +``` + +## Источники + + +- [Статья "Безопасный режим работы" - руководство разработчика 1С 8.3.22](https://its.1c.ru/db/v8322doc#bookmark:dev:TI000000186@ee788d9) +- [Стандарт "Ограничение на выполнение «внешнего» кода"](https://its.1c.ru/db/v8std/content/669/hdoc) +- [Стандарт "Безопасность прикладного программного интерфейса сервера"](https://its.1c.ru/db/v8std/content/678/hdoc) +- [Стандарт "Ограничения на использование Выполнить и Вычислить на сервере"](https://its.1c.ru/db/v8std#content:770:hdoc) +- [Стандарт Использование привилегированного режима](https://its.1c.ru/db/v8std/content/485/hdoc) diff --git a/docs/diagnostics/ExternalAppStarting.md b/docs/diagnostics/ExternalAppStarting.md new file mode 100644 index 00000000000..711d1403a18 --- /dev/null +++ b/docs/diagnostics/ExternalAppStarting.md @@ -0,0 +1,78 @@ +# Запуск внешних приложений (ExternalAppStarting) + + +## Описание диагностики + +Для повышения качества и безопасности решения на 1С необходимо контролировать запуск внешних приложений из кода 1С. + +Данное правило распространяется на все способы запуска внешних программ, в том числе: +- КомандаСистемы +- ЗапуститьСистему +- ЗапуститьПриложение +- НачатьЗапускПриложения +- ЗапуститьПриложениеАсинх +- ПерейтиПоНавигационнойСсылке или ФайловаяСистемаКлиент.ОткрытьНавигационнуюСсылку +- ФайловаяСистемаКлиент.ЗапуститьПрограмму (в клиентском коде) и ФайловаяСистема.ЗапуститьПрограмму (в серверном коде) +- ФайловаяСистемаКлиент.ОткрытьПроводник +- ФайловаяСистемаКлиент.ОткрытьФайл + +## Примеры + +```bsl +Процедура Метод() + СтрокаКоманды = ""; + ТекущийКаталог = ""; + ДождатьсяЗавершения = Истина; + ОписаниеОповещения = Неопределено; + ПараметрыКоманды = Новый Структура; + + КомандаСистемы(СтрокаКоманды, ТекущийКаталог); // есть замечание + ЗапуститьПриложение(СтрокаКоманды, ТекущийКаталог); // есть замечание + ЗапуститьПриложение(СтрокаКоманды, ТекущийКаталог, Истина); // есть замечание + + НачатьЗапускПриложения(ОписаниеОповещения, СтрокаКоманды, ТекущийКаталог, ДождатьсяЗавершения); // есть замечание + + ПерейтиПоНавигационнойСсылке(СтрокаКоманды); // есть замечание + ФайловаяСистемаКлиент.ОткрытьНавигационнуюСсылку(СтрокаКоманды); // есть замечание + ФайловаяСистемаКлиент.ОткрытьНавигационнуюСсылку(СтрокаКоманды, ОписаниеОповещения); // есть замечание + + ФайловаяСистемаКлиент.ЗапуститьПрограмму("ping 127.0.0.1 -n 5", ПараметрыКоманды); // есть замечание + ФайловаяСистемаКлиент.ЗапуститьПрограмму(СтрокаКоманды, ПараметрыКоманды); // есть замечание + ФайловаяСистема.ЗапуститьПрограмму(СтрокаКоманды); // есть замечание + ФайловаяСистема.ЗапуститьПрограмму(СтрокаКоманды, ПараметрыКоманды); // есть замечание + + ФайловаяСистемаКлиент.ОткрытьПроводник("C:\Users"); // есть замечание + ФайловаяСистемаКлиент.ОткрытьФайл(СтрокаКоманды); // есть замечание + ФайловаяСистемаКлиент.ОткрытьФайл(СтрокаКоманды, ОписаниеОповещения); // есть замечание + +КонецПроцедуры + +&НаКлиенте +Асинх Процедура Подключить() + СтрокаКоманды = ""; + ТекущийКаталог = ""; + ДождатьсяЗавершения = Истина; + + Ждать ЗапуститьПриложениеАсинх(СтрокаКоманды, ТекущийКаталог, ДождатьсяЗавершения); // есть замечание +КонецПроцедуры + +&НаКлиенте +Процедура ПроверкаЗапуститьСистему(ДополнительныеПараметрыКоманднойСтроки, КодВозврата) + ДождатьсяЗавершения = Истина; + + ЗапуститьСистему(); // есть замечание + ЗапуститьСистему(ДополнительныеПараметрыКоманднойСтроки); // есть замечание + ЗапуститьСистему(ДополнительныеПараметрыКоманднойСтроки, ДождатьсяЗавершения); // есть замечание + ЗапуститьСистему(ДополнительныеПараметрыКоманднойСтроки, ДождатьсяЗавершения, КодВозврата); // есть замечание +КонецПроцедуры +``` + +## Источники + + +- [стандарт Безопасность запуска приложений](https://its.1c.ru/db/v8std/content/774/hdoc) +- [стандарт Ограничение на выполнение «внешнего» кода](https://its.1c.ru/db/v8std/content/669/hdoc ) diff --git a/docs/diagnostics/FileSystemAccess.md b/docs/diagnostics/FileSystemAccess.md new file mode 100644 index 00000000000..ea11adf570b --- /dev/null +++ b/docs/diagnostics/FileSystemAccess.md @@ -0,0 +1,39 @@ +# Доступ к файловой системе (FileSystemAccess) + + +## Описание диагностики + +При код-ревью или аудите кода необходимо проверять обращения к файлам, каталогам и набор действий, выполняемых с ними, для исключения передачи конфиденциальной или защищенной информации, а также для исключения деструктивных действий с файловой системой. +Важно проверять код от сторонних разработчиков, подрядчиков, из различных интернет-сервисов, каталогов и т.п. + +По найденным замечаниям рекомендуется выполнить ручной аудит кода на предмет его правильности и безопасности. + +## Примеры + +```bsl + Текст = Новый ЧтениеТекста(ПутьФайла, КодировкаТекста.ANSI); // есть замечание + Текст = Новый ЗаписьТекста(ПутьФайла, КодировкаТекста.ANSI); // есть замечание + + ЗначениеВФайл(ПутьФайла, ЛичныеДанные); // есть замечание + КопироватьФайл(ПутьФайла, ДругойПутьФайла); // есть замечание + + МассивИмен = Новый Массив(); + МассивИмен.Добавить(ПутьФайла); + ОбъединитьФайлы(МассивИмен, ДругойПутьФайла); // есть замечание + + ПереместитьФайл(ПутьФайла, ДругойПутьФайла); // есть замечание + РазделитьФайл(ПутьФайла, 1024 * 1024 ); // есть замечание + СоздатьКаталог(ИмяКаталога); // есть замечание + УдалитьФайлы(ПутьФайла); // есть замечание +``` + +## Источники + + +* [Стандарт Доступ к файловой системе из кода конфигурации](https://its.1c.ru/db/v8std#content:542:hdoc) +* [Стандарт Безопасность запуска приложений](https://its.1c.ru/db/v8std#content:774:hdoc) +* [Безопасный режим работы - руководство разработчика](https://its.1c.ru/db/v8323doc#bookmark:dev:TI000000186) diff --git a/docs/diagnostics/GlobalContextMethodCollision8312.md b/docs/diagnostics/GlobalContextMethodCollision8312.md index 9532b1c3100..b782e38028f 100644 --- a/docs/diagnostics/GlobalContextMethodCollision8312.md +++ b/docs/diagnostics/GlobalContextMethodCollision8312.md @@ -19,7 +19,7 @@ ПобитовыйСдвигВлево|BitwiseShiftLeft ПобитовыйСдвигВправо|BitwiseShiftRight -Необходимо существующие функции конфигурации прикладного решения необходимо либо переименовать, либо удалить, заменив обращение к ним на методы глобального контекста. +Необходимо существующие функции конфигурации прикладного решения переименовать или удалить, заменив обращение к ним на методы глобального контекста. ## Примеры diff --git a/docs/diagnostics/InternetAccess.md b/docs/diagnostics/InternetAccess.md new file mode 100644 index 00000000000..974639618c7 --- /dev/null +++ b/docs/diagnostics/InternetAccess.md @@ -0,0 +1,21 @@ +# Обращение к Интернет-ресурсам (InternetAccess) + + +## Описание диагностики + +Проверьте обращение к Интернет-ресурсам и набор передаваемых данных для исключения передачи конфиденциальной или защищенной информации. + +## Примеры + +```bsl +HTTPСоединение = Новый HTTPСоединение("zabbix.localhost", 80); // замечание +FTPСоединение = Новый FTPСоединение(Сервер, Порт, Пользователь, Пароль); // замечание +``` + +## Источники + + diff --git a/docs/diagnostics/MagicDate.md b/docs/diagnostics/MagicDate.md index 9f76aaa598b..986489a1b5c 100644 --- a/docs/diagnostics/MagicDate.md +++ b/docs/diagnostics/MagicDate.md @@ -22,3 +22,16 @@ ХоверБордБудетИзобретен = Неопределено; КонецЕсли; ``` + +Также хорошим решением является использование специального метода с говорящим названием, который возвращает +дату-константу + +```bsl +Функция ДатаИзобретенияХовера() + Возврат '20151021'; +КонецФункции + +Если текДата < ДатаИзобретенияХовера() Тогда + ХоверБордБудетИзобретен = Неопределено; +КонецЕсли; +``` diff --git a/docs/diagnostics/PrivilegedModuleMethodCall.md b/docs/diagnostics/PrivilegedModuleMethodCall.md new file mode 100644 index 00000000000..5fe2ea880ef --- /dev/null +++ b/docs/diagnostics/PrivilegedModuleMethodCall.md @@ -0,0 +1,26 @@ +# Обращение к методам привилегированных модулей (PrivilegedModuleMethodCall) + + +## Описание диагностики + +При обращении к публичным процедурам и функциям привилегированных общих модулей могут нарушаться ограничения конфигурации по правам и ролям конфигурации, решения 1С. +Необходимо провалидировать подобные обращения для исключения обхода ограничений. + +## Примеры + +Например, в конфигурации существует привилегированный модуль выполнения заданий с именем `Задания`. +В этом модуле есть публичная функция `Функция ДобавитьЗадание(Знач ИмяМетода, Знач Параметры) Экспорт`. +Какой-то код конфигурации или расширения обращается к этому методу `Задания.ДобавитьЗадание("МетодДляВыполнения", Параметры);` + +Необходимо проанализировать код и убедиться в том, что: +- указан правильный метод для выполнения задания - `МетодДляВыполнения` +- метод `МетодДляВыполнения` для выполнения задания не выполняет деструктивных действий +- и не выдает пользователям данные, запрещенные ограничениями конфигурации + +## Источники + + diff --git a/docs/diagnostics/ServerSideExportFormMethod.md b/docs/diagnostics/ServerSideExportFormMethod.md index 65e25bf1e72..192641e72ca 100644 --- a/docs/diagnostics/ServerSideExportFormMethod.md +++ b/docs/diagnostics/ServerSideExportFormMethod.md @@ -5,7 +5,7 @@ В модуле формы можно объявлять экспортные методы, доступные в клиентском контексте (обычно это методы-обработчики событий оповещения формы). -У экспортных методов формы может быть указана только директива компиляции `НаКлиенте`, так как для остальных практического смысла нет: обращение к методам формы из вне доступно только после вызова метода `ПолучитьФорму`, который доступен только на клиенте. +У экспортных методов формы может быть указана только директива компиляции `НаКлиенте`, так как для остальных практического смысла нет: обращение к методам формы извне доступно только после вызова метода `ПолучитьФорму`, который доступен только на клиенте. Указание экспортному методу формы иной директивы компиляции либо ее опускание считается ошибкой. diff --git a/docs/diagnostics/UsageWriteLogEvent.md b/docs/diagnostics/UsageWriteLogEvent.md index 33a392f0721..ed54fefae36 100644 --- a/docs/diagnostics/UsageWriteLogEvent.md +++ b/docs/diagnostics/UsageWriteLogEvent.md @@ -57,7 +57,27 @@ ВызватьИсключение; КонецПопытки; ``` +В то же время, если во внешней попытке делается запись в ЖР, то во вложенной делать её повторно уже не нужно: +```bsl +Процедура ЗагрузитьДанные() Экспорт + Попытка + ВыполнитьЗаписьДанных(); + Исключение + ЗаписьЖурналаРегистрации(); // <- исключение подавляется с записью в ЖР + КонецПопытки; +КонецПроцедуры +Процедура ВыполнитьЗаписьДанных() + НачатьТранзакцию(); + Попытка + // ... + ЗафиксироватьТранзакцию(); + Исключение + ОтменитьТранзакцию(); + ВызватьИсключение; // <- вложенная попытка, запись в ЖР не требуется + КонецПопытки; +КонецПроцедуры +``` ## Источники ## Описание диагностики -Запрещено использовать методы поиска элементов "НайтиПоНаименованию" или "НайтиПоКоду". +Правило находит использование методов `НайтиПоНаименованию`, `НайтиПоКоду` или `НайтиПоНомеру` с указанием конкретных и +уникальных номеров, кодов и названий элементов или документов. +Скорее всего, подобный код не будет работать в других ИБ, что приведет к ошибкам выполнения. +Возможно, в финальный код попал тестовый код, что также не рекомендовано. + +Константные значения данных из ИБ рекомендуется указывать в константах ИБ, предопределенных элементах метаданных. ## Примеры +Неправильно: ```bsl Должность = Справочники.Должности.НайтиПоНаименованию("Ведущий бухгалтер"); ``` +или +```bsl +Должность = Справочники.Должности.НайтиПоКоду("00-0000001"); +``` или ```bsl -Должность = Справочники.Должности.НайтиПоКоду("00-0000001"); +ОбъектНазначения = Документы.ПередачаТоваровМеждуОрганизациями.НайтиПоНомеру("0000-000001", ТекущаяДата()); ``` Допустимо использование: @@ -24,3 +34,7 @@ ```bsl Справочники.КлассификаторБанков.НайтиПоКоду(СведенияОБанке.БИК); ``` + +```bsl +Документы.Реализация.НайтиПоНомеру(НомерДокумента); +``` diff --git a/docs/en/contributing/DiagnosticStructure.md b/docs/en/contributing/DiagnosticStructure.md index b08d50035b8..fc4669a1b0b 100644 --- a/docs/en/contributing/DiagnosticStructure.md +++ b/docs/en/contributing/DiagnosticStructure.md @@ -45,26 +45,33 @@ At the time of this writing, the following properties are available: - The type of diagnostics is `type` and its importance is `severity`, for each diagnostics it is necessary to define them. In order to choose the correct type and importance of diagnostics, you can refer to [article](DiagnosticTypeAndSeverity.md). - Time to fix issue `minutesToFix` (default 0). This value is used when calculating the total technical debt of the project in labor costs to correct all comments (the sum of time to correct for all detected comments). It is worth indicating the time, as realistic as possible, that the developer should spend on fixing. +- Using the `extraMinForComplexity` parameter, you can dynamically increase the time to correct a comment for diagnostics that take into account several places that violate the rule, for example, when calculating the complexity of a method. - A set of diagnostics tags `tag` that indicate the group to which it belongs. Read more about tags in the [article](DiagnosticTag.md). - Applicability limit `scope` (by default `ALL`, i.e. no limit). BSL LS supports multiple languages (oscript and bsl) and diagnostics can be applied to one specific language or to all at once. - Default diagnostic active `activatedByDefault` (default `True`). When developing experimental, controversial, or not applicable in most projects, it is worth turning off diagnostics by default, the activation will be performed by the end user of the solution. - Compatibility mode `compatibilityMode`, by which diagnostics are filtered when using metadata. The default is `UNDEFINED`. - +- List of module types `modules` for the ability to limit the area analyzed by diagnostics +- Sign of the ability to set issues on the entire project `canLocateOnProject`. Used for diagnostics not related to the source code module. At the moment, the option is accepted only by SonarQube, other tools ignore it. The last two can be omitted. Annotation example ```java @DiagnosticMetadata( - type = DiagnosticType.CODE_SMELL, - severity = DiagnosticSeverity.MINOR, - minutesToFix = 1, - activatedByDefault = false, // Deactivated by default - scope = DiagnosticScope.BSL, // Applicable only for BSL - compatibilityMode = DiagnosticCompatibilityMode.COMPATIBILITY_MODE_8_3_3, // 8.3.3 compatibility mode + type = DiagnosticType.CODE_SMELL, + severity = DiagnosticSeverity.MINOR, + minutesToFix = 1, + activatedByDefault = false, + scope = DiagnosticScope.BSL, + compatibilityMode = DiagnosticCompatibilityMode.COMPATIBILITY_MODE_8_3_3, tags = { - DiagnosticTag.STANDARD // This is a diagnosis for violation of the 1C standard - } + DiagnosticTag.STANDARD + }, + modules = { + ModuleType.CommonModule + }, + canLocateOnProject = false, + extraMinForComplexity = 1 // For each additional note position (`DiagnosticRelatedInformation`) one minute will be added ) ``` @@ -217,7 +224,7 @@ Examples: ### Diagnostics class, inherits from AbstractSDBLVisitorDiagnostic -The diagnostic class implements the necessary `AST visitors`, according to the grammar of the query language (see [BSLParser](https://github.com/1c-syntax/bsl-parser/blob/master/src/main/antlr/SDBLParser. g4)). The complete list of visitor methods is in the `SDBLParserBaseVisitor` class. +The diagnostic class implements the necessary `AST visitors`, according to the grammar of the query language (see [BSLParser](https://github.com/1c-syntax/bsl-parser/blob/master/src/main/antlr/SDBLParser.g4)). The complete list of visitor methods is in the `SDBLParserBaseVisitor` class. The rest of the rules are identical to `AbstractVisitorDiagnostic`. @@ -355,7 +362,7 @@ The fixtures are the contents of the test resource file located in the `src/test It is necessary to add both erroneous and correct code, **marking the places of errors with comments**. It is best if the test cases are `real`, from practice, and not synthetic, invented `for diagnostics`. -## Diagnostics description +## Description The diagnostic description is created in the [Markdown](https://ru.wikipedia.org/wiki/Markdown) format in two versions - for Russian and English. The files are located in the `docs/diagnostics` directory for Russian, for English in `docs/en/diagnostics`. The file has the structure diff --git a/docs/en/diagnostics/CanonicalSpellingKeywords.md b/docs/en/diagnostics/CanonicalSpellingKeywords.md index 72511e8f523..6b77e38575f 100644 --- a/docs/en/diagnostics/CanonicalSpellingKeywords.md +++ b/docs/en/diagnostics/CanonicalSpellingKeywords.md @@ -32,7 +32,7 @@ A built-in language constructs, keywords must be written canonically. | Неопределено | Undefined | | Перейти | Goto | | Перем | Var | -| По | For | +| По | To | | Пока | While | | Попытка | Try | | Процедура | Procedure | diff --git a/docs/en/diagnostics/DeprecatedCurrentDate.md b/docs/en/diagnostics/DeprecatedCurrentDate.md index 62b65410d66..4673c51026b 100644 --- a/docs/en/diagnostics/DeprecatedCurrentDate.md +++ b/docs/en/diagnostics/DeprecatedCurrentDate.md @@ -1,7 +1,8 @@ # Using of the deprecated method "CurrentDate" (DeprecatedCurrentDate) - -## Diagnostic description + +## Description + The configurations must be designed to work in conditions where the time zone on the server computer does not match the real time zone of the infobase users. For example, employees of a company from Vladivostok work with a server located in Moscow, and all operations in the system must be performed in local time (Vladivostok). Such a work scenario is often in demand in client-server infobases and in applied solutions in the service model (SaaS). diff --git a/docs/en/diagnostics/DisableSafeMode.md b/docs/en/diagnostics/DisableSafeMode.md new file mode 100644 index 00000000000..da4c2057737 --- /dev/null +++ b/docs/en/diagnostics/DisableSafeMode.md @@ -0,0 +1,45 @@ +# Disable safe mode (DisableSafeMode) + + +## Description + +In addition to configuration code, the application solution can execute third-party program code, which can be connected in various ways (external reports and data processing, extensions, external components, etc.). The developer cannot guarantee the reliability of this code. An attacker can include various destructive actions in it that can harm user computers, servers, and data in the program. + +The listed security problems are especially critical when operating configurations in the service model, because Having gained access to the service, malicious code can immediately gain access to all applications of all users of the service. + +It is important to control the execution of such external code in safe mode, in exceptional cases (after verification) allowing code to be executed in unsafe mode. + +The rule diagnoses calls to the methods `SetSafeMode` and `SetDisableSafeMode` in the mode of disabling safe mode control +- Method call `SetDisableSafeMode(true)` is ignored +- Method call `SetDisableSafeMode(false)` is ignored + +## Examples + +``` + SetSafeMode (False); // is error + + Value = False; + SetSafeMode(Value); // is error + + SetSafeMode (True); // no error + + SetDisableSafeMode(True); // is error + + Value = True; + SetDisableSafeMode(Value); // is error + + SetDisableSafeMode(False); // no error +``` + +## Sources + + +- [Developer's Guide 8.3.22: Safe operation (RU)](https://its.1c.ru/db/v8322doc#bookmark:dev:TI000000186) +- [Standard: Restriction on the execution of "external" code (RU)](https://its.1c.ru/db/v8std/content/669/hdoc) +- [Standard: Server API Security (RU)](https://its.1c.ru/db/v8std/content/678/hdoc) +- [Standard: Restrictions on the use of Execute and Eval on the server (RU)](https://its.1c.ru/db/v8std#content:770:hdoc) +- [Standard: Using Privileged Mode (RU)](https://its.1c.ru/db/v8std/content/485/hdoc) diff --git a/docs/en/diagnostics/ExternalAppStarting.md b/docs/en/diagnostics/ExternalAppStarting.md new file mode 100644 index 00000000000..59ae54e2bc5 --- /dev/null +++ b/docs/en/diagnostics/ExternalAppStarting.md @@ -0,0 +1,78 @@ +# External applications starting (ExternalAppStarting) + + +## Description + +To improve the quality and security of 1C solutions, it is necessary to control the launch of external applications from 1C code. + +This rule applies to all methods of launching external programs, including: +- System +- RunSystem +- RunApp +- BeginRunningApplication +- RunAppAsync +- GotoURL or FileSystems.OpenURL +- FileSystemsClient.RunApp (for client side) and FileSystems.RunApp (for server side) +- FileSystemClient.OpenExplorer +- FileSystemClient.OpenFile + +## Examples + +```bsl +Процедура Метод() + СтрокаКоманды = ""; + ТекущийКаталог = ""; + ДождатьсяЗавершения = Истина; + ОписаниеОповещения = Неопределено; + ПараметрыКоманды = Новый Структура; + + КомандаСистемы(СтрокаКоманды, ТекущийКаталог); // есть замечание + ЗапуститьПриложение(СтрокаКоманды, ТекущийКаталог); // есть замечание + ЗапуститьПриложение(СтрокаКоманды, ТекущийКаталог, Истина); // есть замечание + + НачатьЗапускПриложения(ОписаниеОповещения, СтрокаКоманды, ТекущийКаталог, ДождатьсяЗавершения); // есть замечание + + ПерейтиПоНавигационнойСсылке(СтрокаКоманды); // есть замечание + ФайловаяСистемаКлиент.ОткрытьНавигационнуюСсылку(СтрокаКоманды); // есть замечание + ФайловаяСистемаКлиент.ОткрытьНавигационнуюСсылку(СтрокаКоманды, ОписаниеОповещения); // есть замечание + + ФайловаяСистемаКлиент.ЗапуститьПрограмму("ping 127.0.0.1 -n 5", ПараметрыКоманды); // есть замечание + ФайловаяСистемаКлиент.ЗапуститьПрограмму(СтрокаКоманды, ПараметрыКоманды); // есть замечание + ФайловаяСистема.ЗапуститьПрограмму(СтрокаКоманды); // есть замечание + ФайловаяСистема.ЗапуститьПрограмму(СтрокаКоманды, ПараметрыКоманды); // есть замечание + + ФайловаяСистемаКлиент.ОткрытьПроводник("C:\Users"); // есть замечание + ФайловаяСистемаКлиент.ОткрытьФайл(СтрокаКоманды); // есть замечание + ФайловаяСистемаКлиент.ОткрытьФайл(СтрокаКоманды, ОписаниеОповещения); // есть замечание + +КонецПроцедуры + +&НаКлиенте +Асинх Процедура Подключить() + СтрокаКоманды = ""; + ТекущийКаталог = ""; + ДождатьсяЗавершения = Истина; + + Ждать ЗапуститьПриложениеАсинх(СтрокаКоманды, ТекущийКаталог, ДождатьсяЗавершения); // есть замечание +КонецПроцедуры + +&НаКлиенте +Процедура ПроверкаЗапуститьСистему(ДополнительныеПараметрыКоманднойСтроки, КодВозврата) + ДождатьсяЗавершения = Истина; + + ЗапуститьСистему(); // есть замечание + ЗапуститьСистему(ДополнительныеПараметрыКоманднойСтроки); // есть замечание + ЗапуститьСистему(ДополнительныеПараметрыКоманднойСтроки, ДождатьсяЗавершения); // есть замечание + ЗапуститьСистему(ДополнительныеПараметрыКоманднойСтроки, ДождатьсяЗавершения, КодВозврата); // есть замечание +КонецПроцедуры +``` + +## Sources + + +- [Standard: Application launch security (RU)](https://its.1c.ru/db/v8std#content:774:hdoc) +- Standard: [Restriction on the execution of "external" code (RU)](https://its.1c.ru/db/v8std/content/669/hdoc) diff --git a/docs/en/diagnostics/FileSystemAccess.md b/docs/en/diagnostics/FileSystemAccess.md new file mode 100644 index 00000000000..8d42717a40a --- /dev/null +++ b/docs/en/diagnostics/FileSystemAccess.md @@ -0,0 +1,38 @@ +# File system access (FileSystemAccess) + + +## Description + +It is important to review your code. Be sure to pay attention to accessing the file system and using “external code” + +The found sections of the code must be analyzed, a manual audit of the code must be performed for its correctness and safety. + +## Examples + +```bsl + Текст = Новый ЧтениеТекста(ПутьФайла, КодировкаТекста.ANSI); // есть замечание + Текст = Новый ЗаписьТекста(ПутьФайла, КодировкаТекста.ANSI); // есть замечание + + ЗначениеВФайл(ПутьФайла, ЛичныеДанные); // есть замечание + КопироватьФайл(ПутьФайла, ДругойПутьФайла); // есть замечание + + МассивИмен = Новый Массив(); + МассивИмен.Добавить(ПутьФайла); + ОбъединитьФайлы(МассивИмен, ДругойПутьФайла); // есть замечание + + ПереместитьФайл(ПутьФайла, ДругойПутьФайла); // есть замечание + РазделитьФайл(ПутьФайла, 1024 * 1024 ); // есть замечание + СоздатьКаталог(ИмяКаталога); // есть замечание + УдалитьФайлы(ПутьФайла); // есть замечание +``` + +## Sources + + +* [File system access from application code (RU)](https://its.1c.ru/db/v8std#content:542:hdoc) +* [Standard: Application launch security (RU)](https://its.1c.ru/db/v8std#content:774:hdoc) +* [Safe operation - Developer's Guide (RU](https://its.1c.ru/db/v8323doc#bookmark:dev:TI000000186) diff --git a/docs/en/diagnostics/InternetAccess.md b/docs/en/diagnostics/InternetAccess.md new file mode 100644 index 00000000000..ffbd2238150 --- /dev/null +++ b/docs/en/diagnostics/InternetAccess.md @@ -0,0 +1,21 @@ +# Referring to Internet resources (InternetAccess) + + +## Description + +Check access to Internet resources and the set of transmitted data to prevent the transfer of confidential or protected information. + +## Examples + +```bsl +HTTPConnection = New HTTPConnection("zabbix.localhost", 80); // error +FTPConnection = New FTPConnection(Server, Port, User, Pwd); // error +``` + +## Sources + + diff --git a/docs/en/diagnostics/MagicDate.md b/docs/en/diagnostics/MagicDate.md index 158097d92b9..49635b0166c 100644 --- a/docs/en/diagnostics/MagicDate.md +++ b/docs/en/diagnostics/MagicDate.md @@ -22,3 +22,16 @@ If now < PredictedDate Then HoverBoardIsReal = Undefined; EndIf; ``` + +Also, a good solution is to use a special method with "telling name" that returns +constant + +```bsl +Function DateInventionHover() + Return '20151021'; +EndFunction + +If CurrentDate < DateInventionHover() Then + HoverBoardWillBeInvented = Undefined; +EndIf; +``` diff --git a/docs/en/diagnostics/PrivilegedModuleMethodCall.md b/docs/en/diagnostics/PrivilegedModuleMethodCall.md new file mode 100644 index 00000000000..87647762992 --- /dev/null +++ b/docs/en/diagnostics/PrivilegedModuleMethodCall.md @@ -0,0 +1,16 @@ +# Accessing privileged module methods (PrivilegedModuleMethodCall) + + +## Description + +Code running in `privileged` `mode` must be checked. + +## Examples + + +## Sources + + diff --git a/docs/en/diagnostics/ServerSideExportFormMethod.md b/docs/en/diagnostics/ServerSideExportFormMethod.md index d886a1f4f1c..478e3f60df2 100644 --- a/docs/en/diagnostics/ServerSideExportFormMethod.md +++ b/docs/en/diagnostics/ServerSideExportFormMethod.md @@ -2,7 +2,6 @@ ## Description - In a form module, you can declare export methods that are available in the client context (usually, these are form notification event handlers). For export methods of the form, only the compilation directive `AtClient` can be specified, since for the rest there is no practical sense: accessing form methods from outside is available only after calling the method `GetForm`, which is available only on the client. diff --git a/docs/en/diagnostics/TransferringParametersBetweenClientAndServer.md b/docs/en/diagnostics/TransferringParametersBetweenClientAndServer.md index d0045c5c7fa..d6eaf85bcee 100644 --- a/docs/en/diagnostics/TransferringParametersBetweenClientAndServer.md +++ b/docs/en/diagnostics/TransferringParametersBetweenClientAndServer.md @@ -1,8 +1,7 @@ -# Transferring parameters between client and server (TransferringParametersBetweenClientAndServer) +# Transferring parameters between the client and the server (TransferringParametersBetweenClientAndServer) - -## Diagnostic description - + +## Description When transferring control from the client to the server (and vice versa), copies of the parameters are always transferred. diff --git a/docs/en/diagnostics/UsageWriteLogEvent.md b/docs/en/diagnostics/UsageWriteLogEvent.md index 241ae91838d..b91b67c66be 100644 --- a/docs/en/diagnostics/UsageWriteLogEvent.md +++ b/docs/en/diagnostics/UsageWriteLogEvent.md @@ -55,7 +55,27 @@ Correct code Raise; EndTry; ``` - +If an outer attempt makes a log entry, then there is no need to do it again in a nested attempt: +```bsl +Процедура ЗагрузитьДанные() Экспорт + Попытка + ВыполнитьЗаписьДанных(); + Исключение + ЗаписьЖурналаРегистрации(); // <- исключение подавляется с записью в ЖР + КонецПопытки; +КонецПроцедуры + +Процедура ВыполнитьЗаписьДанных() + НачатьТранзакцию(); + Попытка + // ... + ЗафиксироватьТранзакцию(); + Исключение + ОтменитьТранзакцию(); + ВызватьИсключение; // <- вложенная попытка, запись в ЖР не требуется + КонецПопытки; +КонецПроцедуры +``` ## Sources ## Description -It is forbidden to use the search methods for elements "FindByName" or "FindByCode". +The rule finds the use of the `FindByName`, `FindByCode` or `FindByNumber` methods using specific numbers, codes and names of elements or documents. +Similar code may not work correctly in other databases. +Often such code is test code included in the release version, which is also not recommended. + +It is recommended to specify constant data values ​​from the database in "Сonstants" or predefined metadata elements. ## Examples +Incorrect: ```bsl Position = Catalogs.Positions.FindByName("Senior Accountant"); ``` +or +```bsl +Position = Catalogs.Positions.FindByCode("00-0000001"); +``` or ```bsl -Position = Catalogs.Positions.FindByCode("00-0000001"); +Object = Documents.Invoice.FindByNumber("0000-000001", CurrentDate()); ``` Acceptable use: @@ -24,3 +33,7 @@ Catalogs.Currencies.FindByCode(CurrentData.CurrencyCodeDigital); ```bsl Catalogs.BankClassifier.FindByCode(BankDetails.BIK); ``` + +```bsl +Documents.Invoice.FindByNumber(Number); +``` diff --git a/docs/en/systemRequirements.md b/docs/en/systemRequirements.md index 64b79c356af..edc3e8a9044 100644 --- a/docs/en/systemRequirements.md +++ b/docs/en/systemRequirements.md @@ -6,7 +6,7 @@ Using `BSL Language Server` has some limitations, listed bellow `BSL Language Server` is a console Java application and requires the presence of a Java virtual machine on the computer. -The minimum supported version is Java 17, but as part of the build pipelines, a health check is performed when using more recent versions. Java versions 17 and 20 are currently supported. +The minimum supported version is Java 17, but as part of the build pipelines, a health check is performed when using more recent versions. Java versions 17 and 21 are currently supported. JDK vendor is also interesting. Due to the changed licensing policy of Oracle, it is recommended to use open implementations of the `OpenJDK` virtual machine: AdoptOpenJDK, Liberica JDK. diff --git a/docs/index.md b/docs/index.md index c476360630e..cc06a95a501 100644 --- a/docs/index.md +++ b/docs/index.md @@ -207,7 +207,7 @@ Run analysis and get diagnostic info ``` Для указания каталога расположения анализируемых исходников используется параметр `--srcDir` (сокращенно `-s`), за которым следует путь (относительный или абсолютный) к каталогу исходников. -Для формирования отчета об анализе требуется указать один или "репортеров". Для указания репортера используется параметр `--reporter` (сокращенно `-r`), за которым следует ключ репортера. Допустимо указывать несколько репортеров. Список репортетов см. в разделе **Репортеры**. +Для формирования отчета об анализе требуется указать один из "репортеров". Для указания репортера используется параметр `--reporter` (сокращенно `-r`), за которым следует ключ репортера. Допустимо указывать несколько репортеров. Список репортетов см. в разделе **Репортеры**. Пример строки запуска анализа: diff --git a/docs/systemRequirements.md b/docs/systemRequirements.md index 6d6bc14fad1..a5038f2bb47 100644 --- a/docs/systemRequirements.md +++ b/docs/systemRequirements.md @@ -6,7 +6,7 @@ `BSL Language Server` представляет собой консольное Java приложение, соответственно, для его функционирования необходимо наличие виртуальной машины Java на компьютере. -На данный момент минимальной поддерживаемой версией является Java 17, но в рамках сборочных конвейеров происходит проверка работоспособности при использовании более свежих версий. На данный момент поддерживаются Java версий 17 и 20. +На данный момент минимальной поддерживаемой версией является Java 17, но в рамках сборочных конвейеров происходит проверка работоспособности при использовании более свежих версий. На данный момент поддерживаются Java версий 17 и 21. Кроме версии Java интересен и вендор JDK. В связи с изменившейся политикой лицензирования Oracle, рекомендуется использование открытых реализаций виртуальной машины `OpenJDK`: AdoptOpenJDK, Liberica JDK. diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 943f0cbfa75..e6441136f3d 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37aef8d3f0c..a4413138c96 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68d65c..b740cf13397 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index 93e3f59f135..25da30dbdee 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/qodana.yaml b/qodana.yaml index 52d8b52a379..69ef158b519 100644 --- a/qodana.yaml +++ b/qodana.yaml @@ -1,5 +1,4 @@ version: "1.0" -linter: jetbrains/qodana-jvm-community:2023.1 projectJDK: 17 profile: name: qodana.starter diff --git a/src/jmh/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/VariableSymbolCreate.java b/src/jmh/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/VariableSymbolCreate.java index 3b5a9e2d329..52a03b7ef1e 100644 --- a/src/jmh/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/VariableSymbolCreate.java +++ b/src/jmh/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/VariableSymbolCreate.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/AnalyzeProjectOnStart.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/AnalyzeProjectOnStart.java index 5283444a4f6..10310f35fcb 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/AnalyzeProjectOnStart.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/AnalyzeProjectOnStart.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/AutoServerInfo.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/AutoServerInfo.java index b3c0177b21c..69a3736c835 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/AutoServerInfo.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/AutoServerInfo.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLSBinding.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLSBinding.java index cc3e40d152c..389198abccd 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLSBinding.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLSBinding.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLSPLauncher.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLSPLauncher.java index 0f6cfb922d6..5e67d295856 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLSPLauncher.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLSPLauncher.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLanguageServer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLanguageServer.java index 19ba3a0b523..2be3d0562e6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLanguageServer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLanguageServer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLTextDocumentService.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLTextDocumentService.java index 6dbca3ef889..b2e534bd14b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLTextDocumentService.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLTextDocumentService.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLWorkspaceService.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLWorkspaceService.java index 2ed324237aa..0cdf596d6c8 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLWorkspaceService.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLWorkspaceService.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/ClientCapabilitiesHolder.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/ClientCapabilitiesHolder.java index 7992a306fb5..39913004743 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/ClientCapabilitiesHolder.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/ClientCapabilitiesHolder.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/LanguageClientHolder.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/LanguageClientHolder.java index 5f179ab0f3e..45b6a3aaaf4 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/LanguageClientHolder.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/LanguageClientHolder.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/ParentProcessWatcher.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/ParentProcessWatcher.java index 5c7ced2a0e5..50e35d7f40d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/ParentProcessWatcher.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/ParentProcessWatcher.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/WorkDoneProgressHelper.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/WorkDoneProgressHelper.java index c5d19f8a7a1..835890fbe24 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/WorkDoneProgressHelper.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/WorkDoneProgressHelper.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/AspectJConfiguration.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/AspectJConfiguration.java index 4b2b2435ab6..feb40b151ea 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/AspectJConfiguration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/AspectJConfiguration.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/EventPublisherAspect.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/EventPublisherAspect.java index b2f265a1d93..8c38c404081 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/EventPublisherAspect.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/EventPublisherAspect.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/MeasuresAspect.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/MeasuresAspect.java index bf5436ceeb1..38745564840 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/MeasuresAspect.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/MeasuresAspect.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/Pointcuts.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/Pointcuts.java index 1285caca0a9..ae1c46cfcaa 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/Pointcuts.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/Pointcuts.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/SentryAspect.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/SentryAspect.java index 3b07903ac1b..f87f9cf88e7 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/SentryAspect.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/SentryAspect.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/ConditionalOnMeasuresEnabled.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/ConditionalOnMeasuresEnabled.java index 44fb92099b1..7c4adde9697 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/ConditionalOnMeasuresEnabled.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/ConditionalOnMeasuresEnabled.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/DocumentContextLazyDataMeasurer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/DocumentContextLazyDataMeasurer.java index f82356afbff..a19c9a2fa57 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/DocumentContextLazyDataMeasurer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/DocumentContextLazyDataMeasurer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/MeasureCollector.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/MeasureCollector.java index 87b274c09a8..006596e4d88 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/MeasureCollector.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/MeasureCollector.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/package-info.java index 3af96a17ddb..d131b505558 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/package-info.java index e646d8a9ba5..2597ae3f002 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/PermissionFilterBeforeSendCallback.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/PermissionFilterBeforeSendCallback.java index 15a3c4d835d..0e6d4d3866f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/PermissionFilterBeforeSendCallback.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/PermissionFilterBeforeSendCallback.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/SentryScopeConfigurer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/SentryScopeConfigurer.java index 5312e2a1339..0753d40ce13 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/SentryScopeConfigurer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/SentryScopeConfigurer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -21,7 +21,7 @@ */ package com.github._1c_syntax.bsl.languageserver.aop.sentry; -import io.sentry.Scope; +import io.sentry.IScope; import io.sentry.Sentry; import io.sentry.protocol.User; import jakarta.annotation.PostConstruct; @@ -48,7 +48,7 @@ public class SentryScopeConfigurer { @PostConstruct public void init() { - Sentry.configureScope((Scope scope) -> { + Sentry.configureScope((IScope scope) -> { var user = new User(); user.setId(UUID.randomUUID().toString()); scope.setUser(user); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/package-info.java index 17c0c356ec1..9e54ce5f89a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/AbstractCfgVisitor.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/AbstractCfgVisitor.java index c1fb0bd2b52..46eb90351f8 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/AbstractCfgVisitor.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/AbstractCfgVisitor.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/BasicBlockVertex.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/BasicBlockVertex.java index e3d5d72ffd7..1c28ce385bf 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/BasicBlockVertex.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/BasicBlockVertex.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/BranchingVertex.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/BranchingVertex.java index de47fe605fc..0f1cec35cd4 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/BranchingVertex.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/BranchingVertex.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgBuildingParseTreeVisitor.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgBuildingParseTreeVisitor.java index 9f4b65e72e4..63db55f1d30 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgBuildingParseTreeVisitor.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgBuildingParseTreeVisitor.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import java.util.stream.Collectors; public class CfgBuildingParseTreeVisitor extends BSLParserBaseVisitor { @@ -148,12 +147,12 @@ public ParseTree visitIfStatement(BSLParser.IfStatementContext ctx) { while (!currentLevelBlock.getBuildParts().isEmpty()) { var blockTail = currentLevelBlock.getBuildParts().pop(); - if (hasNoSignificantEdges(blockTail) && blockTail instanceof BasicBlockVertex) { - // это мертвый код. Он может быть пустым блоком - // тогда он не нужен сам по себе - var basicBlock = (BasicBlockVertex) blockTail; - if (basicBlock.statements().isEmpty()) - continue; + // это мертвый код. Он может быть пустым блоком + // тогда он не нужен сам по себе + if (hasNoSignificantEdges(blockTail) + && blockTail instanceof BasicBlockVertex basicBlock + && basicBlock.statements().isEmpty()) { + continue; } graph.addEdge(blockTail, upperBlock.end()); } @@ -163,7 +162,9 @@ public ParseTree visitIfStatement(BSLParser.IfStatementContext ctx) { private boolean hasNoSignificantEdges(CfgVertex blockTail) { var edges = graph.incomingEdgesOf(blockTail); - return edges.isEmpty() || (adjacentDeadCodeEnabled && edges.stream().allMatch(x -> x.getType() == CfgEdgeType.ADJACENT_CODE)); + return edges.isEmpty() + || (adjacentDeadCodeEnabled + && edges.stream().allMatch(x -> x.getType() == CfgEdgeType.ADJACENT_CODE)); } @Override @@ -372,8 +373,9 @@ public ParseTree visitPreproc_if(BSLParser.Preproc_ifContext ctx) { return ctx; } - if (!isStatementLevelPreproc(ctx)) + if (!isStatementLevelPreproc(ctx)) { return super.visitPreproc_if(ctx); + } var node = new PreprocessorConditionVertex(ctx); graph.addVertex(node); @@ -477,14 +479,15 @@ public ParseTree visitPreproc_endif(BSLParser.Preproc_endifContext ctx) { // присоединяем все прямые выходы из тел условий while (!mainIf.getBuildParts().isEmpty()) { var blockTail = mainIf.getBuildParts().pop(); - if (hasNoSignificantEdges(blockTail) && blockTail instanceof BasicBlockVertex) { - // это мертвый код. Он может быть пустым блоком - // тогда он не нужен сам по себе - var basicBlock = (BasicBlockVertex) blockTail; - if (basicBlock.statements().isEmpty()) { - graph.removeVertex(basicBlock); - continue; - } + + // это мертвый код. Он может быть пустым блоком + // тогда он не нужен сам по себе + if (hasNoSignificantEdges(blockTail) + && blockTail instanceof BasicBlockVertex basicBlock + && basicBlock.statements().isEmpty()) { + + graph.removeVertex(basicBlock); + continue; } graph.addVertex(blockTail); graph.addEdge(blockTail, upperBlock.end()); @@ -493,15 +496,15 @@ public ParseTree visitPreproc_endif(BSLParser.Preproc_endifContext ctx) { return ctx; } - private boolean isStatementLevelPreproc(BSLParserRuleContext ctx) { + private static boolean isStatementLevelPreproc(BSLParserRuleContext ctx) { return ctx.getParent().getParent().getRuleIndex() == BSLParser.RULE_statement; } private PreprocessorConditionVertex popPreprocCondition() { var node = blocks.getCurrentBlock().getBuildParts().peek(); - if (node instanceof PreprocessorConditionVertex) { + if (node instanceof PreprocessorConditionVertex preprocessorConditionVertex) { blocks.getCurrentBlock().getBuildParts().pop(); - return (PreprocessorConditionVertex) node; + return preprocessorConditionVertex; } return null; } @@ -545,12 +548,11 @@ private void buildLoopSubgraph(BSLParser.CodeBlockContext ctx, LoopVertex loopSt private void connectGraphTail(StatementsBlockWriter.StatementsBlockRecord currentBlock, CfgVertex vertex) { - if (!(currentBlock.end() instanceof BasicBlockVertex)) { + if (!(currentBlock.end() instanceof BasicBlockVertex currentTail)) { graph.addEdge(currentBlock.end(), vertex); return; } - var currentTail = (BasicBlockVertex) currentBlock.end(); if (currentTail.statements().isEmpty()) { // перевести все связи на новую вершину var incoming = graph.incomingEdgesOf(currentTail); @@ -575,17 +577,17 @@ private void connectGraphTail(StatementsBlockWriter.StatementsBlockRecord curren private void removeOrphanedNodes() { var orphans = graph.vertexSet().stream() .filter(vertex -> !(vertex instanceof ExitVertex)) - .filter(vertex -> { + .filter((CfgVertex vertex) -> { var edges = new ArrayList<>(graph.edgesOf(vertex)); - return edges.isEmpty() || - adjacentDeadCodeEnabled && - edges.size() == 1 - && edges.get(0).getType() == CfgEdgeType.ADJACENT_CODE - && graph.getEdgeTarget(edges.get(0)) == vertex; + return edges.isEmpty() + || (adjacentDeadCodeEnabled + && edges.size() == 1 + && edges.get(0).getType() == CfgEdgeType.ADJACENT_CODE + && graph.getEdgeTarget(edges.get(0)) == vertex); }) - .collect(Collectors.toList()); + .toList(); // в одном стриме бывает ConcurrentModificationException // делаем через другую коллекцию diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgEdge.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgEdge.java index 5b99f4d9dfc..c4184513306 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgEdge.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgEdge.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgEdgeType.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgEdgeType.java index 25adafc7be6..89baae8a99a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgEdgeType.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgEdgeType.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgVertex.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgVertex.java index 6f6cddf1392..4e621e1d7e2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgVertex.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/CfgVertex.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ConditionalVertex.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ConditionalVertex.java index 70b26a4431a..1c20e28010f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ConditionalVertex.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ConditionalVertex.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraph.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraph.java index 73af51e6e56..af2e91499b0 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraph.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraph.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -25,13 +25,12 @@ import lombok.Setter; import org.jgrapht.graph.DefaultDirectedGraph; +@Getter public class ControlFlowGraph extends DefaultDirectedGraph { - @Getter @Setter private CfgVertex entryPoint; - @Getter private ExitVertex exitPoint; ControlFlowGraph() { diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraphWalker.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraphWalker.java index ed4d97f67c2..feda24b33d2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraphWalker.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraphWalker.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ExitVertex.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ExitVertex.java index f7dced458e4..94407fdc387 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ExitVertex.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ExitVertex.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ForLoopVertex.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ForLoopVertex.java index 98bec0a1932..9ba50bb6e5e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ForLoopVertex.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ForLoopVertex.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ForeachLoopVertex.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ForeachLoopVertex.java index b9b1a988f3c..17579cf1d41 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ForeachLoopVertex.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ForeachLoopVertex.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/LabelVertex.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/LabelVertex.java index 5fa55c76c73..2c11dd87b5e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/LabelVertex.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/LabelVertex.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/LoopVertex.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/LoopVertex.java index 9212464e231..6fc53f87154 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/LoopVertex.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/LoopVertex.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/PreprocessorConditionVertex.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/PreprocessorConditionVertex.java index 6e10a64f960..e9e5178117f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/PreprocessorConditionVertex.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/PreprocessorConditionVertex.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/PreprocessorConstraints.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/PreprocessorConstraints.java index c0d78a9b8e4..f6f780424d4 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/PreprocessorConstraints.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/PreprocessorConstraints.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/StatementsBlockWriter.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/StatementsBlockWriter.java index b7f77846ed8..87ef438a26e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/StatementsBlockWriter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/StatementsBlockWriter.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -22,6 +22,7 @@ package com.github._1c_syntax.bsl.languageserver.cfg; import com.github._1c_syntax.bsl.parser.BSLParserRuleContext; +import lombok.Getter; import java.util.ArrayDeque; import java.util.Deque; @@ -42,6 +43,8 @@ static class StatementsBlockRecord { private BasicBlockVertex statements = new BasicBlockVertex(); private final Deque buildStack = new ArrayDeque<>(); + + @Getter private final JumpInformationRecord jumpContext; public StatementsBlockRecord() { @@ -62,10 +65,6 @@ public Deque getBuildParts() { return buildStack; } - public JumpInformationRecord getJumpContext() { - return jumpContext; - } - public void split() { if (subgraphBegin instanceof BasicBlockVertex && subgraphBegin == subgraphEnd) { subgraphBegin = statements; diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/TryExceptVertex.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/TryExceptVertex.java index 32a9fa5e74d..552a7c6a527 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/TryExceptVertex.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/TryExceptVertex.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/WhileLoopVertex.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/WhileLoopVertex.java index 7fe1b979a27..056d3d6a1c1 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/WhileLoopVertex.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/WhileLoopVertex.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/AnalyzeCommand.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/AnalyzeCommand.java index 06908fbabc3..376965cefda 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/AnalyzeCommand.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/AnalyzeCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -22,13 +22,12 @@ package com.github._1c_syntax.bsl.languageserver.cli; import com.github._1c_syntax.bsl.languageserver.configuration.LanguageServerConfiguration; -import com.github._1c_syntax.bsl.languageserver.context.MetricStorage; import com.github._1c_syntax.bsl.languageserver.context.ServerContext; import com.github._1c_syntax.bsl.languageserver.reporters.ReportersAggregator; import com.github._1c_syntax.bsl.languageserver.reporters.data.AnalysisInfo; import com.github._1c_syntax.bsl.languageserver.reporters.data.FileInfo; +import com.github._1c_syntax.bsl.mdo.MD; import com.github._1c_syntax.bsl.types.MdoReference; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; import com.github._1c_syntax.utils.Absolute; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; @@ -37,7 +36,6 @@ import me.tongfei.progressbar.ProgressBarBuilder; import me.tongfei.progressbar.ProgressBarStyle; import org.apache.commons.io.FileUtils; -import org.eclipse.lsp4j.Diagnostic; import org.springframework.stereotype.Component; import picocli.CommandLine.Command; @@ -205,10 +203,10 @@ private FileInfo getFileInfoFromFile(Path srcDir, File file) { context.rebuildDocument(documentContext); var filePath = srcDir.relativize(Absolute.path(file)); - List diagnostics = documentContext.getDiagnostics(); - MetricStorage metrics = documentContext.getMetrics(); + var diagnostics = documentContext.getDiagnostics(); + var metrics = documentContext.getMetrics(); var mdoRef = documentContext.getMdObject() - .map(AbstractMDObjectBase::getMdoReference) + .map(MD::getMdoReference) .map(MdoReference::getMdoRef) .orElse(""); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/FormatCommand.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/FormatCommand.java index 11345db9657..9be7ea72071 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/FormatCommand.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/FormatCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/LanguageServerStartCommand.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/LanguageServerStartCommand.java index 52d2d9b8949..76a5bf337e4 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/LanguageServerStartCommand.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/LanguageServerStartCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/VersionCommand.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/VersionCommand.java index d17e0baffa1..04cbe9a4225 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/VersionCommand.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/VersionCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/WebsocketCommand.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/WebsocketCommand.java index 7d97c8cec7c..76156230de9 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/WebsocketCommand.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/WebsocketCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/lsp/FileAwarePrintWriter.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/lsp/FileAwarePrintWriter.java index 5a4392c293a..1cc604009e2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/lsp/FileAwarePrintWriter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/lsp/FileAwarePrintWriter.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/lsp/LanguageServerLauncherConfiguration.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/lsp/LanguageServerLauncherConfiguration.java index d0457ca0831..a0574ab0e9d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/lsp/LanguageServerLauncherConfiguration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/lsp/LanguageServerLauncherConfiguration.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/lsp/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/lsp/package-info.java index ee164ce739b..e135db8dda8 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/lsp/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/lsp/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/package-info.java index f418478518d..f0323c8bdab 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/AbstractQuickFixSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/AbstractQuickFixSupplier.java index 41b06a99f20..10b92ea5e4f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/AbstractQuickFixSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/AbstractQuickFixSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/CodeActionSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/CodeActionSupplier.java index 7d23127aa46..d06a03a2894 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/CodeActionSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/CodeActionSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/DisableDiagnosticTriggeringSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/DisableDiagnosticTriggeringSupplier.java index 5563997567b..723dbad7c4f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/DisableDiagnosticTriggeringSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/DisableDiagnosticTriggeringSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/ExtractStructureConstructorSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/ExtractStructureConstructorSupplier.java index bee397e8149..3afcc32cd63 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/ExtractStructureConstructorSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/ExtractStructureConstructorSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -32,7 +32,6 @@ import com.github._1c_syntax.bsl.parser.BSLParser; import com.github._1c_syntax.bsl.parser.BSLParserRuleContext; import lombok.RequiredArgsConstructor; -import org.antlr.v4.runtime.RuleContext; import org.antlr.v4.runtime.tree.TerminalNode; import org.eclipse.lsp4j.CodeAction; import org.eclipse.lsp4j.CodeActionKind; @@ -44,12 +43,10 @@ import org.springframework.stereotype.Component; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.function.Predicate; -import java.util.stream.Collectors; @Component @RequiredArgsConstructor @@ -80,16 +77,14 @@ public List getCodeActions(CodeActionParams params, DocumentContext return Collections.emptyList(); } - var doCall = maybeDoCall.get(); - - List parameters = maybeDoCall + var parameters = maybeDoCall .map(BSLParser.DoCallContext::callParamList) .map(callParamListContext -> callParamListContext.children) + .orElse(Collections.emptyList()) .stream() - .flatMap(Collection::stream) .filter(Predicate.not(TerminalNode.class::isInstance)) .map(BSLParser.CallParamContext.class::cast) - .collect(Collectors.toList()); + .toList(); if (parameters.isEmpty()) { return Collections.emptyList(); @@ -105,6 +100,7 @@ public List getCodeActions(CodeActionParams params, DocumentContext return Collections.emptyList(); } + var doCall = maybeDoCall.get(); var assignment = (BSLParser.AssignmentContext) Trees.getAncestorByRuleIndex(doCall, BSLParser.RULE_assignment); if (assignment == null || isParentAssignment(doCall, assignment)) { return Collections.emptyList(); @@ -118,24 +114,24 @@ public List getCodeActions(CodeActionParams params, DocumentContext var lValueName = lValue.getText(); var insert = Resources.getResourceString(configuration.getLanguage(), getClass(), "insert"); - String[] keys = Strings.trimQuotes(firstToken.getText()).split(","); + var keys = Strings.trimQuotes(firstToken.getText()).split(","); var workspaceEdit = new WorkspaceEdit(); var changes = new ArrayList(); var constructorEdit = new TextEdit(Ranges.create(doCall), "()"); changes.add(constructorEdit); - int intendSize = Ranges.create(lValue).getStart().getCharacter(); + var indentSize = Ranges.create(lValue).getStart().getCharacter(); var rparenRange = Ranges.create(doCall.RPAREN()); var constructorLine = rparenRange.getEnd().getLine(); var position = new Position(constructorLine + 1, 0); var range = new Range(position, position); - var indent = documentContext.getContentList()[constructorLine].substring(0, intendSize); + var indent = documentContext.getContentList()[constructorLine].substring(0, indentSize); for (var i = 0; i < keys.length; i++) { - String key = keys[i].trim(); + var key = keys[i].trim(); var value = ""; var separator = ""; if (parameters.size() > i + 1) { diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/FixAllCodeActionSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/FixAllCodeActionSupplier.java index 6bb040d76d4..e0d2b5075c6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/FixAllCodeActionSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/FixAllCodeActionSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/GenerateStandardRegionsSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/GenerateStandardRegionsSupplier.java index 368c161de7b..6993e357ede 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/GenerateStandardRegionsSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/GenerateStandardRegionsSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/QuickFixCodeActionSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/QuickFixCodeActionSupplier.java index 48cee5f1f1e..1471721a81c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/QuickFixCodeActionSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/QuickFixCodeActionSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/QuickFixSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/QuickFixSupplier.java index 3d12744d685..f1cdcf3a836 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/QuickFixSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/QuickFixSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/package-info.java index b5da17dd824..3e97832ce87 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/AbstractMethodComplexityCodeLensSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/AbstractMethodComplexityCodeLensSupplier.java index a71cf923df7..231eb13df03 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/AbstractMethodComplexityCodeLensSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/AbstractMethodComplexityCodeLensSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/AbstractRunTestsCodeLensSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/AbstractRunTestsCodeLensSupplier.java index 0c66055a232..3cbf5a209a3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/AbstractRunTestsCodeLensSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/AbstractRunTestsCodeLensSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CodeLensData.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CodeLensData.java index c3c678afdcd..7938e8c442e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CodeLensData.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CodeLensData.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CodeLensSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CodeLensSupplier.java index 12366d5af64..d05d61fbd01 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CodeLensSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CodeLensSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CognitiveComplexityCodeLensSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CognitiveComplexityCodeLensSupplier.java index ab13f820e4f..88b2de2c385 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CognitiveComplexityCodeLensSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CognitiveComplexityCodeLensSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CyclomaticComplexityCodeLensSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CyclomaticComplexityCodeLensSupplier.java index bdfbc4553a6..3e246981447 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CyclomaticComplexityCodeLensSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CyclomaticComplexityCodeLensSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/DefaultCodeLensData.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/DefaultCodeLensData.java index 51cbb6f6920..b2c6a9bec44 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/DefaultCodeLensData.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/DefaultCodeLensData.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunAllTestsCodeLensSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunAllTestsCodeLensSupplier.java index 8077915b378..10d7ca8ac74 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunAllTestsCodeLensSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunAllTestsCodeLensSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunTestCodeLensSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunTestCodeLensSupplier.java index c9d754beedb..10edb38b9c7 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunTestCodeLensSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunTestCodeLensSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -26,18 +26,14 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.context.FileType; import com.github._1c_syntax.bsl.languageserver.context.symbol.MethodSymbol; -import com.github._1c_syntax.bsl.languageserver.events.LanguageServerInitializeRequestReceivedEvent; import com.github._1c_syntax.bsl.languageserver.utils.Resources; import lombok.EqualsAndHashCode; import lombok.RequiredArgsConstructor; import lombok.ToString; import lombok.Value; import lombok.extern.slf4j.Slf4j; -import org.eclipse.lsp4j.ClientInfo; import org.eclipse.lsp4j.CodeLens; import org.eclipse.lsp4j.Command; -import org.eclipse.lsp4j.InitializeParams; -import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; import java.beans.ConstructorProperties; diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/infrastructure/CodeLensesConfiguration.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/infrastructure/CodeLensesConfiguration.java index cbcfc32480d..d02b788aed5 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/infrastructure/CodeLensesConfiguration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/infrastructure/CodeLensesConfiguration.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/infrastructure/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/infrastructure/package-info.java index d9346663ff3..e7dc14afc23 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/infrastructure/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/infrastructure/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/package-info.java index 58586c08f71..3095e10fa2b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/testrunner/TestRunnerAdapter.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/testrunner/TestRunnerAdapter.java index 513894317e6..badd8e71f7f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/testrunner/TestRunnerAdapter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/testrunner/TestRunnerAdapter.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -38,6 +38,7 @@ import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Paths; +import java.time.Duration; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -83,14 +84,14 @@ private List computeTestIds(DocumentContext documentContext) { var getTestsCommand = new CommandLine(executable).addArguments(arguments, false); var timeout = 10_000L; - var watchdog = new ExecuteWatchdog(timeout); + var watchdog = ExecuteWatchdog.builder().setTimeout(Duration.ofMillis(timeout)).get(); var outputStream = new ByteArrayOutputStream(); var streamHandler = new PumpStreamHandler(outputStream); var resultHandler = new DefaultExecuteResultHandler(); - var executor = new DefaultExecutor(); + var executor = DefaultExecutor.builder().get(); executor.setWatchdog(watchdog); executor.setStreamHandler(streamHandler); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/testrunner/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/testrunner/package-info.java index 39ce288f548..78ab38cedfe 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/testrunner/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/codelenses/testrunner/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/BSLColor.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/BSLColor.java index c8c94119635..f3c7b60fff2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/BSLColor.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/BSLColor.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ColorInformationSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ColorInformationSupplier.java index 77554e359de..6f5fddc49c3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ColorInformationSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ColorInformationSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ColorPresentationSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ColorPresentationSupplier.java index e3e6f35fa95..1a9f7bd4f5e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ColorPresentationSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ColorPresentationSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorInformationSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorInformationSupplier.java index 1c74bd6c233..11c2ed98c5e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorInformationSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorInformationSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -22,9 +22,9 @@ package com.github._1c_syntax.bsl.languageserver.color; import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; -import com.github._1c_syntax.bsl.languageserver.utils.bsl.Constructors; import com.github._1c_syntax.bsl.languageserver.utils.Ranges; import com.github._1c_syntax.bsl.languageserver.utils.Trees; +import com.github._1c_syntax.bsl.languageserver.utils.bsl.Constructors; import com.github._1c_syntax.bsl.parser.BSLParser; import com.github._1c_syntax.utils.CaseInsensitivePattern; import org.antlr.v4.runtime.Token; diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorPresentationSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorPresentationSupplier.java index 44cb4515b72..1a4921ea44f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorPresentationSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorPresentationSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/WebColor.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/WebColor.java index 415b177453e..f13eaea4da3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/WebColor.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/WebColor.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorInformationSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorInformationSupplier.java index 82204162629..a7a50e06f7e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorInformationSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorInformationSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorPresentationSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorPresentationSupplier.java index 36bf95d8b58..1c42c9121dc 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorPresentationSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorPresentationSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/package-info.java index 3c5be816cc3..5034bf05f7a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/color/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/CommandArguments.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/CommandArguments.java index 4e66dff0579..b6354ef8300 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/CommandArguments.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/CommandArguments.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/CommandSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/CommandSupplier.java index 7a604f3b6b2..3de60bb2d92 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/CommandSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/CommandSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/DefaultCommandArguments.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/DefaultCommandArguments.java index 2b0fc89b5e5..3cbf1caf2c0 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/DefaultCommandArguments.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/DefaultCommandArguments.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCognitiveComplexityInlayHintsCommandSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCognitiveComplexityInlayHintsCommandSupplier.java index 8d32a87f321..7edfca092ba 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCognitiveComplexityInlayHintsCommandSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCognitiveComplexityInlayHintsCommandSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCyclomaticComplexityInlayHintsCommandSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCyclomaticComplexityInlayHintsCommandSupplier.java index 343b1989b06..6fe3782e439 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCyclomaticComplexityInlayHintsCommandSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCyclomaticComplexityInlayHintsCommandSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/complexity/AbstractToggleComplexityInlayHintsCommandSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/complexity/AbstractToggleComplexityInlayHintsCommandSupplier.java index 86f0a04f9d9..2796b1291d1 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/complexity/AbstractToggleComplexityInlayHintsCommandSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/complexity/AbstractToggleComplexityInlayHintsCommandSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/complexity/ToggleComplexityInlayHintsCommandArguments.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/complexity/ToggleComplexityInlayHintsCommandArguments.java index bd899446aa2..18607281671 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/complexity/ToggleComplexityInlayHintsCommandArguments.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/complexity/ToggleComplexityInlayHintsCommandArguments.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/complexity/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/complexity/package-info.java index c910dca8805..a796282ec0c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/complexity/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/complexity/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/infrastructure/CommandsConfiguration.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/infrastructure/CommandsConfiguration.java index a3c85772a78..654582c2230 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/infrastructure/CommandsConfiguration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/infrastructure/CommandsConfiguration.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/infrastructure/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/infrastructure/package-info.java index fc7a54028c1..32a3a7b7158 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/infrastructure/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/infrastructure/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/package-info.java index 748bdbca505..a1f734f56b9 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/commands/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/Language.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/Language.java index 7a05e0e4af8..f403380fa7b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/Language.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/Language.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -29,6 +29,7 @@ * Язык для сообщений, ресурсов и прочих взаимодействий между * BSL Language Server и пользователем. */ +@Getter public enum Language { /** @@ -49,13 +50,11 @@ public enum Language { /** * Код языка в соответствии с {@link java.util.Locale#getLanguage()}. */ - @Getter private final String languageCode; /** * Локаль языка. */ - @Getter private final Locale locale; /** diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/LanguageServerConfiguration.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/LanguageServerConfiguration.java index 307ac1986c4..b35dac566fc 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/LanguageServerConfiguration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/LanguageServerConfiguration.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -56,7 +56,6 @@ import java.util.List; import java.util.Optional; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.stream.Stream; import static com.fasterxml.jackson.databind.MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS; @@ -147,7 +146,7 @@ public void reset() { public static Path getCustomConfigurationRoot(LanguageServerConfiguration configuration, Path srcDir) { Path rootPath = null; - Path pathFromConfiguration = configuration.getConfigurationRoot(); + var pathFromConfiguration = configuration.getConfigurationRoot(); if (pathFromConfiguration == null) { rootPath = Absolute.path(srcDir); @@ -161,7 +160,7 @@ public static Path getCustomConfigurationRoot(LanguageServerConfiguration config } if (rootPath != null) { - File fileConfiguration = getConfigurationFile(rootPath); + var fileConfiguration = getConfigurationFile(rootPath); if (fileConfiguration != null) { if (fileConfiguration.getAbsolutePath().endsWith(".mdo")) { rootPath = Optional.of(fileConfiguration.toPath()) @@ -178,7 +177,6 @@ public static Path getCustomConfigurationRoot(LanguageServerConfiguration config } return rootPath; - } @SuppressFBWarnings( @@ -190,7 +188,7 @@ private static File getConfigurationFile(Path rootPath) { List listPath = new ArrayList<>(); try (Stream stream = Files.find(rootPath, 50, (path, basicFileAttributes) -> basicFileAttributes.isRegularFile() && searchConfiguration.matcher(path.getFileName().toString()).find())) { - listPath = stream.collect(Collectors.toList()); + listPath = stream.toList(); } catch (IOException e) { LOGGER.error("Error on read configuration file", e); } @@ -219,7 +217,6 @@ private void loadConfigurationFile(File configurationFile) { } this.configurationFile = configurationFile; - copyPropertiesFrom(configuration); } @@ -233,5 +230,4 @@ private void copyPropertiesFrom(LanguageServerConfiguration configuration) { PropertyUtils.copyProperties(this.documentLinkOptions, configuration.documentLinkOptions); PropertyUtils.copyProperties(this.formattingOptions, configuration.formattingOptions); } - } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/SendErrorsMode.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/SendErrorsMode.java index 58aa3f340f2..6eff543e329 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/SendErrorsMode.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/SendErrorsMode.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/codelens/CodeLensOptions.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/codelens/CodeLensOptions.java index 34ef851a01d..654f5fc094a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/codelens/CodeLensOptions.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/codelens/CodeLensOptions.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/codelens/TestRunnerAdapterOptions.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/codelens/TestRunnerAdapterOptions.java index e0e9c4ee133..c368f8872e5 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/codelens/TestRunnerAdapterOptions.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/codelens/TestRunnerAdapterOptions.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/codelens/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/codelens/package-info.java index 83d6eafb0c6..99bf2b19d92 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/codelens/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/codelens/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/databind/ParametersDeserializer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/databind/ParametersDeserializer.java index 3697e933f98..8f94f39cbb6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/databind/ParametersDeserializer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/databind/ParametersDeserializer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/databind/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/databind/package-info.java index 58b77385b71..8f152e1301f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/databind/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/databind/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/ComputeTrigger.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/ComputeTrigger.java index 93091091cfe..fadb8ccaaf9 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/ComputeTrigger.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/ComputeTrigger.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/DiagnosticsOptions.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/DiagnosticsOptions.java index 040cb33f2ec..d445a027530 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/DiagnosticsOptions.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/DiagnosticsOptions.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/Mode.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/Mode.java index 54bc8f0c477..41c8938a3d4 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/Mode.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/Mode.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/SkipSupport.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/SkipSupport.java index 67ffa7258ed..7570456eb14 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/SkipSupport.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/SkipSupport.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/SubsystemFilter.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/SubsystemFilter.java index db07d116bd2..1e89e458003 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/SubsystemFilter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/SubsystemFilter.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/package-info.java index ac284d5e026..2ca9f5a44b5 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/diagnostics/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/documentlink/DocumentLinkOptions.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/documentlink/DocumentLinkOptions.java index 7d92105e989..bec9d64f0dc 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/documentlink/DocumentLinkOptions.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/documentlink/DocumentLinkOptions.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/documentlink/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/documentlink/package-info.java index 0b3a1738e34..814184ee631 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/documentlink/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/documentlink/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/events/LanguageServerConfigurationChangedEvent.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/events/LanguageServerConfigurationChangedEvent.java index 0cc0037e1ee..cd6cdd2e3bd 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/events/LanguageServerConfigurationChangedEvent.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/events/LanguageServerConfigurationChangedEvent.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/events/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/events/package-info.java index f05a9a9449d..4ffc46ddfe2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/events/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/events/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/formating/FormattingOptions.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/formating/FormattingOptions.java index 8b75ba75e24..a6375c02e1f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/formating/FormattingOptions.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/formating/FormattingOptions.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/formating/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/formating/package-info.java index 3a06871316d..c623a042804 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/formating/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/formating/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/inlayhints/InlayHintOptions.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/inlayhints/InlayHintOptions.java index d102a695947..10f268d953f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/inlayhints/InlayHintOptions.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/inlayhints/InlayHintOptions.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/inlayhints/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/inlayhints/package-info.java index 038ac7ca0cb..b2526efce46 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/inlayhints/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/inlayhints/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/package-info.java index f8801f1699d..eb3be79b95c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/ConfigurationFileChangeListener.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/ConfigurationFileChangeListener.java index 564d20a53fb..0736502ba52 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/ConfigurationFileChangeListener.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/ConfigurationFileChangeListener.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/ConfigurationFileSystemWatcher.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/ConfigurationFileSystemWatcher.java index d25734c2ded..c7175da391e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/ConfigurationFileSystemWatcher.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/ConfigurationFileSystemWatcher.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/package-info.java index ccea8d07e41..dedf81ea2b1 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContext.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContext.java index c52fec899b7..ab853043114 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContext.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContext.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -33,16 +33,15 @@ import com.github._1c_syntax.bsl.languageserver.context.symbol.MethodSymbol; import com.github._1c_syntax.bsl.languageserver.context.symbol.SymbolTree; import com.github._1c_syntax.bsl.languageserver.utils.Trees; +import com.github._1c_syntax.bsl.mdo.MD; import com.github._1c_syntax.bsl.mdo.support.ScriptVariant; import com.github._1c_syntax.bsl.parser.BSLLexer; import com.github._1c_syntax.bsl.parser.BSLParser; import com.github._1c_syntax.bsl.parser.BSLTokenizer; import com.github._1c_syntax.bsl.parser.SDBLTokenizer; -import com.github._1c_syntax.bsl.supconf.SupportConfiguration; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.ConfigurationSource; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; import com.github._1c_syntax.utils.Lazy; import edu.umd.cs.findbugs.annotations.Nullable; import jakarta.annotation.PostConstruct; @@ -68,7 +67,6 @@ import java.util.Collections; import java.util.List; import java.util.Locale; -import java.util.Map; import java.util.Optional; import java.util.concurrent.locks.ReentrantLock; import java.util.regex.Pattern; @@ -120,8 +118,6 @@ public class DocumentContext { private final Lazy contentList = new Lazy<>(this::computeContentList, computeLock); private final Lazy moduleType = new Lazy<>(this::computeModuleType, computeLock); - private final Lazy> supportVariants - = new Lazy<>(this::computeSupportVariants, computeLock); private final Lazy cognitiveComplexityData = new Lazy<>(this::computeCognitiveComplexity, computeLock); private final Lazy cyclomaticComplexityData @@ -240,13 +236,12 @@ public ModuleType getModuleType() { return moduleType.getOrCompute(); } - public Map getSupportVariants() { - return supportVariants.getOrCompute(); + public SupportVariant getSupportVariant() { + return getMdObject().map(MD::getSupportVariant).orElse(SupportVariant.NONE); } - public Optional getMdObject() { - return Optional - .ofNullable((AbstractMDObjectBase) getServerContext().getConfiguration().getModulesByObject().get(getUri())); + public Optional getMdObject() { + return getServerContext().getConfiguration().findChild(getUri()); } public List getQueries() { @@ -340,7 +335,6 @@ private void clearDependantData() { diagnosticsLock.unlock(); computeLock.unlock(); } - } private static FileType computeFileType(URI uri) { @@ -371,11 +365,7 @@ private SymbolTree computeSymbolTree() { private ModuleType computeModuleType() { - return context.getConfiguration().getModuleType(uri); - } - - private Map computeSupportVariants() { - return context.getConfiguration().getModuleSupport(uri); + return context.getConfiguration().getModuleTypeByURI(uri); } private ComplexityData computeCognitiveComplexity() { diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/FileType.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/FileType.java index 1f9cce28965..55a924ac48d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/FileType.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/FileType.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/MetricStorage.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/MetricStorage.java index 064aee78d0b..bc9eef0e6b1 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/MetricStorage.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/MetricStorage.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/ServerContext.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/ServerContext.java index 67e54a57078..9835fc5cb1e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/ServerContext.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/ServerContext.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -26,8 +26,9 @@ import com.github._1c_syntax.bsl.languageserver.utils.MdoRefBuilder; import com.github._1c_syntax.bsl.languageserver.utils.NamedForkJoinWorkerThreadFactory; import com.github._1c_syntax.bsl.languageserver.utils.Resources; +import com.github._1c_syntax.bsl.mdclasses.CF; +import com.github._1c_syntax.bsl.mdclasses.MDClasses; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.Configuration; import com.github._1c_syntax.utils.Absolute; import com.github._1c_syntax.utils.Lazy; import edu.umd.cs.findbugs.annotations.Nullable; @@ -63,7 +64,7 @@ public class ServerContext { private final LanguageServerConfiguration languageServerConfiguration; private final Map documents = Collections.synchronizedMap(new HashMap<>()); - private final Lazy configurationMetadata = new Lazy<>(this::computeConfigurationMetadata); + private final Lazy configurationMetadata = new Lazy<>(this::computeConfigurationMetadata); @Nullable @Setter private Path configurationRoot; @@ -258,7 +259,7 @@ public void closeDocument(DocumentContext documentContext) { documentContext.clearSecondaryData(); } - public Configuration getConfiguration() { + public CF getConfiguration() { return configurationMetadata.getOrCompute(); } @@ -273,9 +274,9 @@ private DocumentContext createDocumentContext(URI uri) { return documentContext; } - private Configuration computeConfigurationMetadata() { + private CF computeConfigurationMetadata() { if (configurationRoot == null) { - return Configuration.create(); + return (CF) MDClasses.createConfiguration(); } var progress = workDoneProgressHelper.createProgress(0, ""); @@ -284,15 +285,15 @@ private Configuration computeConfigurationMetadata() { var factory = new NamedForkJoinWorkerThreadFactory("compute-configuration-"); var executorService = new ForkJoinPool(ForkJoinPool.getCommonPoolParallelism(), factory, null, true); - Configuration configuration; + CF configuration; try { - configuration = executorService.submit(() -> Configuration.create(configurationRoot)).get(); + configuration = (CF) executorService.submit(() -> MDClasses.createConfiguration(configurationRoot)).get(); } catch (ExecutionException e) { LOGGER.error("Can't parse configuration metadata. Execution exception.", e); - configuration = Configuration.create(); + configuration = (CF) MDClasses.createConfiguration(); } catch (InterruptedException e) { LOGGER.error("Can't parse configuration metadata. Interrupted exception.", e); - configuration = Configuration.create(); + configuration = (CF) MDClasses.createConfiguration(); Thread.currentThread().interrupt(); } finally { executorService.shutdown(); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CognitiveComplexityComputer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CognitiveComplexityComputer.java index 615e71f3e92..51c4ef89747 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CognitiveComplexityComputer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CognitiveComplexityComputer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -97,7 +97,7 @@ public ComplexityData compute() { methodsComplexity.clear(); ignoredContexts.clear(); - ParseTreeWalker walker = new ParseTreeWalker(); + var walker = new ParseTreeWalker(); walker.walk(this, documentContext.getAst()); return new ComplexityData( @@ -265,7 +265,7 @@ public void enterGotoStatement(BSLParser.GotoStatementContext ctx) { @Override public void enterGlobalMethodCall(BSLParser.GlobalMethodCallContext ctx) { - BSLParser.MethodNameContext methodNameContext = ctx.methodName(); + var methodNameContext = ctx.methodName(); if (methodNameContext != null && currentMethod != null) { String calledMethodName = methodNameContext.getText(); if (currentMethod.getName().equalsIgnoreCase(calledMethodName)) { @@ -286,7 +286,7 @@ public void enterExpression(BSLParser.ExpressionContext ctx) { final List flattenExpression = flattenExpression(ctx); int emptyTokenType = -1; - AtomicInteger lastOperationType = new AtomicInteger(emptyTokenType); + var lastOperationType = new AtomicInteger(emptyTokenType); flattenExpression.forEach((Token token) -> { int currentOperationType = token.getType(); @@ -309,15 +309,14 @@ private List flattenExpression(BSLParser.ExpressionContext ctx) { final List children = Trees.getChildren(ctx); for (Tree tree : children) { - if (!(tree instanceof BSLParserRuleContext)) { + if (!(tree instanceof BSLParserRuleContext parserRule)) { continue; } - BSLParserRuleContext parserRule = ((BSLParserRuleContext) tree); - if (parserRule instanceof BSLParser.MemberContext) { - flattenMember(result, (BSLParser.MemberContext) parserRule); - } else if (parserRule instanceof BSLParser.OperationContext) { - flattenOperation(result, (BSLParser.OperationContext) parserRule); + if (parserRule instanceof BSLParser.MemberContext memberContext) { + flattenMember(result, memberContext); + } else if (parserRule instanceof BSLParser.OperationContext operationContext) { + flattenOperation(result, operationContext); } } @@ -339,7 +338,7 @@ private void flattenMember(List result, BSLParser.MemberContext member) { final BSLParser.UnaryModifierContext unaryModifier = member.unaryModifier(); if (unaryModifier != null && unaryModifier.NOT_KEYWORD() != null) { - final CommonToken splitter = new CommonToken(-1); + final var splitter = new CommonToken(-1); result.add(splitter); result.addAll(nestedTokens); result.add(splitter); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ComplexityData.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ComplexityData.java index de72240f2c9..030d9588758 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ComplexityData.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ComplexityData.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ComplexitySecondaryLocation.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ComplexitySecondaryLocation.java index 9763b40963a..b942bb9cefc 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ComplexitySecondaryLocation.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ComplexitySecondaryLocation.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/Computer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/Computer.java index 58b525ac782..d50f5015482 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/Computer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/Computer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CyclomaticComplexityComputer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CyclomaticComplexityComputer.java index ef248e2425d..26cb9e3423b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CyclomaticComplexityComputer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CyclomaticComplexityComputer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -201,7 +201,7 @@ public void enterExceptCodeBlock(BSLParser.ExceptCodeBlockContext ctx) { @Override public void enterGlobalMethodCall(BSLParser.GlobalMethodCallContext ctx) { - BSLParser.MethodNameContext methodNameContext = ctx.methodName(); + var methodNameContext = ctx.methodName(); if (methodNameContext != null && currentMethod != null) { String calledMethodName = methodNameContext.getText(); if (currentMethod.getName().equalsIgnoreCase(calledMethodName)) { @@ -234,15 +234,14 @@ private static List flattenExpression(BSLParser.ExpressionContext ctx) { final List children = Trees.getChildren(ctx); for (Tree tree : children) { - if (!(tree instanceof BSLParserRuleContext)) { + if (!(tree instanceof BSLParserRuleContext parserRule)) { continue; } - BSLParserRuleContext parserRule = ((BSLParserRuleContext) tree); - if (parserRule instanceof BSLParser.MemberContext) { - flattenMember(result, (BSLParser.MemberContext) parserRule); - } else if (parserRule instanceof BSLParser.OperationContext) { - flattenOperation(result, (BSLParser.OperationContext) parserRule); + if (parserRule instanceof BSLParser.MemberContext memberContext) { + flattenMember(result, memberContext); + } else if (parserRule instanceof BSLParser.OperationContext operationContext) { + flattenOperation(result, operationContext); } } @@ -264,7 +263,7 @@ private static void flattenMember(List result, BSLParser.MemberContext me final BSLParser.UnaryModifierContext unaryModifier = member.unaryModifier(); if (unaryModifier != null && unaryModifier.NOT_KEYWORD() != null) { - final CommonToken splitter = new CommonToken(-1); + final var splitter = new CommonToken(-1); result.add(splitter); result.addAll(nestedTokens); result.add(splitter); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/DiagnosticComputer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/DiagnosticComputer.java index 32c092533d6..fccf771950b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/DiagnosticComputer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/DiagnosticComputer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/DiagnosticIgnoranceComputer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/DiagnosticIgnoranceComputer.java index dc28b5f33ba..28ace78241f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/DiagnosticIgnoranceComputer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/DiagnosticIgnoranceComputer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.java index 22a0fd295fd..0fd1d55c87e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ModuleSymbolComputer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ModuleSymbolComputer.java index 432c50a3f22..695c4fcce05 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ModuleSymbolComputer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ModuleSymbolComputer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/QueryComputer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/QueryComputer.java index cb3f6765e67..5269748c21b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/QueryComputer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/QueryComputer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/RegionSymbolComputer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/RegionSymbolComputer.java index 9f49d7171a2..d099cd793c5 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/RegionSymbolComputer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/RegionSymbolComputer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/SymbolTreeComputer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/SymbolTreeComputer.java index 66a14639305..17e4e3c0603 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/SymbolTreeComputer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/SymbolTreeComputer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/VariableSymbolComputer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/VariableSymbolComputer.java index 03665c3b20e..ef1da40a5e6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/VariableSymbolComputer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/VariableSymbolComputer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -229,6 +229,30 @@ private Optional createDescription(BSLParser.LValueContext ); } + private Optional createDescription(BSLParser.ForEachStatementContext ctx) { + var trailingComments = Trees.getTrailingComment(documentContext.getTokens(), ctx.IDENTIFIER().getSymbol()); + + if (trailingComments.isEmpty()) { + return Optional.empty(); + } + + return Optional.of( + new VariableDescription(Collections.emptyList(), trailingComments) + ); + } + + private Optional createDescription(BSLParser.ForStatementContext ctx) { + var trailingComments = Trees.getTrailingComment(documentContext.getTokens(), ctx.IDENTIFIER().getSymbol()); + + if (trailingComments.isEmpty()) { + return Optional.empty(); + } + + return Optional.of( + new VariableDescription(Collections.emptyList(), trailingComments) + ); + } + private Optional createDescription(BSLParserRuleContext ctx) { List tokens = documentContext.getTokens(); List comments = new ArrayList<>(); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/package-info.java index bdc801d11ef..81376e2e7e0 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/events/DocumentContextContentChangedEvent.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/events/DocumentContextContentChangedEvent.java index 8ce9ef55ff1..62c1535b1f6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/events/DocumentContextContentChangedEvent.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/events/DocumentContextContentChangedEvent.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/events/ServerContextPopulatedEvent.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/events/ServerContextPopulatedEvent.java index f7fd2c6491c..d27ced1e733 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/events/ServerContextPopulatedEvent.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/events/ServerContextPopulatedEvent.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/events/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/events/package-info.java index 9c717431fb4..2d133bd98c9 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/events/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/events/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/package-info.java index 6210f93446f..5dc64df4c54 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/AbstractVariableSymbol.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/AbstractVariableSymbol.java index ab41e8af344..529b33fb768 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/AbstractVariableSymbol.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/AbstractVariableSymbol.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -46,7 +46,7 @@ @NonFinal @Builder(builderClassName = "Builder") @EqualsAndHashCode(onlyExplicitlyIncluded = true) -@ToString(exclude = {"children", "parent"}) +@ToString(exclude = {"parent"}) public abstract class AbstractVariableSymbol implements VariableSymbol { /** @@ -74,12 +74,6 @@ public abstract class AbstractVariableSymbol implements VariableSymbol { @NonFinal Optional parent; - /** - * Список "детей" символа - символов, которые располагаются внутри данного символа. - */ - @Getter - List children; - /** * Тип переменной. */ @@ -95,6 +89,11 @@ public abstract class AbstractVariableSymbol implements VariableSymbol { */ Optional description; + @Override + public List getChildren() { + return Collections.emptyList(); + } + @Override public SymbolKind getSymbolKind() { return SymbolKind.Variable; @@ -129,10 +128,6 @@ public static class Builder { @Accessors(fluent = true, chain = true) Optional parent = Optional.empty(); - @Setter - @Accessors(fluent = true, chain = true) - List children = Collections.emptyList(); - private int startLine; private int startCharacter; private int endLine; @@ -179,7 +174,6 @@ public VariableSymbol build() { scope, owner, parent, - children, (byte) kind.ordinal(), export, description, @@ -197,7 +191,6 @@ public VariableSymbol build() { scope, owner, parent, - children, (byte) kind.ordinal(), export, description, diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/Describable.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/Describable.java index 7e50096a7d9..60079d66b3d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/Describable.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/Describable.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/Exportable.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/Exportable.java index f95de417026..e94a0f24f5c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/Exportable.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/Exportable.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/IntBasedVariableSymbol.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/IntBasedVariableSymbol.java index 36c2b64eeba..977d18ba6eb 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/IntBasedVariableSymbol.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/IntBasedVariableSymbol.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -32,7 +32,6 @@ import lombok.experimental.NonFinal; import org.eclipse.lsp4j.Range; -import java.util.List; import java.util.Optional; /** @@ -65,7 +64,6 @@ public IntBasedVariableSymbol( SourceDefinedSymbol scope, DocumentContext owner, Optional parent, - List children, byte kind, boolean export, Optional description, @@ -77,7 +75,7 @@ public IntBasedVariableSymbol( int variableNameStartCharacter, int variableNameEndCharacter ) { - super(name, scope, owner, parent, children, kind, export, description); + super(name, scope, owner, parent, kind, export, description); this.startLine = startLine; this.startCharacter = startCharacter; diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/MethodSymbol.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/MethodSymbol.java index fb86a38a296..99ee4bca83a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/MethodSymbol.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/MethodSymbol.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/ModuleSymbol.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/ModuleSymbol.java index 42e0a89997e..fa58f67e29a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/ModuleSymbol.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/ModuleSymbol.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/ParameterDefinition.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/ParameterDefinition.java index be308284168..aa495748161 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/ParameterDefinition.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/ParameterDefinition.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/RegionSymbol.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/RegionSymbol.java index 3bc6385a94a..acee636f1a9 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/RegionSymbol.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/RegionSymbol.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/ShortBasedVariableSymbol.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/ShortBasedVariableSymbol.java index df05f003cca..854661b50b8 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/ShortBasedVariableSymbol.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/ShortBasedVariableSymbol.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -32,7 +32,6 @@ import lombok.experimental.NonFinal; import org.eclipse.lsp4j.Range; -import java.util.List; import java.util.Optional; /** @@ -65,7 +64,6 @@ public ShortBasedVariableSymbol( SourceDefinedSymbol scope, DocumentContext owner, Optional parent, - List children, byte kind, boolean export, Optional description, @@ -77,7 +75,7 @@ public ShortBasedVariableSymbol( short variableNameStartCharacter, short variableNameEndCharacter ) { - super(name, scope, owner, parent, children, kind, export, description); + super(name, scope, owner, parent, kind, export, description); this.startLine = startLine; this.startCharacter = startCharacter; diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/SourceDefinedSymbol.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/SourceDefinedSymbol.java index 2e306c61cb7..cd83b26db30 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/SourceDefinedSymbol.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/SourceDefinedSymbol.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/Symbol.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/Symbol.java index bb66b9f77b0..8d14f7d625e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/Symbol.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/Symbol.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/SymbolTree.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/SymbolTree.java index 3da895c08a0..640cfc02249 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/SymbolTree.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/SymbolTree.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/SymbolTreeVisitor.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/SymbolTreeVisitor.java index 47757b28271..59ba6bb075c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/SymbolTreeVisitor.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/SymbolTreeVisitor.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/VariableSymbol.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/VariableSymbol.java index a47e2321f4a..4d5c492459a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/VariableSymbol.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/VariableSymbol.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/Annotation.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/Annotation.java index b45c4213908..bc5a302973f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/Annotation.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/Annotation.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/AnnotationKind.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/AnnotationKind.java index b33cbf96db2..2d7f5cd24c0 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/AnnotationKind.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/AnnotationKind.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/AnnotationParameterDefinition.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/AnnotationParameterDefinition.java index a1a89948ff2..db4e17c9cc3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/AnnotationParameterDefinition.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/AnnotationParameterDefinition.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/CompilerDirectiveKind.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/CompilerDirectiveKind.java index f12f2a2f0c6..1b228c48451 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/CompilerDirectiveKind.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/CompilerDirectiveKind.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/package-info.java index 4cec16a53f4..85338488712 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/annotations/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/DescriptionReader.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/DescriptionReader.java index 8a0882a888d..dd9247ddef8 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/DescriptionReader.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/DescriptionReader.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -236,7 +236,9 @@ private String getDescriptionString(BSLParserRuleContext ctx) { return strings.toString().strip(); } - private List getParametersStrings(List strings) { + private List getParametersStrings( + List strings) { + List result = new ArrayList<>(); var current = new TempParameterData(); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/MethodDescription.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/MethodDescription.java index 4a871e5ae14..2ba21694ef6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/MethodDescription.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/MethodDescription.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/ParameterDescription.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/ParameterDescription.java index 843c794adca..1557265e322 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/ParameterDescription.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/ParameterDescription.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/SourceDefinedSymbolDescription.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/SourceDefinedSymbolDescription.java index 69c589d68d8..8a50211432c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/SourceDefinedSymbolDescription.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/SourceDefinedSymbolDescription.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/TypeDescription.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/TypeDescription.java index 335857ebd3a..416470cb082 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/TypeDescription.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/TypeDescription.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/package-info.java index eaa798e0009..dd1bfa7bdef 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/package-info.java index c0806e5b864..bbeebf6b7ef 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/variable/VariableDescription.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/variable/VariableDescription.java index 9c390277844..7d4e7b0a6e2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/variable/VariableDescription.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/variable/VariableDescription.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/variable/VariableKind.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/variable/VariableKind.java index a7cff3569c7..7838c9eb5b1 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/variable/VariableKind.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/variable/VariableKind.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/databind/ObjectMapperConfiguration.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/databind/ObjectMapperConfiguration.java index 3e40bc52c03..3c4b8925020 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/databind/ObjectMapperConfiguration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/databind/ObjectMapperConfiguration.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/databind/URITypeAdapter.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/databind/URITypeAdapter.java index b62570d5aee..282a1ea1f3e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/databind/URITypeAdapter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/databind/URITypeAdapter.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/databind/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/databind/package-info.java index c5a502cf620..1b66b7ca64b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/databind/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/databind/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractCommonModuleNameDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractCommonModuleNameDiagnostic.java index 7d442b99905..f18ca2d252a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractCommonModuleNameDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractCommonModuleNameDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -23,8 +23,7 @@ import com.github._1c_syntax.bsl.languageserver.configuration.LanguageServerConfiguration; import com.github._1c_syntax.bsl.languageserver.utils.Ranges; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.utils.CaseInsensitivePattern; import java.util.regex.Matcher; @@ -49,36 +48,36 @@ protected void check() { } documentContext.getMdObject() - .filter(MDCommonModule.class::isInstance) - .map(MDCommonModule.class::cast) + .filter(CommonModule.class::isInstance) + .map(CommonModule.class::cast) .filter(this::flagsCheck) - .map(AbstractMDObjectBase::getName) + .map(CommonModule::getName) .map(pattern::matcher) .filter(this::matchCheck) .ifPresent(commonModule -> diagnosticStorage.addDiagnostic(range)); } - protected abstract boolean flagsCheck(MDCommonModule commonModule); + protected abstract boolean flagsCheck(CommonModule commonModule); protected boolean matchCheck(Matcher matcher) { return !matcher.find(); } - protected boolean isClientServer(MDCommonModule commonModule) { + protected boolean isClientServer(CommonModule commonModule) { return !commonModule.isServerCall() && commonModule.isServer() && commonModule.isExternalConnection() && isClientApplication(commonModule); } - protected boolean isClient(MDCommonModule commonModule) { + protected boolean isClient(CommonModule commonModule) { return !commonModule.isServerCall() && !commonModule.isServer() && !commonModule.isExternalConnection() && isClientApplication(commonModule); } - protected boolean isServerCall(MDCommonModule commonModule) { + protected boolean isServerCall(CommonModule commonModule) { return commonModule.isServerCall() && commonModule.isServer() && !commonModule.isExternalConnection() @@ -86,7 +85,7 @@ protected boolean isServerCall(MDCommonModule commonModule) { && !commonModule.isClientManagedApplication(); } - protected boolean isServer(MDCommonModule commonModule) { + protected boolean isServer(CommonModule commonModule) { return !commonModule.isServerCall() && commonModule.isServer() && commonModule.isExternalConnection() @@ -94,12 +93,12 @@ && isClientOrdinaryAppIfNeed(commonModule) && !commonModule.isClientManagedApplication(); } - private boolean isClientApplication(MDCommonModule commonModule) { + private boolean isClientApplication(CommonModule commonModule) { return isClientOrdinaryAppIfNeed(commonModule) && commonModule.isClientManagedApplication(); } - private boolean isClientOrdinaryAppIfNeed(MDCommonModule commonModule) { + private boolean isClientOrdinaryAppIfNeed(CommonModule commonModule) { return commonModule.isClientOrdinaryApplication() || !serverConfiguration.getDiagnosticsOptions().isOrdinaryAppSupport(); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractDiagnostic.java index d6bcdf7a833..2a1212388f5 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractExecuteExternalCodeDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractExecuteExternalCodeDiagnostic.java index 03e50ad08a5..2ce6daa58b3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractExecuteExternalCodeDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractExecuteExternalCodeDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractFindMethodDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractFindMethodDiagnostic.java index 624b71d56a0..99f454b8908 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractFindMethodDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractFindMethodDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -83,10 +83,10 @@ protected boolean checkMethodCall(BSLParser.MethodCallContext ctx) { */ protected String getMessage(BSLParserRuleContext ctx) { - if (ctx instanceof BSLParser.GlobalMethodCallContext) { - return info.getMessage(((BSLParser.GlobalMethodCallContext) ctx).methodName().getText()); - } else if (ctx instanceof BSLParser.MethodCallContext) { - return info.getMessage(((BSLParser.MethodCallContext) ctx).methodName().getText()); + if (ctx instanceof BSLParser.GlobalMethodCallContext globalMethodCallContext) { + return info.getMessage(globalMethodCallContext.methodName().getText()); + } else if (ctx instanceof BSLParser.MethodCallContext methodCallContext) { + return info.getMessage(methodCallContext.methodName().getText()); } else { return info.getMessage(); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractListenerDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractListenerDiagnostic.java index 03c853dcdee..2cfe9af1461 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractListenerDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractListenerDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractMetadataDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractMetadataDiagnostic.java index e1a429211a8..1e8eb6c4759 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractMetadataDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractMetadataDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -22,10 +22,10 @@ package com.github._1c_syntax.bsl.languageserver.diagnostics; import com.github._1c_syntax.bsl.languageserver.utils.Ranges; +import com.github._1c_syntax.bsl.mdo.MD; +import com.github._1c_syntax.bsl.mdo.ModuleOwner; import com.github._1c_syntax.bsl.types.MDOType; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBSL; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; import org.eclipse.lsp4j.Range; import java.util.ArrayList; @@ -103,24 +103,25 @@ protected void addDiagnostic(String message) { diagnosticStorage.addDiagnostic(diagnosticRange, message); } - protected abstract void checkMetadata(AbstractMDObjectBase mdo); + protected abstract void checkMetadata(MD mdo); private void checkMetadataWithModules() { documentContext.getMdObject() .filter(mdo -> filterMdoTypes.contains(mdo.getMdoType())) - .filter(AbstractMDObjectBSL.class::isInstance) + .filter(ModuleOwner.class::isInstance) + .map(ModuleOwner.class::cast) .filter(this::haveMatchingModule) .ifPresent(this::checkMetadata); } - private boolean haveMatchingModule(AbstractMDObjectBase mdo) { + private boolean haveMatchingModule(ModuleOwner mdo) { // чтобы не анализировать несколько раз и не выдавать одинаковые результаты для разных модулей, // выберем только один модуль, например модуль менеджера - if (documentContext.getModuleType() == ModuleType.ManagerModule){ + if (documentContext.getModuleType() == ModuleType.ManagerModule) { return true; } - return ((AbstractMDObjectBSL) mdo).getModules().stream() + return mdo.getModules().stream() .filter(mdoModule -> OBJECT_MODULES.contains(mdoModule.getModuleType())) .count() == 1; } @@ -135,8 +136,8 @@ private boolean haveMatchingModule(AbstractMDObjectBase mdo) { private void checkMetadataWithoutModules() { documentContext.getServerContext().getConfiguration().getChildren().stream() .filter(mdo -> filterMdoTypes.contains(mdo.getMdoType())) - .filter(mdo -> !(mdo instanceof AbstractMDObjectBSL) - || (((AbstractMDObjectBSL) mdo).getModules().stream() + .filter(mdo -> !(mdo instanceof ModuleOwner moduleOwner) + || (moduleOwner.getModules().stream() .noneMatch(module -> OBJECT_MODULES.contains(module.getModuleType())))) .forEach(this::checkMetadata); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractMultilingualStringDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractMultilingualStringDiagnostic.java index 0c60e0b4f00..bb982a47384 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractMultilingualStringDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractMultilingualStringDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -34,7 +34,7 @@ public abstract class AbstractMultilingualStringDiagnostic extends AbstractVisit @DiagnosticParameter( type = String.class, - defaultValue = "" + DECLARED_LANGUAGES_DEFAULT + defaultValue = DECLARED_LANGUAGES_DEFAULT ) private String declaredLanguages = DECLARED_LANGUAGES_DEFAULT; protected MultilingualStringAnalyser parser = new MultilingualStringAnalyser(DECLARED_LANGUAGES_DEFAULT); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSDBLListenerDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSDBLListenerDiagnostic.java index 1b52ec5aa73..1423b353211 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSDBLListenerDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSDBLListenerDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSDBLVisitorDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSDBLVisitorDiagnostic.java index a859272ac25..b08643bd1a2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSDBLVisitorDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSDBLVisitorDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSymbolTreeDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSymbolTreeDiagnostic.java index 4169c4bed49..4b838e20baf 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSymbolTreeDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSymbolTreeDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractVisitorDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractVisitorDiagnostic.java index 854c626738b..7e6c57f0d7e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractVisitorDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractVisitorDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AllFunctionPathMustHaveReturnDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AllFunctionPathMustHaveReturnDiagnostic.java index 550c3be7953..230e856b569 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AllFunctionPathMustHaveReturnDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AllFunctionPathMustHaveReturnDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -58,7 +58,6 @@ DiagnosticTag.BADPRACTICE, DiagnosticTag.SUSPICIOUS } - ) public class AllFunctionPathMustHaveReturnDiagnostic extends AbstractVisitorDiagnostic { @@ -114,7 +113,7 @@ private void checkAllPathsHaveReturns(BSLParser.FunctionContext ctx) { .map(graph::getEdgeSource) .map(vertex -> nonExplicitReturnNode(vertex, graph)) .flatMap(Optional::stream) - .collect(Collectors.toList()); + .toList(); if (incomingVertices.isEmpty()) { return; @@ -136,12 +135,12 @@ private void checkAllPathsHaveReturns(BSLParser.FunctionContext ctx) { } private Optional nonExplicitReturnNode(CfgVertex v, ControlFlowGraph graph) { - if (v instanceof BasicBlockVertex) { - return checkBasicBlockExitingNode((BasicBlockVertex) v); - } else if (v instanceof LoopVertex) { - return checkLoopExitingNode((LoopVertex) v); - } else if (v instanceof ConditionalVertex) { - return checkElseIfClauseExitingNode((ConditionalVertex) v, graph); + if (v instanceof BasicBlockVertex basicBlock) { + return checkBasicBlockExitingNode(basicBlock); + } else if (v instanceof LoopVertex loop) { + return checkLoopExitingNode(loop); + } else if (v instanceof ConditionalVertex conditional) { + return checkElseIfClauseExitingNode(conditional, graph); } return v.getAst(); @@ -158,14 +157,14 @@ private Optional checkElseIfClauseExitingNode(ConditionalV } var expression = v.getExpression(); - if (expression.getParent() instanceof BSLParser.ElsifBranchContext && !ignoreMissingElseOnExit) { - return Optional.of((BSLParser.ElsifBranchContext) expression.getParent()); + if (expression.getParent() instanceof BSLParser.ElsifBranchContext elsifBranch && !ignoreMissingElseOnExit) { + return Optional.of(elsifBranch.getParent()); } return Optional.empty(); } - private Optional checkBasicBlockExitingNode(BasicBlockVertex block) { + private static Optional checkBasicBlockExitingNode(BasicBlockVertex block) { if (!block.statements().isEmpty()) { var lastStatement = block.statements().get(block.statements().size() - 1); @@ -178,22 +177,19 @@ private Optional checkBasicBlockExitingNode(BasicBlockVert } private Optional checkLoopExitingNode(LoopVertex v) { - if (v instanceof WhileLoopVertex) { - var whileLoop = (WhileLoopVertex) v; - if (isEndlessLoop(whileLoop)) { - return Optional.empty(); - } + if (v instanceof WhileLoopVertex whileLoop && isEndlessLoop(whileLoop)) { + return Optional.empty(); } if (loopsExecutedAtLeastOnce) { - // из цикла в exit может придти только falseBranch или пустое тело цикла + // из цикла в exit может прийти только falseBranch или пустое тело цикла // и то и другое не нужно нам в рамках диагностики return Optional.empty(); } return v.getAst(); } - private boolean isEndlessLoop(WhileLoopVertex whileLoop) { + private static boolean isEndlessLoop(WhileLoopVertex whileLoop) { var expression = whileLoop.getExpression(); return expression.getChildCount() == 1 && expression.member(0).constValue() != null diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AssignAliasFieldsInQueryDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AssignAliasFieldsInQueryDiagnostic.java index 5c5cba9a51a..c2dd0841bb1 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AssignAliasFieldsInQueryDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AssignAliasFieldsInQueryDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BSLDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BSLDiagnostic.java index 8ba7530cfd7..1afdca40bb8 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BSLDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BSLDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic.java index 0a40ebb529a..2ddf0211188 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -26,10 +26,10 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.languageserver.utils.Ranges; import com.github._1c_syntax.utils.CaseInsensitivePattern; import java.util.Map; -import java.util.regex.Matcher; import java.util.regex.Pattern; @DiagnosticMetadata( @@ -44,6 +44,7 @@ public class BadWordsDiagnostic extends AbstractDiagnostic { private static final String BAD_WORDS_DEFAULT = ""; + private static final boolean FIND_IN_COMMENTS_DEFAULT = true; @DiagnosticParameter( type = String.class, @@ -51,10 +52,17 @@ public class BadWordsDiagnostic extends AbstractDiagnostic { ) private Pattern badWords = CaseInsensitivePattern.compile(BAD_WORDS_DEFAULT); - @Override + @DiagnosticParameter( + type = Boolean.class, + defaultValue = "" + FIND_IN_COMMENTS_DEFAULT + ) + private boolean findInComments = FIND_IN_COMMENTS_DEFAULT; + + @Override public void configure(Map configuration) { this.badWords = CaseInsensitivePattern.compile( (String) configuration.getOrDefault("badWords", BAD_WORDS_DEFAULT)); + this.findInComments = (boolean) configuration.getOrDefault("findInComments", FIND_IN_COMMENTS_DEFAULT); } @Override @@ -63,13 +71,39 @@ protected void check() { if (badWords.pattern().isBlank()) { return; } + var moduleLines = documentContext.getContentList(); + if (findInComments) { + checkAllLines(moduleLines); + return; + } + checkLinesWithoutComments(moduleLines); + } - String[] moduleLines = documentContext.getContentList(); - for (int i = 0; i < moduleLines.length; i++) { - Matcher matcher = badWords.matcher(moduleLines[i]); - while (matcher.find()) { - diagnosticStorage.addDiagnostic(i, matcher.start(), i, matcher.end()); - } + private void checkAllLines(String[] moduleLines) { + for (var i = 0; i < moduleLines.length; i++) { + checkLine(moduleLines, i); + } + } + + private void checkLinesWithoutComments(String[] moduleLines) { + final var nclocData = documentContext.getMetrics().getNclocData(); + for (int i : nclocData) { + final var moduleNumber = i - 1; // т.к. в токенах нумерация строк с 1, а в moduleLines с 0 + checkLine(moduleLines, moduleNumber); + } + } + + private void checkLine(String[] lines, int lineNumber) { + var moduleLine = lines[lineNumber]; + if (moduleLine.isEmpty()) { + return; + } + var matcher = badWords.matcher(moduleLine); + while (matcher.find()) { + diagnosticStorage.addDiagnostic( + Ranges.create(lineNumber, matcher.start(), lineNumber, matcher.end()), + info.getMessage(matcher.group()) + ); } } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BeginTransactionBeforeTryCatchDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BeginTransactionBeforeTryCatchDiagnostic.java index 65e103f4b06..76d45e5c962 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BeginTransactionBeforeTryCatchDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BeginTransactionBeforeTryCatchDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CachedPublicDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CachedPublicDiagnostic.java index efd49c36e72..5138e87791e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CachedPublicDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CachedPublicDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -28,9 +28,9 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; import com.github._1c_syntax.bsl.languageserver.utils.Keywords; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.mdo.support.ReturnValueReuse; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; import com.github._1c_syntax.utils.CaseInsensitivePattern; import java.util.regex.Pattern; @@ -68,18 +68,14 @@ protected void check() { .forEach(regionSymbol -> diagnosticStorage.addDiagnostic(regionSymbol.getRegionNameRange())); } - private boolean isCashed(DocumentContext documentContext) { + private static boolean isCashed(DocumentContext documentContext) { return documentContext.getMdObject() - .filter(MDCommonModule.class::isInstance) - .map(MDCommonModule.class::cast) - .map(MDCommonModule::getReturnValuesReuse) - .filter(this::isReuseValue) + .filter(CommonModule.class::isInstance) + .map(CommonModule.class::cast) + .map(CommonModule::getReturnValuesReuse) + .filter(value -> value == ReturnValueReuse.DURING_REQUEST + || value == ReturnValueReuse.DURING_SESSION) .isPresent(); } - private Boolean isReuseValue(ReturnValueReuse value) { - return value == ReturnValueReuse.DURING_REQUEST - || value == ReturnValueReuse.DURING_SESSION; - } - } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsDiagnostic.java index c82a69ec8a5..ba9a385fe97 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeAfterAsyncCallDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeAfterAsyncCallDiagnostic.java index 20a8e07f331..adb11f9885c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeAfterAsyncCallDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeAfterAsyncCallDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -36,7 +36,6 @@ import java.util.List; import java.util.Optional; import java.util.regex.Pattern; -import java.util.stream.Collectors; import static com.github._1c_syntax.bsl.parser.BSLParser.RULE_codeBlock; import static com.github._1c_syntax.bsl.parser.BSLParser.RULE_statement; @@ -56,7 +55,6 @@ ModuleType.FormModule, ModuleType.ManagedApplicationModule } - ) public class CodeAfterAsyncCallDiagnostic extends AbstractVisitorDiagnostic { private static final Pattern ASYNC_METHODS = CaseInsensitivePattern.compile( @@ -90,7 +88,7 @@ private static boolean checkNextBlocks(BSLParser.StatementContext statement) { final var statements = codeBlock.statement().stream() .filter(statementContext -> statementContext != statement && statementContext.getStart().getLine() > asyncLine) - .collect(Collectors.toList()); + .toList(); final var compoundCtx = statements.stream() .findFirst() .map(BSLParser.StatementContext::compoundStatement); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeBlockBeforeSubDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeBlockBeforeSubDiagnostic.java index adaffaa2247..14ac7bef009 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeBlockBeforeSubDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeBlockBeforeSubDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeOutOfRegionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeOutOfRegionDiagnostic.java index a55e3a4c228..6531354ce29 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeOutOfRegionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeOutOfRegionDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CognitiveComplexityDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CognitiveComplexityDiagnostic.java index 92734d20c93..f7d9bd1bfc9 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CognitiveComplexityDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CognitiveComplexityDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -46,7 +46,8 @@ minutesToFix = 15, tags = { DiagnosticTag.BRAINOVERLOAD - } + }, + extraMinForComplexity = 1 ) public class CognitiveComplexityDiagnostic extends AbstractVisitorDiagnostic { @@ -99,28 +100,6 @@ public ParseTree visitSub(BSLParser.SubContext ctx) { Integer methodComplexity = documentContext.getCognitiveComplexityData().getMethodsComplexity().get(methodSymbol); if (methodComplexity > complexityThreshold) { - - List relatedInformation = new ArrayList<>(); - - relatedInformation.add(RelatedInformation.create( - documentContext.getUri(), - methodSymbol.getSubNameRange(), - info.getMessage(methodSymbol.getName(), methodComplexity, complexityThreshold) - )); - - List secondaryLocations = - documentContext.getCognitiveComplexityData().getMethodsComplexitySecondaryLocations().get(methodSymbol); - - secondaryLocations.stream() - .map((ComplexitySecondaryLocation secondaryLocation) -> - RelatedInformation.create( - documentContext.getUri(), - secondaryLocation.getRange(), - secondaryLocation.getMessage() - ) - ) - .collect(Collectors.toCollection(() -> relatedInformation)); - diagnosticStorage.addDiagnostic( methodSymbol.getSubNameRange(), info.getMessage(methodSymbol.getName(), methodComplexity, complexityThreshold), diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommandModuleExportMethodsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommandModuleExportMethodsDiagnostic.java index 1f4a22c53bc..6f59bb13fd9 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommandModuleExportMethodsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommandModuleExportMethodsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommentedCodeDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommentedCodeDiagnostic.java index 98bc1581d9e..b3cb9999794 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommentedCodeDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommentedCodeDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -87,7 +87,7 @@ public void configure(Map configuration) { threshold = ((Number) configuration.getOrDefault("threshold", threshold)).floatValue(); codeRecognizer = new CodeRecognizer(threshold, new BSLFootprint()); - String excludePrefixesString = (String) configuration.getOrDefault("exclusionPrefixes", ""); + var excludePrefixesString = (String) configuration.getOrDefault("exclusionPrefixes", ""); exclusionPrefixes = Arrays.stream(excludePrefixesString.split(",")) .map(String::trim) .filter(s -> !s.isEmpty()) @@ -138,11 +138,9 @@ private static List initNewGroup(Token comment) { } private boolean isAdjacent(Token comment, List currentGroup) { - - Token last = currentGroup.get(currentGroup.size() - 1); + var last = currentGroup.get(currentGroup.size() - 1); return last.getLine() + 1 == comment.getLine() && onlyEmptyDelimiters(last.getTokenIndex(), comment.getTokenIndex()); - } private boolean onlyEmptyDelimiters(int firstTokenIndex, int lastTokenIndex) { @@ -165,17 +163,17 @@ private boolean isCommentGroupNotMethodDescription(List commentGroup) { return true; } - final Token first = commentGroup.get(0); - final Token last = commentGroup.get(commentGroup.size() - 1); + final var first = commentGroup.get(0); + final var last = commentGroup.get(commentGroup.size() - 1); return methodDescriptions.stream().noneMatch(methodDescription -> methodDescription.contains(first, last)); } private void checkCommentGroup(List commentGroup) { - Token firstComment = commentGroup.get(0); - Token lastComment = commentGroup.get(commentGroup.size() - 1); + var firstComment = commentGroup.get(0); + var lastComment = commentGroup.get(commentGroup.size() - 1); - for (Token comment : commentGroup) { + for (var comment : commentGroup) { if (isTextParsedAsCode(comment.getText())) { diagnosticStorage.addDiagnostic(firstComment, lastComment); return; @@ -184,9 +182,9 @@ private void checkCommentGroup(List commentGroup) { } private boolean isTextParsedAsCode(String text) { - String uncommented = uncomment(text); + var uncommented = uncomment(text); - for (String prefix : exclusionPrefixes) { + for (var prefix : exclusionPrefixes) { if (uncommented.startsWith(prefix)) { return false; } @@ -195,16 +193,16 @@ private boolean isTextParsedAsCode(String text) { return false; } - BSLTokenizer tokenizer = new BSLTokenizer(uncommented); - final List tokens = tokenizer.getTokens(); + var tokenizer = new BSLTokenizer(uncommented); + final var tokens = tokenizer.getTokens(); // Если меньше двух токенов нет смысла анализировать - это код if (tokens.size() >= MINIMAL_TOKEN_COUNT) { - List tokenTypes = tokens.stream() + var tokenTypes = tokens.stream() .map(Token::getType) .filter(t -> t != BSLParser.WHITE_SPACE) - .collect(Collectors.toList()); + .toList(); // Если два идентификатора идут подряд - это не код for (int i = 0; i < tokenTypes.size() - 1; i++) { @@ -229,10 +227,10 @@ public List getQuickFixes( List diagnostics, CodeActionParams params, DocumentContext documentContext ) { - List textEdits = diagnostics.stream() + var textEdits = diagnostics.stream() .map(Diagnostic::getRange) .map(range -> new TextEdit(range, "")) - .collect(Collectors.toList()); + .toList(); return CodeActionProvider.createCodeActions( textEdits, diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommitTransactionOutsideTryCatchDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommitTransactionOutsideTryCatchDiagnostic.java index 332dbb50f79..801a91e70de 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommitTransactionOutsideTryCatchDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommitTransactionOutsideTryCatchDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleAssignDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleAssignDiagnostic.java index 050e29ec191..95b6e454c1a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleAssignDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleAssignDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -26,9 +26,7 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; import com.github._1c_syntax.bsl.parser.BSLParser; -import com.github._1c_syntax.mdclasses.Configuration; import org.antlr.v4.runtime.tree.ParseTree; -import org.antlr.v4.runtime.tree.TerminalNode; @DiagnosticMetadata( type = DiagnosticType.ERROR, @@ -43,15 +41,14 @@ public class CommonModuleAssignDiagnostic extends AbstractVisitorDiagnostic { @Override public ParseTree visitLValue(BSLParser.LValueContext ctx) { - TerminalNode identifier = ctx.IDENTIFIER(); + var identifier = ctx.IDENTIFIER(); - if (identifier == null - || ctx.acceptor() != null) { + if (identifier == null || ctx.acceptor() != null) { return ctx; } - Configuration configuration = documentContext.getServerContext().getConfiguration(); - if (configuration.getCommonModule(identifier.getText()).isPresent()) { + var configuration = documentContext.getServerContext().getConfiguration(); + if (configuration.findCommonModule(identifier.getText()).isPresent()) { diagnosticStorage.addDiagnostic(identifier, info.getMessage(identifier.getText())); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleInvalidTypeDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleInvalidTypeDiagnostic.java index 48d16860240..934772c6e1c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleInvalidTypeDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleInvalidTypeDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -27,8 +27,8 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; import java.util.regex.Matcher; @@ -45,9 +45,7 @@ DiagnosticTag.UNPREDICTABLE, DiagnosticTag.DESIGN } - ) - public class CommonModuleInvalidTypeDiagnostic extends AbstractCommonModuleNameDiagnostic { public CommonModuleInvalidTypeDiagnostic(LanguageServerConfiguration serverConfiguration) { @@ -55,7 +53,7 @@ public CommonModuleInvalidTypeDiagnostic(LanguageServerConfiguration serverConfi } @Override - protected boolean flagsCheck(MDCommonModule commonModule) { + protected boolean flagsCheck(CommonModule commonModule) { return !isServer(commonModule) && !isServerCall(commonModule) diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleMissingAPIDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleMissingAPIDiagnostic.java index 0de2c03091e..cbeb0010087 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleMissingAPIDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleMissingAPIDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameCachedDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameCachedDiagnostic.java index 07ee6bb7d53..102086f27d0 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameCachedDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameCachedDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -27,9 +27,9 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.mdo.support.ReturnValueReuse; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; @DiagnosticMetadata( type = DiagnosticType.CODE_SMELL, @@ -47,7 +47,6 @@ ) public class CommonModuleNameCachedDiagnostic extends AbstractCommonModuleNameDiagnostic { - private static final String REGEXP = "повторноеиспользование|повтисп|cached"; public CommonModuleNameCachedDiagnostic(LanguageServerConfiguration serverConfiguration) { @@ -55,9 +54,8 @@ public CommonModuleNameCachedDiagnostic(LanguageServerConfiguration serverConfig } @Override - protected boolean flagsCheck(MDCommonModule commonModule) { + protected boolean flagsCheck(CommonModule commonModule) { return commonModule.getReturnValuesReuse() == ReturnValueReuse.DURING_REQUEST || commonModule.getReturnValuesReuse() == ReturnValueReuse.DURING_SESSION; } - } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientDiagnostic.java index 2349de3a0e1..6e39db28b54 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -27,8 +27,8 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; @DiagnosticMetadata( type = DiagnosticType.CODE_SMELL, @@ -53,10 +53,8 @@ public CommonModuleNameClientDiagnostic(LanguageServerConfiguration serverConfig } @Override - protected boolean flagsCheck(MDCommonModule commonModule) { + protected boolean flagsCheck(CommonModule commonModule) { return !commonModule.isGlobal() && isClient(commonModule); } - - } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientServerDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientServerDiagnostic.java index 9e49412059a..f2c7fe62a45 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientServerDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientServerDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -27,8 +27,8 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; @DiagnosticMetadata( type = DiagnosticType.CODE_SMELL, @@ -53,7 +53,7 @@ public CommonModuleNameClientServerDiagnostic(LanguageServerConfiguration server } @Override - protected boolean flagsCheck(MDCommonModule commonModule) { + protected boolean flagsCheck(CommonModule commonModule) { return isClientServer(commonModule); } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameFullAccessDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameFullAccessDiagnostic.java index b88d86ec27e..613a2aa0fb8 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameFullAccessDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameFullAccessDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -27,8 +27,8 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; @DiagnosticMetadata( type = DiagnosticType.SECURITY_HOTSPOT, @@ -53,7 +53,7 @@ public CommonModuleNameFullAccessDiagnostic(LanguageServerConfiguration serverCo } @Override - protected boolean flagsCheck(MDCommonModule commonModule) { + protected boolean flagsCheck(CommonModule commonModule) { return commonModule.isPrivileged(); } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalClientDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalClientDiagnostic.java index ed7b5b1fe98..eeaaf0f84a5 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalClientDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalClientDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -27,8 +27,8 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; @DiagnosticMetadata( type = DiagnosticType.CODE_SMELL, @@ -51,7 +51,7 @@ public CommonModuleNameGlobalClientDiagnostic(LanguageServerConfiguration server } @Override - protected boolean flagsCheck(MDCommonModule commonModule) { + protected boolean flagsCheck(CommonModule commonModule) { return commonModule.isGlobal() && isClient(commonModule); } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalDiagnostic.java index 8f6609550a0..7f92a0df203 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -27,8 +27,8 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; @DiagnosticMetadata( type = DiagnosticType.CODE_SMELL, @@ -53,7 +53,7 @@ public CommonModuleNameGlobalDiagnostic(LanguageServerConfiguration serverConfig } @Override - protected boolean flagsCheck(MDCommonModule commonModule) { + protected boolean flagsCheck(CommonModule commonModule) { return commonModule.isGlobal(); } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameServerCallDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameServerCallDiagnostic.java index 7468c937aec..b10e6f45d4c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameServerCallDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameServerCallDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -27,8 +27,8 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; @DiagnosticMetadata( type = DiagnosticType.CODE_SMELL, @@ -53,7 +53,7 @@ public CommonModuleNameServerCallDiagnostic(LanguageServerConfiguration serverCo } @Override - protected boolean flagsCheck(MDCommonModule commonModule) { + protected boolean flagsCheck(CommonModule commonModule) { return isServerCall(commonModule); } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameWordsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameWordsDiagnostic.java index ecbd20b0e92..0a670fcfba7 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameWordsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameWordsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -28,8 +28,8 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; import com.github._1c_syntax.utils.CaseInsensitivePattern; import java.util.Map; @@ -73,7 +73,7 @@ public void configure(Map configuration) { } @Override - protected boolean flagsCheck(MDCommonModule commonModule) { + protected boolean flagsCheck(CommonModule commonModule) { return true; } @@ -81,6 +81,4 @@ protected boolean flagsCheck(MDCommonModule commonModule) { protected boolean matchCheck(Matcher matcher) { return matcher.find(); } - } - diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveLostDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveLostDiagnostic.java index fa4ce7d8369..2cd0fde4c4d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveLostDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveLostDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -26,10 +26,10 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.Form; import com.github._1c_syntax.bsl.mdo.support.FormType; import com.github._1c_syntax.bsl.parser.BSLParser; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDOForm; import org.antlr.v4.runtime.tree.ParseTree; @DiagnosticMetadata( @@ -53,11 +53,8 @@ public class CompilationDirectiveLostDiagnostic extends AbstractVisitorDiagnosti public ParseTree visitFile(BSLParser.FileContext ctx) { if (documentContext.getModuleType() == ModuleType.FormModule) { var mdo = documentContext.getMdObject(); - if (mdo.isPresent() && mdo.get() instanceof AbstractMDOForm) { - var form = (AbstractMDOForm) mdo.get(); - if (form.getFormType() != FormType.MANAGED) { - return ctx; - } + if (mdo.isPresent() && mdo.get() instanceof Form form && form.getFormType() != FormType.MANAGED) { + return ctx; } } return super.visitFile(ctx); @@ -65,22 +62,17 @@ public ParseTree visitFile(BSLParser.FileContext ctx) { @Override public ParseTree visitProcDeclaration(BSLParser.ProcDeclarationContext ctx) { - if (ctx.compilerDirective().isEmpty()) { diagnosticStorage.addDiagnostic(ctx.subName(), info.getMessage(ctx.subName().getText())); } - return ctx; } @Override public ParseTree visitFuncDeclaration(BSLParser.FuncDeclarationContext ctx) { - if (ctx.compilerDirective().isEmpty()) { diagnosticStorage.addDiagnostic(ctx.subName(), info.getMessage(ctx.subName().getText())); } - return ctx; } } - diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveNeedLessDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveNeedLessDiagnostic.java index c916085d8ab..c5d2c450af8 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveNeedLessDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveNeedLessDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ConsecutiveEmptyLinesDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ConsecutiveEmptyLinesDiagnostic.java index e43981931ab..89a7abe0d8d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ConsecutiveEmptyLinesDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ConsecutiveEmptyLinesDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CrazyMultilineStringDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CrazyMultilineStringDiagnostic.java index 5054e52a2d3..e539085f2e5 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CrazyMultilineStringDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CrazyMultilineStringDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CreateQueryInCycleDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CreateQueryInCycleDiagnostic.java index 76ed4af40fb..cc307657ca0 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CreateQueryInCycleDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CreateQueryInCycleDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -31,6 +31,7 @@ import com.github._1c_syntax.bsl.parser.BSLParserRuleContext; import com.github._1c_syntax.utils.CaseInsensitivePattern; import edu.umd.cs.findbugs.annotations.Nullable; +import lombok.Getter; import lombok.ToString; import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.RuleContext; @@ -119,10 +120,9 @@ private static String getVariableNameFromCallStatementContext(BSLParser.CallStat private static String getVariableNameFromModifierContext(BSLParser.ModifierContext modifier) { ParserRuleContext parent = modifier.getParent(); - if (parent instanceof BSLParser.ComplexIdentifierContext) { - return getComplexPathName(((BSLParser.ComplexIdentifierContext) parent), modifier); - } else if (parent instanceof BSLParser.CallStatementContext) { - BSLParser.CallStatementContext parentCall = (BSLParser.CallStatementContext) parent; + if (parent instanceof BSLParser.ComplexIdentifierContext complexIdentifierContext) { + return getComplexPathName(complexIdentifierContext, modifier); + } else if (parent instanceof BSLParser.CallStatementContext parentCall) { return parentCall.modifier().stream() .takeWhile(e -> !e.equals(modifier)) @@ -235,11 +235,10 @@ public ParseTree visitAccessCall(BSLParser.AccessCallContext ctx) { String variableName = null; BSLParserRuleContext errorContext = null; BSLParserRuleContext parent = ctx.getParent(); - if (parent instanceof BSLParser.CallStatementContext) { + if (parent instanceof BSLParser.CallStatementContext callStatementContext) { errorContext = parent; - variableName = getVariableNameFromCallStatementContext((BSLParser.CallStatementContext) parent); - } else if (parent instanceof BSLParser.ModifierContext) { - BSLParser.ModifierContext callModifier = (BSLParser.ModifierContext) parent; + variableName = getVariableNameFromCallStatementContext(callStatementContext); + } else if (parent instanceof BSLParser.ModifierContext callModifier) { errorContext = callModifier.getParent(); variableName = getVariableNameFromModifierContext(callModifier); } @@ -320,6 +319,7 @@ public void addDeclaration(ParseTree firstDeclaration) { } private static class Scope { + @Getter private final String name; private final HashMap variables = new HashMap<>(); @@ -341,10 +341,6 @@ public void addVariable(VariableDefinition variableDefinition, boolean typesMerg return key; }); } - - public String getName() { - return name; - } } private static class VariableScope extends ArrayDeque { diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CyclomaticComplexityDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CyclomaticComplexityDiagnostic.java index 094bad96e11..569d96ddbb9 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CyclomaticComplexityDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CyclomaticComplexityDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -46,7 +46,8 @@ minutesToFix = 25, tags = { DiagnosticTag.BRAINOVERLOAD - } + }, + extraMinForComplexity = 1 ) public class CyclomaticComplexityDiagnostic extends AbstractVisitorDiagnostic { private static final int COMPLEXITY_THRESHOLD = 20; diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DataExchangeLoadingDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DataExchangeLoadingDiagnostic.java index 3baa3fdefa0..072430f357c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DataExchangeLoadingDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DataExchangeLoadingDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeletingCollectionItemDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeletingCollectionItemDiagnostic.java index 64ecc6a47cb..eeba497567f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeletingCollectionItemDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeletingCollectionItemDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DenyIncompleteValuesDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DenyIncompleteValuesDiagnostic.java index 896bc6fb8f9..e7a16a2dba2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DenyIncompleteValuesDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DenyIncompleteValuesDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -27,14 +27,12 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; import com.github._1c_syntax.bsl.languageserver.utils.MdoRefBuilder; +import com.github._1c_syntax.bsl.mdo.MD; +import com.github._1c_syntax.bsl.mdo.Register; +import com.github._1c_syntax.bsl.mdo.children.Dimension; import com.github._1c_syntax.bsl.types.MDOType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectComplex; -import com.github._1c_syntax.mdclasses.mdo.attributes.Dimension; -import org.jetbrains.annotations.NotNull; import java.util.List; -import java.util.stream.Stream; @DiagnosticMetadata( activatedByDefault = false, @@ -44,7 +42,8 @@ tags = { DiagnosticTag.BADPRACTICE }, - scope = DiagnosticScope.BSL + scope = DiagnosticScope.BSL, + canLocateOnProject = true ) public class DenyIncompleteValuesDiagnostic extends AbstractMetadataDiagnostic { @@ -54,23 +53,18 @@ public DenyIncompleteValuesDiagnostic() { MDOType.ACCUMULATION_REGISTER, MDOType.ACCOUNTING_REGISTER, MDOType.CALCULATION_REGISTER - )); + )); } @Override - protected void checkMetadata(AbstractMDObjectBase mdo) { - getWrongDimensions((AbstractMDObjectComplex) mdo) - .forEach((Dimension dimension) -> { - var ownerMDOName = MdoRefBuilder.getLocaleOwnerMdoName(documentContext, mdo); - addDiagnostic(info.getMessage(dimension.getName(), ownerMDOName)); - }); - } - - @NotNull - private static Stream getWrongDimensions(AbstractMDObjectComplex mdo) { - return mdo.getChildren().stream() - .filter(Dimension.class::isInstance) - .map(Dimension.class::cast) - .filter(dimension -> !dimension.isDenyIncompleteValues()); + protected void checkMetadata(MD mdo) { + if (mdo instanceof Register register) { + register.getDimensions().stream() + .filter(dimension -> !dimension.isDenyIncompleteValues()) + .forEach((Dimension dimension) -> { + var ownerMDOName = MdoRefBuilder.getLocaleOwnerMdoName(documentContext, mdo); + addDiagnostic(info.getMessage(dimension.getName(), ownerMDOName)); + }); + } } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedAttributes8312Diagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedAttributes8312Diagnostic.java index a53ff889f00..1df38e8628a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedAttributes8312Diagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedAttributes8312Diagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedCurrentDateDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedCurrentDateDiagnostic.java index 4453696ba64..24ecaf6a095 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedCurrentDateDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedCurrentDateDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedFindDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedFindDiagnostic.java index c6f2816ccab..96a664ff493 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedFindDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedFindDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMessageDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMessageDiagnostic.java index 9e2b0251156..144a7b94b7f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMessageDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMessageDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnostic.java index a2956c86e7e..e43afa828cf 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8310Diagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8310Diagnostic.java index c9037a66a34..f885bf66202 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8310Diagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8310Diagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8317Diagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8317Diagnostic.java index 60adc5d849e..e74cc92c8d7 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8317Diagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8317Diagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedTypeManagedFormDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedTypeManagedFormDiagnostic.java index 1489fc62fac..7cb9f486574 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedTypeManagedFormDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedTypeManagedFormDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticStorage.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticStorage.java index d45b7fd9878..34f7f982e84 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticStorage.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticStorage.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -209,10 +209,10 @@ public void addDiagnostic( } public void addDiagnostic(ParseTree tree) { - if (tree instanceof BSLParserRuleContext) { - addDiagnostic((BSLParserRuleContext) tree); - } else if (tree instanceof TerminalNode) { - addDiagnostic((TerminalNode) tree); + if (tree instanceof BSLParserRuleContext parserRuleContext) { + addDiagnostic(parserRuleContext); + } else if (tree instanceof TerminalNode terminalNode) { + addDiagnostic(terminalNode); } else { throw new IllegalArgumentException("Unsupported parameter type " + tree); } @@ -253,5 +253,4 @@ private static Diagnostic createDiagnostic( } return diagnostic; } - } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DisableSafeModeDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DisableSafeModeDiagnostic.java new file mode 100644 index 00000000000..fb77b6ee573 --- /dev/null +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DisableSafeModeDiagnostic.java @@ -0,0 +1,83 @@ +/* + * This file is a part of BSL Language Server. + * + * Copyright (c) 2018-2024 + * Alexey Sosnoviy , Nikita Fedkin and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * BSL Language Server is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * BSL Language Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with BSL Language Server. + */ +package com.github._1c_syntax.bsl.languageserver.diagnostics; + +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticMetadata; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticScope; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.parser.BSLParser; +import com.github._1c_syntax.utils.CaseInsensitivePattern; + +import java.util.Optional; +import java.util.regex.Pattern; + +@DiagnosticMetadata( + type = DiagnosticType.VULNERABILITY, + severity = DiagnosticSeverity.MAJOR, + minutesToFix = 15, + tags = { + DiagnosticTag.SUSPICIOUS + }, + scope = DiagnosticScope.BSL +) +public class DisableSafeModeDiagnostic extends AbstractFindMethodDiagnostic { + private static final Pattern methodPattern = CaseInsensitivePattern.compile( + "УстановитьБезопасныйРежим|SetSafeMode|УстановитьОтключениеБезопасногоРежима|SetSafeModeDisabled"); + private static final Pattern safeModePattern = CaseInsensitivePattern.compile( + "УстановитьБезопасныйРежим|SetSafeMode"); + + public DisableSafeModeDiagnostic() { + super(methodPattern); + } + + @Override + protected boolean checkGlobalMethodCall(BSLParser.GlobalMethodCallContext ctx) { + final var result = super.checkGlobalMethodCall(ctx); + if (!result) { + return false; + } + final int enabledValue; + if(safeModePattern.matcher(ctx.methodName().getText()).matches()){ + enabledValue = BSLParser.TRUE; + } else { + enabledValue = BSLParser.FALSE; + } + return !enabledCall(ctx, enabledValue); + } + + private static boolean enabledCall(BSLParser.GlobalMethodCallContext ctx, int enabledValue) { + return Optional.of(ctx) + .map(BSLParser.GlobalMethodCallContext::doCall) + .map(BSLParser.DoCallContext::callParamList) + .map(BSLParser.CallParamListContext::callParam) + .filter(callParamContexts -> callParamContexts.size() == 1) + .map(callParamContexts -> callParamContexts.get(0)) + .map(BSLParser.CallParamContext::expression) + .map(BSLParser.ExpressionContext::member) + .map(memberContexts -> memberContexts.get(0)) + .map(BSLParser.MemberContext::constValue) + .filter(constValueContext -> constValueContext.getToken(enabledValue, 0) != null) + .isPresent(); + } +} diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateRegionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateRegionDiagnostic.java index 89e89d223c0..8e8823f358a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateRegionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateRegionDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateStringLiteralDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateStringLiteralDiagnostic.java index 34c52920d73..2469ea938fe 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateStringLiteralDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateStringLiteralDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicatedInsertionIntoCollectionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicatedInsertionIntoCollectionDiagnostic.java index 12f37bfcc85..16d08ab5a41 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicatedInsertionIntoCollectionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicatedInsertionIntoCollectionDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -60,10 +60,10 @@ DiagnosticTag.SUSPICIOUS, DiagnosticTag.BADPRACTICE } - ) public class DuplicatedInsertionIntoCollectionDiagnostic extends AbstractVisitorDiagnostic { - private static final Pattern INSERT_ADD_METHOD_PATTERN = CaseInsensitivePattern.compile("вставить|добавить|insert|add"); + private static final Pattern INSERT_ADD_METHOD_PATTERN = + CaseInsensitivePattern.compile("вставить|добавить|insert|add"); private static final Pattern INSERT_METHOD_PATTERN = CaseInsensitivePattern.compile("вставить|insert"); private static final Pattern IGNORED_BSL_VALUES_PATTERN = CaseInsensitivePattern.compile( "неопределено|undefined|0|символы\\.[\\wа-яё]+|chars\\.[\\wа-яё]+"); @@ -106,7 +106,7 @@ private static class GroupingData { public void configure(Map configuration) { super.configure(configuration); - if (!isAllowedMethodADD){ + if (!isAllowedMethodADD) { methodPattern = INSERT_METHOD_PATTERN; } } @@ -114,7 +114,7 @@ public void configure(Map configuration) { @Override public ParseTree visitCodeBlock(BSLParser.CodeBlockContext codeBlock) { this.codeBlock = codeBlock; - final List possibleDuplicateStatements = getPossibleDuplicates(); + final var possibleDuplicateStatements = getPossibleDuplicates(); if (!possibleDuplicateStatements.isEmpty()) { blockRange = Ranges.create(codeBlock); @@ -135,11 +135,11 @@ private List getPossibleDuplicates() { .collect(Collectors.toList()); } - private @Nullable - GroupingData groupingCalls(BSLParser.CallStatementContext callStatement, BSLParser.AccessCallContext accessCallContext) { + private @Nullable GroupingData groupingCalls(BSLParser.CallStatementContext callStatement, + BSLParser.AccessCallContext accessCallContext) { final var methodCallContext = accessCallContext.methodCall(); final var callParams = methodCallContext.doCall().callParamList().callParam(); - final CallParamContext firstParamContext = callParams.get(0); + final var firstParamContext = callParams.get(0); if (firstParamContext.getChildCount() == 0) { return null; } @@ -153,7 +153,7 @@ GroupingData groupingCalls(BSLParser.CallStatementContext callStatement, BSLPars } final TerminalNode identifierContext; final String parens; - if (callStatement.IDENTIFIER() != null){ + if (callStatement.IDENTIFIER() != null) { identifierContext = callStatement.IDENTIFIER(); parens = ""; } else { @@ -204,7 +204,6 @@ private Stream> explorePossibleDuplicateStatements(List excludeValidChanges(List duplicates) { - var result = new ArrayList(); for (var i = 0; i < duplicates.size(); i++) { if (!excludeValidElements(duplicates, i, result)) { @@ -257,8 +256,8 @@ private boolean usedIdentifiers(String expression, GroupingData groupingData) { } return getAllInnerIdentifiersWithDot(groupingData.firstParamContext).stream() .anyMatch(identifierWithDot -> - startWithIgnoreCase(identifierWithDot, expressionWithDot) - || startWithIgnoreCase(expressionWithDot, identifierWithDot) + startWithIgnoreCase(identifierWithDot, expressionWithDot) + || startWithIgnoreCase(expressionWithDot, identifierWithDot) ); } @@ -352,7 +351,7 @@ private List getAllInnerIdentifiersWithDot(CallParamContext param) { final var identifiers = Trees.findAllRuleNodes(param, BSLParser.RULE_complexIdentifier).stream() .map(BSLParser.ComplexIdentifierContext.class::cast) .filter(complexIdentifierContext -> complexIdentifierContext.IDENTIFIER() != null) - .collect(Collectors.toList()); + .toList(); final var reducedIdentifiers = new ArrayList(); for (BSLParser.ComplexIdentifierContext identifier : identifiers) { final List modifiers = identifier.modifier(); @@ -361,9 +360,9 @@ private List getAllInnerIdentifiersWithDot(CallParamContext param) { reducedIdentifiers.add(fullIdentifier); var reducedIdentifier = firstIdentifier; - for (BSLParser.ModifierContext modifier : modifiers) { - var modfifier = modifier.getText(); - reducedIdentifier = reducedIdentifier.concat(".").concat(modfifier); + for (var modifier : modifiers) { + var text = modifier.getText(); + reducedIdentifier = reducedIdentifier.concat(".").concat(text); reducedIdentifiers.add(reducedIdentifier); } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyCodeBlockDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyCodeBlockDiagnostic.java index 53accb94018..a677faf1f75 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyCodeBlockDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyCodeBlockDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -32,10 +32,7 @@ import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.tree.ParseTree; import org.antlr.v4.runtime.tree.TerminalNode; -import org.antlr.v4.runtime.tree.Tree; -import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; @DiagnosticMetadata( @@ -84,10 +81,10 @@ public ParseTree visitCodeBlock(BSLParser.CodeBlockContext ctx) { int lineOfStop = ctx.getStop().getLine(); - List list = Trees.getChildren(ctx.getParent()).stream() + var list = Trees.getChildren(ctx.getParent()).stream() .filter(TerminalNode.class::isInstance) .filter(node -> ((TerminalNode) node).getSymbol().getLine() == lineOfStop) - .collect(Collectors.toList()); + .toList(); if (!list.isEmpty()) { TerminalNode first = (TerminalNode) list.get(0); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyRegionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyRegionDiagnostic.java index 2fff5bf7c9d..78e2467a22b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyRegionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyRegionDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyStatementDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyStatementDiagnostic.java index de74e91b652..bab137ee836 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyStatementDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyStatementDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExcessiveAutoTestCheckDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExcessiveAutoTestCheckDiagnostic.java index 58fddb1b00e..bf272609fc5 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExcessiveAutoTestCheckDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExcessiveAutoTestCheckDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeDiagnostic.java index 39cb27ba695..bd693d1de93 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeInCommonModuleDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeInCommonModuleDiagnostic.java index 0573e40d9fb..56a48a279b6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeInCommonModuleDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeInCommonModuleDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -26,9 +26,9 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.parser.BSLParser; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; import org.antlr.v4.runtime.tree.ParseTree; @DiagnosticMetadata( @@ -50,8 +50,8 @@ public class ExecuteExternalCodeInCommonModuleDiagnostic extends AbstractExecute public ParseTree visitFile(BSLParser.FileContext ctx) { // если модуль не серверный, не внешнее соединение и не обычный клиент, то не проверяем if (documentContext.getMdObject() - .filter(MDCommonModule.class::isInstance) - .map(MDCommonModule.class::cast) + .filter(CommonModule.class::isInstance) + .map(CommonModule.class::cast) .filter(commonModule -> commonModule.isServer() || commonModule.isClientOrdinaryApplication() || commonModule.isExternalConnection()) diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExportVariablesDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExportVariablesDiagnostic.java index 7325bc1ac26..eff3f55deb1 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExportVariablesDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExportVariablesDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExternalAppStartingDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExternalAppStartingDiagnostic.java new file mode 100644 index 00000000000..94e4cdbb2c9 --- /dev/null +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExternalAppStartingDiagnostic.java @@ -0,0 +1,80 @@ +/* + * This file is a part of BSL Language Server. + * + * Copyright (c) 2018-2024 + * Alexey Sosnoviy , Nikita Fedkin and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * BSL Language Server is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * BSL Language Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with BSL Language Server. + */ +package com.github._1c_syntax.bsl.languageserver.diagnostics; + +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticMetadata; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticParameter; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticScope; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.utils.CaseInsensitivePattern; + +import java.util.Map; +import java.util.regex.Pattern; + +@DiagnosticMetadata( + type = DiagnosticType.VULNERABILITY, + severity = DiagnosticSeverity.MAJOR, + minutesToFix = 5, + tags = { + DiagnosticTag.SUSPICIOUS + }, + scope = DiagnosticScope.BSL + +) +public class ExternalAppStartingDiagnostic extends AbstractFindMethodDiagnostic { + private static final String DEFAULT_PATTERN_STRING = + "КомандаСистемы|System|ЗапуститьСистему|RunSystem|ЗапуститьПриложение|RunApp" + + "|НачатьЗапускПриложения|BeginRunningApplication" + + "|ЗапуститьПриложениеАсинх|RunAppAsync|ЗапуститьПрограмму|ОткрытьПроводник|ОткрытьФайл"; + private static final String PATTERN_STRING_FOR_NAVI = + "|ПерейтиПоНавигационнойСсылке|GotoURL|ОткрытьНавигационнуюСсылку"; + private static final Pattern DEFAULT_PATTERN = CaseInsensitivePattern.compile(DEFAULT_PATTERN_STRING); + private static final boolean CHECK_GOTO_URL = false; + + @DiagnosticParameter( + type = Boolean.class, + defaultValue = "" + CHECK_GOTO_URL + ) + private boolean checkGotoUrl = CHECK_GOTO_URL; + + @DiagnosticParameter( + type = String.class, + defaultValue = DEFAULT_PATTERN_STRING + ) + private String userPatternString = DEFAULT_PATTERN_STRING; + + public ExternalAppStartingDiagnostic() { + super(DEFAULT_PATTERN); + } + + @Override + public void configure(Map configuration) { + super.configure(configuration); + var pattern = userPatternString; + if (checkGotoUrl){ + pattern += PATTERN_STRING_FOR_NAVI; + } + setMethodPattern(CaseInsensitivePattern.compile(pattern)); + } +} diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExtraCommasDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExtraCommasDiagnostic.java index 4e917a8d1ff..97d3160bd8b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExtraCommasDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExtraCommasDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FieldsFromJoinsWithoutIsNullDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FieldsFromJoinsWithoutIsNullDiagnostic.java index 552a62c9452..f7634bdc669 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FieldsFromJoinsWithoutIsNullDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FieldsFromJoinsWithoutIsNullDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FileSystemAccessDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FileSystemAccessDiagnostic.java new file mode 100644 index 00000000000..a7c6a933b47 --- /dev/null +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FileSystemAccessDiagnostic.java @@ -0,0 +1,121 @@ +/* + * This file is a part of BSL Language Server. + * + * Copyright (c) 2018-2024 + * Alexey Sosnoviy , Nikita Fedkin and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * BSL Language Server is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * BSL Language Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with BSL Language Server. + */ +package com.github._1c_syntax.bsl.languageserver.diagnostics; + +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticMetadata; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticParameter; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticScope; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.languageserver.utils.bsl.Constructors; +import com.github._1c_syntax.bsl.parser.BSLParser; +import com.github._1c_syntax.utils.CaseInsensitivePattern; +import org.antlr.v4.runtime.tree.ParseTree; + +import java.util.Map; +import java.util.regex.Pattern; + +@DiagnosticMetadata( + type = DiagnosticType.VULNERABILITY, + severity = DiagnosticSeverity.MAJOR, + minutesToFix = 3, + tags = { + DiagnosticTag.SUSPICIOUS + }, + scope = DiagnosticScope.BSL, + activatedByDefault = false +) +public class FileSystemAccessDiagnostic extends AbstractFindMethodDiagnostic { + public static final String NEW_EXPRESSION = "File|Файл|xBase|HTMLWriter|ЗаписьHTML|HTMLReader|ЧтениеHTML" + + "|FastInfosetReader|ЧтениеFastInfoset|FastInfosetWriter|ЗаписьFastInfoset|XSLTransform|ПреобразованиеXSL" + + "|ZipFileWriter|ЗаписьZipФайла|ZipFileReader|ЧтениеZipФайла|TextReader|ЧтениеТекста|TextWriter|ЗаписьТекста" + + "|TextExtraction|ИзвлечениеТекста|BinaryData|ДвоичныеДанные|FileStream|ФайловыйПоток" + + "|FileStreamsManager|МенеджерФайловыхПотоков|DataWriter|ЗаписьДанных|DataReader|ЧтениеДанных"; + + public static final String GLOBAL_METHODS = "ЗначениеВФайл|ValueToFile|КопироватьФайл|FileCopy" + + "|ОбъединитьФайлы|MergeFiles|ПереместитьФайл|MoveFile|РазделитьФайл|SplitFile|СоздатьКаталог|CreateDirectory|" + + "УдалитьФайлы|DeleteFiles|КаталогПрограммы|BinDir|КаталогВременныхФайлов|TempFilesDir" + + "|КаталогДокументов|DocumentsDir|РабочийКаталогДанныхПользователя|UserDataWorkDir" + + "|НачатьПодключениеРасширенияРаботыСФайлами|BeginAttachingFileSystemExtension" + + "|НачатьУстановкуРасширенияРаботыСФайлами|BeginInstallFileSystemExtension" + + "|УстановитьРасширениеРаботыСФайлами|InstallFileSystemExtension" + + "|УстановитьРасширениеРаботыСФайламиАсинх|InstallFileSystemExtensionAsync" + + "|ПодключитьРасширениеРаботыСФайламиАсинх|AttachFileSystemExtensionAsync|" + + "КаталогВременныхФайловАсинх|TempFilesDirAsync|КаталогДокументовАсинх|DocumentsDirAsync" + + "|НачатьПолучениеКаталогаВременныхФайлов|BeginGettingTempFilesDir" + + "|НачатьПолучениеКаталогаДокументов|BeginGettingDocumentsDir" + + "|НачатьПолучениеРабочегоКаталогаДанныхПользователя|BeginGettingUserDataWorkDir" + + "|РабочийКаталогДанныхПользователяАсинх|UserDataWorkDirAsync" + + "|КопироватьФайлАсинх|CopyFileAsync|НайтиФайлыАсинх|FindFilesAsync|НачатьКопированиеФайла|BeginCopyingFile" + + "|НачатьПеремещениеФайла|BeginMovingFile|НачатьПоискФайлов|BeginFindingFiles" + + "|НачатьСозданиеДвоичныхДанныхИзФайла|BeginCreateBinaryDataFromFile" + + "|НачатьСозданиеКаталога|BeginCreatingDirectory" + + "|НачатьУдалениеФайлов|BeginDeletingFiles|ПереместитьФайлАсинх|MoveFileAsync" + + "|СоздатьДвоичныеДанныеИзФайлаАсинх|CreateBinaryDataFromFileAsync|СоздатьКаталогАсинх|CreateDirectoryAsync" + + "|УдалитьФайлыАсинх|DeleteFilesAsync"; + private static final Pattern GLOBAL_METHODS_PATTERN = getPattern(GLOBAL_METHODS); + + @DiagnosticParameter( + type = String.class, + defaultValue = GLOBAL_METHODS + ) + private String globalMethods = GLOBAL_METHODS; + + @DiagnosticParameter( + type = String.class, + defaultValue = NEW_EXPRESSION + ) + private String newExpression = NEW_EXPRESSION; + private Pattern newExpressionPattern = getPattern(newExpression); + + public FileSystemAccessDiagnostic() { + super(GLOBAL_METHODS_PATTERN); + } + + private static Pattern getPattern(String newExpression) { + return CaseInsensitivePattern.compile(newExpression); + } + + @Override + public void configure(Map configuration) { + super.configure(configuration); + setMethodPattern(getPattern(globalMethods)); + newExpressionPattern = getPattern(newExpression); + } + + @Override + protected boolean checkMethodCall(BSLParser.MethodCallContext ctx) { + return false; + } + + @Override + public ParseTree visitNewExpression(BSLParser.NewExpressionContext ctx) { + Constructors.typeName(ctx).ifPresent((String typeName) -> { + var matcherTypeName = newExpressionPattern.matcher(typeName); + if (matcherTypeName.matches()) { + diagnosticStorage.addDiagnostic(ctx); + } + }); + return super.visitNewExpression(ctx); + } +} diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ForbiddenMetadataNameDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ForbiddenMetadataNameDiagnostic.java index de12ab27d3e..af3a78aa126 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ForbiddenMetadataNameDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ForbiddenMetadataNameDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -28,15 +28,14 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.AttributeOwner; +import com.github._1c_syntax.bsl.mdo.ChildrenOwner; +import com.github._1c_syntax.bsl.mdo.MD; import com.github._1c_syntax.bsl.types.MdoReference; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectComplex; -import com.github._1c_syntax.mdclasses.mdo.attributes.TabularSection; import com.github._1c_syntax.utils.CaseInsensitivePattern; import lombok.RequiredArgsConstructor; -import java.util.Collection; import java.util.regex.Pattern; @DiagnosticMetadata( @@ -54,7 +53,8 @@ ModuleType.ValueManagerModule, ModuleType.SessionModule }, - scope = DiagnosticScope.BSL + scope = DiagnosticScope.BSL, + canLocateOnProject = true ) @RequiredArgsConstructor public class ForbiddenMetadataNameDiagnostic extends AbstractMetadataDiagnostic { @@ -131,23 +131,15 @@ public class ForbiddenMetadataNameDiagnostic extends AbstractMetadataDiagnostic private final LanguageServerConfiguration serverConfiguration; @Override - protected void checkMetadata(AbstractMDObjectBase mdo) { + protected void checkMetadata(MD mdo) { // проверка имени метаданного checkName(mdo.getName(), mdo.getMdoReference()); - if (mdo instanceof AbstractMDObjectComplex) { - // проверка имен реквизитов и табличных частей - ((AbstractMDObjectComplex) mdo).getAttributes() - .forEach(attribute -> checkName(attribute.getName(), attribute.getMdoReference())); - - // проверка имен реквизитов табличных частей - ((AbstractMDObjectComplex) mdo).getAttributes().stream() - .filter(TabularSection.class::isInstance) - .map(TabularSection.class::cast) - .map(TabularSection::getAttributes) - .flatMap(Collection::stream) - .forEach(attribute -> checkName(attribute.getName(), attribute.getMdoReference())); + // проверка имен реквизитов и табличных частей + if (mdo instanceof AttributeOwner childrenOwner) { + childrenOwner.getPlainStorageFields() + .forEach(child -> checkName(child.getName(), child.getMdoReference())); } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FormDataToValueDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FormDataToValueDiagnostic.java index d9a35614b2f..da0a2bef9ee 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FormDataToValueDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FormDataToValueDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FullOuterJoinQueryDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FullOuterJoinQueryDiagnostic.java index 89cb2e2e4ff..7e8f6b94b6a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FullOuterJoinQueryDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FullOuterJoinQueryDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionNameStartsWithGetDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionNameStartsWithGetDiagnostic.java index a0e3f1e4d60..97e2d6b41d6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionNameStartsWithGetDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionNameStartsWithGetDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionOutParameterDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionOutParameterDiagnostic.java index 13c4e260155..6cf2a4d8371 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionOutParameterDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionOutParameterDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -35,7 +35,6 @@ import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; @@ -47,7 +46,6 @@ tags = { DiagnosticTag.DESIGN } - ) public class FunctionOutParameterDiagnostic extends AbstractVisitorDiagnostic { @@ -61,14 +59,13 @@ public ParseTree visitFunction(BSLParser.FunctionContext ctx) { .map(MethodSymbol::getParameters) .flatMap(Collection::stream) .filter(param -> !param.isByValue()) - .collect(Collectors.toList()); + .toList(); if (parameters.isEmpty()) { return ctx; } - Map lvalues = Trees - .findAllRuleNodes(ctx.subCodeBlock(), BSLParser.RULE_lValue) + var lvalues = Trees.findAllRuleNodes(ctx.subCodeBlock(), BSLParser.RULE_lValue) .stream() .collect( Collectors.toMap( diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionReturnsSamePrimitiveDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionReturnsSamePrimitiveDiagnostic.java index 39ce0386192..f498af45d1d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionReturnsSamePrimitiveDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionReturnsSamePrimitiveDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionShouldHaveReturnDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionShouldHaveReturnDiagnostic.java index f031925bd5b..449b1fb50a8 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionShouldHaveReturnDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionShouldHaveReturnDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GetFormMethodDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GetFormMethodDiagnostic.java index e4e230e64f6..991c5903bd6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GetFormMethodDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GetFormMethodDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GlobalContextMethodCollision8312Diagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GlobalContextMethodCollision8312Diagnostic.java index 9d920a3bef8..ee3882f8b7b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GlobalContextMethodCollision8312Diagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GlobalContextMethodCollision8312Diagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IdenticalExpressionsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IdenticalExpressionsDiagnostic.java index 118947e1cee..5b81dee5aa8 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IdenticalExpressionsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IdenticalExpressionsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfConditionComplexityDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfConditionComplexityDiagnostic.java index 5e9fa7365f9..7ba9a64aa14 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfConditionComplexityDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfConditionComplexityDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedCodeBlockDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedCodeBlockDiagnostic.java index f64b2925466..aeb97826cce 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedCodeBlockDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedCodeBlockDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -72,7 +72,7 @@ public ParseTree visitIfStatement(BSLParser.IfStatementContext ctx) { .collect(Collectors.toCollection(() -> codeBlocks)); - BSLParser.ElseBranchContext elseBranch = ctx.elseBranch(); + var elseBranch = ctx.elseBranch(); if (elseBranch != null) { codeBlocks.add(elseBranch.codeBlock()); } @@ -90,23 +90,21 @@ private void findDuplicatedCodeBlock(List codeBlockC } private void checkCodeBlock(List codeBlockContexts, int i) { - BSLParser.CodeBlockContext currentCodeBlock = codeBlockContexts.get(i); + var currentCodeBlock = codeBlockContexts.get(i); - List identicalCodeBlocks = codeBlockContexts.stream() + var identicalCodeBlocks = codeBlockContexts.stream() .skip(i) .filter(codeBlockContext -> !codeBlockContext.equals(currentCodeBlock) && !(currentCodeBlock.children == null && codeBlockContext.children == null) && DiagnosticHelper.equalNodes(currentCodeBlock, codeBlockContext)) - .collect(Collectors.toList()); + .toList(); if (identicalCodeBlocks.isEmpty()) { return; } - identicalCodeBlocks.stream() - .collect(Collectors.toCollection(() -> checkedBlocks)); - + identicalCodeBlocks.stream().collect(Collectors.toCollection(() -> checkedBlocks)); List relatedInformation = new ArrayList<>(); relatedInformation.add(RelatedInformation.create( diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedConditionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedConditionDiagnostic.java index 4a24dc32a7c..3cff8eb3ebc 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedConditionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedConditionDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -85,22 +85,20 @@ private void findDuplicatedExpression(List expressi } private void checkExpression(List expressionContexts, int i) { - BSLParser.ExpressionContext currentExpression = expressionContexts.get(i); + var currentExpression = expressionContexts.get(i); - List identicalExpressions = expressionContexts.stream() + var identicalExpressions = expressionContexts.stream() .skip(i) .filter(expressionContext -> !expressionContext.equals(currentExpression) && DiagnosticHelper.equalNodes(currentExpression, expressionContext)) - .collect(Collectors.toList()); + .toList(); if (identicalExpressions.isEmpty()) { return; } - identicalExpressions.stream() - .collect(Collectors.toCollection(() -> checkedConditions)); - + identicalExpressions.stream().collect(Collectors.toCollection(() -> checkedConditions)); List relatedInformation = new ArrayList<>(); relatedInformation.add(RelatedInformation.create( @@ -121,6 +119,4 @@ private void checkExpression(List expressionContext diagnosticStorage.addDiagnostic(currentExpression, relatedInformation); } - } - diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseIfEndsWithElseDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseIfEndsWithElseDiagnostic.java index df75d461dc6..97428c28d41 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseIfEndsWithElseDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseIfEndsWithElseDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectLineBreakDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectLineBreakDiagnostic.java index 57a68257470..283e1628c7a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectLineBreakDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectLineBreakDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -71,7 +71,7 @@ public class IncorrectLineBreakDiagnostic extends AbstractDiagnostic { @DiagnosticParameter( type = String.class, - defaultValue = "" + DEFAULT_LIST_FOR_CHECK_START + defaultValue = DEFAULT_LIST_FOR_CHECK_START ) private Pattern listOfIncorrectFirstSymbol = createPatternIncorrectStartLine(DEFAULT_LIST_FOR_CHECK_START); @@ -83,7 +83,7 @@ public class IncorrectLineBreakDiagnostic extends AbstractDiagnostic { @DiagnosticParameter( type = String.class, - defaultValue = "" + DEFAULT_LIST_FOR_CHECK_END + defaultValue = DEFAULT_LIST_FOR_CHECK_END ) private Pattern listOfIncorrectLastSymbol = createPatternIncorrectEndLine(DEFAULT_LIST_FOR_CHECK_END); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseLikeInQueryDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseLikeInQueryDiagnostic.java index e972b4f5ca7..3351ecd899f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseLikeInQueryDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseLikeInQueryDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseOfStrTemplateDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseOfStrTemplateDiagnostic.java index 9c31b6db066..1d197d60398 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseOfStrTemplateDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseOfStrTemplateDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/InternetAccessDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/InternetAccessDiagnostic.java new file mode 100644 index 00000000000..cb5c0017b64 --- /dev/null +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/InternetAccessDiagnostic.java @@ -0,0 +1,61 @@ +/* + * This file is a part of BSL Language Server. + * + * Copyright (c) 2018-2024 + * Alexey Sosnoviy , Nikita Fedkin and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * BSL Language Server is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * BSL Language Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with BSL Language Server. + */ +package com.github._1c_syntax.bsl.languageserver.diagnostics; + +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticMetadata; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.languageserver.utils.bsl.Constructors; +import com.github._1c_syntax.bsl.parser.BSLParser; +import com.github._1c_syntax.utils.CaseInsensitivePattern; +import org.antlr.v4.runtime.tree.ParseTree; + +import java.util.regex.Pattern; + +@DiagnosticMetadata( + type = DiagnosticType.VULNERABILITY, + severity = DiagnosticSeverity.MAJOR, + minutesToFix = 60, + tags = { + DiagnosticTag.SUSPICIOUS + }, + activatedByDefault = false +) + +public class InternetAccessDiagnostic extends AbstractVisitorDiagnostic { + private static final Pattern PATTERN_NEW_EXPRESSION = CaseInsensitivePattern.compile( + "FTPСоединение|FTPConnection|HTTPСоединение|HTTPConnection|WSОпределения|WSDefinitions|WSПрокси|WSProxy" + + "|ИнтернетПочтовыйПрофиль|InternetMailProfile|ИнтернетПочта|InternetMail|Почта|Mail|HTTPЗапрос|HTTPRequest|" + + "ИнтернетПрокси|InternetProxy"); + + @Override + public ParseTree visitNewExpression(BSLParser.NewExpressionContext ctx) { + Constructors.typeName(ctx).ifPresent((String typeName) -> { + var matcherTypeName = PATTERN_NEW_EXPRESSION.matcher(typeName); + if (matcherTypeName.matches()) { + diagnosticStorage.addDiagnostic(ctx); + } + }); + return super.visitNewExpression(ctx); + } +} diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/InvalidCharacterInFileDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/InvalidCharacterInFileDiagnostic.java index 462d81e1bab..4fa8170f271 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/InvalidCharacterInFileDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/InvalidCharacterInFileDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IsInRoleMethodDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IsInRoleMethodDiagnostic.java index 79e13548ec3..8494808f4e6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IsInRoleMethodDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IsInRoleMethodDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithSubQueryDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithSubQueryDiagnostic.java index f675f363a65..54562abf2c5 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithSubQueryDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithSubQueryDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithVirtualTableDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithVirtualTableDiagnostic.java index 7aebf5a6c9e..a7a8b483693 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithVirtualTableDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithVirtualTableDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LatinAndCyrillicSymbolInWordDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LatinAndCyrillicSymbolInWordDiagnostic.java index 725291e88bc..451ace6cfd2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LatinAndCyrillicSymbolInWordDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LatinAndCyrillicSymbolInWordDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -86,7 +86,7 @@ public class LatinAndCyrillicSymbolInWordDiagnostic extends AbstractDiagnostic { @DiagnosticParameter( type = String.class, - defaultValue = "" + DEFAULT_EXCLUDE_WORDS + defaultValue = DEFAULT_EXCLUDE_WORDS ) private Pattern excludeWords = createExcludeWordPattern(DEFAULT_EXCLUDE_WORDS); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LineLengthDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LineLengthDiagnostic.java index 255da942530..214595b2fba 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LineLengthDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LineLengthDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LogicalOrInTheWhereSectionOfQueryDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LogicalOrInTheWhereSectionOfQueryDiagnostic.java index 05d73e1f9e8..949931ada16 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LogicalOrInTheWhereSectionOfQueryDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LogicalOrInTheWhereSectionOfQueryDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicDateDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicDateDiagnostic.java index ab216658a53..362eace6414 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicDateDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicDateDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -29,9 +29,7 @@ import com.github._1c_syntax.bsl.parser.BSLParser; import com.github._1c_syntax.bsl.parser.BSLParserRuleContext; import com.github._1c_syntax.utils.CaseInsensitivePattern; -import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.tree.ParseTree; -import org.antlr.v4.runtime.tree.TerminalNode; import java.util.Arrays; import java.util.HashSet; @@ -60,16 +58,18 @@ public class MagicDateDiagnostic extends AbstractVisitorDiagnostic { ); private static final Pattern paramPattern = CaseInsensitivePattern.compile( - "\"\\d{8}.*" + "\"[0123]{1}\\d{7}\"|\"[0123]{1}\\d{13}\"" ); + private static final Pattern zeroPattern = Pattern.compile("^0+"); private static final Pattern nonNumberPattern = CaseInsensitivePattern.compile( "\\D" ); + public static final int MAX_YEAR_BY_1C = 9999; @DiagnosticParameter( type = String.class, - defaultValue = "" + DEFAULT_AUTHORIZED_DATES + defaultValue = DEFAULT_AUTHORIZED_DATES ) private final Set authorizedDates = new HashSet<>(Arrays.asList(DEFAULT_AUTHORIZED_DATES.split(","))); @@ -84,50 +84,116 @@ public void configure(Map configuration) { } @Override - public ParseTree visitGlobalMethodCall(BSLParser.GlobalMethodCallContext ctx) { - Optional.of(ctx) - .filter(it -> methodPattern.matcher(it.methodName().getText()).matches()) - .map(BSLParser.GlobalMethodCallContext::doCall) - .map(BSLParser.DoCallContext::callParamList) - .filter(callParamList -> paramPattern.matcher(callParamList.getText()).matches()) - .ifPresent(this::checkExclAddDiagnostic); - - return super.visitGlobalMethodCall(ctx); + public ParseTree visitConstValue(BSLParser.ConstValueContext ctx) { + var tNode = ctx.DATETIME(); + var sNode = ctx.string(); + if ((tNode != null || sNode != null) && isAccepted(ctx)) { + if (sNode != null && !isValidDate(sNode)) { + return defaultResult(); + } + + final var expressionContext = getExpression(Optional.of(ctx)); + if (!insideSimpleDateAssignment(expressionContext) && !insideReturnSimpleDate(expressionContext) + && !insideAssignmentWithDateMethodForSimpleDate(expressionContext)) { + diagnosticStorage.addDiagnostic(ctx, info.getMessage(ctx.getText())); + } + } + + return defaultResult(); } - @Override - public ParseTree visitConstValue(BSLParser.ConstValueContext ctx) { - TerminalNode tNode = ctx.DATETIME(); - if (tNode != null) { - checkExclAddDiagnostic(ctx); + private static boolean isValidDate(BSLParser.StringContext ctx) { + final var text = ctx.getText(); + if (!paramPattern.matcher(text).matches()) { + return false; } + var strDate = text.substring(1, text.length() - 1); // убрать кавычки + return isValidDate(strDate); + } - return ctx; + private static boolean isValidDate(String strDate) { + var year = parseInt(strDate.substring(0, 4)); + if (year < 1 || year > MAX_YEAR_BY_1C) { + return false; + } + var month = parseInt(strDate.substring(4, 6)); + var day = parseInt(strDate.substring(6, 8)); + if (month < 1 || month > 12 || day < 1 || day > 31) { + return false; + } + if (strDate.length() == 8) { + return true; + } + var hh = parseInt(strDate.substring(8, 10)); + var mm = parseInt(strDate.substring(10, 12)); + var ss = parseInt(strDate.substring(12, 14)); + return hh <= 24 && mm <= 60 && ss <= 60; } - private void checkExclAddDiagnostic(BSLParserRuleContext ctx){ - String checked = ctx.getText(); - if (checked != null && !isExcluded(checked)) { - ParserRuleContext expression; - if (ctx instanceof BSLParser.CallParamListContext){ - expression = ctx.getParent().getParent().getParent().getParent().getParent(); - } else { - expression = ctx.getParent().getParent(); - } - if (expression instanceof BSLParser.ExpressionContext - && (!isAssignExpression((BSLParser.ExpressionContext) expression))) { - diagnosticStorage.addDiagnostic(ctx.stop, info.getMessage(checked)); - } + private static int parseInt(String text) { + String s = zeroPattern.matcher(text).replaceAll(""); + try { + return Integer.parseInt(s); + } catch (NumberFormatException e) { + return 0; } } - private boolean isExcluded(String sIn) { - String s = nonNumberPattern.matcher(sIn).replaceAll(""); + private boolean isAccepted(BSLParser.ConstValueContext ctx) { + String text = ctx.getText(); + return text != null && !text.isEmpty() && !isExcluded(text); + } + + private boolean isExcluded(String text) { + String s = nonNumberPattern.matcher(text).replaceAll(""); return authorizedDates.contains(s); } - private static boolean isAssignExpression(BSLParser.ExpressionContext expression) { - return (expression.getChildCount() <= 1); + private static Optional getExpression(Optional constValue) { + return constValue + .map(BSLParserRuleContext::getParent) + .filter(context -> context.getChildCount() == 1) + .map(BSLParserRuleContext::getParent) + .filter(context -> context.getChildCount() == 1) + .filter(BSLParser.ExpressionContext.class::isInstance) + .map(BSLParser.ExpressionContext.class::cast); + } + + private static boolean insideSimpleDateAssignment(Optional expression) { + return insideContext(expression, BSLParser.AssignmentContext.class); } + private static boolean insideContext(Optional expression, + Class assignmentContextClass) { + return expression + .map(BSLParserRuleContext::getParent) + .filter(assignmentContextClass::isInstance) + .isPresent(); + } + + private static boolean insideReturnSimpleDate(Optional expression) { + return insideContext(expression, BSLParser.ReturnStatementContext.class); + } + + private static boolean insideAssignmentWithDateMethodForSimpleDate(Optional expression) { + return expression + .map(BSLParserRuleContext::getParent) // callParam + .filter(context -> context.getChildCount() == 1) + .map(BSLParserRuleContext::getParent) // callParamList + .filter(context -> context.getChildCount() == 1) + .map(BSLParserRuleContext::getParent) // doCall + .map(BSLParserRuleContext::getParent) // globalCall - метод Дата(ХХХ) + .filter(BSLParser.GlobalMethodCallContext.class::isInstance) + .map(BSLParser.GlobalMethodCallContext.class::cast) + .filter(context -> methodPattern.matcher(context.methodName().getText()).matches()) + .map(BSLParserRuleContext::getParent) // complexId + .filter(context -> context.getChildCount() == 1) + .map(BSLParserRuleContext::getParent) // member + .filter(context -> context.getChildCount() == 1) + .map(BSLParserRuleContext::getParent) // expression + .filter(context -> context.getChildCount() == 1) + .map(BSLParserRuleContext::getParent) + .filter(BSLParser.AssignmentContext.class::isInstance) + .isPresent(); + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicNumberDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicNumberDiagnostic.java index c739e570cc4..1718d8795af 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicNumberDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicNumberDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -28,13 +28,14 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; import com.github._1c_syntax.bsl.languageserver.utils.DiagnosticHelper; import com.github._1c_syntax.bsl.parser.BSLParser; -import org.antlr.v4.runtime.ParserRuleContext; +import com.github._1c_syntax.bsl.parser.BSLParserRuleContext; import org.antlr.v4.runtime.tree.ParseTree; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.Optional; @DiagnosticMetadata( type = DiagnosticType.CODE_SMELL, @@ -49,10 +50,9 @@ public class MagicNumberDiagnostic extends AbstractVisitorDiagnostic { private static final String DEFAULT_AUTHORIZED_NUMBERS = "-1,0,1"; private static final boolean DEFAULT_ALLOW_MAGIC_NUMBER = true; - @DiagnosticParameter( type = String.class, - defaultValue = "" + DEFAULT_AUTHORIZED_NUMBERS + defaultValue = DEFAULT_AUTHORIZED_NUMBERS ) private final List authorizedNumbers = new ArrayList<>(Arrays.asList(DEFAULT_AUTHORIZED_NUMBERS.split(","))); @@ -75,37 +75,54 @@ public void configure(Map configuration) { } } + private static Optional getExpression(BSLParserRuleContext ctx) { + return Optional.of(ctx) + .filter(context -> context.getChildCount() == 1) + .map(BSLParserRuleContext::getParent) + .filter(context -> context.getChildCount() == 1) + .map(BSLParserRuleContext::getParent) + .filter(BSLParser.ExpressionContext.class::isInstance) + .map(BSLParser.ExpressionContext.class::cast); + } + + private static boolean isNumericExpression(BSLParser.ExpressionContext expression) { + return (expression.getChildCount() <= 1); + } + + private static boolean insideCallParam(BSLParser.ExpressionContext expression) { + return expression.getParent() instanceof BSLParser.CallParamContext; + } + @Override public ParseTree visitNumeric(BSLParser.NumericContext ctx) { String checked = ctx.getText(); - if (checked != null && !isExcluded(checked)) { - ParserRuleContext expression = ctx.getParent().getParent().getParent(); - if (expression instanceof BSLParser.ExpressionContext - && (!isNumericExpression((BSLParser.ExpressionContext) expression) - || mayBeNumberAccess((BSLParser.ExpressionContext) expression))) { + if (checked != null && isAllowed(checked)) { + final var parent = ctx.getParent(); + if (parent.getParent() instanceof BSLParser.DefaultValueContext || isWrongExpression(parent)) { diagnosticStorage.addDiagnostic(ctx.stop, info.getMessage(checked)); } } - - return ctx; + return defaultResult(); } - private boolean isExcluded(String s) { + private boolean isAllowed(String s) { for (String elem : this.authorizedNumbers) { if (s.compareTo(elem) == 0) { - return true; + return false; } } + return true; + } - return false; + private boolean isWrongExpression(BSLParserRuleContext numericContextParent) { + return getExpression(numericContextParent) + .filter((BSLParser.ExpressionContext expression) -> + (!isNumericExpression(expression) || mayBeNumberAccess(expression) || insideCallParam(expression))) + .isPresent(); } private boolean mayBeNumberAccess(BSLParser.ExpressionContext expression) { return !allowMagicIndexes && expression.getParent() instanceof BSLParser.AccessIndexContext; } - - private static boolean isNumericExpression(BSLParser.ExpressionContext expression) { - return (expression.getChildCount() <= 1); - } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MetadataObjectNameLengthDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MetadataObjectNameLengthDiagnostic.java index 7b6602d35c5..21f26f99a26 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MetadataObjectNameLengthDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MetadataObjectNameLengthDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -29,9 +29,9 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.MD; import com.github._1c_syntax.bsl.types.MDOType; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; import java.util.List; @@ -42,14 +42,15 @@ scope = DiagnosticScope.BSL, tags = { DiagnosticTag.STANDARD - } + }, + canLocateOnProject = true ) public class MetadataObjectNameLengthDiagnostic extends AbstractMetadataDiagnostic { - private final LanguageServerConfiguration serverConfiguration; - private static final int MAX_METADATA_OBJECT_NAME_LENGTH = 80; + private final LanguageServerConfiguration serverConfiguration; + @DiagnosticParameter( type = Integer.class, defaultValue = "" + MAX_METADATA_OBJECT_NAME_LENGTH @@ -62,7 +63,7 @@ public class MetadataObjectNameLengthDiagnostic extends AbstractMetadataDiagnost } @Override - protected void checkMetadata(AbstractMDObjectBase mdo) { + protected void checkMetadata(MD mdo) { if (mdo.getName().length() > maxMetadataObjectNameLength) { addAttributeDiagnostic(mdo); } @@ -76,13 +77,12 @@ protected void check() { if (computeDiagnosticRange()) { documentContext.getMdObject().ifPresent(this::checkMetadata); } - } else { super.check(); } } - private void addAttributeDiagnostic(AbstractMDObjectBase attribute) { + private void addAttributeDiagnostic(MD attribute) { String mdoRef; if (serverConfiguration.getLanguage() == Language.RU) { mdoRef = attribute.getMdoReference().getMdoRefRu(); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MethodSizeDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MethodSizeDiagnostic.java index 7c9becccd91..079523c7a29 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MethodSizeDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MethodSizeDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java index 26a464bffdd..8fc323b798f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCodeTryCatchExDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCodeTryCatchExDiagnostic.java index d38bde0ac5e..73e3e5e87ac 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCodeTryCatchExDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCodeTryCatchExDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCommonModuleMethodDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCommonModuleMethodDiagnostic.java index 74133a4a1cb..302750eb50c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCommonModuleMethodDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCommonModuleMethodDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingEventSubscriptionHandlerDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingEventSubscriptionHandlerDiagnostic.java index 45a7c146688..819042adc93 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingEventSubscriptionHandlerDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingEventSubscriptionHandlerDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -28,15 +28,12 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; import com.github._1c_syntax.bsl.languageserver.utils.Ranges; +import com.github._1c_syntax.bsl.mdo.CommonModule; +import com.github._1c_syntax.bsl.mdo.EventSubscription; import com.github._1c_syntax.bsl.types.ConfigurationSource; -import com.github._1c_syntax.bsl.types.MDOType; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; -import com.github._1c_syntax.mdclasses.mdo.MDEventSubscription; import org.eclipse.lsp4j.Range; -import java.util.regex.Pattern; - @DiagnosticMetadata( type = DiagnosticType.ERROR, severity = DiagnosticSeverity.BLOCKER, @@ -57,7 +54,6 @@ public class MissingEventSubscriptionHandlerDiagnostic extends AbstractDiagnosti * Костыль, но пока так */ private Range diagnosticRange; - private static final Pattern SPLIT_PATTERN = Pattern.compile("\\."); @Override protected void check() { @@ -73,47 +69,45 @@ protected void check() { } // для анализа выбираются все имеющиеся подписки на события - configuration.getChildren().stream() - .filter(mdo -> mdo.getMdoType() == MDOType.EVENT_SUBSCRIPTION) - .map(MDEventSubscription.class::cast) - .forEach((MDEventSubscription eventSubs) -> { + configuration.getEventSubscriptions() + .forEach((EventSubscription eventSubs) -> { // проверка на пустой обработчик if (eventSubs.getHandler().isEmpty()) { addDiagnostic(eventSubs); return; } - var handlerParts = SPLIT_PATTERN.split(eventSubs.getHandler()); - // правильный обработчик состоит из трех частей: // - CommonModule - тип объекта, всегда постоянный: общий модуль // - Имя - имя модуля // - ИмяМетода - имя метода в модуле - if (handlerParts.length != 3) { - addDiagnostic("incorrectHandler", eventSubs, eventSubs.getHandler()); + // если имя метода пустое, то дальше и смотреть нет смысла + if (eventSubs.getHandler().getMethodName().isEmpty()) { + addDiagnostic("incorrectHandler", eventSubs, eventSubs.getHandler().getMethodPath()); return; } // проверка на существование модуля - var module = configuration.getCommonModule(handlerParts[1]); + var module = configuration.findCommonModule(eventSubs.getHandler().getModuleName()); + if (module.isEmpty()) { - addDiagnostic("missingModule", eventSubs, handlerParts[1]); + addDiagnostic("missingModule", eventSubs, eventSubs.getHandler().getModuleName()); return; } var commonModule = module.get(); // проверка наличия у модуля серверного флага if (!commonModule.isServer()) { - addDiagnostic("shouldBeServer", eventSubs, handlerParts[1]); + addDiagnostic("shouldBeServer", eventSubs, eventSubs.getHandler().getModuleName()); } // проверка на наличие метода и его экспортности - checkMethod(eventSubs, handlerParts[2], commonModule); + checkMethod(eventSubs, eventSubs.getHandler().getMethodName(), commonModule); }); } - private void checkMethod(MDEventSubscription eventSubs, String methodName, MDCommonModule commonModule) { + private void checkMethod(EventSubscription eventSubs, String methodName, CommonModule commonModule) { documentContext.getServerContext() .getDocument(commonModule.getMdoReference().getMdoRef(), ModuleType.CommonModule) .ifPresent((DocumentContext commonModuleContext) -> { @@ -130,12 +124,12 @@ private void checkMethod(MDEventSubscription eventSubs, String methodName, MDCom }); } - private void addDiagnostic(String messageString, MDEventSubscription eventSubs, String text) { + private void addDiagnostic(String messageString, EventSubscription eventSubs, String text) { diagnosticStorage.addDiagnostic(diagnosticRange, info.getResourceString(messageString, text, eventSubs.getName())); } - private void addDiagnostic(MDEventSubscription eventSubs) { + private void addDiagnostic(EventSubscription eventSubs) { diagnosticStorage.addDiagnostic(diagnosticRange, info.getMessage(eventSubs.getName())); } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingParameterDescriptionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingParameterDescriptionDiagnostic.java index 00699b1a29f..30fb86cd23a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingParameterDescriptionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingParameterDescriptionDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingReturnedValueDescriptionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingReturnedValueDescriptionDiagnostic.java index f6c471c9848..8aadabcf3be 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingReturnedValueDescriptionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingReturnedValueDescriptionDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingSpaceDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingSpaceDiagnostic.java index 9bdf174db6f..c522fb3a041 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingSpaceDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingSpaceDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -85,19 +85,19 @@ public class MissingSpaceDiagnostic extends AbstractDiagnostic implements QuickF @DiagnosticParameter( type = String.class, - defaultValue = "" + DEFAULT_LIST_FOR_CHECK_LEFT + defaultValue = DEFAULT_LIST_FOR_CHECK_LEFT ) private String listForCheckLeft = DEFAULT_LIST_FOR_CHECK_LEFT; @DiagnosticParameter( type = String.class, - defaultValue = "" + DEFAULT_LIST_FOR_CHECK_RIGHT + defaultValue = DEFAULT_LIST_FOR_CHECK_RIGHT ) private String listForCheckRight = DEFAULT_LIST_FOR_CHECK_RIGHT; @DiagnosticParameter( type = String.class, - defaultValue = "" + DEFAULT_LIST_FOR_CHECK_LEFT_AND_RIGHT + defaultValue = DEFAULT_LIST_FOR_CHECK_LEFT_AND_RIGHT ) private String listForCheckLeftAndRight = DEFAULT_LIST_FOR_CHECK_LEFT_AND_RIGHT; @@ -169,9 +169,7 @@ public void check() { } addDiagnosticLeftRight(token, noSpaceLeft, noSpaceRight); } - } - } @Override @@ -196,21 +194,17 @@ public List getQuickFixes( String diagnosticMessage = diagnostic.getMessage().toLowerCase(Locale.ENGLISH); // TODO @YanSergey. Переделать после выполнения issue #371 'Доработки ядра. Хранение информации для квикфиксов' - boolean missedLeft = diagnosticMessage.contains("слева") || diagnosticMessage.contains("left"); - boolean missedRight = diagnosticMessage.contains("справа") || diagnosticMessage.contains("right"); + var missedLeft = diagnosticMessage.contains("слева") || diagnosticMessage.contains("left"); + var missedRight = diagnosticMessage.contains("справа") || diagnosticMessage.contains("right"); var range = diagnostic.getRange(); if (missedLeft) { - var textEdit = new TextEdit( - new Range(range.getStart(), range.getStart()), - " "); + var textEdit = new TextEdit(new Range(range.getStart(), range.getStart()), " "); textEdits.add(textEdit); } if (missedRight) { - var textEdit = new TextEdit( - new Range(range.getEnd(), range.getEnd()), - " "); + var textEdit = new TextEdit(new Range(range.getEnd(), range.getEnd()), " "); textEdits.add(textEdit); } }); @@ -243,7 +237,6 @@ private void addDiagnosticLeftRight(Token token, boolean noSpaceLeft, boolean no } private static boolean noSpaceLeft(List tokens, Token t) { - var previousToken = tokens.get(t.getTokenIndex() - 1); return previousToken.getType() != BSLParser.LPAREN && !StringUtils.isWhitespace(previousToken.getText()); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTempStorageDeletionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTempStorageDeletionDiagnostic.java index 4936abe1b49..183f6451deb 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTempStorageDeletionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTempStorageDeletionDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTemporaryFileDeletionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTemporaryFileDeletionDiagnostic.java index 7ba1565e992..2894bd97cdf 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTemporaryFileDeletionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTemporaryFileDeletionDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -120,15 +120,15 @@ private boolean foundDeleteFile(BSLParser.CodeBlockContext codeBlockContext, Str .stream() .map(BSLParserRuleContext.class::cast) .filter((BSLParserRuleContext node) -> node.getStart().getLine() > filterLine) - .collect(Collectors.toList()); + .toList(); for (var node : listCallStatements) { String fullCallMethod; BSLParser.DoCallContext doCallContext; - if (node instanceof BSLParser.GlobalMethodCallContext) { - fullCallMethod = ((BSLParser.GlobalMethodCallContext) node).methodName().getText(); - doCallContext = ((BSLParser.GlobalMethodCallContext) node).doCall(); + if (node instanceof BSLParser.GlobalMethodCallContext globalMethodCallContext) { + fullCallMethod = globalMethodCallContext.methodName().getText(); + doCallContext = globalMethodCallContext.doCall(); } else { fullCallMethod = getFullMethodName((BSLParser.AccessCallContext) node); doCallContext = ((BSLParser.AccessCallContext) node).methodCall().doCall(); @@ -136,7 +136,7 @@ private boolean foundDeleteFile(BSLParser.CodeBlockContext codeBlockContext, Str if (doCallContext != null) { var matcher = searchDeleteFileMethod.matcher(fullCallMethod); - if (matcher.matches() && fullCallMethod.length() > 0 + if (matcher.matches() && !fullCallMethod.isEmpty() && foundVariableInCallParams(doCallContext, variableName)) { result = true; break; @@ -191,11 +191,9 @@ private static String getFullMethodName(BSLParser.AccessCallContext ctx) { var prefix = ""; List modifiers; - if (parent instanceof BSLParser.CallStatementContext) { + if (parent instanceof BSLParser.CallStatementContext callStatement) { - var callStatement = (BSLParser.CallStatementContext) parent; - - modifiers =callStatement.modifier(); + modifiers = callStatement.modifier(); if (callStatement.globalMethodCall() != null) { prefix = callStatement.globalMethodCall().methodName().IDENTIFIER().getText(); } else { @@ -203,9 +201,8 @@ private static String getFullMethodName(BSLParser.AccessCallContext ctx) { } } else if (parent instanceof BSLParser.ModifierContext - && parent.getParent() instanceof BSLParser.ComplexIdentifierContext) { + && parent.getParent() instanceof BSLParser.ComplexIdentifierContext root) { - var root = (BSLParser.ComplexIdentifierContext) parent.getParent(); modifiers = root.modifier(); var terminalNode = root.IDENTIFIER(); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingVariablesDescriptionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingVariablesDescriptionDiagnostic.java index 7db66864215..1c339329c97 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingVariablesDescriptionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingVariablesDescriptionDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilineStringInQueryDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilineStringInQueryDiagnostic.java index 9d3ef00ed1a..a22b1945d0d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilineStringInQueryDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilineStringInQueryDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringHasAllDeclaredLanguagesDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringHasAllDeclaredLanguagesDiagnostic.java index 200fbebbbb6..4d0fee60d8e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringHasAllDeclaredLanguagesDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringHasAllDeclaredLanguagesDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringUsingWithTemplateDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringUsingWithTemplateDiagnostic.java index 6a9141b7474..a4b1dfae901 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringUsingWithTemplateDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringUsingWithTemplateDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedConstructorsInStructureDeclarationDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedConstructorsInStructureDeclarationDiagnostic.java index 9ccab85306c..01a01506768 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedConstructorsInStructureDeclarationDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedConstructorsInStructureDeclarationDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedFunctionInParametersDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedFunctionInParametersDiagnostic.java index fab4d1142b2..3fb36458984 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedFunctionInParametersDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedFunctionInParametersDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedStatementsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedStatementsDiagnostic.java index 514df54dcdc..22a889c399b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedStatementsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedStatementsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedTernaryOperatorDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedTernaryOperatorDiagnostic.java index 66cfefc41a3..f4d4e2fd839 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedTernaryOperatorDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedTernaryOperatorDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonExportMethodsInApiRegionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonExportMethodsInApiRegionDiagnostic.java index 7ca071eacd0..0c928698982 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonExportMethodsInApiRegionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonExportMethodsInApiRegionDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonStandardRegionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonStandardRegionDiagnostic.java index 00946886e32..9e637f2f37c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonStandardRegionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonStandardRegionDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfOptionalParamsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfOptionalParamsDiagnostic.java index 1087ffee4cf..f6e34cd651c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfOptionalParamsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfOptionalParamsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfParamsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfParamsDiagnostic.java index e2110602620..92a7c1d04be 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfParamsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfParamsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfValuesInStructureConstructorDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfValuesInStructureConstructorDiagnostic.java index 05e20485198..a3d6f0d5ea2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfValuesInStructureConstructorDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfValuesInStructureConstructorDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OSUsersMethodDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OSUsersMethodDiagnostic.java index 6b25a7b9dc0..82c3e321ad0 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OSUsersMethodDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OSUsersMethodDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OneStatementPerLineDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OneStatementPerLineDiagnostic.java index a75ce4e5255..10d718191cf 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OneStatementPerLineDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OneStatementPerLineDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrderOfParamsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrderOfParamsDiagnostic.java index 9ca55e4e4be..61b0ef713dd 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrderOfParamsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrderOfParamsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrdinaryAppSupportDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrdinaryAppSupportDiagnostic.java index dcc55b9b7d0..b8025fee139 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrdinaryAppSupportDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrdinaryAppSupportDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -28,6 +28,7 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; import com.github._1c_syntax.bsl.languageserver.utils.Ranges; +import com.github._1c_syntax.bsl.mdclasses.Configuration; import com.github._1c_syntax.bsl.types.ModuleType; import lombok.RequiredArgsConstructor; import org.eclipse.lsp4j.Range; @@ -64,16 +65,15 @@ protected void check() { } private void checkProperties(Range range) { - var configuration = documentContext.getServerContext().getConfiguration(); - if (!configuration.isUseManagedFormInOrdinaryApplication()) { - diagnosticStorage.addDiagnostic(range, info.getResourceString("managedFormInOrdinaryApp")); - } + if (configuration instanceof Configuration cf) { // у расширения нет таких атрибутов + if (!cf.isUseManagedFormInOrdinaryApplication()) { + diagnosticStorage.addDiagnostic(range, info.getResourceString("managedFormInOrdinaryApp")); + } - if (configuration.isUseOrdinaryFormInManagedApplication()) { - diagnosticStorage.addDiagnostic(range, info.getResourceString("ordinaryFormInManagedApp")); + if (cf.isUseOrdinaryFormInManagedApplication()) { + diagnosticStorage.addDiagnostic(range, info.getResourceString("ordinaryFormInManagedApp")); + } } - } - } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PairingBrokenTransactionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PairingBrokenTransactionDiagnostic.java index 5d6c3f30f5e..55201f69cef 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PairingBrokenTransactionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PairingBrokenTransactionDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ParseErrorDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ParseErrorDiagnostic.java index 82e25478e0e..d79e7a38c3b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ParseErrorDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ParseErrorDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic.java new file mode 100644 index 00000000000..11204eebe64 --- /dev/null +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic.java @@ -0,0 +1,109 @@ +/* + * This file is a part of BSL Language Server. + * + * Copyright (c) 2018-2024 + * Alexey Sosnoviy , Nikita Fedkin and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * BSL Language Server is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * BSL Language Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with BSL Language Server. + */ +package com.github._1c_syntax.bsl.languageserver.diagnostics; + +import com.github._1c_syntax.bsl.languageserver.context.symbol.ModuleSymbol; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticMetadata; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticParameter; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticScope; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.languageserver.references.ReferenceIndex; +import com.github._1c_syntax.bsl.languageserver.references.model.Reference; +import com.github._1c_syntax.bsl.mdo.CommonModule; +import com.github._1c_syntax.bsl.types.ModuleType; +import lombok.RequiredArgsConstructor; +import org.eclipse.lsp4j.SymbolKind; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +@DiagnosticMetadata( + type = DiagnosticType.SECURITY_HOTSPOT, + severity = DiagnosticSeverity.MAJOR, + minutesToFix = 60, + tags = { + DiagnosticTag.SUSPICIOUS + }, + scope = DiagnosticScope.BSL +) +@RequiredArgsConstructor +public class PrivilegedModuleMethodCallDiagnostic extends AbstractDiagnostic { + + private static final boolean VALIDATE_NESTED_CALLS = true; + + @DiagnosticParameter( + type = Boolean.class, + defaultValue = "" + VALIDATE_NESTED_CALLS + ) + private boolean validateNestedCalls = VALIDATE_NESTED_CALLS; + + private final ReferenceIndex referenceIndex; + private List privilegedModuleSymbols = new ArrayList<>(); + + @Override + protected void check() { + if (privilegedModuleSymbols.isEmpty()) { + privilegedModuleSymbols = getPrivilegedModuleSymbols(); + } + if (privilegedModuleSymbols.isEmpty()) { + return; + } + + referenceIndex.getReferencesFrom(documentContext.getUri(), SymbolKind.Method).stream() + .filter(this::isReferenceToModules) + .forEach(this::fireIssue); + } + + private List getPrivilegedModuleSymbols() { + return documentContext.getServerContext().getConfiguration().getCommonModules() + .stream() + .filter(CommonModule::isPrivileged) + .flatMap(mdCommonModule -> getPrivilegedModuleSymbol(mdCommonModule).stream()) + .toList(); + } + + private Optional getPrivilegedModuleSymbol(CommonModule mdCommonModule) { + return documentContext.getServerContext().getDocument( + mdCommonModule.getMdoReference().getMdoRef(), ModuleType.CommonModule) + .map(documentContext1 -> documentContext1.getSymbolTree().getModule()); + } + + private boolean isReferenceToModules(Reference reference) { + if (!validateNestedCalls && reference.getUri().equals(documentContext.getUri())) { + return false; + } + return reference.getSourceDefinedSymbol() + .flatMap(sourceDefinedSymbol -> sourceDefinedSymbol.getRootParent(SymbolKind.Module)) + .filter(ModuleSymbol.class::isInstance) + .map(ModuleSymbol.class::cast) + .filter(privilegedModuleSymbols::contains) + .isPresent(); + } + + private void fireIssue(Reference reference) { + diagnosticStorage.addDiagnostic(reference.getSelectionRange(), + info.getMessage(reference.getSymbol().getName())); + } +} diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProcedureReturnsValueDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProcedureReturnsValueDiagnostic.java index d65c22476f7..85e250f9002 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProcedureReturnsValueDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProcedureReturnsValueDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PublicMethodsDescriptionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PublicMethodsDescriptionDiagnostic.java index aee6292c61a..3d04a8a2ebd 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PublicMethodsDescriptionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PublicMethodsDescriptionDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryParseErrorDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryParseErrorDiagnostic.java index 0ccd2fe438d..f47e4b68894 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryParseErrorDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryParseErrorDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryToMissingMetadataDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryToMissingMetadataDiagnostic.java index cedb64f1875..fd3f1fd23bf 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryToMissingMetadataDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryToMissingMetadataDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -26,13 +26,12 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.MD; import com.github._1c_syntax.bsl.parser.SDBLParser; import com.github._1c_syntax.bsl.types.ConfigurationSource; import com.github._1c_syntax.bsl.types.MDOType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; import org.antlr.v4.runtime.tree.ParseTree; -import java.util.Map; import java.util.Optional; @DiagnosticMetadata( @@ -50,17 +49,14 @@ public class QueryToMissingMetadataDiagnostic extends AbstractSDBLVisitorDiagnos @Override public ParseTree visitQueryPackage(SDBLParser.QueryPackageContext ctx) { - if (documentContext.getServerContext().getConfiguration().getConfigurationSource() == ConfigurationSource.EMPTY) { return ctx; } - return super.visitQueryPackage(ctx); } @Override public ParseTree visitMdo(SDBLParser.MdoContext mdo) { - if (nonMdoExists(mdo.type.getText(), mdo.tableName.getText())) { diagnosticStorage.addDiagnostic(mdo, info.getMessage(mdo.getText())); @@ -72,13 +68,9 @@ private boolean nonMdoExists(String mdoType, String mdoName) { return getMdo(mdoType, mdoName).isEmpty(); } - private Optional getMdo(String mdoTypeName, String mdoName) { + private Optional getMdo(String mdoTypeName, String mdoName) { return MDOType.fromValue(mdoTypeName).flatMap(mdoType -> - documentContext.getServerContext().getConfiguration().getChildrenByMdoRef().entrySet().stream() - .filter(entry -> entry.getKey().getType() == mdoType - && mdoName.equalsIgnoreCase(entry.getValue().getName())) - .map(Map.Entry::getValue) - .findFirst() - ); + documentContext.getServerContext().getConfiguration().findChild(mdo -> mdo.getMdoType() == mdoType + && mdoName.equalsIgnoreCase(mdo.getName()))); } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QuickFixProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QuickFixProvider.java index f2258c27874..9fd8f840dd2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QuickFixProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QuickFixProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RedundantAccessToObjectDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RedundantAccessToObjectDiagnostic.java index acfcee7d451..4a0306b2816 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RedundantAccessToObjectDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RedundantAccessToObjectDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -28,12 +28,12 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.CommonModule; +import com.github._1c_syntax.bsl.mdo.MD; import com.github._1c_syntax.bsl.mdo.support.ReturnValueReuse; import com.github._1c_syntax.bsl.parser.BSLParser; import com.github._1c_syntax.bsl.types.MDOType; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; import com.github._1c_syntax.utils.CaseInsensitivePattern; import org.antlr.v4.runtime.tree.ParseTree; import org.eclipse.lsp4j.Diagnostic; @@ -68,8 +68,8 @@ public class RedundantAccessToObjectDiagnostic extends AbstractVisitorDiagnostic private static final boolean CHECK_FORM_MODULE = true; private static final boolean CHECK_RECORD_SET_MODULE = true; - private boolean needCheckName = false; - private boolean skipLValue = false; + private boolean needCheckName; + private boolean skipLValue; private Pattern namePatternWithDot; @DiagnosticParameter( @@ -94,14 +94,13 @@ public class RedundantAccessToObjectDiagnostic extends AbstractVisitorDiagnostic public List getDiagnostics(DocumentContext documentContext) { var typeModule = documentContext.getModuleType(); if (typeModule == ModuleType.CommonModule || typeModule == ModuleType.ManagerModule) { - documentContext.getMdObject().ifPresent((AbstractMDObjectBase mdObjectBase) -> { - - needCheckName = !(mdObjectBase instanceof MDCommonModule) - || ((MDCommonModule) mdObjectBase).getReturnValuesReuse() == ReturnValueReuse.DONT_USE; + documentContext.getMdObject().ifPresent((MD mdo) -> { + needCheckName = !(mdo instanceof CommonModule commonModule) + || commonModule.getReturnValuesReuse() == ReturnValueReuse.DONT_USE; skipLValue = true; namePatternWithDot = CaseInsensitivePattern.compile( - String.format(getManagerModuleName(mdObjectBase.getMdoType()), mdObjectBase.getName()) + String.format(getManagerModuleName(mdo.getMdoType()), mdo.getName()) ); }); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RefOveruseDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RefOveruseDiagnostic.java index 7c24af98dbe..0ddb0d606ac 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RefOveruseDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RefOveruseDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -28,14 +28,13 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; import com.github._1c_syntax.bsl.languageserver.utils.Ranges; import com.github._1c_syntax.bsl.languageserver.utils.Trees; +import com.github._1c_syntax.bsl.mdo.TabularSection; +import com.github._1c_syntax.bsl.mdo.TabularSectionOwner; import com.github._1c_syntax.bsl.parser.BSLParserRuleContext; import com.github._1c_syntax.bsl.parser.SDBLParser; import com.github._1c_syntax.bsl.types.ConfigurationSource; import com.github._1c_syntax.bsl.types.MDOType; import com.github._1c_syntax.bsl.types.MdoReference; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectComplex; -import com.github._1c_syntax.mdclasses.mdo.attributes.TabularSection; import com.github._1c_syntax.utils.CaseInsensitivePattern; import edu.umd.cs.findbugs.annotations.Nullable; import lombok.AllArgsConstructor; @@ -154,7 +153,8 @@ private Map> dataSourcesWithTabularSection(SDBLParser.Query } private Map> calcDataSourceWithTabularSectionNames( - Stream dataSources) { + Stream dataSources + ) { return dataSources .map(dataSourceContext -> new TabularSectionTable(getTableNameOrAlias(dataSourceContext), @@ -177,7 +177,9 @@ private static Stream findAllDataSourceW ); } - private static Collection getInnerDataSource(SDBLParser.DataSourceContext dataSourceContext) { + private static Collection getInnerDataSource( + SDBLParser.DataSourceContext dataSourceContext + ) { var result = new ArrayList(); Optional.ofNullable(dataSourceContext.dataSource()) .map(RefOveruseDiagnostic::getInnerDataSource) @@ -186,12 +188,12 @@ private static Collection getInnerDataSource(SDBLP var joinDataSources = dataSourceContext.joinPart().stream() .map(SDBLParser.JoinPartContext::dataSource) .filter(Objects::nonNull) - .collect(Collectors.toList()); + .toList(); result.addAll(joinDataSources); var dataSourcesFromJoins = joinDataSources.stream() .flatMap(dataSourceContext1 -> getInnerDataSource(dataSourceContext1).stream()) - .collect(Collectors.toList()); + .toList(); result.addAll(dataSourcesFromJoins); return result; @@ -210,7 +212,6 @@ private static String getTableNameOrAlias(SDBLParser.DataSourceContext dataSourc .map(tableContext -> (ParseTree) tableContext.parameter())) .map(ParseTree::getText) .orElse(""); - } private List getTabularSectionNames(SDBLParser.DataSourceContext dataSourceContext) { @@ -242,18 +243,19 @@ private List getTabularSectionNames(SDBLParser.MdoContext mdo) { return Collections.emptyList(); } return MDOType.fromValue(mdo.type.getText()).stream() - .map(mdoType1 -> MdoReference.create(mdoType1, mdo.tableName.getText())) - .map(mdoReference -> configuration.getChildrenByMdoRef().get(mdoReference)) - .filter(AbstractMDObjectComplex.class::isInstance) - .map(AbstractMDObjectComplex.class::cast) + .map(mdoTypeTabular -> MdoReference.create(mdoTypeTabular, mdo.tableName.getText())) + .map(configuration::findChild) + .filter(Optional::isPresent) + .map(Optional::get) + .filter(TabularSectionOwner.class::isInstance) + .map(TabularSectionOwner.class::cast) .flatMap(RefOveruseDiagnostic::getTabularSectionNames) .collect(Collectors.toList()); } - private static Stream getTabularSectionNames(AbstractMDObjectComplex mdObjectComplex) { - return mdObjectComplex.getAttributes().stream() - .filter(TabularSection.class::isInstance) - .map(AbstractMDObjectBase::getName); + private static Stream getTabularSectionNames(TabularSectionOwner tabularSectionOwner) { + return tabularSectionOwner.getTabularSections().stream() + .map(TabularSection::getName); } private static Stream getSimpleOverused(List columnsCollection) { @@ -284,8 +286,7 @@ private boolean isOveruse(SDBLParser.ColumnContext ctx) { var children = extractFirstMetadataTypeName(ctx); var refIndex = findLastRef(children); - final int childCount = children.size(); - final var lastIndex = childCount - 1; + final var lastIndex = children.size() - 1; if (refIndex == lastIndex) { var penultimateIdentifierName = children.get(lastIndex - LAST_INDEX_OF_TABLE_DOT_REF).getText(); return dataSourceWithTabularSectionNames.get(penultimateIdentifierName) == null; diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnostic.java index 9949d5f4d25..d7a1ede5933 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -84,7 +84,8 @@ private static Stream> getParametersByVa .map(parameterDefinition -> Pair.of(methodSymbol, parameterDefinition)); } - private static Stream getVariableByParameter(MethodSymbol method, ParameterDefinition parameterDefinition) { + private static Stream getVariableByParameter(MethodSymbol method, + ParameterDefinition parameterDefinition) { return method.getChildren().stream() // в будущем могут появиться и другие символы, подчиненные методам .filter(sourceDefinedSymbol -> sourceDefinedSymbol.getSymbolKind() == SymbolKind.Variable) @@ -181,7 +182,7 @@ private void fireIssue(VariableSymbol variable, Reference nodeForIssue, List(); resultRefs.add(RelatedInformation.create( documentContext.getUri(), diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SameMetadataObjectAndChildNamesDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SameMetadataObjectAndChildNamesDiagnostic.java index b93f790761a..54dda675e11 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SameMetadataObjectAndChildNamesDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SameMetadataObjectAndChildNamesDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -28,12 +28,14 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.Attribute; +import com.github._1c_syntax.bsl.mdo.AttributeOwner; +import com.github._1c_syntax.bsl.mdo.ChildrenOwner; +import com.github._1c_syntax.bsl.mdo.MD; +import com.github._1c_syntax.bsl.mdo.TabularSection; +import com.github._1c_syntax.bsl.mdo.TabularSectionOwner; import com.github._1c_syntax.bsl.types.MDOType; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectComplex; -import com.github._1c_syntax.mdclasses.mdo.attributes.AbstractMDOAttribute; -import com.github._1c_syntax.mdclasses.mdo.attributes.TabularSection; import com.github._1c_syntax.utils.StringInterner; import java.util.List; @@ -52,8 +54,8 @@ ModuleType.ObjectModule, ModuleType.SessionModule }, - scope = DiagnosticScope.BSL - + scope = DiagnosticScope.BSL, + canLocateOnProject = true ) public class SameMetadataObjectAndChildNamesDiagnostic extends AbstractMetadataDiagnostic { @@ -83,28 +85,31 @@ public class SameMetadataObjectAndChildNamesDiagnostic extends AbstractMetadataD } @Override - protected void checkMetadata(AbstractMDObjectBase mdo) { - if (!(mdo instanceof AbstractMDObjectComplex) || ((AbstractMDObjectComplex) mdo).getAttributes().isEmpty()) { + protected void checkMetadata(MD mdo) { + if (!(mdo instanceof ChildrenOwner)) { return; } - var mdoName = stringInterner.intern(mdo.getName()); - ((AbstractMDObjectComplex) mdo).getAttributes().stream() - .filter(attribute -> mdoName.equalsIgnoreCase(attribute.getName())) - .forEach(attribute -> addAttributeDiagnostic(attribute, mdoName)); + if (mdo instanceof AttributeOwner attributeOwner && !attributeOwner.getAllAttributes().isEmpty()) { + var mdoName = stringInterner.intern(mdo.getName()); + checkkAttributes(attributeOwner.getAllAttributes(), mdoName); + } - ((AbstractMDObjectComplex) mdo).getAttributes().stream() - .filter(TabularSection.class::isInstance) - .map(TabularSection.class::cast) - .forEach((TabularSection table) -> { + if (mdo instanceof TabularSectionOwner tabularSectionOwner && !tabularSectionOwner.getTabularSections().isEmpty()) { + tabularSectionOwner.getTabularSections().forEach((TabularSection table) -> { var tableName = stringInterner.intern(table.getName()); - table.getAttributes().stream() - .filter(attribute -> tableName.equalsIgnoreCase(attribute.getName())) - .forEach(attribute -> addAttributeDiagnostic(attribute, tableName)); + checkkAttributes(table.getAllAttributes(), tableName); }); + } + } + + private void checkkAttributes(List attributeOwner, String mdoName) { + attributeOwner.stream() + .filter(attribute -> mdoName.equalsIgnoreCase(attribute.getName())) + .forEach(attribute -> addAttributeDiagnostic(attribute, mdoName)); } - private void addAttributeDiagnostic(AbstractMDOAttribute attribute, String mdoName) { + private void addAttributeDiagnostic(Attribute attribute, String mdoName) { String mdoRef; if (serverConfiguration.getLanguage() == Language.RU) { mdoRef = attribute.getMdoReference().getMdoRefRu(); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ScheduledJobHandlerDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ScheduledJobHandlerDiagnostic.java index f89e66a7e2d..23723598af1 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ScheduledJobHandlerDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ScheduledJobHandlerDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -29,11 +29,11 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; import com.github._1c_syntax.bsl.languageserver.references.ReferenceIndex; +import com.github._1c_syntax.bsl.mdo.CommonModule; +import com.github._1c_syntax.bsl.mdo.MD; +import com.github._1c_syntax.bsl.mdo.ScheduledJob; import com.github._1c_syntax.bsl.types.MDOType; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; -import com.github._1c_syntax.mdclasses.mdo.MDScheduledJob; import java.util.ArrayList; import java.util.Comparator; @@ -48,9 +48,9 @@ tags = { DiagnosticTag.ERROR }, - scope = DiagnosticScope.BSL + scope = DiagnosticScope.BSL, + canLocateOnProject = true ) - public class ScheduledJobHandlerDiagnostic extends AbstractMetadataDiagnostic { private static final String DIAGNOSTIC_MESSAGE = "diagnosticMessage"; @@ -62,19 +62,19 @@ public class ScheduledJobHandlerDiagnostic extends AbstractMetadataDiagnostic { private static final String DOUBLE_MESSAGE = "doubleMessage"; private final ReferenceIndex referenceIndex; - private final Map> scheduledJobHandlers = new HashMap<>(); + private final Map> scheduledJobHandlers = new HashMap<>(); - private static String getFullName(MDCommonModule mdCommonModule, String methodName) { - return getFullName(mdCommonModule.getName(), methodName); + public ScheduledJobHandlerDiagnostic(ReferenceIndex referenceIndex) { + super(List.of(MDOType.SCHEDULED_JOB)); + this.referenceIndex = referenceIndex; } - private static String getFullName(String commonModuleName, String methodName) { - return commonModuleName.concat(".").concat(methodName); + private static String getFullName(CommonModule commonModule, String methodName) { + return getFullName(commonModule.getName(), methodName); } - public ScheduledJobHandlerDiagnostic(ReferenceIndex referenceIndex) { - super(List.of(MDOType.SCHEDULED_JOB)); - this.referenceIndex = referenceIndex; + private static String getFullName(String commonModuleName, String methodName) { + return commonModuleName.concat(".").concat(methodName); } @Override @@ -86,29 +86,29 @@ protected void check() { private void checkHandlerDoubles() { scheduledJobHandlers.values().stream() .filter(mdScheduledJobs -> mdScheduledJobs.size() > 1) - .map((List mdScheduledJobs) -> { - mdScheduledJobs.sort(Comparator.comparing(AbstractMDObjectBase::getName)); + .map((List mdScheduledJobs) -> { + mdScheduledJobs.sort(Comparator.comparing(ScheduledJob::getName)); return mdScheduledJobs; }) .forEach(this::fireIssueForDoubles); scheduledJobHandlers.clear(); } - private void fireIssueForDoubles(List mdScheduledJobs) { + private void fireIssueForDoubles(List mdScheduledJobs) { final var scheduleJobNames = mdScheduledJobs.stream() - .map(AbstractMDObjectBase::getName) + .map(ScheduledJob::getName) .reduce((s, s2) -> s.concat(", ").concat(s2)) .orElseThrow(); - final var mdScheduledJob = mdScheduledJobs.get(0).getHandler(); + final var mdScheduledJob = mdScheduledJobs.get(0).getMethodName(); final var methodPath = getFullName(mdScheduledJob.getModuleName(), mdScheduledJob.getMethodName()); addDiagnostic(info.getResourceString(DOUBLE_MESSAGE, methodPath, scheduleJobNames)); } @Override - protected void checkMetadata(AbstractMDObjectBase mdo) { - final var scheduleJob = (MDScheduledJob) mdo; - final var handler = scheduleJob.getHandler(); + protected void checkMetadata(MD mdo) { + final var scheduleJob = (ScheduledJob) mdo; + final var handler = scheduleJob.getMethodName(); if (handler.isEmpty()) { addDiagnostic(scheduleJob); return; @@ -116,8 +116,8 @@ protected void checkMetadata(AbstractMDObjectBase mdo) { final var moduleName = handler.getModuleName(); - final var commonModuleOptional = - documentContext.getServerContext().getConfiguration().getCommonModule(moduleName); + final var commonModuleOptional = documentContext.getServerContext().getConfiguration() + .findCommonModule(moduleName); if (commonModuleOptional.isEmpty()) { addDiagnostic(MISSING_MODULE_MESSAGE, scheduleJob, moduleName); return; @@ -130,7 +130,7 @@ protected void checkMetadata(AbstractMDObjectBase mdo) { checkMethod(scheduleJob, mdCommonModule, handler.getMethodName()); } - private void checkMethod(MDScheduledJob scheduleJob, MDCommonModule mdCommonModule, String methodName) { + private void checkMethod(ScheduledJob scheduleJob, CommonModule mdCommonModule, String methodName) { final var fullName = getFullName(mdCommonModule, methodName); scheduledJobHandlers.computeIfAbsent(fullName, k -> new ArrayList<>()).add(scheduleJob); @@ -148,7 +148,7 @@ private void checkMethod(MDScheduledJob scheduleJob, MDCommonModule mdCommonModu }); } - private void checkMethod(MDScheduledJob scheduleJob, String fullName, MethodSymbol methodSymbol) { + private void checkMethod(ScheduledJob scheduleJob, String fullName, MethodSymbol methodSymbol) { if (!methodSymbol.isExport()) { addDiagnostic(NON_EXPORT_METHOD_MESSAGE, scheduleJob, fullName); } @@ -169,11 +169,11 @@ private boolean isEmptyMethodBody(MethodSymbol methodSymbol) { return referenceIndex.getReferencesFrom(methodSymbol).isEmpty(); } - private void addDiagnostic(String messageString, MDScheduledJob scheduleJob, String text) { + private void addDiagnostic(String messageString, ScheduledJob scheduleJob, String text) { addDiagnostic(info.getResourceString(messageString, text, scheduleJob.getName())); } - private void addDiagnostic(MDScheduledJob scheduleJob) { + private void addDiagnostic(ScheduledJob scheduleJob) { addDiagnostic(info.getMessage("", scheduleJob.getName())); } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelectTopWithoutOrderByDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelectTopWithoutOrderByDiagnostic.java index 20233fa8792..7dd0fff364b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelectTopWithoutOrderByDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelectTopWithoutOrderByDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfAssignDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfAssignDiagnostic.java index 0d773038121..d21b9c7023f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfAssignDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfAssignDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfInsertionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfInsertionDiagnostic.java index 9a6dd8f2657..36cf5e61d50 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfInsertionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfInsertionDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SemicolonPresenceDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SemicolonPresenceDiagnostic.java index 8dd58606281..99dddb44850 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SemicolonPresenceDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SemicolonPresenceDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ServerSideExportFormMethodDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ServerSideExportFormMethodDiagnostic.java index 84dea6a2502..6b142971a00 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ServerSideExportFormMethodDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ServerSideExportFormMethodDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -29,10 +29,10 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdo.Form; +import com.github._1c_syntax.bsl.mdo.MD; import com.github._1c_syntax.bsl.mdo.support.FormType; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDOForm; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; @DiagnosticMetadata( type = DiagnosticType.ERROR, @@ -52,9 +52,9 @@ public class ServerSideExportFormMethodDiagnostic extends AbstractSymbolTreeDiag @Override public void visitModule(ModuleSymbol module) { - documentContext.getMdObject().ifPresent((AbstractMDObjectBase mdo) -> { + documentContext.getMdObject().ifPresent((MD mdo) -> { // проверка актуальна только для управляемых форм - if (mdo instanceof AbstractMDOForm && ((AbstractMDOForm) mdo).getFormType() != FormType.ORDINARY) { + if (mdo instanceof Form form && form.getFormType() != FormType.ORDINARY) { super.visitModule(module); } }); @@ -63,8 +63,7 @@ public void visitModule(ModuleSymbol module) { @Override public void visitMethod(MethodSymbol method) { if (method.isExport() - && method.getCompilerDirectiveKind() - .orElse(CompilerDirectiveKind.AT_SERVER) != CompilerDirectiveKind.AT_CLIENT) { + && method.getCompilerDirectiveKind().orElse(CompilerDirectiveKind.AT_SERVER) != CompilerDirectiveKind.AT_CLIENT) { diagnosticStorage.addDiagnostic(method); } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPermissionsForNewObjectsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPermissionsForNewObjectsDiagnostic.java index ee070e84998..a1e1198f04b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPermissionsForNewObjectsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPermissionsForNewObjectsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -28,8 +28,8 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; import com.github._1c_syntax.bsl.languageserver.utils.Ranges; +import com.github._1c_syntax.bsl.mdo.Role; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.MDRole; import java.util.Map; import java.util.Set; @@ -55,7 +55,7 @@ public class SetPermissionsForNewObjectsDiagnostic extends AbstractDiagnostic { @DiagnosticParameter( type = String.class, - defaultValue = "" + NAMES_FULL_ACCESS_ROLE + defaultValue = NAMES_FULL_ACCESS_ROLE ) private Set namesFullAccessRole = getSetFromString(NAMES_FULL_ACCESS_ROLE); @@ -68,8 +68,8 @@ public void check() { } documentContext.getServerContext().getConfiguration().getRoles().stream() - .filter(role -> role.getRoleData().isSetForNewObjects()) - .map(MDRole::getName) + .filter(role -> role.getData().isSetForNewObjects()) + .map(Role::getName) .filter(Predicate.not(namesFullAccessRole::contains)) .map(info::getMessage) .forEach((String diagnosticMessage) -> diagnosticStorage.addDiagnostic(range, diagnosticMessage) diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPrivilegedModeDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPrivilegedModeDiagnostic.java index 5107320a096..7e3ef02a411 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPrivilegedModeDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPrivilegedModeDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SeveralCompilerDirectivesDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SeveralCompilerDirectivesDiagnostic.java index bb2035ee2be..7ce31cf2443 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SeveralCompilerDirectivesDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SeveralCompilerDirectivesDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SpaceAtStartCommentDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SpaceAtStartCommentDiagnostic.java index 0e6cb6b984f..e7341928a72 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SpaceAtStartCommentDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SpaceAtStartCommentDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -72,7 +72,7 @@ public class SpaceAtStartCommentDiagnostic extends AbstractDiagnostic implements @DiagnosticParameter( type = String.class, - defaultValue = "" + DEFAULT_COMMENTS_ANNOTATION + defaultValue = DEFAULT_COMMENTS_ANNOTATION ) private Pattern commentsAnnotation = DiagnosticHelper.createPatternFromString(DEFAULT_COMMENTS_ANNOTATION); @@ -116,7 +116,7 @@ public List getQuickFixes( diagnostics.forEach((Diagnostic diagnostic) -> { var range = diagnostic.getRange(); - String currentText = documentContext.getText(range); + var currentText = documentContext.getText(range); var textEdit = new TextEdit( range, diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/StyleElementConstructorsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/StyleElementConstructorsDiagnostic.java index c8e94f90236..192b3ed210b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/StyleElementConstructorsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/StyleElementConstructorsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TempFilesDirDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TempFilesDirDiagnostic.java index 5dce0d1baa5..968c4fc6992 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TempFilesDirDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TempFilesDirDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TernaryOperatorUsageDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TernaryOperatorUsageDiagnostic.java index 5ec3c096d23..e9379f68cfb 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TernaryOperatorUsageDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TernaryOperatorUsageDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ThisObjectAssignDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ThisObjectAssignDiagnostic.java index ff8462cdd93..4ede7ef7381 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ThisObjectAssignDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ThisObjectAssignDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TimeoutsInExternalResourcesDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TimeoutsInExternalResourcesDiagnostic.java index e06d7039cd8..10ffa1aef88 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TimeoutsInExternalResourcesDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TimeoutsInExternalResourcesDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TooManyReturnsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TooManyReturnsDiagnostic.java index b06fca52a31..d4f30b9910f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TooManyReturnsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TooManyReturnsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnostic.java index a891f1804f9..99e6b35144b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -58,13 +58,13 @@ DiagnosticTag.STANDARD } ) - @RequiredArgsConstructor public class TransferringParametersBetweenClientAndServerDiagnostic extends AbstractDiagnostic { private static final Set SERVER_COMPILER_DIRECTIVE_KINDS = EnumSet.of( CompilerDirectiveKind.AT_SERVER, CompilerDirectiveKind.AT_SERVER_NO_CONTEXT ); + private final ReferenceIndex referenceIndex; // Не учитываются вложенные вызовы. Только прямые - клиентский метод вызывает серверный метод напрямую @@ -86,7 +86,7 @@ private Stream calcIssues() { } private Optional getParamReference(MethodSymbol method) { - List parameterDefinitions = calcNotAssignedParams(method); + var parameterDefinitions = calcNotAssignedParams(method); if (parameterDefinitions.isEmpty()) { return Optional.empty(); } @@ -99,17 +99,18 @@ private Optional getParamReference(MethodSymbol method) { } private List calcNotAssignedParams(MethodSymbol method) { - List parameterDefinitions = getMethodParamsByRef(method); + var parameterDefinitions = getMethodParamsByRef(method); if (parameterDefinitions.isEmpty()) { return Collections.emptyList(); } return calcNotAssignedParams(method, parameterDefinitions); } - private List calcNotAssignedParams(MethodSymbol method, List parameterDefinitions) { + private List calcNotAssignedParams(MethodSymbol method, + List parameterDefinitions) { return parameterDefinitions.stream() .filter(parameterDefinition -> isAssignedParam(method, parameterDefinition)) - .collect(Collectors.toUnmodifiableList()); + .toList(); } private boolean isAssignedParam(MethodSymbol method, ParameterDefinition parameterDefinition) { @@ -118,7 +119,8 @@ private boolean isAssignedParam(MethodSymbol method, ParameterDefinition paramet .anyMatch(ref -> ref.getOccurrenceType() == OccurrenceType.DEFINITION)); } - private static Stream getVariableByParameter(MethodSymbol method, ParameterDefinition parameterDefinition) { + private static Stream getVariableByParameter(MethodSymbol method, + ParameterDefinition parameterDefinition) { return method.getChildren().stream() // в будущем могут появиться и другие символы, подчиненные методам .filter(sourceDefinedSymbol -> sourceDefinedSymbol.getSymbolKind() == SymbolKind.Variable) @@ -133,7 +135,7 @@ private List getRefsFromClientCalls(MethodSymbol method) { // в будущем могут появиться и другие виды ссылок .filter(ref -> ref.getOccurrenceType() == OccurrenceType.REFERENCE) .filter(TransferringParametersBetweenClientAndServerDiagnostic::isClientCall) - .collect(Collectors.toUnmodifiableList()); + .toList(); } private static boolean isClientCall(Reference ref) { @@ -159,7 +161,7 @@ private static boolean isEqualCompilerDirective(MethodSymbol method) { private static List getMethodParamsByRef(MethodSymbol methodSymbol) { return methodSymbol.getParameters().stream() .filter(parameterDefinition -> !parameterDefinition.isByValue()) - .collect(Collectors.toUnmodifiableList()); + .toList(); } private static List getRelatedInformation(List references) { diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TryNumberDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TryNumberDiagnostic.java index 9e7741f7014..5df398eeb24 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TryNumberDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TryNumberDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TypoDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TypoDiagnostic.java index 804a7f72b3c..32db59a0a11 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TypoDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TypoDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -38,8 +38,7 @@ import org.antlr.v4.runtime.Token; import org.apache.commons.lang3.StringUtils; import org.languagetool.JLanguageTool; -import org.languagetool.language.AmericanEnglish; -import org.languagetool.language.Russian; +import org.languagetool.Languages; import org.languagetool.rules.RuleMatch; import java.io.IOException; @@ -68,8 +67,8 @@ public class TypoDiagnostic extends AbstractDiagnostic { @Getter(lazy = true, value = AccessLevel.PRIVATE) private static final Map languageToolPoolMap = Map.of( - "en", new JLanguageToolPool(new AmericanEnglish()), - "ru", new JLanguageToolPool(new Russian()) + "en", new JLanguageToolPool(Languages.getLanguageForShortCode("en-US")), + "ru", new JLanguageToolPool(Languages.getLanguageForShortCode("ru")) ); /** diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnaryPlusInConcatenationDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnaryPlusInConcatenationDiagnostic.java index 119f93c5539..162872cff59 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnaryPlusInConcatenationDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnaryPlusInConcatenationDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnionAllDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnionAllDiagnostic.java index 5a37399a69b..4c826bda573 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnionAllDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnionAllDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnknownPreprocessorSymbolDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnknownPreprocessorSymbolDiagnostic.java index 47e4e98b408..6977413e068 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnknownPreprocessorSymbolDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnknownPreprocessorSymbolDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnreachableCodeDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnreachableCodeDiagnostic.java index d62d5678398..a88bb85abab 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnreachableCodeDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnreachableCodeDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnsafeSafeModeMethodCallDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnsafeSafeModeMethodCallDiagnostic.java index 2f8b9976495..41e9eff42b9 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnsafeSafeModeMethodCallDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnsafeSafeModeMethodCallDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnostic.java index 886c7f2ae55..b04114a518e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -37,18 +37,17 @@ import org.antlr.v4.runtime.tree.Trees; import java.util.EnumSet; -import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.regex.Pattern; -import java.util.stream.Collectors; @DiagnosticMetadata( type = DiagnosticType.CODE_SMELL, severity = DiagnosticSeverity.MAJOR, modules = { - ModuleType.CommonModule + ModuleType.CommonModule, + ModuleType.ObjectModule }, minutesToFix = 1, tags = { @@ -74,6 +73,7 @@ public class UnusedLocalMethodDiagnostic extends AbstractVisitorDiagnostic { AnnotationKind.BEFORE, AnnotationKind.CHANGEANDVALIDATE ); + private static final boolean CHECK_OBJECT_MODULE = false; @DiagnosticParameter( type = String.class, @@ -81,10 +81,18 @@ public class UnusedLocalMethodDiagnostic extends AbstractVisitorDiagnostic { ) private Pattern attachableMethodPrefixes = DiagnosticHelper.createPatternFromString(ATTACHABLE_METHOD_PREFIXES); + @DiagnosticParameter( + type = Boolean.class, + defaultValue = "" + CHECK_OBJECT_MODULE + ) + private boolean checkObjectModule = CHECK_OBJECT_MODULE; + @Override public void configure(Map configuration) { this.attachableMethodPrefixes = DiagnosticHelper.createPatternFromString( (String) configuration.getOrDefault("attachableMethodPrefixes", ATTACHABLE_METHOD_PREFIXES)); + + this.checkObjectModule = (boolean) configuration.getOrDefault("checkObjectModule", CHECK_OBJECT_MODULE); } private boolean isAttachable(MethodSymbol methodSymbol) { @@ -104,12 +112,16 @@ private static boolean isOverride(MethodSymbol method) { @Override public ParseTree visitFile(BSLParser.FileContext ctx) { + var moduleType = documentContext.getModuleType(); + if (!checkObjectModule && moduleType == ModuleType.ObjectModule) { + return ctx; + } - List collect = Trees.findAllRuleNodes(ctx, BSLParser.RULE_globalMethodCall) + var collect = Trees.findAllRuleNodes(ctx, BSLParser.RULE_globalMethodCall) .stream() .map(parseTree -> ((BSLParser.GlobalMethodCallContext) parseTree).methodName().getText().toLowerCase(Locale.ENGLISH)) - .collect(Collectors.toList()); + .toList(); documentContext.getSymbolTree().getMethods() .stream() diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnostic.java index 3e64d706021..f9308c3caf6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedParametersDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedParametersDiagnostic.java index 18c8a51ecaf..a3d6a21abcc 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedParametersDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedParametersDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -30,12 +30,9 @@ import com.github._1c_syntax.bsl.parser.BSLParser; import com.github._1c_syntax.utils.CaseInsensitivePattern; import org.antlr.v4.runtime.tree.ParseTree; -import org.antlr.v4.runtime.tree.TerminalNode; -import java.util.List; import java.util.Locale; import java.util.Objects; -import java.util.Optional; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -63,14 +60,14 @@ public ParseTree visitSubCodeBlock(BSLParser.SubCodeBlockContext ctx) { return ctx; } - List params = Trees.findAllRuleNodes(ctx.getParent(), BSLParser.RULE_param) + var params = Trees.findAllRuleNodes(ctx.getParent(), BSLParser.RULE_param) .stream() .map(BSLParser.ParamContext.class::cast) .map(BSLParser.ParamContext::IDENTIFIER) .filter(Objects::nonNull) - .collect(Collectors.toList()); + .toList(); - List paramsNames = params + var paramsNames = params .stream() .map(ind -> ind.getText().toLowerCase(Locale.getDefault())) .collect(Collectors.toList()); @@ -93,15 +90,11 @@ public ParseTree visitSubCodeBlock(BSLParser.SubCodeBlockContext ctx) { } private static boolean itsHandler(BSLParser.SubCodeBlockContext ctx) { - - Optional subNames = Trees.findAllRuleNodes(ctx.getParent(), BSLParser.RULE_subName).stream().findFirst(); - - String subName = ""; + var subNames = Trees.findAllRuleNodes(ctx.getParent(), BSLParser.RULE_subName).stream().findFirst(); + var subName = ""; if (subNames.isPresent()) { subName = subNames.get().getText(); } - return HANDLER_PATTERN.matcher(subName).matches(); } - } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsageWriteLogEventDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsageWriteLogEventDiagnostic.java index d8a1674db97..fcc14160600 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsageWriteLogEventDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsageWriteLogEventDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseLessForEachDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseLessForEachDiagnostic.java index 953c7b9c046..b82df25e064 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseLessForEachDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseLessForEachDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseSystemInformationDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseSystemInformationDiagnostic.java index 7290a126e12..83310f1d55d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseSystemInformationDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseSystemInformationDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingCancelParameterDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingCancelParameterDiagnostic.java index 540b515d5f4..1f3d72eae1d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingCancelParameterDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingCancelParameterDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingExternalCodeToolsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingExternalCodeToolsDiagnostic.java index 4423c1336d3..0af1d03913c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingExternalCodeToolsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingExternalCodeToolsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnostic.java index 7414902952d..23bd8100480 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -30,7 +30,6 @@ import com.github._1c_syntax.utils.CaseInsensitivePattern; import org.antlr.v4.runtime.tree.ParseTree; -import java.util.regex.Matcher; import java.util.regex.Pattern; @DiagnosticMetadata( @@ -48,13 +47,13 @@ public class UsingFindElementByStringDiagnostic extends AbstractVisitorDiagnostic { private final Pattern pattern = CaseInsensitivePattern.compile( - "(НайтиПоНаименованию|FindByDescription|НайтиПоКоду|FindByCode)" + "(НайтиПоНаименованию|FindByDescription|НайтиПоКоду|FindByCode|НайтиПоНомеру|FindByNumber)" ); @Override public ParseTree visitMethodCall(BSLParser.MethodCallContext ctx) { - Matcher matcher = pattern.matcher(ctx.methodName().getText()); - if (matcher.find()) { + var matcher = pattern.matcher(ctx.methodName().getText()); + if (matcher.matches()) { BSLParser.CallParamContext param = ctx.doCall().callParamList().callParam().get(0); if (param.children == null || param.getStart().getType() == BSLParser.STRING || diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingGotoDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingGotoDiagnostic.java index 03b1105fb5d..8d9886ced66 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingGotoDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingGotoDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeNetworkAddressDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeNetworkAddressDiagnostic.java index bb99b6e7df8..58864961406 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeNetworkAddressDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeNetworkAddressDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodePathDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodePathDiagnostic.java index 0d9437367f4..30a235b71dd 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodePathDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodePathDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeSecretInformationDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeSecretInformationDiagnostic.java index bc0279b1e06..a4ff6f4e3f0 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeSecretInformationDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeSecretInformationDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingLikeInQueryDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingLikeInQueryDiagnostic.java index 7d17fcc5ec9..c86a2c15c95 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingLikeInQueryDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingLikeInQueryDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingModalWindowsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingModalWindowsDiagnostic.java index 327938e4fac..d32f2a5ebb6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingModalWindowsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingModalWindowsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -28,6 +28,7 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdclasses.Configuration; import com.github._1c_syntax.bsl.mdo.support.UseMode; import com.github._1c_syntax.bsl.parser.BSLParser; import com.github._1c_syntax.utils.CaseInsensitivePattern; @@ -95,10 +96,10 @@ public UsingModalWindowsDiagnostic() { @Override public ParseTree visitFile(BSLParser.FileContext ctx) { var configuration = documentContext.getServerContext().getConfiguration(); - // если использование модальных окон разрешено (без предупреждение) + // если использование модальных окон разрешено (без предупреждения) // и не установлен флаг игнорирования использования модальных окон, то // ничего не диагностируется - if (!forceModalityMode && configuration.getModalityUseMode() == UseMode.USE) { + if (!forceModalityMode && configuration instanceof Configuration cf && cf.getModalityUseMode() == UseMode.USE) { return ctx; } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingObjectNotAvailableUnixDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingObjectNotAvailableUnixDiagnostic.java index 224b80f160b..c78604e5488 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingObjectNotAvailableUnixDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingObjectNotAvailableUnixDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingServiceTagDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingServiceTagDiagnostic.java index d9ebe30ef31..e5f27ace558 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingServiceTagDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingServiceTagDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -29,7 +29,6 @@ import org.antlr.v4.runtime.Token; import java.util.Map; -import java.util.regex.Matcher; import java.util.regex.Pattern; @DiagnosticMetadata( @@ -49,7 +48,7 @@ public class UsingServiceTagDiagnostic extends AbstractDiagnostic { @DiagnosticParameter( type = String.class, - defaultValue = "" + SERVICE_TAGS_DEFAULT + defaultValue = SERVICE_TAGS_DEFAULT ) private String serviceTags = SERVICE_TAGS_DEFAULT; private Pattern pattern = getPatternSearch(SERVICE_TAGS_DEFAULT); @@ -71,7 +70,7 @@ public void check() { documentContext.getComments() .parallelStream() .forEach((Token token) -> { - Matcher matcher = pattern.matcher(token.getText()); + var matcher = pattern.matcher(token.getText()); if (!matcher.find()) { return; } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnostic.java index 0622ad0e411..3c65954060d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -28,6 +28,7 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.mdclasses.Configuration; import com.github._1c_syntax.bsl.mdo.support.UseMode; import com.github._1c_syntax.bsl.parser.BSLParser; import com.github._1c_syntax.utils.CaseInsensitivePattern; @@ -127,9 +128,9 @@ public UsingSynchronousCallsDiagnostic() { @Override public ParseTree visitFile(BSLParser.FileContext ctx) { var configuration = documentContext.getServerContext().getConfiguration(); - // если использование синхронных вызовов разрешено (без предупреждение), то + // если использование синхронных вызовов разрешено (без предупреждения), то // ничего не диагностируется - if (configuration.getSynchronousExtensionAndAddInCallUseMode() == UseMode.USE) { + if (configuration instanceof Configuration cf && cf.getSynchronousExtensionAndAddInCallUseMode() == UseMode.USE) { return ctx; } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingThisFormDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingThisFormDiagnostic.java index e6a0c62fa0a..0bc8af1032d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingThisFormDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingThisFormDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/VirtualTableCallWithoutParametersDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/VirtualTableCallWithoutParametersDiagnostic.java index dbcc5b4cb34..d17047b1ae8 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/VirtualTableCallWithoutParametersDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/VirtualTableCallWithoutParametersDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnostic.java index 1f7085631e2..a0e573239a2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -27,11 +27,11 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; import com.github._1c_syntax.bsl.languageserver.utils.Ranges; +import com.github._1c_syntax.bsl.mdo.Form; +import com.github._1c_syntax.bsl.mdo.MD; +import com.github._1c_syntax.bsl.mdo.storage.form.FormItem; import com.github._1c_syntax.bsl.mdo.support.ScriptVariant; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; -import com.github._1c_syntax.mdclasses.mdo.children.Form; -import com.github._1c_syntax.mdclasses.mdo.children.form.FormItem; import org.eclipse.lsp4j.Range; import java.util.function.Predicate; @@ -50,7 +50,6 @@ tags = { DiagnosticTag.UNPREDICTABLE, } - ) public class WrongDataPathForFormElementsDiagnostic extends AbstractDiagnostic { @@ -58,7 +57,6 @@ public class WrongDataPathForFormElementsDiagnostic extends AbstractDiagnostic { @Override protected void check() { - var range = documentContext.getSymbolTree().getModule().getSelectionRange(); if (!Ranges.isEmpty(range)) { checkCurrentModule(range); @@ -66,7 +64,7 @@ protected void check() { } private static boolean wrongDataPath(FormItem formItem) { - return formItem.getDataPath().getSegment().startsWith("~"); + return formItem.getDataPath().getSegments().startsWith("~"); } private static boolean haveFormModules(Form form) { @@ -86,11 +84,10 @@ private void checkCurrentModule(Range range) { private void checkAllFormsWithoutModules() { checkMdoObjectStream(form -> !haveFormModules(form), - documentContext.getServerContext().getConfiguration().getChildrenByMdoRef().values().stream()); + documentContext.getServerContext().getConfiguration().getPlainChildren().stream()); } - private void checkMdoObjectStream(Predicate
formFilter, Stream stream) { - + private void checkMdoObjectStream(Predicate formFilter, Stream stream) { stream .filter(Form.class::isInstance) .map(Form.class::cast) @@ -99,13 +96,11 @@ private void checkMdoObjectStream(Predicate formFilter, Stream diagnosticStorage.addDiagnostic(diagnosticRange, diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongHttpServiceHandlerDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongHttpServiceHandlerDiagnostic.java index 96a85efae00..7d183c65bdd 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongHttpServiceHandlerDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongHttpServiceHandlerDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -28,9 +28,9 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; import com.github._1c_syntax.bsl.languageserver.utils.Ranges; +import com.github._1c_syntax.bsl.mdo.HTTPService; +import com.github._1c_syntax.bsl.mdo.children.HTTPServiceMethod; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.MDHttpService; -import com.github._1c_syntax.mdclasses.mdo.children.HTTPServiceMethod; import org.eclipse.lsp4j.Range; @DiagnosticMetadata( @@ -64,18 +64,16 @@ protected void check() { private void processModule() { documentContext.getMdObject() - .filter(MDHttpService.class::isInstance) - .map(MDHttpService.class::cast) + .filter(HTTPService.class::isInstance) + .map(HTTPService.class::cast) .ifPresent(this::checkService); } - private void checkService(MDHttpService mdHttpService) { - - mdHttpService.getUrlTemplates().stream() - .flatMap(httpServiceURLTemplate -> httpServiceURLTemplate.getHttpServiceMethods().stream()) + private void checkService(HTTPService httpService) { + httpService.getUrlTemplates().stream() + .flatMap(httpServiceURLTemplate -> httpServiceURLTemplate.getMethods().stream()) .forEach((HTTPServiceMethod service) -> { final var serviceName = service.getMdoReference().getMdoRef(); - if (service.getHandler().isEmpty()) { addMissingHandlerDiagnostic(serviceName); return; diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseFunctionProceedWithCallDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseFunctionProceedWithCallDiagnostic.java index 78ba1a15060..148c68888f2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseFunctionProceedWithCallDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseFunctionProceedWithCallDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseOfRollbackTransactionMethodDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseOfRollbackTransactionMethodDiagnostic.java index 910e148f784..2ee8488594a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseOfRollbackTransactionMethodDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseOfRollbackTransactionMethodDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -31,7 +31,6 @@ import com.github._1c_syntax.utils.CaseInsensitivePattern; import java.util.regex.Pattern; -import java.util.stream.Collectors; @DiagnosticMetadata( type = DiagnosticType.ERROR, @@ -41,7 +40,6 @@ tags = { DiagnosticTag.STANDARD } - ) public class WrongUseOfRollbackTransactionMethodDiagnostic extends AbstractFindMethodDiagnostic { @@ -65,7 +63,7 @@ protected boolean checkGlobalMethodCall(BSLParser.GlobalMethodCallContext ctx) { var methodsList = Trees.findAllRuleNodes(parentNode, BSLParser.RULE_globalMethodCall).stream() .map(BSLParser.GlobalMethodCallContext.class::cast) .map(e -> e.methodName().getText()) - .collect(Collectors.toList()); + .toList(); if (MESSAGE_PATTERN.matcher(ctx.methodName().getText()).matches()) { return methodsList.indexOf(ctx.methodName().getText()) != 0; diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongWebServiceHandlerDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongWebServiceHandlerDiagnostic.java index aeaa7be9699..27ad40d53d4 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongWebServiceHandlerDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongWebServiceHandlerDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -27,9 +27,9 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; import com.github._1c_syntax.bsl.languageserver.utils.Ranges; +import com.github._1c_syntax.bsl.mdo.WebService; +import com.github._1c_syntax.bsl.mdo.children.WebServiceOperation; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.MDWebService; -import com.github._1c_syntax.mdclasses.mdo.children.WEBServiceOperation; import org.eclipse.lsp4j.Range; @DiagnosticMetadata( @@ -63,20 +63,19 @@ protected void check() { private void processModule() { documentContext.getMdObject() - .filter(MDWebService.class::isInstance) - .map(MDWebService.class::cast) + .filter(WebService.class::isInstance) + .map(WebService.class::cast) .ifPresent(this::checkService); } - private void checkService(MDWebService mdWebService) { - + private void checkService(WebService mdWebService) { mdWebService.getOperations() .forEach(webServiceOperation -> checkOperation(mdWebService.getName(), webServiceOperation)); } - private void checkOperation(String serviceName, WEBServiceOperation webServiceOperation) { + private void checkOperation(String serviceName, WebServiceOperation webServiceOperation) { final var operationName = webServiceOperation.getName(); - final var handler = webServiceOperation.getHandler(); + final var handler = webServiceOperation.getProcedureName(); if (handler.isEmpty()) { addMissingHandlerDiagnostic(serviceName, operationName); return; @@ -101,5 +100,4 @@ private void addMissingHandlerDiagnostic(String serviceName, String operationNam diagnosticRange, info.getResourceString("missingHandler", operationName, serviceName)); } - } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/YoLetterUsageDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/YoLetterUsageDiagnostic.java index c7fc53f89a7..fef6ed25a34 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/YoLetterUsageDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/YoLetterUsageDiagnostic.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticBeanPostProcessor.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticBeanPostProcessor.java index d2a164f4fa1..3663d0453b6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticBeanPostProcessor.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticBeanPostProcessor.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -44,7 +44,7 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) { return bean; } - BSLDiagnostic diagnostic = (BSLDiagnostic) bean; + var diagnostic = (BSLDiagnostic) bean; var info = diagnosticInfos.get(diagnostic.getClass()); diagnostic.setInfo(info); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticInfosConfiguration.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticInfosConfiguration.java index 3c98b8ac90f..99e0b47052a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticInfosConfiguration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticInfosConfiguration.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticObjectProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticObjectProvider.java index 9892536bf70..865a2922549 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticObjectProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticObjectProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticsConfiguration.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticsConfiguration.java index 47386ef182a..a32fd4660b4 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticsConfiguration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticsConfiguration.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -31,12 +31,12 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticCompatibilityMode; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticInfo; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticScope; -import com.github._1c_syntax.bsl.supconf.SupportConfiguration; +import com.github._1c_syntax.bsl.mdclasses.CF; +import com.github._1c_syntax.bsl.mdo.MD; +import com.github._1c_syntax.bsl.mdo.MDChild; import com.github._1c_syntax.bsl.support.CompatibilityMode; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; -import com.github._1c_syntax.mdclasses.mdo.MDSubsystem; import lombok.RequiredArgsConstructor; import org.eclipse.lsp4j.jsonrpc.messages.Either; import org.springframework.beans.factory.annotation.Lookup; @@ -47,11 +47,9 @@ import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import java.util.stream.Stream; @Configuration @RequiredArgsConstructor @@ -64,17 +62,16 @@ public abstract class DiagnosticsConfiguration { @Scope("prototype") public List diagnostics(DocumentContext documentContext) { - Collection diagnosticInfos = diagnosticInfos(); - - DiagnosticsOptions diagnosticsOptions = configuration.getDiagnosticsOptions(); + var diagnosticInfos = diagnosticInfos(); + var diagnosticsOptions = configuration.getDiagnosticsOptions(); if (needToComputeDiagnostics(documentContext, diagnosticsOptions)) { - FileType fileType = documentContext.getFileType(); - CompatibilityMode compatibilityMode = documentContext + var fileType = documentContext.getFileType(); + var compatibilityMode = documentContext .getServerContext() .getConfiguration() .getCompatibilityMode(); - ModuleType moduleType = documentContext.getModuleType(); + var moduleType = documentContext.getModuleType(); return diagnosticInfos.stream() .filter(diagnosticInfo -> isEnabled(diagnosticInfo, diagnosticsOptions)) @@ -110,9 +107,7 @@ private static boolean filterSubsystems(DocumentContext documentContext, Diagnos return true; } - var subsystemsNames = subsystemFlatList(mdoObject.get().getIncludedSubsystems()).stream() - .map(AbstractMDObjectBase::getName) - .collect(Collectors.toList()); + var subsystemsNames = getSubsystemNames(documentContext.getServerContext().getConfiguration(), mdoObject.get()); var include = subsystemsFilter.getInclude().isEmpty() || subsystemsNames.stream() @@ -133,16 +128,11 @@ private static boolean checkSupport(DocumentContext documentContext, Diagnostics } var configuredSkipSupport = diagnosticsOptions.getSkipSupport(); - if (configuredSkipSupport == SkipSupport.NEVER) { return true; } - Map supportVariants = documentContext.getSupportVariants(); - var moduleSupportVariant = supportVariants.values().stream() - .min(Comparator.naturalOrder()) - .orElse(SupportVariant.NONE); - + var moduleSupportVariant = documentContext.getSupportVariant(); if (moduleSupportVariant == SupportVariant.NONE) { return true; } @@ -155,7 +145,6 @@ private static boolean checkSupport(DocumentContext documentContext, Diagnostics } private boolean isEnabled(DiagnosticInfo diagnosticInfo, DiagnosticsOptions diagnosticsOptions) { - var mode = diagnosticsOptions.getMode(); if (mode == Mode.OFF) { return false; @@ -188,7 +177,7 @@ private boolean isEnabled(DiagnosticInfo diagnosticInfo, DiagnosticsOptions diag } private static boolean inScope(DiagnosticInfo diagnosticInfo, FileType fileType) { - DiagnosticScope scope = diagnosticInfo.getScope(); + var scope = diagnosticInfo.getScope(); DiagnosticScope fileScope; if (fileType == FileType.OS) { fileScope = DiagnosticScope.OS; @@ -204,13 +193,13 @@ private static boolean correctModuleType(DiagnosticInfo diagnosticInfo, ModuleTy return true; } - ModuleType[] diagnosticModules = diagnosticInfo.getModules(); + var diagnosticModules = diagnosticInfo.getModules(); if (diagnosticModules.length == 0) { return true; } - boolean contain = false; + var contain = false; for (ModuleType module : diagnosticModules) { if (module == moduletype) { contain = true; @@ -224,8 +213,7 @@ private static boolean passedCompatibilityMode( DiagnosticInfo diagnosticInfo, CompatibilityMode contextCompatibilityMode ) { - DiagnosticCompatibilityMode compatibilityMode = diagnosticInfo.getCompatibilityMode(); - + var compatibilityMode = diagnosticInfo.getCompatibilityMode(); if (compatibilityMode == DiagnosticCompatibilityMode.UNDEFINED) { return true; } @@ -233,11 +221,20 @@ private static boolean passedCompatibilityMode( return CompatibilityMode.compareTo(compatibilityMode.getCompatibilityMode(), contextCompatibilityMode) >= 0; } - // перенести в mdClasses - private static List subsystemFlatList(Collection subsystems) { - return subsystems.stream() - .flatMap(subsys -> Stream.concat(Stream.of(subsys), subsystemFlatList(subsys.getIncludedSubsystems()).stream())) + private static List getSubsystemNames(CF configuration, MD mdObject) { + var subsystemsNames = configuration + .includedSubsystems(mdObject, true) + .stream() + .map(MD::getName) .collect(Collectors.toList()); - } + // если объект не обнаружен, попробуем поискать его родителя + if (subsystemsNames.isEmpty() && mdObject instanceof MDChild child) { + var parent = configuration.findChild(child.getOwner()); + if (parent.isPresent()) { + subsystemsNames = getSubsystemNames(configuration, parent.get()); + } + } + return subsystemsNames; + } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/Disabled.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/Disabled.java index 2f7e686db05..4f561691eaa 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/Disabled.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/Disabled.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/package-info.java index 19e53bacee5..6a586b7b560 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticCode.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticCode.java index d173a8ed321..781534ce0e2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticCode.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticCode.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticCompatibilityMode.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticCompatibilityMode.java index d1d5ee259d0..d33f1d93bbc 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticCompatibilityMode.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticCompatibilityMode.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -22,6 +22,7 @@ package com.github._1c_syntax.bsl.languageserver.diagnostics.metadata; import com.github._1c_syntax.bsl.support.CompatibilityMode; +import lombok.Getter; public enum DiagnosticCompatibilityMode { UNDEFINED(0, 0), @@ -48,16 +49,15 @@ public enum DiagnosticCompatibilityMode { COMPATIBILITY_MODE_8_3_18(3, 18), COMPATIBILITY_MODE_8_3_19(3, 19), COMPATIBILITY_MODE_8_3_20(3, 20), - COMPATIBILITY_MODE_8_3_21(3, 21) - ; + COMPATIBILITY_MODE_8_3_21(3, 21), + COMPATIBILITY_MODE_8_3_22(3, 22), + COMPATIBILITY_MODE_8_3_23(3, 23), + COMPATIBILITY_MODE_8_3_24(3, 24); + @Getter private final CompatibilityMode compatibilityMode; DiagnosticCompatibilityMode(int minor, int version) { this.compatibilityMode = new CompatibilityMode(minor, version); } - - public CompatibilityMode getCompatibilityMode() { - return compatibilityMode; - } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticInfo.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticInfo.java index eaf151b2d26..7c0d2c2aff7 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticInfo.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticInfo.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -27,11 +27,11 @@ import com.github._1c_syntax.bsl.languageserver.utils.Resources; import com.github._1c_syntax.bsl.types.ModuleType; import com.github._1c_syntax.utils.StringInterner; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import java.io.IOException; -import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; @@ -49,6 +49,7 @@ public class DiagnosticInfo { = createSeverityToLSPSeverityMap(); private static final Map diagnosticTagMap = createDiagnosticTagMap(); + @Getter private final Class diagnosticClass; private final LanguageServerConfiguration configuration; private final StringInterner stringInterner; @@ -71,17 +72,13 @@ public DiagnosticInfo( diagnosticParameters = DiagnosticParameterInfo.createDiagnosticParameters(this); } - public Class getDiagnosticClass() { - return diagnosticClass; - } - public DiagnosticCode getCode() { return diagnosticCode; } public String getDiagnosticCodeDescriptionHref() { var language = configuration.getLanguage(); - boolean useDevSite = configuration.isUseDevSite(); + var useDevSite = configuration.isUseDevSite(); var siteRoot = configuration.getSiteRoot(); var devSuffix = useDevSite ? "/dev" : ""; @@ -102,10 +99,10 @@ public String getName() { } public String getDescription() { - String langCode = configuration.getLanguage().getLanguageCode(); + var langCode = configuration.getLanguage().getLanguageCode(); - String resourceName = langCode + "/" + diagnosticCode.getStringValue() + ".md"; - InputStream descriptionStream = diagnosticClass.getResourceAsStream(resourceName); + var resourceName = langCode + "/" + diagnosticCode.getStringValue() + ".md"; + var descriptionStream = diagnosticClass.getResourceAsStream(resourceName); if (descriptionStream == null) { LOGGER.error("Can't find resource {}", resourceName); @@ -194,6 +191,14 @@ public Optional getParameter(String parameterName) { return diagnosticParameters.stream().filter(param -> param.getName().equals(parameterName)).findAny(); } + public boolean canLocateOnProject() { + return diagnosticMetadata.canLocateOnProject(); + } + + public double getExtraMinForComplexity() { + return diagnosticMetadata.extraMinForComplexity(); + } + public Map getDefaultConfiguration() { return diagnosticParameters.stream() .collect(Collectors.toMap(DiagnosticParameterInfo::getName, DiagnosticParameterInfo::getDefaultValue)); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticMetadata.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticMetadata.java index 6a452a6ffb0..ad4c2979aa3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticMetadata.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticMetadata.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -39,19 +39,53 @@ @Primary @Scope("prototype") public @interface DiagnosticMetadata { + /** + * Тип диагностики + */ DiagnosticType type() default DiagnosticType.ERROR; + /** + * Серьезность замечания + */ DiagnosticSeverity severity() default DiagnosticSeverity.MINOR; + /** + * Область применения диагностики по диалекту языка (bsl или oscript) + */ DiagnosticScope scope() default DiagnosticScope.ALL; + /** + * Типы модулей, анализируемых диагностикой + */ ModuleType[] modules() default {}; + /** + * Время, необходимое для исправления замечания + */ int minutesToFix() default 0; + /** + * Признак включения диагностики в профиле по умолчанию + */ boolean activatedByDefault() default true; + /** + * Версия платформы 1С:Предприятие, с которой диагностика применяется + */ DiagnosticCompatibilityMode compatibilityMode() default DiagnosticCompatibilityMode.UNDEFINED; + /** + * Перечень меток (тегов) диагностики + */ DiagnosticTag[] tags() default {}; + + /** + * Замечания диагностики могут быть прикреплены на уровень анализируемого проекта (в частности в SonarQube) + */ + boolean canLocateOnProject() default false; + + /** + * Надбавка ко времени исправления замечания за повышенную сложность + */ + double extraMinForComplexity() default 0; } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticParameter.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticParameter.java index 2e40852fb11..352ba9d873c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticParameter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticParameter.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticParameterInfo.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticParameterInfo.java index 5e27e578cdb..ffd1b2f76ac 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticParameterInfo.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticParameterInfo.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -21,11 +21,17 @@ */ package com.github._1c_syntax.bsl.languageserver.diagnostics.metadata; +import lombok.Getter; + import java.lang.reflect.Field; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; +/** + * Описание параметров диагностики + */ +@Getter public final class DiagnosticParameterInfo { private final Class type; @@ -34,29 +40,11 @@ public final class DiagnosticParameterInfo { private final Object defaultValue; private DiagnosticParameterInfo(Field field, String description) { - DiagnosticParameter diagnosticParameter = field.getAnnotation(DiagnosticParameter.class); this.type = diagnosticParameter.type(); this.name = field.getName(); this.description = description; this.defaultValue = castDiagnosticParameterValue(diagnosticParameter.defaultValue()); - - } - - public Class getType() { - return type; - } - - public String getName() { - return name; - } - - public String getDescription() { - return this.description; - } - - public Object getDefaultValue() { - return this.defaultValue; } private Object castDiagnosticParameterValue(String valueToCast) { diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticScope.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticScope.java index f904b2d69cc..72b527f8918 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticScope.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticScope.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticSeverity.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticSeverity.java index e03c105e427..ec43834b3d6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticSeverity.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticSeverity.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticTag.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticTag.java index fa5b8632bf9..471ed773fb7 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticTag.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticTag.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -21,6 +21,11 @@ */ package com.github._1c_syntax.bsl.languageserver.diagnostics.metadata; +import lombok.Getter; + +/** + * Варианты тегов диагностик + */ public enum DiagnosticTag { STANDARD("Нарушение стандартов 1С"), LOCKINOS("Не будет работать в другой ОС"), @@ -37,13 +42,11 @@ public enum DiagnosticTag { ERROR("Ошибочная конструкция"), LOCALIZE("Проблемы локализации"); + @Getter private final String description; DiagnosticTag(String descriptionRu) { this.description = descriptionRu; } - public String getDescription() { - return description; - } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticType.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticType.java index d71777dcf04..6683a18ecba 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticType.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticType.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/package-info.java index 0b737a92089..f9bf1dc673f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/package-info.java index 7bfe61b4ecb..654e5fa820e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/typo/JLanguageToolPool.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/typo/JLanguageToolPool.java index a01f15f9a23..b9ad3dc17b0 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/typo/JLanguageToolPool.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/typo/JLanguageToolPool.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/documentlink/DiagnosticDescriptionDocumentLinkSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/documentlink/DiagnosticDescriptionDocumentLinkSupplier.java index 9589179f3fa..84ace808869 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/documentlink/DiagnosticDescriptionDocumentLinkSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/documentlink/DiagnosticDescriptionDocumentLinkSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/documentlink/DocumentLinkSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/documentlink/DocumentLinkSupplier.java index 39c4f6f7d88..feaebeaa226 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/documentlink/DocumentLinkSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/documentlink/DocumentLinkSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/documentlink/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/documentlink/package-info.java index 59a2af69363..4c0519b3089 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/documentlink/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/documentlink/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/events/LanguageServerInitializeRequestReceivedEvent.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/events/LanguageServerInitializeRequestReceivedEvent.java index 1f87425c6b9..6cb369704dd 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/events/LanguageServerInitializeRequestReceivedEvent.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/events/LanguageServerInitializeRequestReceivedEvent.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/events/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/events/package-info.java index ec8a9b42b85..f598ee19660 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/events/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/events/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/AbstractCommentFoldingRangeSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/AbstractCommentFoldingRangeSupplier.java index c45369b98a7..c8a87144fab 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/AbstractCommentFoldingRangeSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/AbstractCommentFoldingRangeSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/CodeBlockFoldingRangeSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/CodeBlockFoldingRangeSupplier.java index 4ff5ba8dcaf..d8f5c44b154 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/CodeBlockFoldingRangeSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/CodeBlockFoldingRangeSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -43,7 +43,7 @@ public class CodeBlockFoldingRangeSupplier implements FoldingRangeSupplier { @Override public List getFoldingRanges(DocumentContext documentContext) { - CodeBlockVisitor codeBlockVisitor = new CodeBlockVisitor(); + var codeBlockVisitor = new CodeBlockVisitor(); codeBlockVisitor.visitFile(documentContext.getAst()); return codeBlockVisitor.getRegionRanges(); } @@ -104,7 +104,7 @@ private void addRegionRange(@Nullable TerminalNode start, @Nullable TerminalNode int stopLine = stop.getSymbol().getLine(); if (stopLine > startLine) { - FoldingRange foldingRange = new FoldingRange(startLine - 1, stopLine - 1); + var foldingRange = new FoldingRange(startLine - 1, stopLine - 1); foldingRange.setKind(FoldingRangeKind.Region); regionRanges.add(foldingRange); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/CommentFoldingRangeSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/CommentFoldingRangeSupplier.java index ce3e7481fe5..bd2159a6a67 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/CommentFoldingRangeSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/CommentFoldingRangeSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/FoldingRangeSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/FoldingRangeSupplier.java index d629a73bbe3..b68a01c7984 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/FoldingRangeSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/FoldingRangeSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/PreprocIfFoldingRangeSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/PreprocIfFoldingRangeSupplier.java index cb5fbcbf073..5ba1970ac53 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/PreprocIfFoldingRangeSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/PreprocIfFoldingRangeSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryCommentFoldingRangeSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryCommentFoldingRangeSupplier.java index 69f638d44ad..27d6db1a44d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryCommentFoldingRangeSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryCommentFoldingRangeSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryPackageFoldingRangeSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryPackageFoldingRangeSupplier.java index c6a9986ad92..584a1a9fb1c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryPackageFoldingRangeSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryPackageFoldingRangeSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/RegionFoldingRangeSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/RegionFoldingRangeSupplier.java index dacc939481b..8b9adcf449d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/RegionFoldingRangeSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/RegionFoldingRangeSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/UseFoldingRangeSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/UseFoldingRangeSupplier.java index 1fc6e3271e7..3744d77b5fc 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/UseFoldingRangeSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/UseFoldingRangeSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/package-info.java index 8df58ac0838..899cf0674cf 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/folding/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/MarkupContentBuilder.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/MarkupContentBuilder.java index 406ab49e871..8ef2864767f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/MarkupContentBuilder.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/MarkupContentBuilder.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/MarkupContentBuilderConfiguration.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/MarkupContentBuilderConfiguration.java index 568845cbb1d..4b50b69af67 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/MarkupContentBuilderConfiguration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/MarkupContentBuilderConfiguration.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/MethodSymbolMarkupContentBuilder.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/MethodSymbolMarkupContentBuilder.java index da940f2a04d..de16d79d37f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/MethodSymbolMarkupContentBuilder.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/MethodSymbolMarkupContentBuilder.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/VariableSymbolMarkupContentBuilder.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/VariableSymbolMarkupContentBuilder.java index 045a4a45c32..0b442a85e0f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/VariableSymbolMarkupContentBuilder.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/VariableSymbolMarkupContentBuilder.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/package-info.java index b571bd8bac6..80fc3773041 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/LanguageClientAwareAppender.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/LanguageClientAwareAppender.java index 56a77678a51..3e69be06eef 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/LanguageClientAwareAppender.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/LanguageClientAwareAppender.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/LogbackConfiguration.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/LogbackConfiguration.java index eee439b6cbc..b7b74bd053c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/LogbackConfiguration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/LogbackConfiguration.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/SchedulingConfiguration.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/SchedulingConfiguration.java index 96c4766b3ff..125d10ea026 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/SchedulingConfiguration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/SchedulingConfiguration.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/UtilsConfiguration.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/UtilsConfiguration.java index 55480c69a23..fb0f8ffe8be 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/UtilsConfiguration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/UtilsConfiguration.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -22,19 +22,23 @@ package com.github._1c_syntax.bsl.languageserver.infrastructure; import com.github._1c_syntax.utils.StringInterner; +import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Role; /** * Конфигурация бинов из 1c-syntax/utils. */ @Configuration +@Role(BeanDefinition.ROLE_INFRASTRUCTURE) public class UtilsConfiguration { /** * @return Настроенный объект интернирователя строк. */ @Bean + @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public StringInterner stringInterner() { return new StringInterner(); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/package-info.java index 156128d9b20..6167f32c836 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/infrastructure/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/AbstractComplexityInlayHintSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/AbstractComplexityInlayHintSupplier.java index 636e8c83ceb..e6a3021aa9e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/AbstractComplexityInlayHintSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/AbstractComplexityInlayHintSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CognitiveComplexityInlayHintSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CognitiveComplexityInlayHintSupplier.java index 9acef3ce5f5..e1236c620f9 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CognitiveComplexityInlayHintSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CognitiveComplexityInlayHintSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CyclomaticComplexityInlayHintSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CyclomaticComplexityInlayHintSupplier.java index 4706d4fce7a..f1441f59a6a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CyclomaticComplexityInlayHintSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CyclomaticComplexityInlayHintSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/InlayHintSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/InlayHintSupplier.java index 8895dbea30c..d35ffc8e9e4 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/InlayHintSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/InlayHintSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplier.java index b3bce437605..d47e73023be 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -197,11 +197,9 @@ private boolean showDefaultValues() { private static boolean isRightMethod(BSLParserRuleContext doCallParent, Reference reference) { var selectionRange = reference.getSelectionRange(); - if (doCallParent instanceof BSLParser.MethodCallContext) { - var methodCallContext = (BSLParser.MethodCallContext) doCallParent; + if (doCallParent instanceof BSLParser.MethodCallContext methodCallContext) { return selectionRange.equals(Ranges.create(methodCallContext.methodName())); - } else if (doCallParent instanceof BSLParser.GlobalMethodCallContext) { - var globalMethodCallContext = (BSLParser.GlobalMethodCallContext) doCallParent; + } else if (doCallParent instanceof BSLParser.GlobalMethodCallContext globalMethodCallContext) { return selectionRange.equals(Ranges.create(globalMethodCallContext.methodName())); } else { return false; diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/infrastructure/InlayHintsConfiguration.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/infrastructure/InlayHintsConfiguration.java index 181d6b04aea..a0263e25abc 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/infrastructure/InlayHintsConfiguration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/infrastructure/InlayHintsConfiguration.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/infrastructure/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/infrastructure/package-info.java index cc7b3a31dd7..43e3dce9c92 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/infrastructure/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/infrastructure/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/package-info.java index 1ad5dcd5c05..6599b40b255 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/DiagnosticParams.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/DiagnosticParams.java index de5d73e81c6..228ca4d1d0d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/DiagnosticParams.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/DiagnosticParams.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/Diagnostics.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/Diagnostics.java index a502eff4d95..c4a00fb8de4 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/Diagnostics.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/Diagnostics.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/ProtocolExtension.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/ProtocolExtension.java index f62865bb5e8..3add486d78b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/ProtocolExtension.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/ProtocolExtension.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/package-info.java index 5c1cf9b61d1..5265e568191 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/jsonrpc/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/package-info.java index 99ec344bb67..46fd58beb90 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CallHierarchyProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CallHierarchyProvider.java index af6b69fe572..b91f98ce9f7 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CallHierarchyProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CallHierarchyProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeActionProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeActionProvider.java index 3abbd9ea9ea..f201d532b3a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeActionProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeActionProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProvider.java index 6b3b3ec770f..203c96b51d6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/ColorProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/ColorProvider.java index a57a62ceebd..30e84fb7b4f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/ColorProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/ColorProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CommandProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CommandProvider.java index c2e3efc1991..6d32e0c3354 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CommandProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/CommandProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DefinitionProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DefinitionProvider.java index fea2b496e00..2e4c0692d2d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DefinitionProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DefinitionProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DiagnosticProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DiagnosticProvider.java index c16f84abd4b..109e4b8fcc6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DiagnosticProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DiagnosticProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentLinkProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentLinkProvider.java index e4c5f2d0f59..6c95d73f5b5 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentLinkProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentLinkProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentSymbolProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentSymbolProvider.java index 797b8aad309..e62aecb7f8b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentSymbolProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentSymbolProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -45,6 +45,7 @@ public final class DocumentSymbolProvider { private static final Set supportedVariableKinds = EnumSet.of( VariableKind.MODULE, + VariableKind.LOCAL, VariableKind.GLOBAL ); @@ -64,6 +65,7 @@ private static DocumentSymbol toDocumentSymbol(SourceDefinedSymbol symbol) { ); List children = symbol.getChildren().stream() + .filter(DocumentSymbolProvider::isSupported) .map(DocumentSymbolProvider::toDocumentSymbol) .collect(Collectors.toList()); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/FoldingRangeProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/FoldingRangeProvider.java index 50537585acb..437fc0a4996 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/FoldingRangeProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/FoldingRangeProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/FormatProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/FormatProvider.java index e95699fe35b..b9885a6743b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/FormatProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/FormatProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/HoverProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/HoverProvider.java index 3b3e46e08bf..2d180202559 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/HoverProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/HoverProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/InlayHintProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/InlayHintProvider.java index 14c96421732..79b02e1d628 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/InlayHintProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/InlayHintProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/ReferencesProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/ReferencesProvider.java index 9c58fb4c817..c0b9817079b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/ReferencesProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/ReferencesProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProvider.java index 7a094a0df46..1317c304edf 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/SelectionRangeProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/SelectionRangeProvider.java index 6b2cdec75ef..2be3cd77170 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/SelectionRangeProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/SelectionRangeProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -75,7 +75,7 @@ public class SelectionRangeProvider { * Получение данных о {@link SelectionRange} по позиции в документе. * * @param documentContext контекст документа. - * @param params параметры вызова. + * @param params параметры вызова. * @return список найденных диапазонов. */ public List getSelectionRange(DocumentContext documentContext, SelectionRangeParams params) { @@ -129,8 +129,8 @@ private static Optional nextParentWithDifferentRange(ParseTree ctx) { } private static BSLParserRuleContext getParentContext(ParseTree ctx) { - if (ctx instanceof BSLParser.StatementContext) { - return getStatementParent((BSLParser.StatementContext) ctx); + if (ctx instanceof BSLParser.StatementContext statementContext) { + return getStatementParent(statementContext); } return getDefaultParent(ctx); @@ -138,7 +138,7 @@ private static BSLParserRuleContext getParentContext(ParseTree ctx) { @Nullable private static BSLParserRuleContext getDefaultParent(ParseTree ctx) { - return (BSLParserRuleContext) ctx.getParent(); + return (BSLParserRuleContext) ctx.getParent(); } private static BSLParserRuleContext getStatementParent(BSLParser.StatementContext statement) { @@ -201,13 +201,11 @@ private static BSLParserRuleContext getStatementParent(BSLParser.StatementContex } private static boolean ifBranchMatchesIfStatement(BSLParserRuleContext ctx) { - if (!(ctx instanceof BSLParser.IfBranchContext)) { + if (!(ctx instanceof BSLParser.IfBranchContext ifBranch)) { return false; } - var ifBranch = (BSLParser.IfBranchContext) ctx; var ifStatement = (BSLParser.IfStatementContext) ifBranch.getParent(); return ifStatement.elseBranch() == null && ifStatement.elsifBranch().isEmpty(); } - } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/SymbolProvider.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/SymbolProvider.java index e7a9335a812..598ef476300 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/SymbolProvider.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/SymbolProvider.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -55,7 +55,7 @@ public class SymbolProvider { private final ServerContext context; - private static final Set supportedVariableKinds = EnumSet.of( + private static final Set SUPPORTED_VARIABLE_KINDS = EnumSet.of( VariableKind.MODULE, VariableKind.GLOBAL ); @@ -87,14 +87,11 @@ private static Stream> getSymbolPairs(DocumentCon private static boolean isSupported(Symbol symbol) { var symbolKind = symbol.getSymbolKind(); - switch (symbolKind) { - case Method: - return true; - case Variable: - return supportedVariableKinds.contains(((VariableSymbol) symbol).getKind()); - default: - return false; - } + return switch (symbolKind) { + case Method -> true; + case Variable -> SUPPORTED_VARIABLE_KINDS.contains(((VariableSymbol) symbol).getKind()); + default -> false; + }; } private static WorkspaceSymbol createWorkspaceSymbol(Pair symbolPair) { diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/package-info.java index 204fc864b46..d56e9e6cd1d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/AbstractDetector.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/AbstractDetector.java index 50e85ce9704..5e72e243350 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/AbstractDetector.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/AbstractDetector.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/BSLFootprint.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/BSLFootprint.java index 0b7dd1087f2..ff703abe1cb 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/BSLFootprint.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/BSLFootprint.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/CamelCaseDetector.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/CamelCaseDetector.java index a17e374ec24..757f4dd19a2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/CamelCaseDetector.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/CamelCaseDetector.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/CodeRecognizer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/CodeRecognizer.java index ce553aa4e15..ff76aca4726 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/CodeRecognizer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/CodeRecognizer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/ContainsDetector.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/ContainsDetector.java index 12ebee5f621..eb4ac983445 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/ContainsDetector.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/ContainsDetector.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/EndWithDetector.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/EndWithDetector.java index 1b6ad826a3d..5ab5e4debd3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/EndWithDetector.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/EndWithDetector.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/KeywordsDetector.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/KeywordsDetector.java index 1a810929b86..45d2d739a51 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/KeywordsDetector.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/KeywordsDetector.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/LanguageFootprint.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/LanguageFootprint.java index 98a379446a3..d010ab2ab6c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/LanguageFootprint.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/LanguageFootprint.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/PatternDetector.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/PatternDetector.java index 236deae155d..ec3ab0dae67 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/PatternDetector.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/PatternDetector.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/package-info.java index 142a14ffb7c..6df616c5823 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/recognizer/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceFinder.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceFinder.java index fe4fefa42a8..e07e337d254 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceFinder.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceFinder.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java index 30d43cdfba6..0b478d6daea 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFiller.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFiller.java index 1ffbd75354e..bb5b458925a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFiller.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFiller.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -104,7 +104,6 @@ public BSLParserRuleContext visitFuncDeclaration(BSLParser.FuncDeclarationContex @Override public BSLParserRuleContext visitCallStatement(BSLParser.CallStatementContext ctx) { - if (ctx.globalMethodCall() != null) { // see visitGlobalMethodCall return super.visitCallStatement(ctx); @@ -122,14 +121,12 @@ public BSLParserRuleContext visitCallStatement(BSLParser.CallStatementContext ct @Override public BSLParserRuleContext visitComplexIdentifier(BSLParser.ComplexIdentifierContext ctx) { - - String mdoRef = MdoRefBuilder.getMdoRef(documentContext, ctx); + var mdoRef = MdoRefBuilder.getMdoRef(documentContext, ctx); if (mdoRef.isEmpty()) { return super.visitComplexIdentifier(ctx); } Methods.getMethodName(ctx).ifPresent(methodName -> checkCall(mdoRef, methodName)); - return super.visitComplexIdentifier(ctx); } @@ -150,7 +147,7 @@ public BSLParserRuleContext visitGlobalMethodCall(BSLParser.GlobalMethodCallCont public BSLParserRuleContext visitNewExpression(BSLParser.NewExpressionContext ctx) { if (NotifyDescription.isNotifyDescription(ctx)) { final var doCallContext = ctx.doCall(); - if (doCallContext == null){ + if (doCallContext == null) { return super.visitNewExpression(ctx); } var callParamList = doCallContext.callParamList().callParam(); @@ -178,11 +175,11 @@ public BSLParserRuleContext visitNewExpression(BSLParser.NewExpressionContext ct @Override public BSLParserRuleContext visitLValue(BSLParser.LValueContext ctx) { final var identifier = ctx.IDENTIFIER(); - if (identifier != null){ + if (identifier != null) { final List modifiers = Optional.ofNullable(ctx.acceptor()) .map(BSLParser.AcceptorContext::modifier) .orElseGet(Collections::emptyList); - String mdoRef = MdoRefBuilder.getMdoRef(documentContext, identifier, modifiers); + var mdoRef = MdoRefBuilder.getMdoRef(documentContext, identifier, modifiers); if (!mdoRef.isEmpty()) { Methods.getMethodName(ctx).ifPresent(methodName -> checkCall(mdoRef, methodName)); } @@ -193,10 +190,10 @@ public BSLParserRuleContext visitLValue(BSLParser.LValueContext ctx) { private void checkCall(String mdoRef, Token methodName) { var methodNameText = Strings.trimQuotes(methodName.getText()); final var configuration = documentContext.getServerContext().getConfiguration(); - Map modules = configuration.getModulesByMDORef(mdoRef); + Map modules = configuration.mdoModuleTypes(mdoRef); for (ModuleType moduleType : modules.keySet()) { if (!DEFAULT_MODULE_TYPES.contains(moduleType) - || (moduleType == ModuleType.CommonModule && commonModuleMdoRefFromSubParams.contains(mdoRef))) { + || (moduleType == ModuleType.CommonModule && commonModuleMdoRefFromSubParams.contains(mdoRef))) { continue; } addMethodCall(mdoRef, moduleType, methodNameText, Ranges.create(methodName)); @@ -209,7 +206,7 @@ private void addMethodCall(String mdoRef, ModuleType moduleType, String methodNa private void addCallbackMethodCall(BSLParser.CallParamContext methodName, String mdoRef) { // todo: move this out of method - if (mdoRef.isEmpty()){ + if (mdoRef.isEmpty()) { return; } Methods.getMethodName(methodName).ifPresent((Token methodNameToken) -> { @@ -231,7 +228,7 @@ private String getModule(BSLParser.CallParamContext callParamContext) { .map(BSLParser.MemberContext::complexIdentifier) .filter(complexIdentifierContext -> complexIdentifierContext.IDENTIFIER() != null) .filter(complexIdentifierContext -> complexIdentifierContext.modifier().isEmpty()); - if (complexIdentifierContext1.isEmpty()){ + if (complexIdentifierContext1.isEmpty()) { return ""; } return complexIdentifierContext1 @@ -249,7 +246,7 @@ private Set calcParams(@Nullable BSLParser.ParamListContext paramList) { .map(BSLParser.ParamContext::IDENTIFIER) .filter(Objects::nonNull) .map(ParseTree::getText) - .map(configuration::getCommonModule) + .map(configuration::findCommonModule) .filter(Optional::isPresent) .flatMap(Optional::stream) .map(mdCommonModule -> mdCommonModule.getMdoReference().getMdoRef()) @@ -290,7 +287,7 @@ public BSLParserRuleContext visitSub(BSLParser.SubContext ctx) { .ifPresent(scope -> currentScope = scope); } - BSLParserRuleContext result = super.visitSub(ctx); + var result = super.visitSub(ctx); currentScope = documentContext.getSymbolTree().getModule(); return result; } @@ -323,7 +320,10 @@ public BSLParserRuleContext visitCallStatement(BSLParser.CallStatementContext ct var variableName = ctx.IDENTIFIER().getText(); findVariableSymbol(variableName) - .ifPresent(s -> addVariableUsage(s.getRootParent(SymbolKind.Method), variableName, Ranges.create(ctx.IDENTIFIER()), true)); + .ifPresent(s -> addVariableUsage( + s.getRootParent(SymbolKind.Method), variableName, Ranges.create(ctx.IDENTIFIER()), true + ) + ); return super.visitCallStatement(ctx); } @@ -335,7 +335,10 @@ public BSLParserRuleContext visitComplexIdentifier(BSLParser.ComplexIdentifierCo var variableName = ctx.IDENTIFIER().getText(); findVariableSymbol(variableName) - .ifPresent(s -> addVariableUsage(s.getRootParent(SymbolKind.Method), variableName, Ranges.create(ctx.IDENTIFIER()), true)); + .ifPresent(s -> addVariableUsage( + s.getRootParent(SymbolKind.Method), variableName, Ranges.create(ctx.IDENTIFIER()), true + ) + ); return super.visitComplexIdentifier(ctx); } @@ -395,7 +398,8 @@ private boolean notVariableInitialization(BSLParser.LValueContext ctx, VariableS return !Ranges.containsRange(variableSymbol.getRange(), Ranges.create(ctx)); } - private boolean notVariableInitialization(BSLParser.ModuleVarDeclarationContext ctx, VariableSymbol variableSymbol) { + private boolean notVariableInitialization(BSLParser.ModuleVarDeclarationContext ctx, + VariableSymbol variableSymbol) { return !Ranges.containsRange(variableSymbol.getRange(), Ranges.create(ctx)); } @@ -411,7 +415,7 @@ private void addVariableUsage(Optional methodSymbol, String variableName, Range range, boolean usage) { - String methodName = ""; + var methodName = ""; if (methodSymbol.isPresent()) { methodName = methodSymbol.get().getName(); @@ -427,7 +431,5 @@ private void addVariableUsage(Optional methodSymbol, !usage ); } - } - } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexReferenceFinder.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexReferenceFinder.java index 044519450d6..6e8729921ea 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexReferenceFinder.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexReferenceFinder.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolver.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolver.java index 62897b040b1..135eb31b0f3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolver.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolver.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinder.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinder.java index 36e64b6ae8a..019ee801830 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinder.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinder.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Location.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Location.java index 3329ec3c49f..e18daea9bc4 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Location.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Location.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/LocationRepository.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/LocationRepository.java index bff5d9d50e9..94edd7731b3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/LocationRepository.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/LocationRepository.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/OccurrenceType.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/OccurrenceType.java index 87de3b37f08..d98f9e34826 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/OccurrenceType.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/OccurrenceType.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Reference.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Reference.java index e1d28da00de..17c635eb77a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Reference.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Reference.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Symbol.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Symbol.java index e5120da2def..ca8c494d4a6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Symbol.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Symbol.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -41,7 +41,7 @@ public class Symbol implements Comparable { private static GenericInterner interner = new GenericInterner<>(); /** - * Cсылка на объект метаданных в формате ВидОбъектаМетаданных.ИмяОбъекта, в котором расположен символ. + * Ссылка на объект метаданных в формате ВидОбъектаМетаданных.ИмяОбъекта, в котором расположен символ. */ String mdoRef; @@ -98,5 +98,4 @@ public int compareTo(Symbol o) { compareResult = symbolName.compareTo(o.symbolName); return compareResult; } - } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/SymbolOccurrence.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/SymbolOccurrence.java index b8e3fce3ab1..744ebbc06a7 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/SymbolOccurrence.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/SymbolOccurrence.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -55,16 +55,16 @@ public int compareTo(SymbolOccurrence o) { return 0; } final var uriCompare = location.getUri().compareTo(o.location.getUri()); - if (uriCompare != 0){ + if (uriCompare != 0) { return uriCompare; } final var rangesCompare = Ranges.compare(location.getRange(), o.location.getRange()); - if (rangesCompare != 0){ + if (rangesCompare != 0) { return rangesCompare; } - final var occurenceCompare = occurrenceType.compareTo(o.occurrenceType); - if (occurenceCompare != 0){ - return occurenceCompare; + final var occurrenceCompare = occurrenceType.compareTo(o.occurrenceType); + if (occurrenceCompare != 0) { + return occurrenceCompare; } return symbol.compareTo(o.symbol); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/SymbolOccurrenceRepository.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/SymbolOccurrenceRepository.java index 99b381dca96..14a69a5bd9c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/SymbolOccurrenceRepository.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/SymbolOccurrenceRepository.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/package-info.java index c00a0c05a74..da0744a332f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/package-info.java index 911569047c6..6a0266df503 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/references/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/ConsoleReporter.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/ConsoleReporter.java index 84dc37bdc44..1ffe7984e87 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/ConsoleReporter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/ConsoleReporter.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/DiagnosticReporter.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/DiagnosticReporter.java index ffc3c2bf459..affc0644f98 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/DiagnosticReporter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/DiagnosticReporter.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/GenericIssueReport.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/GenericIssueReport.java index 39e343837b8..da17546c9d2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/GenericIssueReport.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/GenericIssueReport.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -26,12 +26,10 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticInfo; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; import com.github._1c_syntax.bsl.languageserver.reporters.data.AnalysisInfo; -import com.github._1c_syntax.bsl.languageserver.reporters.data.FileInfo; import lombok.Getter; import lombok.Value; import org.eclipse.lsp4j.Diagnostic; import org.eclipse.lsp4j.DiagnosticRelatedInformation; -import org.eclipse.lsp4j.Position; import org.eclipse.lsp4j.Range; import java.net.URI; @@ -62,9 +60,9 @@ public GenericIssueReport( public GenericIssueReport(AnalysisInfo analysisInfo, Map diagnosticInfos) { issues = new ArrayList<>(); - for (FileInfo fileInfo : analysisInfo.getFileinfos()) { - for (Diagnostic diagnostic : fileInfo.getDiagnostics()) { - GenericIssueEntry entry = new GenericIssueEntry( + for (var fileInfo : analysisInfo.getFileinfos()) { + for (var diagnostic : fileInfo.getDiagnostics()) { + var entry = new GenericIssueEntry( fileInfo.getPath().toString(), diagnostic, diagnosticInfos.get(DiagnosticCode.getStringValue(diagnostic.getCode())) @@ -111,7 +109,7 @@ public GenericIssueEntry(String fileName, Diagnostic diagnostic, DiagnosticInfo primaryLocation = new Location(fileName, diagnostic); effortMinutes = diagnosticInfo.getMinutesToFix(); - List relatedInformation = diagnostic.getRelatedInformation(); + var relatedInformation = diagnostic.getRelatedInformation(); if (relatedInformation == null) { secondaryLocations = new ArrayList<>(); } else { @@ -172,8 +170,8 @@ public TextRange( } public TextRange(Range range) { - Position startPosition = range.getStart(); - Position endPosition = range.getEnd(); + var startPosition = range.getStart(); + var endPosition = range.getEnd(); startLine = startPosition.getLine() + 1; startColumn = startPosition.getCharacter(); diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/GenericIssueReporter.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/GenericIssueReporter.java index ebe2583200d..c3635c34576 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/GenericIssueReporter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/GenericIssueReporter.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/JUnitReporter.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/JUnitReporter.java index fab1b44e366..c7227bf2131 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/JUnitReporter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/JUnitReporter.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/JUnitTestSuites.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/JUnitTestSuites.java index b774aaebc63..5cc881ed74f 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/JUnitTestSuites.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/JUnitTestSuites.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -39,13 +39,11 @@ import lombok.Value; import org.eclipse.lsp4j.Diagnostic; import org.eclipse.lsp4j.Position; -import org.eclipse.lsp4j.jsonrpc.messages.Either; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale; -import java.util.Map; import java.util.stream.Collectors; @JacksonXmlRootElement(localName = "testsuites") @@ -66,7 +64,7 @@ public JUnitTestSuites(AnalysisInfo analysisInfo) { testsuite = analysisInfo.getFileinfos().stream() .filter(fileInfo -> !fileInfo.getDiagnostics().isEmpty()) .map(JUnitTestSuite::new) - .collect(Collectors.toList()); + .toList(); } public JUnitTestSuites( @@ -91,7 +89,7 @@ public JUnitTestSuite(FileInfo fileInfo) { this.testcase = new ArrayList<>(); List diagnostics = fileInfo.getDiagnostics(); - Map, List> groupedDiagnostics = diagnostics.stream() + var groupedDiagnostics = diagnostics.stream() .collect(Collectors.groupingBy( Diagnostic::getCode, Collectors.toList()) @@ -128,8 +126,8 @@ public JUnitTestCase(List diagnostics, String name, String classname this.classname = classname; List value = new ArrayList<>(); - String type = ""; - String message = ""; + var type = ""; + var message = ""; for (Diagnostic diagnostic : diagnostics) { type = diagnostic.getSeverity().toString().toLowerCase(Locale.ENGLISH); @@ -178,9 +176,9 @@ static class JUnitFailureDeserializer extends JsonDeserializer { public JUnitFailure deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonNode node = jp.getCodec().readTree(jp); - String type = node.get("type").asText(""); - String message = node.get("message").asText(""); - String value = node.get("").asText(""); + var type = node.get("type").asText(""); + var message = node.get("message").asText(""); + var value = node.get("").asText(""); return new JUnitFailure(type, message, value); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/JsonReporter.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/JsonReporter.java index 53544254f5f..dcca6412307 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/JsonReporter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/JsonReporter.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/ReportersAggregator.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/ReportersAggregator.java index 3a22b3a8084..1562bcaa0c5 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/ReportersAggregator.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/ReportersAggregator.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/SarifReporter.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/SarifReporter.java index 0dd62e607e9..5e14005d3a5 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/SarifReporter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/SarifReporter.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReportEntry.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReportEntry.java index ffb737e89ef..5fb32be3521 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReportEntry.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReportEntry.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -30,27 +30,23 @@ import java.util.EnumMap; import java.util.Map; +@Getter class TSLintReportEntry { - @Getter + + private static final Map SEVERITY_MAP = new EnumMap<>(DiagnosticSeverity.class); + private final EntryPosition startPosition; - @Getter private final EntryPosition endPosition; - @Getter private final String failure; - @Getter private final String name; - @Getter private final String ruleName; - @Getter private final String ruleSeverity; - private static final Map severityMap = new EnumMap<>(DiagnosticSeverity.class); - static { - severityMap.put(DiagnosticSeverity.Error, "error"); - severityMap.put(DiagnosticSeverity.Hint, "warn"); - severityMap.put(DiagnosticSeverity.Information, "warn"); - severityMap.put(DiagnosticSeverity.Warning, "warn"); + SEVERITY_MAP.put(DiagnosticSeverity.Error, "error"); + SEVERITY_MAP.put(DiagnosticSeverity.Hint, "warn"); + SEVERITY_MAP.put(DiagnosticSeverity.Information, "warn"); + SEVERITY_MAP.put(DiagnosticSeverity.Warning, "warn"); } TSLintReportEntry(String fileName, Diagnostic diagnostic) { @@ -58,7 +54,7 @@ class TSLintReportEntry { failure = diagnostic.getMessage(); name = fileName; ruleName = DiagnosticCode.getStringValue(diagnostic.getCode()); - ruleSeverity = severityMap.get(diagnostic.getSeverity()); + ruleSeverity = SEVERITY_MAP.get(diagnostic.getSeverity()); startPosition = new EntryPosition(diagnostic.getRange().getStart()); } @@ -78,12 +74,10 @@ public TSLintReportEntry( this.ruleSeverity = ruleSeverity; } + @Getter static class EntryPosition { - @Getter private final int character; - @Getter private final int line; - @Getter private final int position; EntryPosition(org.eclipse.lsp4j.Position position) { diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReporter.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReporter.java index d2ab6b0c11c..58950dac3da 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReporter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReporter.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/data/AnalysisInfo.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/data/AnalysisInfo.java index ff7375ba0e6..3fae749ff08 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/data/AnalysisInfo.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/data/AnalysisInfo.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/data/FileInfo.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/data/FileInfo.java index 78a9c8c630e..f4e3a42c536 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/data/FileInfo.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/data/FileInfo.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -24,17 +24,14 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.context.MetricStorage; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; import com.github._1c_syntax.utils.Absolute; import lombok.AllArgsConstructor; import lombok.Value; import org.eclipse.lsp4j.Diagnostic; -import java.net.URI; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; -import java.util.Optional; @Value @AllArgsConstructor @@ -46,13 +43,13 @@ public class FileInfo { MetricStorage metrics; public FileInfo(String sourceDir, DocumentContext documentContext, List diagnostics) { - URI uri = documentContext.getUri(); + var uri = documentContext.getUri(); path = Absolute.path(sourceDir).relativize(Absolute.path(uri)); this.diagnostics = new ArrayList<>(diagnostics); metrics = documentContext.getMetrics(); - Optional mdObjectBase = documentContext.getMdObject(); - if (mdObjectBase.isPresent()) { - mdoRef = mdObjectBase.get().getMdoReference().getMdoRef(); + var mdo = documentContext.getMdObject(); + if (mdo.isPresent()) { + mdoRef = mdo.get().getMdoReference().getMdoRef(); } else { mdoRef = ""; } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/data/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/data/package-info.java index 776f3975799..b896ce9f2b6 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/data/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/data/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/AnalysisInfoObjectMapper.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/AnalysisInfoObjectMapper.java index e1a53e3b26a..1182c70306b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/AnalysisInfoObjectMapper.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/AnalysisInfoObjectMapper.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/DiagnosticCodeDeserializer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/DiagnosticCodeDeserializer.java index 18446eb8a89..d343841a80b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/DiagnosticCodeDeserializer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/DiagnosticCodeDeserializer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/DiagnosticCodeSerializer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/DiagnosticCodeSerializer.java index 82831e76796..f0ad27db949 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/DiagnosticCodeSerializer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/DiagnosticCodeSerializer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/DiagnosticMixIn.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/DiagnosticMixIn.java index 990ebd9232c..79314e45d07 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/DiagnosticMixIn.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/DiagnosticMixIn.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/package-info.java index cc77b43841c..cde1586e405 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/databind/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/infrastructure/ReportersConfiguration.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/infrastructure/ReportersConfiguration.java index e14469d2603..a8d5db65388 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/infrastructure/ReportersConfiguration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/infrastructure/ReportersConfiguration.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/package-info.java index b6fbe7c01d6..fc82caeb936 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/reporters/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/AbstractObjectPool.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/AbstractObjectPool.java index 35d3af9beff..9f48513a747 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/AbstractObjectPool.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/AbstractObjectPool.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/DiagnosticHelper.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/DiagnosticHelper.java index 7a5b02cbe41..5a6209a0112 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/DiagnosticHelper.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/DiagnosticHelper.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Keywords.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Keywords.java index 29e5f8ca7a0..2d87b377fe4 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Keywords.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Keywords.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/MdoRefBuilder.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/MdoRefBuilder.java index 3121569ce66..007b348d6f0 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/MdoRefBuilder.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/MdoRefBuilder.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -22,22 +22,19 @@ package com.github._1c_syntax.bsl.languageserver.utils; import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.mdo.MD; import com.github._1c_syntax.bsl.mdo.support.ScriptVariant; import com.github._1c_syntax.bsl.parser.BSLParser; import com.github._1c_syntax.bsl.types.MDOType; import com.github._1c_syntax.bsl.types.MdoReference; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; -import com.github._1c_syntax.mdclasses.utils.MDOUtils; import com.github._1c_syntax.utils.StringInterner; import edu.umd.cs.findbugs.annotations.Nullable; import lombok.experimental.UtilityClass; import org.antlr.v4.runtime.tree.ParseTree; import org.antlr.v4.runtime.tree.TerminalNode; -import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; @@ -57,7 +54,7 @@ public String getMdoRef(DocumentContext documentContext, BSLParser.CallStatement public static String getMdoRef(DocumentContext documentContext) { var mdoRef = documentContext.getMdObject() - .map(AbstractMDObjectBase::getMdoReference) + .map(MD::getMdoReference) .map(MdoReference::getMdoRef) .orElseGet(() -> documentContext.getUri().toString()); return stringInterner.intern(mdoRef); @@ -83,8 +80,7 @@ public String getMdoRef( Optional.ofNullable(identifier) .map(ParseTree::getText) .flatMap(MDOType::fromValue) - .filter(mdoType -> MDOUtils.getModuleTypesForMdoTypes() - .getOrDefault(mdoType, Collections.emptySet()) + .filter(mdoType -> ModuleType.byMDOType(mdoType) .contains(ModuleType.ManagerModule)) .map(mdoType -> getMdoRef(mdoType, getMdoName(modifiers))) ) @@ -129,8 +125,8 @@ public String getLocaleOwnerMdoName(DocumentContext documentContext, MD mdo) { private Optional getCommonModuleMdoRef(DocumentContext documentContext, String commonModuleName) { return documentContext.getServerContext() .getConfiguration() - .getCommonModule(commonModuleName) - .map(MDCommonModule::getMdoReference) + .findCommonModule(commonModuleName) + .map(CommonModule::getMdoReference) .map(MdoReference::getMdoRef); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Methods.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Methods.java index 8c17482d43d..f223a5aa390 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Methods.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Methods.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Modules.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Modules.java index 705c0c91225..2c09c0aeafe 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Modules.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Modules.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/MultilingualStringAnalyser.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/MultilingualStringAnalyser.java index caa6b340534..6976dfb507d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/MultilingualStringAnalyser.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/MultilingualStringAnalyser.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/NamedForkJoinWorkerThreadFactory.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/NamedForkJoinWorkerThreadFactory.java index b4532d52506..7252a453fff 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/NamedForkJoinWorkerThreadFactory.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/NamedForkJoinWorkerThreadFactory.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/NotifyDescription.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/NotifyDescription.java index ae9bf17825a..3e28e762282 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/NotifyDescription.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/NotifyDescription.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Ranges.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Ranges.java index 58241c3e033..95f30eda4db 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Ranges.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Ranges.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Regions.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Regions.java index e06c54f55ae..652808b9ffc 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Regions.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Regions.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/RelatedInformation.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/RelatedInformation.java index 0a83fc79413..922d16ded88 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/RelatedInformation.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/RelatedInformation.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Resources.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Resources.java index 19ac1d45586..ee1d47f94d8 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Resources.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Resources.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Strings.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Strings.java index 295bac0c684..1061b85061a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Strings.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Strings.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/ThrowingSupplier.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/ThrowingSupplier.java index 99456d0d2f7..c5fb715def3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/ThrowingSupplier.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/ThrowingSupplier.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Trees.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Trees.java index b9bebdb6bfa..e57dfa3a772 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Trees.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Trees.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -82,12 +82,11 @@ public static List getChildren(Tree t) { * @return Список токенов */ public static List getTokens(ParseTree tree) { - if (tree instanceof BSLParserRuleContext) { - return ((BSLParserRuleContext) tree).getTokens(); + if (tree instanceof BSLParserRuleContext parserRuleContext) { + return parserRuleContext.getTokens(); } - if (tree instanceof TerminalNode) { - TerminalNode node = (TerminalNode) tree; + if (tree instanceof TerminalNode node) { var token = node.getSymbol(); return List.of(token); } @@ -104,8 +103,7 @@ public static List getTokens(ParseTree tree) { private static void getTokensFromParseTree(ParseTree tree, List tokens) { for (var i = 0; i < tree.getChildCount(); i++) { ParseTree child = tree.getChild(i); - if (child instanceof TerminalNode) { - TerminalNode node = (TerminalNode) child; + if (child instanceof TerminalNode node) { var token = node.getSymbol(); tokens.add(token); } else { @@ -138,8 +136,8 @@ private static void flatten(ParseTree t, List flatList) { */ private static int getRuleIndex(ParseTree node) { - if (node instanceof TerminalNode) { - return ((TerminalNode) node).getSymbol().getType(); + if (node instanceof TerminalNode terminalNode) { + return terminalNode.getSymbol().getType(); } else { return ((BSLParserRuleContext) node).getRuleIndex(); } @@ -153,9 +151,8 @@ private static List getDescendantsWithFilter(ParseTree parent, ParseT descendants = org.antlr.v4.runtime.tree.Trees.getDescendants(parent) .stream() .filter(BSLParserRuleContext.class::isInstance) - .filter(node -> (node.equals(tnc) - || getRuleIndex(node) == ruleindex)) - .collect(Collectors.toList()); + .filter(node -> (node.equals(tnc) || getRuleIndex(node) == ruleindex)) + .toList(); } return descendants; } @@ -204,14 +201,11 @@ public static boolean nodeContainsErrors(ParseTree tnc) { * @return tnc - если предыдущая нода не найдена, вернет текущую */ public static ParseTree getPreviousNode(ParseTree parent, ParseTree tnc, int ruleindex) { - List descendants = getDescendantsWithFilter(parent, tnc, ruleindex); - int pos = descendants.indexOf(tnc); if (pos > 0) { return descendants.get(pos - 1); } - return tnc; } @@ -266,14 +260,11 @@ public static Optional getPreviousTokenFromDefaultChannel(List tok * @return tnc - если следующая нода не найдена, вернет текущую */ public static ParseTree getNextNode(ParseTree parent, ParseTree tnc, int ruleindex) { - List descendants = getDescendantsWithFilter(parent, tnc, ruleindex); - int pos = descendants.indexOf(tnc); if (pos + 1 < descendants.size()) { return descendants.get(pos + 1); } - return tnc; } @@ -284,7 +275,6 @@ public static BSLParserRuleContext getRootParent(BSLParserRuleContext tnc) { if (tnc.getParent() != null) { return getRootParent(tnc.getParent()); } - return tnc; } @@ -354,9 +344,7 @@ private static Stream getChildrenStream(Tree t, Integer[] List indexes = Arrays.asList(ruleIndex); return IntStream.range(0, t.getChildCount()) .mapToObj(t::getChild) - .filter((Tree child) -> - child instanceof BSLParserRuleContext - && indexes.contains(((BSLParserRuleContext) child).getRuleIndex())) + .filter(child -> child instanceof BSLParserRuleContext rule && indexes.contains(rule.getRuleIndex())) .map(BSLParserRuleContext.class::cast); } @@ -373,8 +361,7 @@ public static Collection findAllRuleNodes(ParseTree t, Intege public static Collection findAllRuleNodes(ParseTree t, Collection indexes) { List nodes = new ArrayList<>(); - if (t instanceof ParserRuleContext - && indexes.contains(((ParserRuleContext) t).getRuleIndex())) { + if (t instanceof ParserRuleContext parserRuleContext && indexes.contains(parserRuleContext.getRuleIndex())) { nodes.add((ParserRuleContext) t); } @@ -388,29 +375,27 @@ public static Collection findAllRuleNodes(ParseTree t, Collec /** * Получает "первые" дочерние ноды с нужными типами * ВАЖНО: поиск вглубь найденной ноды с нужными индексами не выполняется - * Например, если указать RULE_codeBlock, то найдется только самый верхнеуровневый блок кода, все вложенные найдены не будут + * Например, если указать RULE_codeBlock, то найдется только самый верхнеуровневый блок кода, все + * вложенные найдены не будут * ВАЖНО: начальная нода не проверяется на условие, т.к. тогда она единственная и вернется в результате * - * @param root - начальный узел дерева + * @param root - начальный узел дерева * @param indexes - коллекция индексов * @return найденные узлы */ public static Collection findAllTopLevelDescendantNodes(ParserRuleContext root, Collection indexes) { var result = new ArrayList(); - root.children.stream() .map(node -> findAllTopLevelDescendantNodesInner(node, indexes)) .forEach(result::addAll); - return result; } private static Collection findAllTopLevelDescendantNodesInner(ParseTree root, Collection indexes) { - if (root instanceof ParserRuleContext - && indexes.contains(((ParserRuleContext) root).getRuleIndex())) { - return List.of((ParserRuleContext) root); + if (root instanceof ParserRuleContext rule && indexes.contains(rule.getRuleIndex())) { + return List.of(rule); } List result = new ArrayList<>(); @@ -427,8 +412,7 @@ private static Collection findAllTopLevelDescendantNodesInner public static boolean nodeContains(ParseTree t, Integer... index) { Set indexes = new HashSet<>(Arrays.asList(index)); - if (t instanceof ParserRuleContext - && indexes.contains(((ParserRuleContext) t).getRuleIndex())) { + if (t instanceof ParserRuleContext rule && indexes.contains(rule.getRuleIndex())) { return true; } @@ -442,9 +426,7 @@ public static boolean nodeContains(ParseTree t, Integer... index) { public static boolean nodeContains(ParseTree t, ParseTree exclude, Integer... index) { Set indexes = new HashSet<>(Arrays.asList(index)); - if (t instanceof ParserRuleContext - && !t.equals(exclude) - && indexes.contains(((ParserRuleContext) t).getRuleIndex())) { + if (t instanceof ParserRuleContext rule && !t.equals(exclude) && indexes.contains(rule.getRuleIndex())) { return true; } @@ -455,11 +437,12 @@ public static boolean nodeContains(ParseTree t, ParseTree exclude, Integer... in /** * Получение ноды в дереве по позиции в документе. * - * @param tree - дерево, в котором ищем + * @param tree - дерево, в котором ищем * @param position - искомая позиция * @return терминальная нода на указанной позиции, если есть */ - public static Optional findTerminalNodeContainsPosition(BSLParserRuleContext tree, Position position) { + public static Optional findTerminalNodeContainsPosition(BSLParserRuleContext tree, + Position position) { if (tree.getTokens().isEmpty()) { return Optional.empty(); @@ -475,8 +458,7 @@ public static Optional findTerminalNodeContainsPosition(BSLParserR var children = Trees.getChildren(tree); for (Tree child : children) { - if (child instanceof TerminalNode) { - var terminalNode = (TerminalNode) child; + if (child instanceof TerminalNode terminalNode) { var token = terminalNode.getSymbol(); if (tokenContainsPosition(token, position)) { return Optional.of(terminalNode); @@ -532,15 +514,12 @@ public static List getComments(List tokens, Token token) { } private static void fillCommentsCollection(List tokens, Token currentToken, List lines) { - int index = currentToken.getTokenIndex(); - if (index == 0) { return; } var previousToken = tokens.get(index - 1); - if (abortSearchComments(previousToken, currentToken)) { return; } @@ -564,12 +543,10 @@ private static boolean isBlankLine(Token previousToken, Token currentToken) { } private static boolean treeContainsErrors(ParseTree tnc, boolean recursive) { - if (!(tnc instanceof BSLParserRuleContext)) { + if (!(tnc instanceof BSLParserRuleContext ruleContext)) { return false; } - BSLParserRuleContext ruleContext = (BSLParserRuleContext) tnc; - if (ruleContext.exception != null) { return true; } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/UTF8Control.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/UTF8Control.java index 9e2368ddfd6..11bded401df 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/UTF8Control.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/UTF8Control.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/bsl/Constructors.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/bsl/Constructors.java index 247af3aaa0e..0b784f73465 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/bsl/Constructors.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/bsl/Constructors.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/AbstractCallNode.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/AbstractCallNode.java index 836b73ab6b5..9d3200f42be 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/AbstractCallNode.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/AbstractCallNode.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BinaryOperationNode.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BinaryOperationNode.java index 5543234072c..acde5b6f19b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BinaryOperationNode.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BinaryOperationNode.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BslExpression.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BslExpression.java index e7500ce359e..76bc9dc1da0 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BslExpression.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BslExpression.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BslOperationNode.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BslOperationNode.java index c5a357ba09d..8afabd15956 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BslOperationNode.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BslOperationNode.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BslOperator.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BslOperator.java index 357ef3e9414..0c4543e280d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BslOperator.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BslOperator.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ConstructorCallNode.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ConstructorCallNode.java index 6d6a864ad7f..8c86c700cab 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ConstructorCallNode.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ConstructorCallNode.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/DefaultNodeEqualityComparer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/DefaultNodeEqualityComparer.java index b4ffad22e03..2adecca8171 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/DefaultNodeEqualityComparer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/DefaultNodeEqualityComparer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -40,30 +40,22 @@ public boolean areEqual(BslExpression first, BslExpression second) { return false; } - switch (first.getNodeType()) { - case LITERAL: - return literalsEqual((TerminalSymbolNode) first, (TerminalSymbolNode) second); - case IDENTIFIER: - return identifiersEqual((TerminalSymbolNode) first, (TerminalSymbolNode) second); - case BINARY_OP: - return binaryOperationsEqual((BinaryOperationNode) first, (BinaryOperationNode) second); - case UNARY_OP: - return unaryOperationsEqual((UnaryOperationNode) first, (UnaryOperationNode) second); - case TERNARY_OP: - return ternaryOperatorsEqual((TernaryOperatorNode) first, (TernaryOperatorNode) second); - case SKIPPED_CALL_ARG: - return true; - case CALL: - return callStatementsEqual((AbstractCallNode) first, (AbstractCallNode) second); - default: - throw new IllegalStateException(); - } + return switch (first.getNodeType()) { + case LITERAL -> literalsEqual((TerminalSymbolNode) first, (TerminalSymbolNode) second); + case IDENTIFIER -> identifiersEqual((TerminalSymbolNode) first, (TerminalSymbolNode) second); + case BINARY_OP -> binaryOperationsEqual((BinaryOperationNode) first, (BinaryOperationNode) second); + case UNARY_OP -> unaryOperationsEqual((UnaryOperationNode) first, (UnaryOperationNode) second); + case TERNARY_OP -> ternaryOperatorsEqual((TernaryOperatorNode) first, (TernaryOperatorNode) second); + case SKIPPED_CALL_ARG -> true; + case CALL -> callStatementsEqual((AbstractCallNode) first, (AbstractCallNode) second); + default -> throw new IllegalStateException(); + }; } protected boolean callStatementsEqual(AbstractCallNode first, AbstractCallNode second) { - if (first instanceof MethodCallNode) { - return methodCallsEqual((MethodCallNode) first, (MethodCallNode) second); + if (first instanceof MethodCallNode methodCallNode) { + return methodCallsEqual(methodCallNode, (MethodCallNode) second); } else { return constructorCallsEqual((ConstructorCallNode) first, (ConstructorCallNode) second); } @@ -94,9 +86,9 @@ protected boolean methodCallsEqual(MethodCallNode first, MethodCallNode second) } protected boolean ternaryOperatorsEqual(TernaryOperatorNode first, TernaryOperatorNode second) { - return areEqual(first.getCondition(), second.getCondition()) && - areEqual(first.getTruePart(), second.getTruePart()) && - areEqual(first.getFalsePart(), second.getFalsePart()); + return areEqual(first.getCondition(), second.getCondition()) + && areEqual(first.getTruePart(), second.getTruePart()) + && areEqual(first.getFalsePart(), second.getFalsePart()); } protected boolean unaryOperationsEqual(UnaryOperationNode first, UnaryOperationNode second) { @@ -117,7 +109,6 @@ protected boolean binaryOperationsEqual(BinaryOperationNode first, BinaryOperati } return areEqual(first.getLeft(), second.getLeft()) && areEqual(first.getRight(), second.getRight()); - } protected boolean identifiersEqual(TerminalSymbolNode first, TerminalSymbolNode second) { diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionNodeType.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionNodeType.java index 00437d885fb..4b30ce90048 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionNodeType.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionNodeType.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionParseTreeRewriter.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionParseTreeRewriter.java index 06ed47d2b19..c580191eb8d 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionParseTreeRewriter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionParseTreeRewriter.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionTreeBuildingVisitor.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionTreeBuildingVisitor.java index 6bdeeb7eb50..178e5d79883 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionTreeBuildingVisitor.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionTreeBuildingVisitor.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -20,6 +20,7 @@ * License along with BSL Language Server. */ package com.github._1c_syntax.bsl.languageserver.utils.expressiontree; + import com.github._1c_syntax.bsl.parser.BSLLexer; import com.github._1c_syntax.bsl.parser.BSLParser; import com.github._1c_syntax.bsl.parser.BSLParserBaseVisitor; @@ -31,6 +32,7 @@ import java.util.Collections; import java.util.Deque; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; @@ -129,8 +131,8 @@ public ParseTree visitMember(BSLParser.MemberContext ctx) { } var dispatchChild = ctx.getChild(childIndex); - if (dispatchChild instanceof TerminalNode) { - var token = ((TerminalNode) dispatchChild).getSymbol().getType(); + if (dispatchChild instanceof TerminalNode terminalNode) { + var token = terminalNode.getSymbol().getType(); // ручная диспетчеризация switch (token) { @@ -143,7 +145,6 @@ public ParseTree visitMember(BSLParser.MemberContext ctx) { default: throw new IllegalStateException("Unexpected rule " + dispatchChild); } - } else { dispatchChild.accept(this); } @@ -155,7 +156,8 @@ public ParseTree visitMember(BSLParser.MemberContext ctx) { return ctx; } - private void visitParenthesis(BSLParser.ExpressionContext expression, List modifiers) { + private void visitParenthesis(BSLParser.ExpressionContext expression, + List modifiers) { var subExpr = makeSubexpression(expression); operands.push(subExpr); @@ -163,7 +165,6 @@ private void visitParenthesis(BSLParser.ExpressionContext expression, List BslOperator.UNARY_PLUS; + case BSLLexer.MINUS -> BslOperator.UNARY_MINUS; + case BSLLexer.NOT_KEYWORD -> BslOperator.NOT; + default -> throw new IllegalArgumentException(); + }; operatorsInFly.push(new OperatorInCode(operator, child)); @@ -287,7 +275,6 @@ public ParseTree visitComplexIdentifier(BSLParser.ComplexIdentifierContext ctx) @Override public ParseTree visitGlobalMethodCall(BSLParser.GlobalMethodCallContext ctx) { - var name = ctx.methodName().IDENTIFIER(); var callNode = MethodCallNode.create(name); callNode.setRepresentingAst(ctx); @@ -323,9 +310,7 @@ public ParseTree visitNewExpression(BSLParser.NewExpressionContext ctx) { } callNode.setRepresentingAst(ctx); - addCallArguments(callNode, args); - operands.push(callNode); return ctx; } @@ -345,9 +330,7 @@ public ParseTree visitAccessProperty(BSLParser.AccessPropertyContext ctx) { @Override public ParseTree visitAccessIndex(BSLParser.AccessIndexContext ctx) { var target = operands.pop(); - var expressionArg = makeSubexpression(ctx.expression()); - var indexOperation = BinaryOperationNode.create(BslOperator.INDEX_ACCESS, target, expressionArg, ctx); operands.push(indexOperation); return ctx; @@ -366,7 +349,6 @@ public ParseTree visitAccessCall(BSLParser.AccessCallContext ctx) { @Override public ParseTree visitTernaryOperator(BSLParser.TernaryOperatorContext ctx) { - var ternary = TernaryOperatorNode.create( makeSubexpression(ctx.expression(0)), makeSubexpression(ctx.expression(1)), @@ -384,7 +366,7 @@ private static BslExpression makeSubexpression(BSLParser.ExpressionContext ctx) } private static void addCallArguments(AbstractCallNode callNode, List args) { - for (BSLParser.CallParamContext parameter : args) { + for (var parameter : args) { if (parameter.expression() == null) { callNode.addArgument(new SkippedCallArgumentNode()); } else { @@ -399,19 +381,18 @@ private void buildOperation() { } var operator = operatorsInFly.pop(); - switch (operator.getOperator()) { - case UNARY_MINUS: - case UNARY_PLUS: - case NOT: - var operand = operands.pop(); - var operation = UnaryOperationNode.create(operator.getOperator(), operand, operator.getActualSourceCode()); - operands.push(operation); - break; - default: - var right = operands.pop(); - var left = operands.pop(); - var binaryOp = BinaryOperationNode.create(operator.getOperator(), left, right, operator.getActualSourceCode()); - operands.push(binaryOp); + if (Objects.requireNonNull(operator.getOperator()) == BslOperator.UNARY_MINUS + || operator.getOperator() == BslOperator.NOT + || operator.getOperator() == BslOperator.UNARY_PLUS) { + + var operand = operands.pop(); + var operation = UnaryOperationNode.create(operator.getOperator(), operand, operator.getActualSourceCode()); + operands.push(operation); + } else { + var right = operands.pop(); + var left = operands.pop(); + var binaryOp = BinaryOperationNode.create(operator.getOperator(), left, right, operator.getActualSourceCode()); + operands.push(binaryOp); } } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/MethodCallNode.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/MethodCallNode.java index d123d62a555..60301c54dd2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/MethodCallNode.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/MethodCallNode.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/NodeEqualityComparer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/NodeEqualityComparer.java index 688d6c15756..65321d07391 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/NodeEqualityComparer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/NodeEqualityComparer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/SkippedCallArgumentNode.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/SkippedCallArgumentNode.java index b05bb7536c2..2a1fe6d79ff 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/SkippedCallArgumentNode.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/SkippedCallArgumentNode.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/TerminalSymbolNode.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/TerminalSymbolNode.java index 5a055956b3b..dae120ca7b3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/TerminalSymbolNode.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/TerminalSymbolNode.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/TernaryOperatorNode.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/TernaryOperatorNode.java index 8377e73b609..ef87a7c77be 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/TernaryOperatorNode.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/TernaryOperatorNode.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/TransitiveOperationsIgnoringComparer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/TransitiveOperationsIgnoringComparer.java index 90c3beba624..debce8b1ff2 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/TransitiveOperationsIgnoringComparer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/TransitiveOperationsIgnoringComparer.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/UnaryOperationNode.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/UnaryOperationNode.java index 8f64cb2388f..940390ee30e 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/UnaryOperationNode.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/UnaryOperationNode.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/package-info.java index ad07a9a2e5d..ddf92da990a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/package-info.java index bff49a2a359..a29b3af73b0 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/LSPWebSocketEndpoint.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/LSPWebSocketEndpoint.java index 2209ae56feb..95bbc0c6fde 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/LSPWebSocketEndpoint.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/LSPWebSocketEndpoint.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/WebSocketConfiguration.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/WebSocketConfiguration.java index 1b2063d41d2..5e83ecd58ff 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/WebSocketConfiguration.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/WebSocketConfiguration.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/package-info.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/package-info.java index f4795d58598..0bc11c0ffc9 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/package-info.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/websocket/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/configuration/parameters-schema.json b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/configuration/parameters-schema.json index 498b96475db..749df4a1160 100644 --- a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/configuration/parameters-schema.json +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/configuration/parameters-schema.json @@ -47,6 +47,12 @@ ], "title": "Prohibited words", "properties": { + "findInComments": { + "description": "Find in comments", + "default": true, + "type": "boolean", + "title": "Find in comments" + }, "badWords": { "description": "Regular expression for prohibited words.", "default": "", @@ -510,6 +516,16 @@ "title": "Deprecated ManagedForm type", "$id": "#/definitions/DeprecatedTypeManagedForm" }, + "DisableSafeMode": { + "description": "Disable safe mode", + "default": true, + "type": [ + "boolean", + "object" + ], + "title": "Disable safe mode", + "$id": "#/definitions/DisableSafeMode" + }, "DuplicateRegion": { "description": "Duplicate regions", "default": true, @@ -652,6 +668,30 @@ "title": "Ban export global module variables", "$id": "#/definitions/ExportVariables" }, + "ExternalAppStarting": { + "description": "External applications starting", + "default": true, + "type": [ + "boolean", + "object" + ], + "title": "External applications starting", + "properties": { + "checkGotoUrl": { + "description": "Check navigation links", + "default": false, + "type": "boolean", + "title": "Check navigation links" + }, + "userPatternString": { + "description": "User regex pattern", + "default": "\u041a\u043e\u043c\u0430\u043d\u0434\u0430\u0421\u0438\u0441\u0442\u0435\u043c\u044b|System|\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c\u0421\u0438\u0441\u0442\u0435\u043c\u0443|RunSystem|\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435|RunApp|\u041d\u0430\u0447\u0430\u0442\u044c\u0417\u0430\u043f\u0443\u0441\u043a\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f|BeginRunningApplication|\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u0410\u0441\u0438\u043d\u0445|RunAppAsync|\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443|\u041e\u0442\u043a\u0440\u044b\u0442\u044c\u041f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a|\u041e\u0442\u043a\u0440\u044b\u0442\u044c\u0424\u0430\u0439\u043b", + "type": "string", + "title": "User regex pattern" + } + }, + "$id": "#/definitions/ExternalAppStarting" + }, "ExtraCommas": { "description": "Commas without a parameter at the end of a method call", "default": true, @@ -672,6 +712,30 @@ "title": "No NULL checks for fields from joined tables", "$id": "#/definitions/FieldsFromJoinsWithoutIsNull" }, + "FileSystemAccess": { + "description": "File system access", + "default": false, + "type": [ + "boolean", + "object" + ], + "title": "File system access", + "properties": { + "globalMethods": { + "description": "Global methods pattern (regex)", + "default": "\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u0412\u0424\u0430\u0439\u043b|ValueToFile|\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0424\u0430\u0439\u043b|FileCopy|\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0424\u0430\u0439\u043b\u044b|MergeFiles|\u041f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0424\u0430\u0439\u043b|MoveFile|\u0420\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c\u0424\u0430\u0439\u043b|SplitFile|\u0421\u043e\u0437\u0434\u0430\u0442\u044c\u041a\u0430\u0442\u0430\u043b\u043e\u0433|CreateDirectory|\u0423\u0434\u0430\u043b\u0438\u0442\u044c\u0424\u0430\u0439\u043b\u044b|DeleteFiles|\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b|BinDir|\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445\u0424\u0430\u0439\u043b\u043e\u0432|TempFilesDir|\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432|DocumentsDir|\u0420\u0430\u0431\u043e\u0447\u0438\u0439\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u0414\u0430\u043d\u043d\u044b\u0445\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f|UserDataWorkDir|\u041d\u0430\u0447\u0430\u0442\u044c\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u0420\u0430\u0431\u043e\u0442\u044b\u0421\u0424\u0430\u0439\u043b\u0430\u043c\u0438|BeginAttachingFileSystemExtension|\u041d\u0430\u0447\u0430\u0442\u044c\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u0420\u0430\u0431\u043e\u0442\u044b\u0421\u0424\u0430\u0439\u043b\u0430\u043c\u0438|BeginInstallFileSystemExtension|\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u0420\u0430\u0431\u043e\u0442\u044b\u0421\u0424\u0430\u0439\u043b\u0430\u043c\u0438|InstallFileSystemExtension|\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u0420\u0430\u0431\u043e\u0442\u044b\u0421\u0424\u0430\u0439\u043b\u0430\u043c\u0438\u0410\u0441\u0438\u043d\u0445|InstallFileSystemExtensionAsync|\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u0420\u0430\u0431\u043e\u0442\u044b\u0421\u0424\u0430\u0439\u043b\u0430\u043c\u0438\u0410\u0441\u0438\u043d\u0445|AttachFileSystemExtensionAsync|\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445\u0424\u0430\u0439\u043b\u043e\u0432\u0410\u0441\u0438\u043d\u0445|TempFilesDirAsync|\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432\u0410\u0441\u0438\u043d\u0445|DocumentsDirAsync|\u041d\u0430\u0447\u0430\u0442\u044c\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u0430\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445\u0424\u0430\u0439\u043b\u043e\u0432|BeginGettingTempFilesDir|\u041d\u0430\u0447\u0430\u0442\u044c\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u0430\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432|BeginGettingDocumentsDir|\u041d\u0430\u0447\u0430\u0442\u044c\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u0420\u0430\u0431\u043e\u0447\u0435\u0433\u043e\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u0430\u0414\u0430\u043d\u043d\u044b\u0445\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f|BeginGettingUserDataWorkDir|\u0420\u0430\u0431\u043e\u0447\u0438\u0439\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u0414\u0430\u043d\u043d\u044b\u0445\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u0410\u0441\u0438\u043d\u0445|UserDataWorkDirAsync|\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0424\u0430\u0439\u043b\u0410\u0441\u0438\u043d\u0445|CopyFileAsync|\u041d\u0430\u0439\u0442\u0438\u0424\u0430\u0439\u043b\u044b\u0410\u0441\u0438\u043d\u0445|FindFilesAsync|\u041d\u0430\u0447\u0430\u0442\u044c\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u0424\u0430\u0439\u043b\u0430|BeginCopyingFile|\u041d\u0430\u0447\u0430\u0442\u044c\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u0424\u0430\u0439\u043b\u0430|BeginMovingFile|\u041d\u0430\u0447\u0430\u0442\u044c\u041f\u043e\u0438\u0441\u043a\u0424\u0430\u0439\u043b\u043e\u0432|BeginFindingFiles|\u041d\u0430\u0447\u0430\u0442\u044c\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u0414\u0432\u043e\u0438\u0447\u043d\u044b\u0445\u0414\u0430\u043d\u043d\u044b\u0445\u0418\u0437\u0424\u0430\u0439\u043b\u0430|BeginCreateBinaryDataFromFile|\u041d\u0430\u0447\u0430\u0442\u044c\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u0430|BeginCreatingDirectory|\u041d\u0430\u0447\u0430\u0442\u044c\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u0424\u0430\u0439\u043b\u043e\u0432|BeginDeletingFiles|\u041f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0424\u0430\u0439\u043b\u0410\u0441\u0438\u043d\u0445|MoveFileAsync|\u0421\u043e\u0437\u0434\u0430\u0442\u044c\u0414\u0432\u043e\u0438\u0447\u043d\u044b\u0435\u0414\u0430\u043d\u043d\u044b\u0435\u0418\u0437\u0424\u0430\u0439\u043b\u0430\u0410\u0441\u0438\u043d\u0445|CreateBinaryDataFromFileAsync|\u0421\u043e\u0437\u0434\u0430\u0442\u044c\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u0410\u0441\u0438\u043d\u0445|CreateDirectoryAsync|\u0423\u0434\u0430\u043b\u0438\u0442\u044c\u0424\u0430\u0439\u043b\u044b\u0410\u0441\u0438\u043d\u0445|DeleteFilesAsync", + "type": "string", + "title": "Global methods pattern (regex)" + }, + "newExpression": { + "description": "Class names pattern (regex)", + "default": "File|\u0424\u0430\u0439\u043b|xBase|HTMLWriter|\u0417\u0430\u043f\u0438\u0441\u044cHTML|HTMLReader|\u0427\u0442\u0435\u043d\u0438\u0435HTML|FastInfosetReader|\u0427\u0442\u0435\u043d\u0438\u0435FastInfoset|FastInfosetWriter|\u0417\u0430\u043f\u0438\u0441\u044cFastInfoset|XSLTransform|\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435XSL|ZipFileWriter|\u0417\u0430\u043f\u0438\u0441\u044cZip\u0424\u0430\u0439\u043b\u0430|ZipFileReader|\u0427\u0442\u0435\u043d\u0438\u0435Zip\u0424\u0430\u0439\u043b\u0430|TextReader|\u0427\u0442\u0435\u043d\u0438\u0435\u0422\u0435\u043a\u0441\u0442\u0430|TextWriter|\u0417\u0430\u043f\u0438\u0441\u044c\u0422\u0435\u043a\u0441\u0442\u0430|TextExtraction|\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435\u0422\u0435\u043a\u0441\u0442\u0430|BinaryData|\u0414\u0432\u043e\u0438\u0447\u043d\u044b\u0435\u0414\u0430\u043d\u043d\u044b\u0435|FileStream|\u0424\u0430\u0439\u043b\u043e\u0432\u044b\u0439\u041f\u043e\u0442\u043e\u043a|FileStreamsManager|\u041c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0424\u0430\u0439\u043b\u043e\u0432\u044b\u0445\u041f\u043e\u0442\u043e\u043a\u043e\u0432|DataWriter|\u0417\u0430\u043f\u0438\u0441\u044c\u0414\u0430\u043d\u043d\u044b\u0445|DataReader|\u0427\u0442\u0435\u043d\u0438\u0435\u0414\u0430\u043d\u043d\u044b\u0445", + "type": "string", + "title": "Class names pattern (regex)" + } + }, + "$id": "#/definitions/FileSystemAccess" + }, "ForbiddenMetadataName": { "description": "Metadata object has a forbidden name", "default": true, @@ -898,6 +962,16 @@ "title": "Incorrect use of \"StrTemplate\"", "$id": "#/definitions/IncorrectUseOfStrTemplate" }, + "InternetAccess": { + "description": "Referring to Internet resources", + "default": false, + "type": [ + "boolean", + "object" + ], + "title": "Referring to Internet resources", + "$id": "#/definitions/InternetAccess" + }, "InvalidCharacterInFile": { "description": "Invalid character", "default": true, @@ -1480,6 +1554,24 @@ "title": "Source code parse error", "$id": "#/definitions/ParseError" }, + "PrivilegedModuleMethodCall": { + "description": "Accessing privileged module methods", + "default": true, + "type": [ + "boolean", + "object" + ], + "title": "Accessing privileged module methods", + "properties": { + "validateNestedCalls": { + "description": "Validate nested method calls from privileged modules", + "default": true, + "type": "boolean", + "title": "Validate nested method calls from privileged modules" + } + }, + "$id": "#/definitions/PrivilegedModuleMethodCall" + }, "ProcedureReturnsValue": { "description": "Procedure should not return Value", "default": true, @@ -1902,6 +1994,12 @@ "default": "\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0439_,attachable_", "type": "string", "title": "Method prefixes (comma separated)" + }, + "checkObjectModule": { + "description": "Check object modules", + "default": false, + "type": "boolean", + "title": "Check object modules" } }, "$id": "#/definitions/UnusedLocalMethod" @@ -1977,13 +2075,13 @@ "$id": "#/definitions/UsingExternalCodeTools" }, "UsingFindElementByString": { - "description": "Using FindByName and FindByCode", + "description": "Using FindByName, FindByCode and FindByNumber", "default": true, "type": [ "boolean", "object" ], - "title": "Using FindByName and FindByCode", + "title": "Using FindByName, FindByCode and FindByNumber", "$id": "#/definitions/UsingFindElementByString" }, "UsingGoto": { diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/configuration/schema.json b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/configuration/schema.json index 3626e6d94e2..96fdadfbdff 100644 --- a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/configuration/schema.json +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/configuration/schema.json @@ -146,6 +146,9 @@ "DeprecatedTypeManagedForm": { "$ref": "parameters-schema.json#/definitions/DeprecatedTypeManagedForm" }, + "DisableSafeMode": { + "$ref": "parameters-schema.json#/definitions/DisableSafeMode" + }, "DuplicateRegion": { "$ref": "parameters-schema.json#/definitions/DuplicateRegion" }, @@ -176,12 +179,18 @@ "ExportVariables": { "$ref": "parameters-schema.json#/definitions/ExportVariables" }, + "ExternalAppStarting": { + "$ref": "parameters-schema.json#/definitions/ExternalAppStarting" + }, "ExtraCommas": { "$ref": "parameters-schema.json#/definitions/ExtraCommas" }, "FieldsFromJoinsWithoutIsNull": { "$ref": "parameters-schema.json#/definitions/FieldsFromJoinsWithoutIsNull" }, + "FileSystemAccess": { + "$ref": "parameters-schema.json#/definitions/FileSystemAccess" + }, "ForbiddenMetadataName": { "$ref": "parameters-schema.json#/definitions/ForbiddenMetadataName" }, @@ -233,6 +242,9 @@ "IncorrectUseOfStrTemplate": { "$ref": "parameters-schema.json#/definitions/IncorrectUseOfStrTemplate" }, + "InternetAccess": { + "$ref": "parameters-schema.json#/definitions/InternetAccess" + }, "InvalidCharacterInFile": { "$ref": "parameters-schema.json#/definitions/InvalidCharacterInFile" }, @@ -350,6 +362,9 @@ "ParseError": { "$ref": "parameters-schema.json#/definitions/ParseError" }, + "PrivilegedModuleMethodCall": { + "$ref": "parameters-schema.json#/definitions/PrivilegedModuleMethodCall" + }, "ProcedureReturnsValue": { "$ref": "parameters-schema.json#/definitions/ProcedureReturnsValue" }, diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_en.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_en.properties index d4f0db3b506..5d24e89b057 100644 --- a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_en.properties +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_en.properties @@ -1,3 +1,4 @@ -diagnosticMessage=Prohibited word found. +diagnosticMessage=Prohibited word found <%s>. diagnosticName=Prohibited words badWords=Regular expression for prohibited words. +findInComments=Find in comments diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_ru.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_ru.properties index de3556166c6..952f8aa5921 100644 --- a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_ru.properties +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_ru.properties @@ -1,3 +1,4 @@ -diagnosticMessage=В тексте модуля найдено запрещенное слово. +diagnosticMessage=В тексте модуля найдено запрещенное слово <%s>. diagnosticName=Запрещенные слова badWords=Регулярное выражение для слов-исключений. +findInComments=Искать в комментариях diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/DisableSafeModeDiagnostic_en.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/DisableSafeModeDiagnostic_en.properties new file mode 100644 index 00000000000..7270e9aafaa --- /dev/null +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/DisableSafeModeDiagnostic_en.properties @@ -0,0 +1,2 @@ +diagnosticMessage=Check the safe mode setting +diagnosticName=Disable safe mode diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/DisableSafeModeDiagnostic_ru.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/DisableSafeModeDiagnostic_ru.properties new file mode 100644 index 00000000000..186180f5a86 --- /dev/null +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/DisableSafeModeDiagnostic_ru.properties @@ -0,0 +1,2 @@ +diagnosticMessage=Проверьте отключение безопасного режима +diagnosticName=Отключение безопасного режима diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExternalAppStartingDiagnostic_en.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExternalAppStartingDiagnostic_en.properties new file mode 100644 index 00000000000..117f5638521 --- /dev/null +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExternalAppStartingDiagnostic_en.properties @@ -0,0 +1,4 @@ +diagnosticMessage=Check the launch of an external application +diagnosticName=External applications starting +checkGotoUrl=Check navigation links +userPatternString=User regex pattern diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExternalAppStartingDiagnostic_ru.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExternalAppStartingDiagnostic_ru.properties new file mode 100644 index 00000000000..45d566bc4d6 --- /dev/null +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExternalAppStartingDiagnostic_ru.properties @@ -0,0 +1,4 @@ +diagnosticMessage=Проверьте запуск внешнего приложения +diagnosticName=Запуск внешних приложений +checkGotoUrl=Проверять переход по навигационным ссылкам +userPatternString=Пользовательский шаблон (регулярное выражение) diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/FileSystemAccessDiagnostic_en.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/FileSystemAccessDiagnostic_en.properties new file mode 100644 index 00000000000..aa06ad1bf5e --- /dev/null +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/FileSystemAccessDiagnostic_en.properties @@ -0,0 +1,4 @@ +diagnosticMessage=Check access to the file system +diagnosticName=File system access +globalMethods=Global methods pattern (regex) +newExpression=Class names pattern (regex) diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/FileSystemAccessDiagnostic_ru.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/FileSystemAccessDiagnostic_ru.properties new file mode 100644 index 00000000000..73648370051 --- /dev/null +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/FileSystemAccessDiagnostic_ru.properties @@ -0,0 +1,4 @@ +diagnosticMessage=Проверьте обращение к файловой системе +diagnosticName=Доступ к файловой системе +globalMethods=Шаблон глобальных методов (регулярное выражение) +newExpression=Шаблон классов (регулярное выражение) diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/InternetAccessDiagnostic_en.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/InternetAccessDiagnostic_en.properties new file mode 100644 index 00000000000..1e4019e3eb8 --- /dev/null +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/InternetAccessDiagnostic_en.properties @@ -0,0 +1,2 @@ +diagnosticMessage=Check the reference to Internet resources +diagnosticName=Referring to Internet resources diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/InternetAccessDiagnostic_ru.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/InternetAccessDiagnostic_ru.properties new file mode 100644 index 00000000000..4cf26b98770 --- /dev/null +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/InternetAccessDiagnostic_ru.properties @@ -0,0 +1,2 @@ +diagnosticMessage=Проверьте обращение к Интернет-ресурсам +diagnosticName=Обращение к Интернет-ресурсам diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic_en.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic_en.properties new file mode 100644 index 00000000000..eb7fdf7c62c --- /dev/null +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic_en.properties @@ -0,0 +1,3 @@ +diagnosticMessage=Check the %s method access of the privileged module +diagnosticName=Accessing privileged module methods +validateNestedCalls=Validate nested method calls from privileged modules diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic_ru.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic_ru.properties new file mode 100644 index 00000000000..e350b71eecf --- /dev/null +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnostic_ru.properties @@ -0,0 +1,3 @@ +diagnosticMessage=Проверьте обращение к методу %s привилегированного модуля +diagnosticName=Обращение к методам привилегированных модулей +validateNestedCalls=Проверять вложенные вызовы методов из привилегированных модулей diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnostic_en.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnostic_en.properties index ebadb58a518..14fb4339fec 100644 --- a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnostic_en.properties +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnostic_en.properties @@ -1,3 +1,4 @@ diagnosticMessage=Method "%s" is not called in the module diagnosticName=Unused local method attachableMethodPrefixes=Method prefixes (comma separated) +checkObjectModule=Check object modules diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnostic_ru.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnostic_ru.properties index bcebece21c0..07da1efa33f 100644 --- a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnostic_ru.properties +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnostic_ru.properties @@ -1,3 +1,4 @@ diagnosticMessage=Метод "%s" не вызывается в теле модуля diagnosticName=Неиспользуемый локальный метод attachableMethodPrefixes=Префиксы подключаемых методов (через запятую) +checkObjectModule=Проверять модули объектов diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnostic_en.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnostic_en.properties index 7f80282befe..06f19a2a603 100644 --- a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnostic_en.properties +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnostic_en.properties @@ -1,2 +1,2 @@ diagnosticMessage=Don't use method "%s" and finding by string. -diagnosticName=Using FindByName and FindByCode \ No newline at end of file +diagnosticName=Using FindByName, FindByCode and FindByNumber \ No newline at end of file diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnostic_ru.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnostic_ru.properties index 6ae96c597d6..476a7617437 100644 --- a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnostic_ru.properties +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnostic_ru.properties @@ -1,2 +1,2 @@ diagnosticMessage=Не следует использовать метод "%s" и поиск по строке -diagnosticName=Использование методов "НайтиПоНаименованию" и "НайтиПоКоду" \ No newline at end of file +diagnosticName=Использование методов "НайтиПоНаименованию", "НайтиПоКоду" и "НайтиПоНомеру" \ No newline at end of file diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/AnalyzeProjectOnStartTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/AnalyzeProjectOnStartTest.java index 4c5d1e882b8..faa9c05a617 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/AnalyzeProjectOnStartTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/AnalyzeProjectOnStartTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/AutoServerInfoTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/AutoServerInfoTest.java index b5df4634f19..8ff90150ecd 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/AutoServerInfoTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/AutoServerInfoTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLLSBindingTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLLSBindingTest.java index 119253d190d..6f9e2223ca0 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLLSBindingTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLLSBindingTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLLSPLauncherTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLLSPLauncherTest.java index 981389545a7..d762921c85b 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLLSPLauncherTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLLSPLauncherTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLLanguageServerTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLLanguageServerTest.java index ae784f112cd..73db8cd1116 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLLanguageServerTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLLanguageServerTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -66,7 +66,7 @@ void initialize() throws ExecutionException, InterruptedException { // given InitializeParams params = new InitializeParams(); - WorkspaceFolder workspaceFolder = new WorkspaceFolder(Absolute.path(PATH_TO_METADATA).toUri().toString()); + WorkspaceFolder workspaceFolder = new WorkspaceFolder(Absolute.path(PATH_TO_METADATA).toUri().toString(), "test"); List workspaceFolders = List.of(workspaceFolder); params.setWorkspaceFolders(workspaceFolders); @@ -82,7 +82,7 @@ void initializeRename() throws ExecutionException, InterruptedException { // given InitializeParams params = new InitializeParams(); - WorkspaceFolder workspaceFolder = new WorkspaceFolder(Absolute.path(PATH_TO_METADATA).toUri().toString()); + WorkspaceFolder workspaceFolder = new WorkspaceFolder(Absolute.path(PATH_TO_METADATA).toUri().toString(), "test"); List workspaceFolders = List.of(workspaceFolder); params.setWorkspaceFolders(workspaceFolders); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLTextDocumentServiceTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLTextDocumentServiceTest.java index df50c97734c..7023f3ad0fe 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLTextDocumentServiceTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/BSLTextDocumentServiceTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/ParentProcessWatcherTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/ParentProcessWatcherTest.java index ed7d7331ded..a0198eb1127 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/ParentProcessWatcherTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/ParentProcessWatcherTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/WorkDoneProgressHelperTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/WorkDoneProgressHelperTest.java index 05731571403..d1eb2080b81 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/WorkDoneProgressHelperTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/WorkDoneProgressHelperTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/MeasureCollectorTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/MeasureCollectorTest.java index 8916e4eebda..ea66470a16e 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/MeasureCollectorTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/MeasureCollectorTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/MeasuresSubsystemTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/MeasuresSubsystemTest.java index 85117b98e2a..e46250e938a 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/MeasuresSubsystemTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/aop/measures/MeasuresSubsystemTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/PermissionFilterBeforeSendCallbackTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/PermissionFilterBeforeSendCallbackTest.java index 10ccb19d507..8bcb1bc6d62 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/PermissionFilterBeforeSendCallbackTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/PermissionFilterBeforeSendCallbackTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraphBuilderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraphBuilderTest.java index 3d0ccf616a6..955140d760b 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraphBuilderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraphBuilderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -62,10 +62,11 @@ void linearBlockCanBeBuilt() { @Test void branchingWithOneBranch() { - var code = "А = 1;\n" + - "Если Б = 2 Тогда\n" + - " В = 4;\n" + - "КонецЕсли;"; + var code = """ + А = 1; + Если Б = 2 Тогда + В = 4; + КонецЕсли;"""; var parseTree = parse(code); var builder = new CfgBuildingParseTreeVisitor(); @@ -97,12 +98,12 @@ void branchingWithOneBranch() { @Test void conditionWithElse() { - var code = "А = 1;\n" + - "Если Б = 2 Тогда\n" + - " В = 4;\n" + - "Иначе\n" + - " В = 5;" + - "КонецЕсли;"; + var code = """ + А = 1; + Если Б = 2 Тогда + В = 4; + Иначе + В = 5;КонецЕсли;"""; var parseTree = parse(code); var builder = new CfgBuildingParseTreeVisitor(); @@ -129,15 +130,14 @@ void conditionWithElse() { @Test void multipleConditionsTest() { - var code = "Если Б = 1 Тогда\n" + - " В = 1;\n" + - "ИначеЕсли Б = 2 Тогда\n" + - " В = 2;\n" + - "ИначеЕсли Б = 3 Тогда\n" + - " В = 3;" + - "Иначе\n" + - " В = 4;" + - "КонецЕсли;"; + var code = """ + Если Б = 1 Тогда + В = 1; + ИначеЕсли Б = 2 Тогда + В = 2; + ИначеЕсли Б = 3 Тогда + В = 3;Иначе + В = 4;КонецЕсли;"""; var parseTree = parse(code); var builder = new CfgBuildingParseTreeVisitor(); @@ -181,10 +181,11 @@ void multipleConditionsTest() { @Test void whileLoopTest() { - var code = "А = 1;\n" + - "Пока Б = 1 Цикл\n" + - " В = 1;\n" + - "КонецЦикла;"; + var code = """ + А = 1; + Пока Б = 1 Цикл + В = 1; + КонецЦикла;"""; var parseTree = parse(code); var builder = new CfgBuildingParseTreeVisitor(); @@ -218,19 +219,20 @@ void whileLoopTest() { @Test void testInnerLoops() { - var code = "А = 1;\n" + - "Пока Б = 1 Цикл\n" + - " В = 1;\n" + - " Если А = 1 Тогда\n" + - " Продолжить;\n" + - " КонецЕсли;\n" + - " Для Сч = 1 По 5 Цикл\n" + - " Б = 1;\n" + - " Прервать;\n" + - " В = 2;\n" + - " КонецЦикла;\n" + - " Прервано = Истина;\n" + - "КонецЦикла;"; + var code = """ + А = 1; + Пока Б = 1 Цикл + В = 1; + Если А = 1 Тогда + Продолжить; + КонецЕсли; + Для Сч = 1 По 5 Цикл + Б = 1; + Прервать; + В = 2; + КонецЦикла; + Прервано = Истина; + КонецЦикла;"""; var parseTree = parse(code); var builder = new CfgBuildingParseTreeVisitor(); @@ -288,11 +290,12 @@ void testInnerLoops() { @Test void tryHandlerFlowTest() { - var code = "Попытка\n" + - " А = 1;\n" + - "Исключение\n" + - " Б = 1;\n" + - "КонецПопытки"; + var code = """ + Попытка + А = 1; + Исключение + Б = 1; + КонецПопытки"""; var parseTree = parse(code); var builder = new CfgBuildingParseTreeVisitor(); @@ -315,10 +318,11 @@ void tryHandlerFlowTest() { @Test void linearBlockWithLabel() { - var code = "А = 1;\n" + - "Б = 2;\n" + - "~Прыг:\n" + - "В = 4;"; + var code = """ + А = 1; + Б = 2; + ~Прыг: + В = 4;"""; var parseTree = parse(code); var builder = new CfgBuildingParseTreeVisitor(); @@ -339,12 +343,13 @@ void linearBlockWithLabel() { @Test void linearBlockWithJumpToLabel() { - var code = "А = 1;\n" + - "Б = 2;\n" + - "~Прыг:\n" + - "В = 4;\n" + - "Перейти ~Прыг;\n" + - "МертвыйКод = Истина;"; + var code = """ + А = 1; + Б = 2; + ~Прыг: + В = 4; + Перейти ~Прыг; + МертвыйКод = Истина;"""; var parseTree = parse(code); var builder = new CfgBuildingParseTreeVisitor(); @@ -376,7 +381,7 @@ void hardcoreCrazyJumpingTest() { var list = graph.vertexSet().stream() .filter(x -> x instanceof BasicBlockVertex) - .filter(x -> ((BasicBlockVertex) x).statements().size() == 0) + .filter(x -> ((BasicBlockVertex) x).statements().isEmpty()) .collect(Collectors.toList()); assertThat(list).isEmpty(); @@ -385,11 +390,12 @@ void hardcoreCrazyJumpingTest() { @Test void preprocessorSingleIfBranching() { - var code = "А = 1;\n" + - "#Если Сервер Тогда\n" + - " Б = 2;\n" + - "#КонецЕсли\n" + - "В = 3;"; + var code = """ + А = 1; + #Если Сервер Тогда + Б = 2; + #КонецЕсли + В = 3;"""; var parseTree = parse(code); var builder = new CfgBuildingParseTreeVisitor(); @@ -414,13 +420,13 @@ void preprocessorSingleIfBranching() { @Test void preprocessorIfWithElseBranching() { - var code = "А = 1;\n" + - "#Если Сервер Тогда\n" + - " Б = 2;\n" + - "#Иначе\n" + - " Б = 3;" + - "#КонецЕсли\n" + - "В = 3;"; + var code = """ + А = 1; + #Если Сервер Тогда + Б = 2; + #Иначе + Б = 3;#КонецЕсли + В = 3;"""; var parseTree = parse(code); var builder = new CfgBuildingParseTreeVisitor(); @@ -447,17 +453,17 @@ void preprocessorIfWithElseBranching() { @Test void preprocessorIfWithElseIfBranching() { - var code = "А = 1;\n" + - "#Если Сервер Тогда\n" + - " Б = 2;\n" + - "#ИначеЕсли ВебКлиент Тогда\n" + - " Б = 3;\n" + - "#ИначеЕсли МобильныйКлиент Тогда\n" + - " Б = 4;\n" + - "#Иначе\n" + - " Б = 5;" + - "#КонецЕсли\n" + - "В = 3;"; + var code = """ + А = 1; + #Если Сервер Тогда + Б = 2; + #ИначеЕсли ВебКлиент Тогда + Б = 3; + #ИначеЕсли МобильныйКлиент Тогда + Б = 4; + #Иначе + Б = 5;#КонецЕсли + В = 3;"""; var parseTree = parse(code); var builder = new CfgBuildingParseTreeVisitor(); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/cli/VersionCommandTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/cli/VersionCommandTest.java index a888849b919..cb10c67e30d 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/cli/VersionCommandTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/cli/VersionCommandTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/cli/WebsocketCommandTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/cli/WebsocketCommandTest.java index 7f71b446785..fe7c95416b2 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/cli/WebsocketCommandTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/cli/WebsocketCommandTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/DisableDiagnosticTriggeringSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/DisableDiagnosticTriggeringSupplierTest.java index bb19756f59e..8a7ec6a89a9 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/DisableDiagnosticTriggeringSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/DisableDiagnosticTriggeringSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/ExtractStructureConstructorSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/ExtractStructureConstructorSupplierTest.java index 750d3fcb453..a33fed7fd2d 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/ExtractStructureConstructorSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/ExtractStructureConstructorSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/GenerateStandardRegionsSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/GenerateStandardRegionsSupplierTest.java index 7904ed1d50e..70101561795 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/GenerateStandardRegionsSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/GenerateStandardRegionsSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/QuickFixSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/QuickFixSupplierTest.java index a739ca44aa5..e37eb8c450c 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/QuickFixSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codeactions/QuickFixSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CognitiveComplexityCodeLensSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CognitiveComplexityCodeLensSupplierTest.java index 5c9c6ab94f4..afeafa61a62 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CognitiveComplexityCodeLensSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CognitiveComplexityCodeLensSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CyclomaticComplexityCodeLensSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CyclomaticComplexityCodeLensSupplierTest.java index b972498a354..77dc1a5b1a7 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CyclomaticComplexityCodeLensSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/CyclomaticComplexityCodeLensSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunAllTestsCodeLensSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunAllTestsCodeLensSupplierTest.java index 2ba9080ebfa..cb61f676b29 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunAllTestsCodeLensSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunAllTestsCodeLensSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunTestCodeLensSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunTestCodeLensSupplierTest.java index 5fd85954142..342a126f3d1 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunTestCodeLensSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/codelenses/RunTestCodeLensSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorInformationSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorInformationSupplierTest.java index 4a6532aac74..476774f6998 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorInformationSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorInformationSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorPresentationSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorPresentationSupplierTest.java index 1b5accc5e12..4a04aa643d8 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorPresentationSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/ConstructorColorPresentationSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorInformationSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorInformationSupplierTest.java index 7cb08ff6412..eb98f7210c3 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorInformationSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorInformationSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorPresentationSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorPresentationSupplierTest.java index 21731fd2528..eedc84270a0 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorPresentationSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/color/WebColorPresentationSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCognitiveComplexityInlayHintsCommandSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCognitiveComplexityInlayHintsCommandSupplierTest.java index 865ed9d3444..54faa284ec9 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCognitiveComplexityInlayHintsCommandSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCognitiveComplexityInlayHintsCommandSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCyclomaticComplexityInlayHintsCommandSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCyclomaticComplexityInlayHintsCommandSupplierTest.java index 563addeca9d..fe1cd55467d 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCyclomaticComplexityInlayHintsCommandSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/commands/ToggleCyclomaticComplexityInlayHintsCommandSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/ConfigurationTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/ConfigurationTest.java index 82ffca4531e..bab11690a6c 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/ConfigurationTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/ConfigurationTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/GlobalConfigurationTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/GlobalConfigurationTest.java index 95bb4e94e51..59e841a769c 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/GlobalConfigurationTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/GlobalConfigurationTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/LanguageServerConfigurationTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/LanguageServerConfigurationTest.java index 0dbb67436c4..5dbd499e544 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/LanguageServerConfigurationTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/LanguageServerConfigurationTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/ConfigurationFileSystemWatcherTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/ConfigurationFileSystemWatcherTest.java index f44891e1dbd..5b697d42d03 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/ConfigurationFileSystemWatcherTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/configuration/watcher/ConfigurationFileSystemWatcherTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContextTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContextTest.java index 1591129271b..10cea84790d 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContextTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContextTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -137,7 +137,7 @@ void testRegionsAdjustingCompute() { List regions = documentContext.getSymbolTree().getModuleLevelRegions(); // then - assertThat(regions).anyMatch(regionSymbol -> regionSymbol.getMethods().size() > 0); + assertThat(regions).anyMatch(regionSymbol -> !regionSymbol.getMethods().isEmpty()); } @Test diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/ServerContextTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/ServerContextTest.java index 8e2efa4b1c3..460211b86fc 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/ServerContextTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/ServerContextTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -25,16 +25,13 @@ import com.github._1c_syntax.bsl.mdo.support.ScriptVariant; import com.github._1c_syntax.bsl.types.ConfigurationSource; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.Configuration; import com.github._1c_syntax.utils.Absolute; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import java.io.File; -import java.io.IOException; import java.nio.file.Path; -import java.nio.file.Paths; import static org.assertj.core.api.Assertions.assertThat; @@ -52,10 +49,9 @@ class ServerContextTest { @Test void testConfigurationMetadata() { - Path path = Absolute.path(PATH_TO_METADATA); serverContext.setConfigurationRoot(path); - Configuration configurationMetadata = serverContext.getConfiguration(); + var configurationMetadata = serverContext.getConfiguration(); assertThat(configurationMetadata).isNotNull(); @@ -67,14 +63,12 @@ void testConfigurationMetadata() { assertThat(configurationMetadata.getCompatibilityMode().getVersion()).isEqualTo(10); File file = new File(PATH_TO_METADATA, PATH_TO_MODULE_FILE); - ModuleType type = configurationMetadata.getModuleType(Absolute.uri(file.toURI())); + ModuleType type = configurationMetadata.getModuleTypeByURI(Absolute.uri(file.toURI())); assertThat(type).isEqualTo(ModuleType.CommonModule); - } @Test - void testMdoRefs() throws IOException { - + void testMdoRefs() { var path = Absolute.path(PATH_TO_METADATA); serverContext.setConfigurationRoot(path); var mdoRefCommonModule = "CommonModule.ПервыйОбщийМодуль"; @@ -106,10 +100,10 @@ void testMdoRefs() throws IOException { @Test void testErrorConfigurationMetadata() { - Path path = Absolute.path(Paths.get(PATH_TO_METADATA, "test")); + Path path = Absolute.path(PATH_TO_METADATA + "test"); serverContext.setConfigurationRoot(path); - Configuration configurationMetadata = serverContext.getConfiguration(); + var configurationMetadata = serverContext.getConfiguration(); assertThat(configurationMetadata).isNotNull(); assertThat(configurationMetadata.getModulesByType()).isEmpty(); @@ -137,5 +131,4 @@ private DocumentContext addDocumentContext(ServerContext serverContext, String p serverContext.rebuildDocument(documentContext); return documentContext; } - } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CognitiveComplexityComputerTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CognitiveComplexityComputerTest.java index 8e97a797fb0..842a15d7e28 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CognitiveComplexityComputerTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CognitiveComplexityComputerTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CyclomaticComplexityComputerTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CyclomaticComplexityComputerTest.java index 12a6882ec27..3512108c9a3 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CyclomaticComplexityComputerTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/CyclomaticComplexityComputerTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/DiagnosticIgnoranceComputerTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/DiagnosticIgnoranceComputerTest.java index 86800f523a5..fe8e646bfe9 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/DiagnosticIgnoranceComputerTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/DiagnosticIgnoranceComputerTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputerTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputerTest.java index f60dc4caa92..eea9fb8ee96 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputerTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputerTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ModuleSymbolComputerTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ModuleSymbolComputerTest.java index 70682c80e1b..0dd8dc64d43 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ModuleSymbolComputerTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ModuleSymbolComputerTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -23,9 +23,9 @@ import com.github._1c_syntax.bsl.languageserver.util.TestUtils; import com.github._1c_syntax.bsl.languageserver.utils.Ranges; +import com.github._1c_syntax.bsl.mdo.MD; import com.github._1c_syntax.bsl.types.MdoReference; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; import org.eclipse.lsp4j.SymbolKind; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @@ -68,7 +68,7 @@ void testModuleName() { var mdoReference = mock(MdoReference.class); when(mdoReference.getMdoRef()).thenReturn("Document.Document1"); - AbstractMDObjectBase mdObject = mock(AbstractMDObjectBase.class); + var mdObject = mock(MD.class); when(mdObject.getMdoReference()).thenReturn(mdoReference); doReturn(Optional.of(mdObject)).when(documentContext).getMdObject(); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/QueryComputerTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/QueryComputerTest.java index 277f2ab2a17..9a373864721 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/QueryComputerTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/QueryComputerTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/SymbolTreeComputerTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/SymbolTreeComputerTest.java index cc5fc179125..8dee44842cc 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/SymbolTreeComputerTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/SymbolTreeComputerTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/VariableSymbolTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/VariableSymbolTest.java index 76fd6968938..453e5e766e5 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/VariableSymbolTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/VariableSymbolTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -52,11 +52,11 @@ void setup() { @Test void testVariableSymbolDescription() { - assertThat(variableSymbols).hasSize(19); + assertThat(variableSymbols).hasSize(23); assertThat(variableSymbols) .filteredOn(variableSymbol -> variableSymbol.getDescription().isEmpty()) - .hasSize(9) + .hasSize(11) .anyMatch(variableSymbol -> variableSymbol.getRange().equals(Ranges.create(12, 6, 34))) .anyMatch(variableSymbol -> variableSymbol.getRange().equals(Ranges.create(14, 6, 27))) .anyMatch(variableSymbol -> variableSymbol.getRange().equals(Ranges.create(16, 6, 17))) @@ -65,11 +65,12 @@ void testVariableSymbolDescription() { .anyMatch(variableSymbol -> variableSymbol.getRange().equals(Ranges.create(32, 31, 59))) .anyMatch(variableSymbol -> variableSymbol.getRange().equals(Ranges.create(33, 10, 19))) .anyMatch(variableSymbol -> variableSymbol.getRange().equals(Ranges.create(55, 0, 35))) - .anyMatch(variableSymbol -> variableSymbol.getRange().equals(Ranges.create(56, 0, 47))); + .anyMatch(variableSymbol -> variableSymbol.getRange().equals(Ranges.create(56, 0, 47))) + ; assertThat(variableSymbols) .filteredOn(variableSymbol -> variableSymbol.getDescription().isPresent()) - .hasSize(10) + .hasSize(12) .anyMatch(variableSymbol -> variableSymbol.getRange().equals(Ranges.create(2, 6, 32))) .anyMatch(variableSymbol -> variableSymbol.getRange().equals(Ranges.create(6, 6, 33))) .anyMatch(variableSymbol -> variableSymbol.getRange().equals(Ranges.create(8, 6, 33))) @@ -92,7 +93,7 @@ void testVariableDescriptionRange() { .collect(Collectors.toList()); assertThat(variableDescriptions) - .hasSize(10) + .hasSize(12) .filteredOn(variableDescription -> !variableDescription.getDescription().equals("")) .hasSize(5) .anyMatch(variableDescription -> variableDescription.getRange().equals(Ranges.create(1, 0, 18))) @@ -105,13 +106,15 @@ void testVariableDescriptionRange() { assertThat(variableDescriptions) .extracting(VariableDescription::getTrailingDescription) .filteredOn(Optional::isPresent) - .hasSize(7) + .hasSize(9) .extracting(Optional::get) .anyMatch(trailingDescription -> trailingDescription.getRange().equals(Ranges.create(8, 35, 55))) .anyMatch(variableDescription -> variableDescription.getRange().equals(Ranges.create(19, 20, 42))) .anyMatch(variableDescription -> variableDescription.getRange().equals(Ranges.create(24, 20, 42))) .anyMatch(variableDescription -> variableDescription.getRange().equals(Ranges.create(35, 21, 43))) .anyMatch(variableDescription -> variableDescription.getRange().equals(Ranges.create(39, 21, 43))) + .anyMatch(variableDescription -> variableDescription.getRange().equals(Ranges.create(63, 45, 77))) + .anyMatch(variableDescription -> variableDescription.getRange().equals(Ranges.create(71, 38, 70))) ; } @@ -121,7 +124,7 @@ void testVariableNameRange() { assertThat(variableSymbols) .filteredOn(variableSymbol -> variableSymbol.getDescription().isEmpty()) - .hasSize(9) + .hasSize(11) .anyMatch(variableName -> variableName.getVariableNameRange().equals(Ranges.create(12, 6, 34))) .anyMatch(variableName -> variableName.getVariableNameRange().equals(Ranges.create(14, 6, 27))) .anyMatch(variableName -> variableName.getVariableNameRange().equals(Ranges.create(16, 6, 17))) @@ -131,6 +134,8 @@ void testVariableNameRange() { .anyMatch(variableName -> variableName.getVariableNameRange().equals(Ranges.create(33, 10, 19))) .anyMatch(variableName -> variableName.getVariableNameRange().equals(Ranges.create(55, 0, 35))) .anyMatch(variableName -> variableName.getVariableNameRange().equals(Ranges.create(56, 0, 47))) + .anyMatch(variableName -> variableName.getVariableNameRange().equals(Ranges.create(59, 12, 30))) + .anyMatch(variableName -> variableName.getVariableNameRange().equals(Ranges.create(67, 4, 22))) ; } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/MethodDescriptionTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/MethodDescriptionTest.java index a5659ac4cdc..339f8f752af 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/MethodDescriptionTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/MethodDescriptionTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -59,9 +59,11 @@ void prepare() { @Test void testMethod13() { var method = methodsWithDescription.get(12); - assertThat(method.getPurposeDescription()).isEqualTo("Значения реквизитов, прочитанные из информационной базы для нескольких объектов.\n" + - "\nЕсли необходимо зачитать реквизит независимо от прав текущего пользователя,\n" + - "то следует использовать предварительный переход в привилегированный режим."); + assertThat(method.getPurposeDescription()).isEqualTo(""" + Значения реквизитов, прочитанные из информационной базы для нескольких объектов. + + Если необходимо зачитать реквизит независимо от прав текущего пользователя, + то следует использовать предварительный переход в привилегированный режим."""); assertThat(method.isDeprecated()).isFalse(); assertThat(method.getDeprecationInfo()).isEmpty(); assertThat(method.getExamples()).isEmpty(); @@ -74,9 +76,10 @@ void testMethod13() { assertThat(param.getName()).isEqualTo("Ссылки"); assertThat(param.getTypes()).hasSize(1); assertThat(param.getTypes().get(0).getName()).isEqualTo("Массив"); - assertThat(param.getTypes().get(0).getDescription()).isEqualTo("массив ссылок на объекты одного типа.\n" + - "Значения массива должны быть ссылками на объекты одного типа.\n" + - "если массив пуст, то результатом будет пустое соответствие."); + assertThat(param.getTypes().get(0).getDescription()).isEqualTo(""" + массив ссылок на объекты одного типа. + Значения массива должны быть ссылками на объекты одного типа. + если массив пуст, то результатом будет пустое соответствие."""); assertThat(param.isHyperlink()).isFalse(); param = method.getParameters().get(1); @@ -93,11 +96,12 @@ void testMethod13() { assertThat(param.getTypes()).hasSize(1); assertThat(param.getTypes().get(0).getName()).isEqualTo("Булево"); assertThat(param.getTypes().get(0).getDescription()).isEqualTo( - "если Истина, то запрос к объектам выполняется с учетом прав пользователя, и в случае,\n" + - "- если какой-либо объект будет исключен из выборки по правам, то этот объект\n" + - "будет исключен и из результата;\n" + - "- если Ложь, то возникнет исключение при отсутствии прав на таблицу\n" + - "или любой из реквизитов."); + """ + если Истина, то запрос к объектам выполняется с учетом прав пользователя, и в случае, + - если какой-либо объект будет исключен из выборки по правам, то этот объект + будет исключен и из результата; + - если Ложь, то возникнет исключение при отсутствии прав на таблицу + или любой из реквизитов."""); assertThat(param.isHyperlink()).isFalse(); var type = method.getReturnedValue().get(0); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractDiagnosticTest.java index c290e46bdee..8d845642a63 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSymbolTreeDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSymbolTreeDiagnosticTest.java index 29be15c329f..565457a6583 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSymbolTreeDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractSymbolTreeDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AllFunctionPathMustHaveReturnDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AllFunctionPathMustHaveReturnDiagnosticTest.java index b5383e51261..ffb3d88ed29 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AllFunctionPathMustHaveReturnDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AllFunctionPathMustHaveReturnDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -83,15 +83,16 @@ void testElsIfClausesWithoutElse() { @Test void testEmptyIfBodies() { - var sample = "Функция Тест()\n" + - " Список = Новый СписокЗначений;\n" + - " #Если Сервер Или ТолстыйКлиентОбычноеПриложение Или ВнешнееСоединение Тогда\n" + - " Если Условие Тогда\n" + - " Иначе\n" + - " КонецЕсли;\n" + - " #КонецЕсли\n" + - " Возврат Список;\n" + - "КонецФункции"; + var sample = """ + Функция Тест() + Список = Новый СписокЗначений; + #Если Сервер Или ТолстыйКлиентОбычноеПриложение Или ВнешнееСоединение Тогда + Если Условие Тогда + Иначе + КонецЕсли; + #КонецЕсли + Возврат Список; + КонецФункции"""; var documentContext = TestUtils.getDocumentContext(sample); var diagnostics = getDiagnostics(documentContext); @@ -103,17 +104,18 @@ void testEmptyIfBodies() { @Test void testExitByRaiseException() { var sample = - "Функция Тест()\n" + - "Если Не ВебКлиент Тогда\n" + - " Массив = Новый Массив;\n" + - " Если Условие Тогда\n" + - " Возврат Массив;\n" + - " КонецЕсли;\n" + - " Возврат ПустойМассив;\n" + - "#Иначе\n" + - " ВызватьИсключение \"Упс\";\n" + - "#КонецЕсли\n" + - "КонецФункции"; + """ + Функция Тест() + Если Не ВебКлиент Тогда + Массив = Новый Массив; + Если Условие Тогда + Возврат Массив; + КонецЕсли; + Возврат ПустойМассив; + #Иначе + ВызватьИсключение "Упс"; + #КонецЕсли + КонецФункции"""; var documentContext = TestUtils.getDocumentContext(sample); var diagnostics = getDiagnostics(documentContext); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AssignAliasFieldsInQueryDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AssignAliasFieldsInQueryDiagnosticTest.java index c472aed0c70..0204d6cfcc7 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AssignAliasFieldsInQueryDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AssignAliasFieldsInQueryDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnosticTest.java index 22d5eff9d42..3b9c4cf0dba 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -38,7 +38,7 @@ class BadWordsDiagnosticTest extends AbstractDiagnosticTest{ void test() { List diagnostics = getDiagnostics(); - assertThat(diagnostics).hasSize(0); // Проверка количества + assertThat(diagnostics).isEmpty(); // Проверка количества } @Test @@ -52,11 +52,29 @@ void testConfigure() { assertThat(diagnostics).hasSize(6); assertThat(diagnostics, true) - .hasRange(0, 42, 0, 47) - .hasRange(0, 48, 0, 54) - .hasRange(4, 4, 4, 9) - .hasRange(6, 24, 6, 29) - .hasRange(6, 34, 6, 39) - .hasRange(8, 4, 8, 10); + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <лотус>.", 0, 42, 0, 47) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <шмотус>.", 0, 48, 0, 54) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Лотус>.", 4, 4, 4, 9) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Лотус>.", 6, 24, 6, 29) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Лотус>.", 6, 34, 6, 39) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Шмотус>.", 8, 4, 8, 10); + } + + @Test + void testFindWithoutComments() { + + Map configuration = diagnosticInstance.info.getDefaultConfiguration(); + configuration.put("badWords", "лотус|шмотус"); + configuration.put("findInComments", false); + diagnosticInstance.configure(configuration); + + List diagnostics = getDiagnostics(); + + assertThat(diagnostics).hasSize(4); + assertThat(diagnostics, true) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Лотус>.", 4, 4, 4, 9) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Лотус>.", 6, 24, 6, 29) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Лотус>.", 6, 34, 6, 39) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Шмотус>.", 8, 4, 8, 10); } } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BeginTransactionBeforeTryCatchDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BeginTransactionBeforeTryCatchDiagnosticTest.java index 27298972aad..7bf06ddcf88 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BeginTransactionBeforeTryCatchDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BeginTransactionBeforeTryCatchDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CachedPublicDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CachedPublicDiagnosticTest.java index 13a17ce0d20..53f02b9a8e9 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CachedPublicDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CachedPublicDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -23,8 +23,8 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.mdo.support.ReturnValueReuse; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; import com.github._1c_syntax.utils.Absolute; import lombok.SneakyThrows; import org.apache.commons.io.FileUtils; @@ -48,7 +48,7 @@ class CachedPublicDiagnosticTest extends AbstractDiagnosticTest, Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeAfterAsyncCallDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeAfterAsyncCallDiagnosticTest.java index b9756dd6769..3675dd3711e 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeAfterAsyncCallDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeAfterAsyncCallDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeBlockBeforeSubDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeBlockBeforeSubDiagnosticTest.java index 25ea00e934e..96f4521ddd9 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeBlockBeforeSubDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeBlockBeforeSubDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeOutOfRegionDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeOutOfRegionDiagnosticTest.java index 7ea280a1294..30aa6aeedd4 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeOutOfRegionDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeOutOfRegionDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CognitiveComplexityDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CognitiveComplexityDiagnosticTest.java index 8d36f50ed91..1755f5abd74 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CognitiveComplexityDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CognitiveComplexityDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommandModuleExportMethodsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommandModuleExportMethodsDiagnosticTest.java index 4dcf748f2a6..b88029236cc 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommandModuleExportMethodsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommandModuleExportMethodsDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommentedCodeDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommentedCodeDiagnosticTest.java index c73ee483385..a3c68def6e0 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommentedCodeDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommentedCodeDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -81,9 +81,9 @@ void testConfigure() { Map configuration = diagnosticInstance.info.getDefaultConfiguration(); List thresholdVariants = new ArrayList<>(); - thresholdVariants.add(Float.valueOf(1f)); - thresholdVariants.add(Double.valueOf(1)); - thresholdVariants.add(Integer.valueOf(1)); + thresholdVariants.add(1f); + thresholdVariants.add(1.0); + thresholdVariants.add(1); for (Object threshold : thresholdVariants){ configuration.put("threshold", threshold); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommitTransactionOutsideTryCatchDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommitTransactionOutsideTryCatchDiagnosticTest.java index 26a50825a01..43cceea2ca5 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommitTransactionOutsideTryCatchDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommitTransactionOutsideTryCatchDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleAssignDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleAssignDiagnosticTest.java index 1bfae007369..94aa6a5ac8f 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleAssignDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleAssignDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleInvalidTypeDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleInvalidTypeDiagnosticTest.java index 654e7773960..d1c2ea451b6 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleInvalidTypeDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleInvalidTypeDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -24,7 +24,7 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterEachTestMethod; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.utils.Absolute; import lombok.SneakyThrows; import org.apache.commons.io.FileUtils; @@ -47,7 +47,7 @@ class CommonModuleInvalidTypeDiagnosticTest extends AbstractDiagnosticTest, Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameCachedDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameCachedDiagnosticTest.java index acc188d7e0a..6236d1c0883 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameCachedDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameCachedDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -24,8 +24,8 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterEachTestMethod; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.mdo.support.ReturnValueReuse; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; import com.github._1c_syntax.utils.Absolute; import lombok.SneakyThrows; import org.apache.commons.io.FileUtils; @@ -44,7 +44,7 @@ @CleanupContextBeforeClassAndAfterEachTestMethod class CommonModuleNameCachedDiagnosticTest extends AbstractDiagnosticTest { - private MDCommonModule module; + private CommonModule module; private DocumentContext documentContext; CommonModuleNameCachedDiagnosticTest() { @@ -165,7 +165,6 @@ void testEmptyFile() { @SneakyThrows void getDocumentContextFromFile() { - Path path = Absolute.path(PATH_TO_METADATA); Path testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath(); @@ -176,10 +175,6 @@ void getDocumentContextFromFile() { FileUtils.readFileToString(testFile.toFile(), StandardCharsets.UTF_8), context )); - - - module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri())); - + module = spy((CommonModule) configuration.findChild(documentContext.getUri()).get()); } - } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientDiagnosticTest.java index 17a67f765e0..b4ef16846c5 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -24,7 +24,7 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterEachTestMethod; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.utils.Absolute; import lombok.SneakyThrows; import org.apache.commons.io.FileUtils; @@ -44,7 +44,7 @@ @CleanupContextBeforeClassAndAfterEachTestMethod class CommonModuleNameClientDiagnosticTest extends AbstractDiagnosticTest { private DocumentContext documentContext; - private MDCommonModule module; + private CommonModule module; CommonModuleNameClientDiagnosticTest() { super(CommonModuleNameClientDiagnostic.class); @@ -163,10 +163,8 @@ void testGlobal() { } - @SneakyThrows void getDocumentContextFromFile() { - Path path = Absolute.path(PATH_TO_METADATA); Path testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath(); @@ -177,10 +175,6 @@ void getDocumentContextFromFile() { FileUtils.readFileToString(testFile.toFile(), StandardCharsets.UTF_8), context )); - - - module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri())); - + module = spy((CommonModule) configuration.findChild(documentContext.getUri()).get()); } - } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientServerDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientServerDiagnosticTest.java index 0e1248ccfb1..489831eef7e 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientServerDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameClientServerDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -24,7 +24,7 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterEachTestMethod; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.utils.Absolute; import lombok.SneakyThrows; import org.apache.commons.io.FileUtils; @@ -43,7 +43,7 @@ @CleanupContextBeforeClassAndAfterEachTestMethod class CommonModuleNameClientServerDiagnosticTest extends AbstractDiagnosticTest { - private MDCommonModule module; + private CommonModule module; private DocumentContext documentContext; CommonModuleNameClientServerDiagnosticTest() { @@ -165,7 +165,6 @@ void testFalse2() { @SneakyThrows void getDocumentContextFromFile() { - Path path = Absolute.path(PATH_TO_METADATA); Path testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath(); @@ -176,9 +175,6 @@ void getDocumentContextFromFile() { FileUtils.readFileToString(testFile.toFile(), StandardCharsets.UTF_8), context )); - - - module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri())); - + module = spy((CommonModule) configuration.findChild(documentContext.getUri()).get()); } } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameFullAccessDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameFullAccessDiagnosticTest.java index 4ce1a77f55a..825ce51b1c4 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameFullAccessDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameFullAccessDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -24,7 +24,7 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterEachTestMethod; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.utils.Absolute; import lombok.SneakyThrows; import org.apache.commons.io.FileUtils; @@ -44,7 +44,7 @@ @CleanupContextBeforeClassAndAfterEachTestMethod class CommonModuleNameFullAccessDiagnosticTest extends AbstractDiagnosticTest { private DocumentContext documentContext; - private MDCommonModule module; + private CommonModule module; CommonModuleNameFullAccessDiagnosticTest() { super(CommonModuleNameFullAccessDiagnostic.class); @@ -116,7 +116,6 @@ void testFalse() { @SneakyThrows void getDocumentContextFromFile() { - Path path = Absolute.path(PATH_TO_METADATA); Path testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath(); @@ -128,8 +127,6 @@ void getDocumentContextFromFile() { context )); - - module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri())); - + module = spy((CommonModule) configuration.findChild(documentContext.getUri()).get()); } } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalClientDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalClientDiagnosticTest.java index bf57dc69af6..62902d5fec0 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalClientDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalClientDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -24,7 +24,7 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterEachTestMethod; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.utils.Absolute; import lombok.SneakyThrows; import org.apache.commons.io.FileUtils; @@ -43,7 +43,7 @@ @CleanupContextBeforeClassAndAfterEachTestMethod class CommonModuleNameGlobalClientDiagnosticTest extends AbstractDiagnosticTest { - private MDCommonModule module; + private CommonModule module; private DocumentContext documentContext; CommonModuleNameGlobalClientDiagnosticTest() { @@ -206,7 +206,6 @@ void testClient() { @SneakyThrows void getDocumentContextFromFile() { - Path path = Absolute.path(PATH_TO_METADATA); Path testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath(); @@ -217,9 +216,6 @@ void getDocumentContextFromFile() { FileUtils.readFileToString(testFile.toFile(), StandardCharsets.UTF_8), context )); - - - module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri())); - + module = spy((CommonModule) configuration.findChild(documentContext.getUri()).get()); } } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalDiagnosticTest.java index 5d86f4b365f..3695b89580e 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameGlobalDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -24,7 +24,7 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterEachTestMethod; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.utils.Absolute; import lombok.SneakyThrows; import org.apache.commons.io.FileUtils; @@ -44,7 +44,7 @@ @CleanupContextBeforeClassAndAfterEachTestMethod class CommonModuleNameGlobalDiagnosticTest extends AbstractDiagnosticTest { private DocumentContext documentContext; - private MDCommonModule module; + private CommonModule module; CommonModuleNameGlobalDiagnosticTest() { super(CommonModuleNameGlobalDiagnostic.class); @@ -53,7 +53,6 @@ class CommonModuleNameGlobalDiagnosticTest extends AbstractDiagnosticTest, Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -24,7 +24,7 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterEachTestMethod; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.utils.Absolute; import lombok.SneakyThrows; import org.apache.commons.io.FileUtils; @@ -44,7 +44,7 @@ @CleanupContextBeforeClassAndAfterEachTestMethod class CommonModuleNameServerCallDiagnosticTest extends AbstractDiagnosticTest { - private MDCommonModule module; + private CommonModule module; private DocumentContext documentContext; CommonModuleNameServerCallDiagnosticTest() { @@ -146,7 +146,6 @@ void TestNegative() { @SneakyThrows void getDocumentContextFromFile() { - Path path = Absolute.path(PATH_TO_METADATA); Path testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath(); @@ -157,9 +156,6 @@ void getDocumentContextFromFile() { FileUtils.readFileToString(testFile.toFile(), StandardCharsets.UTF_8), context )); - - - module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri())); - + module = spy((CommonModule) configuration.findChild(documentContext.getUri()).get()); } } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameWordsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameWordsDiagnosticTest.java index b783b50c1bc..dd5aebbe8b9 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameWordsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleNameWordsDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -24,7 +24,7 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterEachTestMethod; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.utils.Absolute; import lombok.SneakyThrows; import org.apache.commons.io.FileUtils; @@ -45,7 +45,7 @@ @CleanupContextBeforeClassAndAfterEachTestMethod class CommonModuleNameWordsDiagnosticTest extends AbstractDiagnosticTest { - private MDCommonModule module; + private CommonModule module; private DocumentContext documentContext; CommonModuleNameWordsDiagnosticTest() { @@ -118,7 +118,6 @@ void testConfigure() { @SneakyThrows void getDocumentContextFromFile() { - Path path = Absolute.path(PATH_TO_METADATA); Path testFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath(); @@ -129,10 +128,7 @@ void getDocumentContextFromFile() { FileUtils.readFileToString(testFile.toFile(), StandardCharsets.UTF_8), context )); - - - module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri())); - + module = spy((CommonModule) configuration.findChild(documentContext.getUri()).get()); } } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveLostDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveLostDiagnosticTest.java index 0a00e8cf490..ea5b1e6d662 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveLostDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveLostDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -21,9 +21,9 @@ */ package com.github._1c_syntax.bsl.languageserver.diagnostics; +import com.github._1c_syntax.bsl.mdo.Form; import com.github._1c_syntax.bsl.mdo.support.FormType; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDOForm; import com.github._1c_syntax.utils.Absolute; import org.eclipse.lsp4j.Diagnostic; import org.junit.jupiter.api.Test; @@ -56,12 +56,11 @@ void test() { void testOriginalFormModule() { final var PATH_TO_METADATA = "src/test/resources/metadata/designer"; initServerContext(Absolute.path(PATH_TO_METADATA)); - var form = spy((AbstractMDOForm) context.getConfiguration().getChildren().stream() + var form = spy((Form) context.getConfiguration().getPlainChildren().stream() .filter(mdo -> mdo.getName().equalsIgnoreCase("ФормаЭлемента")) .findFirst() .get()); - var documentContext = spy(getDocumentContext()); when(documentContext.getModuleType()).thenReturn(ModuleType.FormModule); when(form.getFormType()).thenReturn(FormType.ORDINARY); @@ -71,5 +70,4 @@ void testOriginalFormModule() { assertThat(diagnostics).isEmpty(); } - } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveNeedLessDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveNeedLessDiagnosticTest.java index 4f21cccaba3..a216029eede 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveNeedLessDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CompilationDirectiveNeedLessDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ConsecutiveEmptyLinesDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ConsecutiveEmptyLinesDiagnosticTest.java index 1ddc6f55a9e..57b025766e6 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ConsecutiveEmptyLinesDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ConsecutiveEmptyLinesDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -39,9 +39,10 @@ class ConsecutiveEmptyLinesDiagnosticTest extends AbstractDiagnosticTest diagnostics = getDiagnosticsForText(module); @@ -53,10 +54,11 @@ void test_EmptyTwoFirstLines() { @Test void test_EmptyThreeFirstLines() { - String module = " \n" + - "\n" + - "\n" + - "КонецПроцедуры"; + String module = """ + \s + + + КонецПроцедуры"""; List diagnostics = getDiagnosticsForText(module); @@ -68,10 +70,11 @@ void test_EmptyThreeFirstLines() { @Test void test_EmptyTwoInnerLines() { - String module = "Процедура Первая()\n" + - "\n" + - "\n" + - "КонецПроцедуры"; + String module = """ + Процедура Первая() + + + КонецПроцедуры"""; List diagnostics = getDiagnosticsForText(module); @@ -83,10 +86,11 @@ void test_EmptyTwoInnerLines() { @Test void test_EmptyTwoInnerLinesWithSpaces() { - String module = "Процедура Первая() \n" + - " \n" + - " \n" + - "КонецПроцедуры"; + String module = """ + Процедура Первая() \s + \s + \s + КонецПроцедуры"""; List diagnostics = getDiagnosticsForText(module); @@ -98,12 +102,13 @@ void test_EmptyTwoInnerLinesWithSpaces() { @Test void test_WorseEmptyTwoInnerLines() { - String module = "Процедура Первая() \n" + - " \n" + - " Метод1(); //комментарии \n" + - "\n" + - " \n" + - "КонецПроцедуры"; + String module = """ + Процедура Первая() \s + \s + Метод1(); //комментарии \s + + \s + КонецПроцедуры"""; List diagnostics = getDiagnosticsForText(module); @@ -115,11 +120,12 @@ void test_WorseEmptyTwoInnerLines() { @Test void test_EmptyThreeInnerLines() { - String module = "Процедура Первая()\n" + - "\n" + - "\n" + - "\n" + - "КонецПроцедуры"; + String module = """ + Процедура Первая() + + + + КонецПроцедуры"""; List diagnostics = getDiagnosticsForText(module); @@ -131,8 +137,10 @@ void test_EmptyThreeInnerLines() { @Test void test_EmptyLastLines() { - String module = "Перем А;\n" + - "\n"; + String module = """ + Перем А; + + """; List diagnostics = getDiagnosticsForText(module); @@ -182,11 +190,12 @@ void test_EmptyLinePlusOneFilledLine() { void test_ConfigureEmptyLineParam() { setTwoForAllowedEmptyLinesCount(); - String module = "Процедура Первая()\n" + - "\n" + - "\n" + - "\n" + - "КонецПроцедуры"; + String module = """ + Процедура Первая() + + + + КонецПроцедуры"""; List diagnostics = getDiagnosticsForText(module); @@ -200,10 +209,11 @@ void test_ConfigureEmptyLineParam() { void test_ConfigureEmptyLineParamNoIssue() { setTwoForAllowedEmptyLinesCount(); - String module = "Процедура Первая()\n" + - "\n" + - "\n" + - "КонецПроцедуры"; + String module = """ + Процедура Первая() + + + КонецПроцедуры"""; List diagnostics = getDiagnosticsForText(module); @@ -267,8 +277,10 @@ private void checkQuickFixes(String module, boolean haveFix) { @Test void testQuickFixLastLines() { - String module = "Перем А;\n" + - "\n"; + String module = """ + Перем А; + + """; checkQuickFixes(module, true); } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CrazyMultilineStringDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CrazyMultilineStringDiagnosticTest.java index 11d240543fc..6f33f4e5b2c 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CrazyMultilineStringDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CrazyMultilineStringDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CreateQueryInCycleDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CreateQueryInCycleDiagnosticTest.java index e4a4664fc65..6929a034b34 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CreateQueryInCycleDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CreateQueryInCycleDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CyclomaticComplexityDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CyclomaticComplexityDiagnosticTest.java index 8d75f8bed7e..7f7673f2ea5 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CyclomaticComplexityDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CyclomaticComplexityDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -37,6 +37,8 @@ class CyclomaticComplexityDiagnosticTest extends AbstractDiagnosticTest diagnostics = getDiagnostics(); @@ -45,7 +47,6 @@ void test() { assertThat(diagnostics, true) .hasRange(0, 8, 0, 32); assertThat(diagnostics.get(0).getRelatedInformation()).hasSize(21); - } @Test diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DataExchangeLoadingDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DataExchangeLoadingDiagnosticTest.java index ef7203304c2..9f3c7ca7891 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DataExchangeLoadingDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DataExchangeLoadingDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeletingCollectionItemDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeletingCollectionItemDiagnosticTest.java index a9fb13ae451..eb49f69fb01 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeletingCollectionItemDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeletingCollectionItemDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DenyIncompleteValuesDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DenyIncompleteValuesDiagnosticTest.java index dd2ca68aec6..efde9a9261d 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DenyIncompleteValuesDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DenyIncompleteValuesDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -24,18 +24,18 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.context.ServerContext; import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterEachTestMethod; +import com.github._1c_syntax.bsl.mdo.InformationRegister; +import com.github._1c_syntax.bsl.mdo.MD; import com.github._1c_syntax.bsl.types.MDOType; import com.github._1c_syntax.bsl.types.MdoReference; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; -import com.github._1c_syntax.mdclasses.mdo.MDInformationRegister; import com.github._1c_syntax.utils.Absolute; import org.junit.jupiter.api.Test; import java.io.File; import java.util.Collections; +import java.util.List; import java.util.Optional; -import java.util.Set; import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat; import static org.mockito.Mockito.spy; @@ -86,17 +86,16 @@ private void checkMockHandler(ModuleType type, boolean noneModules) { var documentContext = spy(getDocumentContext()); when(documentContext.getModuleType()).thenReturn(type); - final var mdObjectBase = context.getConfiguration().getChildrenByMdoRef().get( - MdoReference.create(MDOType.INFORMATION_REGISTER, - "РегистрСведений1")); - var spyMdo = spy((MDInformationRegister) mdObjectBase); + final var infoReg = spy((InformationRegister) context.getConfiguration().findChild(MdoReference.create(MDOType.INFORMATION_REGISTER, + "РегистрСведений1")).orElseThrow() + ); - when(documentContext.getMdObject()).thenReturn(Optional.of(spyMdo)); + when(documentContext.getMdObject()).thenReturn(Optional.of(infoReg)); - if (noneModules){ - when(spyMdo.getModules()).thenReturn(Collections.emptyList()); + if (noneModules) { + when(infoReg.getModules()).thenReturn(Collections.emptyList()); - Set children = Set.of(spyMdo); + List children = List.of(infoReg); var configuration = spy(context.getConfiguration()); when(configuration.getChildren()).thenReturn(children); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedAttributes8312DiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedAttributes8312DiagnosticTest.java index 7b880107aac..459d47696b3 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedAttributes8312DiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedAttributes8312DiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedCurrentDateDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedCurrentDateDiagnosticTest.java index 643dfd6bea7..518d661afc6 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedCurrentDateDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedCurrentDateDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedFindDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedFindDiagnosticTest.java index 389c3d1f503..aa0fe683ab6 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedFindDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedFindDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMessageDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMessageDiagnosticTest.java index 919b16501c0..d3d35e7304a 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMessageDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMessageDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnosticTest.java index 22d6b760ebe..eea589a8668 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethodCallDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8310DiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8310DiagnosticTest.java index d19ff3f6acf..579eb69bbf1 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8310DiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8310DiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8317DiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8317DiagnosticTest.java index b2fb755f3d2..2aa288f0b69 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8317DiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedMethods8317DiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedTypeManagedFormDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedTypeManagedFormDiagnosticTest.java index 4c7b028ace1..d632417a708 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedTypeManagedFormDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedTypeManagedFormDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticInfosTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticInfosTest.java index d1ca8416670..403bec0c3ef 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticInfosTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticInfosTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -84,7 +84,7 @@ void testAllDiagnosticsHaveDescriptionResource() { void testAllDiagnosticsHaveTags() { assertThatCode(() -> diagnosticInfos.values().forEach(diagnosticInfo -> assertThat( - diagnosticInfo.getTags().size() > 0 + !diagnosticInfo.getTags().isEmpty() && diagnosticInfo.getTags().size() <= 3) .isTrue())) .doesNotThrowAnyException(); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticsTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticsTest.java index e5c32c7ea97..c5a4d44924f 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticsTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticsTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -30,7 +30,6 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.infrastructure.DiagnosticsConfiguration; import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterClass; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; -import com.github._1c_syntax.bsl.supconf.SupportConfiguration; import com.github._1c_syntax.bsl.support.CompatibilityMode; import com.github._1c_syntax.bsl.support.SupportVariant; import com.github._1c_syntax.bsl.types.ModuleType; @@ -41,7 +40,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -49,7 +47,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @SpringBootTest @@ -146,78 +143,77 @@ void testSkipSupport() { // given documentContext = spy(TestUtils.getDocumentContext("А = 0")); - var supportConfiguration = mock(SupportConfiguration.class); // when-then pairs ComputeDiagnosticsSkipSupport.NEVER configuration.getDiagnosticsOptions().setSkipSupport(SkipSupport.NEVER); - doReturn(Collections.emptyMap()).when(documentContext).getSupportVariants(); + doReturn(SupportVariant.NONE).when(documentContext).getSupportVariant(); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isNotEmpty(); - doReturn(Map.of(supportConfiguration, SupportVariant.NONE)).when(documentContext).getSupportVariants(); + doReturn(SupportVariant.NONE).when(documentContext).getSupportVariant(); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isNotEmpty(); - doReturn(Map.of(supportConfiguration, SupportVariant.NOT_SUPPORTED)).when(documentContext).getSupportVariants(); + doReturn(SupportVariant.NOT_SUPPORTED).when(documentContext).getSupportVariant(); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isNotEmpty(); - doReturn(Map.of(supportConfiguration, SupportVariant.EDITABLE_SUPPORT_ENABLED)).when(documentContext).getSupportVariants(); + doReturn(SupportVariant.EDITABLE_SUPPORT_ENABLED).when(documentContext).getSupportVariant(); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isNotEmpty(); - doReturn(Map.of(supportConfiguration, SupportVariant.NOT_EDITABLE)).when(documentContext).getSupportVariants(); + doReturn(SupportVariant.NOT_EDITABLE).when(documentContext).getSupportVariant(); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isNotEmpty(); // when-then pairs ComputeDiagnosticsSkipSupport.WITHSUPPORTLOCKED configuration.getDiagnosticsOptions().setSkipSupport(SkipSupport.WITH_SUPPORT_LOCKED); - doReturn(Collections.emptyMap()).when(documentContext).getSupportVariants(); + doReturn(SupportVariant.NONE).when(documentContext).getSupportVariant(); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isNotEmpty(); - doReturn(Map.of(supportConfiguration, SupportVariant.NONE)).when(documentContext).getSupportVariants(); + doReturn(SupportVariant.NONE).when(documentContext).getSupportVariant(); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isNotEmpty(); - doReturn(Map.of(supportConfiguration, SupportVariant.NOT_SUPPORTED)).when(documentContext).getSupportVariants(); + doReturn(SupportVariant.NOT_SUPPORTED).when(documentContext).getSupportVariant(); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isNotEmpty(); - doReturn(Map.of(supportConfiguration, SupportVariant.EDITABLE_SUPPORT_ENABLED)).when(documentContext).getSupportVariants(); + doReturn(SupportVariant.EDITABLE_SUPPORT_ENABLED).when(documentContext).getSupportVariant(); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isNotEmpty(); - doReturn(Map.of(supportConfiguration, SupportVariant.NOT_EDITABLE)).when(documentContext).getSupportVariants(); + doReturn(SupportVariant.NOT_EDITABLE).when(documentContext).getSupportVariant(); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isEmpty(); // when-then pairs ComputeDiagnosticsSkipSupport.WITHSUPPORT configuration.getDiagnosticsOptions().setSkipSupport(SkipSupport.WITH_SUPPORT); - doReturn(Collections.emptyMap()).when(documentContext).getSupportVariants(); + doReturn(SupportVariant.NONE).when(documentContext).getSupportVariant(); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isNotEmpty(); - doReturn(Map.of(supportConfiguration, SupportVariant.NONE)).when(documentContext).getSupportVariants(); + doReturn(SupportVariant.NONE).when(documentContext).getSupportVariant(); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isNotEmpty(); - doReturn(Map.of(supportConfiguration, SupportVariant.NOT_SUPPORTED)).when(documentContext).getSupportVariants(); + doReturn(SupportVariant.NOT_SUPPORTED).when(documentContext).getSupportVariant(); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isEmpty(); - doReturn(Map.of(supportConfiguration, SupportVariant.EDITABLE_SUPPORT_ENABLED)).when(documentContext).getSupportVariants(); + doReturn(SupportVariant.EDITABLE_SUPPORT_ENABLED).when(documentContext) + .getSupportVariant(); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isEmpty(); - doReturn(Map.of(supportConfiguration, SupportVariant.NOT_EDITABLE)).when(documentContext).getSupportVariants(); + doReturn(SupportVariant.NOT_EDITABLE).when(documentContext).getSupportVariant(); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isEmpty(); } @Test void testDiagnosticModeOff() { - // when configuration.getDiagnosticsOptions().setMode(Mode.OFF); @@ -226,7 +222,6 @@ void testDiagnosticModeOff() { @Test void testDiagnosticModeOn() { - // when configuration.getDiagnosticsOptions().setMode(Mode.ON); @@ -238,7 +233,6 @@ void testDiagnosticModeOn() { @Test void testDiagnosticModeAll() { - // when configuration.getDiagnosticsOptions().setMode(Mode.ALL); @@ -250,7 +244,6 @@ void testDiagnosticModeAll() { @Test void testDiagnosticModeOnly() { - // when configuration.getDiagnosticsOptions().setMode(Mode.ONLY); Map>> rules = new HashMap<>(); @@ -269,7 +262,6 @@ void testDiagnosticModeOnly() { @Test void testDiagnosticModeExcept() { - // when configuration.getDiagnosticsOptions().setMode(Mode.EXCEPT); Map>> rules = new HashMap<>(); @@ -289,7 +281,6 @@ void testDiagnosticModeExcept() { @Test void testDiagnosticSubsystemsIncludeCheck() { - var PATH_TO_METADATA = "src/test/resources/metadata/subSystemFilter"; context.clear(); context.setConfigurationRoot(Absolute.path(PATH_TO_METADATA)); @@ -297,7 +288,7 @@ void testDiagnosticSubsystemsIncludeCheck() { documentContext = spy(TestUtils.getDocumentContext("А = 0")); - var form = context.getConfiguration().getChildren().stream() + var form = context.getConfiguration().getPlainChildren().stream() .filter(mdo -> mdo.getName().equalsIgnoreCase("ФормаЭлемента")) .findFirst(); @@ -340,13 +331,11 @@ void testDiagnosticSubsystemsIncludeCheck() { .setInclude(new TreeSet<>(List.of("Подсистема3"))); assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isEmpty(); - } // @Test void testDiagnosticSubsystemsExcludeCheck() { - var PATH_TO_METADATA = "src/test/resources/metadata/subSystemFilter"; context.clear(); context.setConfigurationRoot(Absolute.path(PATH_TO_METADATA)); @@ -375,7 +364,6 @@ void testDiagnosticSubsystemsExcludeCheck() { @Test void testDiagnosticSubsystemsIncludeExcludeCheck() { - var PATH_TO_METADATA = "src/test/resources/metadata/subSystemFilter"; context.clear(); context.setConfigurationRoot(Absolute.path(PATH_TO_METADATA)); @@ -404,5 +392,4 @@ void testDiagnosticSubsystemsIncludeExcludeCheck() { assertThat(diagnosticsConfiguration.diagnostics(documentContext)) .isEmpty(); } - } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DisableSafeModeDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DisableSafeModeDiagnosticTest.java new file mode 100644 index 00000000000..0c634a49810 --- /dev/null +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DisableSafeModeDiagnosticTest.java @@ -0,0 +1,49 @@ +/* + * This file is a part of BSL Language Server. + * + * Copyright (c) 2018-2024 + * Alexey Sosnoviy , Nikita Fedkin and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * BSL Language Server is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * BSL Language Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with BSL Language Server. + */ +package com.github._1c_syntax.bsl.languageserver.diagnostics; + +import org.eclipse.lsp4j.Diagnostic; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat; + +class DisableSafeModeDiagnosticTest extends AbstractDiagnosticTest { + DisableSafeModeDiagnosticTest() { + super(DisableSafeModeDiagnostic.class); + } + + @Test + void test() { + + List diagnostics = getDiagnostics(); + + assertThat(diagnostics, true) + .hasRange(2, 4, 29) + .hasRange(5, 4, 29) + .hasRange(9, 4, 41) + .hasRange(12, 4, 41) + .hasSize(4); + + } +} diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateRegionDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateRegionDiagnosticTest.java index fa3b12432be..0fa8db5a6cc 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateRegionDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateRegionDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateStringLiteralDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateStringLiteralDiagnosticTest.java index db26c69bffb..7e74cb73ddb 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateStringLiteralDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateStringLiteralDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicatedInsertionIntoCollectionDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicatedInsertionIntoCollectionDiagnosticTest.java index 5c2edb7e55b..e67ff242a71 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicatedInsertionIntoCollectionDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicatedInsertionIntoCollectionDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyCodeBlockDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyCodeBlockDiagnosticTest.java index 8e722c6c36d..37e895376af 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyCodeBlockDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyCodeBlockDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyRegionDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyRegionDiagnosticTest.java index bc59cb98a4e..f09133aa9a7 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyRegionDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyRegionDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyStatementDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyStatementDiagnosticTest.java index cc3c8707815..00d149c39ba 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyStatementDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/EmptyStatementDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExcessiveAutoTestCheckDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExcessiveAutoTestCheckDiagnosticTest.java index 60dc835db00..78a63257d3d 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExcessiveAutoTestCheckDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExcessiveAutoTestCheckDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeDiagnosticTest.java index c236d8f0236..9f30ededbb7 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeInCommonModuleDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeInCommonModuleDiagnosticTest.java index 75bffe05642..5242b163580 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeInCommonModuleDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExecuteExternalCodeInCommonModuleDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -23,7 +23,7 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.utils.Absolute; import org.eclipse.lsp4j.Diagnostic; import org.junit.jupiter.api.Test; @@ -46,7 +46,7 @@ class ExecuteExternalCodeInCommonModuleDiagnosticTest extends AbstractDiagnostic private static final String PATH_TO_METADATA = "src/test/resources/metadata/designer"; private static final String PATH_TO_MODULE_FILE = "src/test/resources/metadata/designer/CommonModules/ПервыйОбщийМодуль/Ext/Module.bsl"; - private MDCommonModule module; + private CommonModule module; private DocumentContext documentContext; @Test @@ -128,8 +128,6 @@ private void getDocumentContextFromFile() { getText(), context )); - - module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri())); - + module = spy((CommonModule) configuration.findChild(documentContext.getUri()).get()); } } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExportVariablesDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExportVariablesDiagnosticTest.java index d1d9b690967..d15b84df1f0 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExportVariablesDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExportVariablesDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExternalAppStartingDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExternalAppStartingDiagnosticTest.java new file mode 100644 index 00000000000..ad6aeabdce5 --- /dev/null +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExternalAppStartingDiagnosticTest.java @@ -0,0 +1,132 @@ +/* + * This file is a part of BSL Language Server. + * + * Copyright (c) 2018-2024 + * Alexey Sosnoviy , Nikita Fedkin and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * BSL Language Server is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * BSL Language Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with BSL Language Server. + */ +package com.github._1c_syntax.bsl.languageserver.diagnostics; + +import org.eclipse.lsp4j.Diagnostic; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.Map; + +import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat; + +class ExternalAppStartingDiagnosticTest extends AbstractDiagnosticTest { + ExternalAppStartingDiagnosticTest() { + super(ExternalAppStartingDiagnostic.class); + } + + @Test + void test() { + + List diagnostics = getDiagnostics(); + + assertThat(diagnostics, true) + .hasRange(8, 4, 18) + .hasRange(9, 4, 23) + .hasRange(10, 4, 23) + .hasRange(12, 4, 26) + + .hasRange(18, 26, 44) + .hasRange(19, 26, 44) + .hasRange(20, 20, 38) + .hasRange(21, 20, 38) + .hasRange(23, 26, 42) + .hasRange(24, 26, 37) + .hasRange(25, 26, 37) + .hasRange(35, 10, 34) + + .hasRange(53, 4, 20) + .hasRange(54, 4, 20) + .hasRange(55, 4, 20) + .hasRange(56, 4, 20) + .hasSize(16); + } + + @Test + void testConfigure_checkGotoUrl() { + + Map configuration = diagnosticInstance.info.getDefaultConfiguration(); + configuration.put("checkGotoUrl", true); + diagnosticInstance.configure(configuration); + + List diagnostics = getDiagnostics(); + + assertThat(diagnostics, true) + .hasRange(8, 4, 18) + .hasRange(9, 4, 23) + .hasRange(10, 4, 23) + .hasRange(12, 4, 26) + + .hasRange(14, 4, 32) + .hasRange(15, 26, 52) + .hasRange(16, 26, 52) + + .hasRange(18, 26, 44) + .hasRange(19, 26, 44) + .hasRange(20, 20, 38) + .hasRange(21, 20, 38) + .hasRange(23, 26, 42) + .hasRange(24, 26, 37) + .hasRange(25, 26, 37) + .hasRange(35, 10, 34) + + .hasRange(53, 4, 20) + .hasRange(54, 4, 20) + .hasRange(55, 4, 20) + .hasRange(56, 4, 20) + .hasSize(19); + } + + @Test + void testConfigure_userPatternString() { + + Map configuration = diagnosticInstance.info.getDefaultConfiguration(); + configuration.put("userPatternString", "КомандаСистемы"); + diagnosticInstance.configure(configuration); + + List diagnostics = getDiagnostics(); + + assertThat(diagnostics, true) + .hasRange(8, 4, 18) + .hasSize(1); + } + + @Test + void testConfigure_userPatternString_checkGotoUrl() { + + Map configuration = diagnosticInstance.info.getDefaultConfiguration(); + configuration.put("checkGotoUrl", true); + configuration.put("userPatternString", "КомандаСистемы"); + diagnosticInstance.configure(configuration); + + List diagnostics = getDiagnostics(); + + assertThat(diagnostics, true) + .hasRange(8, 4, 18) + + .hasRange(14, 4, 32) + .hasRange(15, 26, 52) + .hasRange(16, 26, 52) + + .hasSize(4); + } +} diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExtraCommasDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExtraCommasDiagnosticTest.java index 20ad1121acc..33144d5b0a3 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExtraCommasDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ExtraCommasDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FieldsFromJoinsWithoutIsNullDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FieldsFromJoinsWithoutIsNullDiagnosticTest.java index defd71ba23f..c420c11f817 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FieldsFromJoinsWithoutIsNullDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FieldsFromJoinsWithoutIsNullDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FileSystemAccessDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FileSystemAccessDiagnosticTest.java new file mode 100644 index 00000000000..d72d0de9dfe --- /dev/null +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FileSystemAccessDiagnosticTest.java @@ -0,0 +1,87 @@ +/* + * This file is a part of BSL Language Server. + * + * Copyright (c) 2018-2024 + * Alexey Sosnoviy , Nikita Fedkin and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * BSL Language Server is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * BSL Language Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with BSL Language Server. + */ +package com.github._1c_syntax.bsl.languageserver.diagnostics; + +import org.eclipse.lsp4j.Diagnostic; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.Map; + +import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat; + +class FileSystemAccessDiagnosticTest extends AbstractDiagnosticTest { + FileSystemAccessDiagnosticTest() { + super(FileSystemAccessDiagnostic.class); + } + + @Test + void test() { + + List diagnostics = getDiagnostics(); + + assertThat(diagnostics, true) + .hasRange(1, 15, 35) + .hasRange(2, 15, 41) + .hasRange(3, 15, 31) + .hasRange(4, 15, 31) + .hasRange(5, 15, 38) + .hasRange(6, 15, 38) + .hasRange(7, 15, 33) + .hasRange(8, 15, 44) + .hasRange(9, 15, 44) + .hasRange(10, 15, 41) + .hasRange(11, 15, 41) + .hasRange(12, 15, 45) + .hasRange(13, 15, 41) + .hasRange(14, 15, 56) + .hasRange(19, 15, 41) + .hasRange(24, 15, 26) + + .hasRange(29, 4, 17) + .hasRange(30, 4, 18) + .hasRange(34, 4, 19) + .hasRange(36, 4, 19) + .hasRange(37, 4, 17) + .hasRange(38, 4, 18) + .hasRange(39, 4, 16) + .hasSize(23) + ; + } + + @Test + void testConfigure() { + + Map configuration = diagnosticInstance.info.getDefaultConfiguration(); + configuration.put("globalMethods", "ЗначениеВФайл"); + configuration.put("newExpression", "File"); + diagnosticInstance.configure(configuration); + + List diagnostics = getDiagnostics(); + + assertThat(diagnostics, true) + .hasRange(1, 15, 35) + .hasRange(29, 4, 17) + .hasSize(2); + } + +} diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ForbiddenMetadataNameDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ForbiddenMetadataNameDiagnosticTest.java index cebec5f9182..1d21cb0ab0a 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ForbiddenMetadataNameDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ForbiddenMetadataNameDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -21,11 +21,9 @@ */ package com.github._1c_syntax.bsl.languageserver.diagnostics; +import com.github._1c_syntax.bsl.mdo.MD; +import com.github._1c_syntax.bsl.mdo.ModuleOwner; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBSL; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectComplex; -import com.github._1c_syntax.mdclasses.mdo.attributes.AbstractMDOAttribute; import com.github._1c_syntax.utils.Absolute; import org.eclipse.lsp4j.Diagnostic; import org.junit.jupiter.api.BeforeEach; @@ -33,10 +31,8 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Optional; -import java.util.Set; import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat; import static org.mockito.Mockito.spy; @@ -58,33 +54,32 @@ void beforeTest() { void testCatalog() { var documentContext = spy(getDocumentContext()); - var mdObjectBase = spy(context.getConfiguration().getChildren().stream() - .filter(mdo -> mdo.getMdoReference().getMdoRefRu().equalsIgnoreCase("Справочник.Справочник1")) - .findFirst() + var spyCatalog = spy(context.getConfiguration() + .findCatalog(catalog -> catalog.getName().equalsIgnoreCase("Справочник1")) .get()); when(documentContext.getModuleType()).thenReturn(ModuleType.ManagerModule); - when(mdObjectBase.getName()).thenReturn("Справочник"); - - List attributes = new ArrayList<>(); - - ((AbstractMDObjectComplex) mdObjectBase).getAttributes().forEach(mdo -> { - var spyMDO = spy(mdo); - when(spyMDO.getName()).thenReturn("РегистрСведений"); - var mdoRef = spy(mdo.getMdoReference()); - when(mdoRef.getMdoRefRu()) - .thenReturn(mdo.getMdoReference().getMdoRefRu().replace("." + mdo.getName(), ".РегистрСведений")); - when(spyMDO.getMdoReference()).thenReturn(mdoRef); - when(spyMDO.getName()).thenReturn("РегистрСведений"); - attributes.add(spyMDO); - }); - - when(((AbstractMDObjectComplex) mdObjectBase).getAttributes()).thenReturn(attributes); - when(documentContext.getMdObject()).thenReturn(Optional.of(mdObjectBase)); + when(spyCatalog.getName()).thenReturn("Справочник"); + + List children = new ArrayList<>(); + spyCatalog.getPlainStorageFields() + .forEach(mdo -> { + var spyMDO = spy(mdo); + when(spyMDO.getName()).thenReturn("РегистрСведений"); + var mdoRef = spy(mdo.getMdoReference()); + when(mdoRef.getMdoRefRu()) + .thenReturn(mdo.getMdoReference().getMdoRefRu().replace("." + mdo.getName(), ".РегистрСведений")); + when(spyMDO.getMdoReference()).thenReturn(mdoRef); + when(spyMDO.getName()).thenReturn("РегистрСведений"); + children.add(spyMDO); + }); + + when(spyCatalog.getPlainStorageFields()).thenReturn(children); + when(documentContext.getMdObject()).thenReturn(Optional.of(spyCatalog)); List diagnostics = diagnosticInstance.getDiagnostics(documentContext); - assertThat(diagnostics).hasSize(5); + assertThat(diagnostics).hasSize(7); assertThat(diagnostics, true) .hasMessageOnRange("Запрещено использовать имя `Справочник` для `Справочник.Справочник1`", 0, 0, 9) .hasMessageOnRange( @@ -100,7 +95,7 @@ void testCatalog() { void testOtherMDO() { var documentContext = spy(getDocumentContext()); - Set children = new HashSet<>(); + List children = new ArrayList<>(); context.getConfiguration().getChildren().forEach(mdo -> { var spyMDO = spy(mdo); @@ -132,7 +127,7 @@ void testOtherMDO() { void testAllMDO() { var documentContext = spy(getDocumentContext()); - Set children = new HashSet<>(); + List children = new ArrayList<>(); context.getConfiguration().getChildren().forEach(mdo -> { var spyMDO = spy(mdo); @@ -142,8 +137,8 @@ void testAllMDO() { .thenReturn(mdo.getMdoReference().getMdoRefRu().replace("." + mdo.getName(), ".РегистрСведений")); when(spyMDO.getMdoReference()).thenReturn(mdoRef); when(spyMDO.getName()).thenReturn("РегистрСведений"); - if (mdo instanceof AbstractMDObjectBSL) { - when(((AbstractMDObjectBSL) spyMDO).getModules()).thenReturn(Collections.emptyList()); + if (mdo instanceof ModuleOwner) { + when(((ModuleOwner) spyMDO).getModules()).thenReturn(Collections.emptyList()); } children.add(spyMDO); }); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FormDataToValueDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FormDataToValueDiagnosticTest.java index d345003af77..a74a04ff7f8 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FormDataToValueDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FormDataToValueDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FullOuterJoinQueryDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FullOuterJoinQueryDiagnosticTest.java index cffeb655235..175278208af 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FullOuterJoinQueryDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FullOuterJoinQueryDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionNameStartsWithGetDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionNameStartsWithGetDiagnosticTest.java index 9b4bdc58472..d537f86bbed 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionNameStartsWithGetDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionNameStartsWithGetDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionOutParameterDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionOutParameterDiagnosticTest.java index 89f12421c5c..5eb8a421e50 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionOutParameterDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionOutParameterDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionReturnsSamePrimitiveDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionReturnsSamePrimitiveDiagnosticTest.java index c5f82b5ec61..addf83b391b 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionReturnsSamePrimitiveDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionReturnsSamePrimitiveDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionShouldHaveReturnDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionShouldHaveReturnDiagnosticTest.java index b1dced0ea3f..5e21ef15c8d 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionShouldHaveReturnDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/FunctionShouldHaveReturnDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GetFormMethodDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GetFormMethodDiagnosticTest.java index 8e9f186abbc..de3b7b1b409 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GetFormMethodDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GetFormMethodDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GlobalContextMethodCollision8312DiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GlobalContextMethodCollision8312DiagnosticTest.java index e415ad405d1..3bfc79e0afc 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GlobalContextMethodCollision8312DiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/GlobalContextMethodCollision8312DiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IdenticalExpressionsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IdenticalExpressionsDiagnosticTest.java index 04d9077b9dc..be1875892df 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IdenticalExpressionsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IdenticalExpressionsDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -67,11 +67,12 @@ void runTest() { @Test void checkMessage() { - var code = "А = ТипДокумента = Тип(\"ДокументСсылка.ПриходнаяНакладная\")\n" + - "Или ТипДокумента = Тип(\"ДокументСсылка.СчетНаОплатуПоставщика\")\n" + - "Или ТипДокумента = Тип(\"ДокументСсылка.КорректировкаПоступления\")\n" + - "Или ТипДокумента = Тип(\"ДокументСсылка.ЗаказПоставщику\")\n" + - "Или ТипДокумента = Тип(\"ДокументСсылка.СчетНаОплатуПоставщика\")"; + var code = """ + А = ТипДокумента = Тип("ДокументСсылка.ПриходнаяНакладная") + Или ТипДокумента = Тип("ДокументСсылка.СчетНаОплатуПоставщика") + Или ТипДокумента = Тип("ДокументСсылка.КорректировкаПоступления") + Или ТипДокумента = Тип("ДокументСсылка.ЗаказПоставщику") + Или ТипДокумента = Тип("ДокументСсылка.СчетНаОплатуПоставщика")"""; var context = TestUtils.getDocumentContext(code); var diagnostics = getDiagnostics(context); @@ -81,9 +82,10 @@ void checkMessage() { @Test void testThatPopularQuantificationSkipped() { - var code = "А = Байты / 1024 / 1024;\n" + - "В = Время / 24 / 60 / 60;\n" + - "Б = Байты = 1024 / \"1024\""; + var code = """ + А = Байты / 1024 / 1024; + В = Время / 24 / 60 / 60; + Б = Байты = 1024 / "1024\""""; var context = TestUtils.getDocumentContext(code); var diagnostics = getDiagnostics(context); @@ -93,9 +95,10 @@ void testThatPopularQuantificationSkipped() { @Test void testThatConfiguredPopularQuantificationSkipped() { - var code = "А = Байты / 1024 / 1024;\n" + - "В = Время / 24 / 60 / 60;\n" + - "Б = Байты = 1024 / \"1024\""; + var code = """ + А = Байты / 1024 / 1024; + В = Время / 24 / 60 / 60; + Б = Байты = 1024 / "1024\""""; // получение текущей конфигурации диагностики var configuration = diagnosticInstance.getInfo().getDefaultConfiguration(); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfConditionComplexityDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfConditionComplexityDiagnosticTest.java index 01af898263a..95e91b839a1 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfConditionComplexityDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfConditionComplexityDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedCodeBlockDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedCodeBlockDiagnosticTest.java index f98ad309a26..35edbddc43c 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedCodeBlockDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedCodeBlockDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedConditionDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedConditionDiagnosticTest.java index 95bc5f63135..d5cd0f4a87a 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedConditionDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseDuplicatedConditionDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseIfEndsWithElseDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseIfEndsWithElseDiagnosticTest.java index 69713617c33..efd26ca8c52 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseIfEndsWithElseDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IfElseIfEndsWithElseDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectLineBreakDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectLineBreakDiagnosticTest.java index fa45619aae2..72b7170bb24 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectLineBreakDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectLineBreakDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseLikeInQueryDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseLikeInQueryDiagnosticTest.java index f7b3b2910ce..5b0a1446c5d 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseLikeInQueryDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseLikeInQueryDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseOfStrTemplateDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseOfStrTemplateDiagnosticTest.java index 4078c6bd8ba..ebaef933392 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseOfStrTemplateDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseOfStrTemplateDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/InternetAccessDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/InternetAccessDiagnosticTest.java new file mode 100644 index 00000000000..2b6216a8a47 --- /dev/null +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/InternetAccessDiagnosticTest.java @@ -0,0 +1,57 @@ +/* + * This file is a part of BSL Language Server. + * + * Copyright (c) 2018-2024 + * Alexey Sosnoviy , Nikita Fedkin and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * BSL Language Server is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * BSL Language Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with BSL Language Server. + */ +package com.github._1c_syntax.bsl.languageserver.diagnostics; + +import org.eclipse.lsp4j.Diagnostic; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat; + +class InternetAccessDiagnosticTest extends AbstractDiagnosticTest { + InternetAccessDiagnosticTest() { + super(InternetAccessDiagnostic.class); + } + + @Test + void test() { + + List diagnostics = getDiagnostics(); + + assertThat(diagnostics, true) + .hasRange(1, 20, 75) + .hasRange(3, 18, 72) + .hasRange(5, 16, 80) + .hasRange(8, 8, 111) + .hasRange(13, 21, 65) + .hasRange(14, 17, 35) + .hasRange(15, 17, 47) + .hasRange(16, 17, 43) + .hasRange(17, 21, 51) + .hasRange(21, 14, 43) + .hasRange(27, 14, 32) + .hasRange(31, 14, 35) + .hasRange(34, 10, 21) + .hasSize(13); + } +} diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/InvalidCharacterInFileDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/InvalidCharacterInFileDiagnosticTest.java index 968d088ad12..3fcb35eec8b 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/InvalidCharacterInFileDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/InvalidCharacterInFileDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -64,19 +64,21 @@ void test() { @Test void testMultiString() { - String module = "//в строке ниже неразрывный пробел\n" + - "А = \" \n" + - "|// минусы с ошибками\n" + - "|//СреднееТире = \n" + - "|–;\n" + - "|//ЦифровоеТире = \n" + - "|‒;\n" + - "|//ДлинноеТире = \n" + - "|—;\n" + - "|//ГоризонтальнаяЛиния = \n" + - "|―;\n" + - "|//НеправильныйМинус = \n" + - "|−;\";\n"; + String module = """ + //в строке ниже неразрывный пробел + А = "  + |// минусы с ошибками + |//СреднееТире =\s + |–; + |//ЦифровоеТире =\s + |‒; + |//ДлинноеТире =\s + |—; + |//ГоризонтальнаяЛиния =\s + |―; + |//НеправильныйМинус =\s + |−;"; + """; var documentContext = TestUtils.getDocumentContext(module); var diagnostics = getDiagnostics(documentContext); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IsInRoleMethodDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IsInRoleMethodDiagnosticTest.java index 5dac8f51502..625460905ee 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IsInRoleMethodDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IsInRoleMethodDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithSubQueryDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithSubQueryDiagnosticTest.java index b00c2c513e9..62d5f3b978e 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithSubQueryDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithSubQueryDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithVirtualTableDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithVirtualTableDiagnosticTest.java index 3d141cfbcbd..e0a2a0cc1bc 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithVirtualTableDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/JoinWithVirtualTableDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LatinAndCyrillicSymbolInWordDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LatinAndCyrillicSymbolInWordDiagnosticTest.java index efe6981af42..19d38500574 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LatinAndCyrillicSymbolInWordDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LatinAndCyrillicSymbolInWordDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LineLengthDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LineLengthDiagnosticTest.java index 06a2846b8b2..c93ee2f908c 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LineLengthDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LineLengthDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LogicalOrInTheWhereSectionOfQueryDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LogicalOrInTheWhereSectionOfQueryDiagnosticTest.java index c02eda43ece..bd58feaa109 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LogicalOrInTheWhereSectionOfQueryDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/LogicalOrInTheWhereSectionOfQueryDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicDateDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicDateDiagnosticTest.java index 353c823612a..3e032ef2095 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicDateDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicDateDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -39,30 +39,48 @@ void test() { List diagnostics = getDiagnostics(); - assertThat(diagnostics).hasSize(5); + assertThat(diagnostics).hasSize(18); assertThat(diagnostics, true) - .hasRange(1, 12, 1, 22) - .hasRange(2, 12, 2, 28) - .hasRange(3, 7, 3, 17) - .hasRange(4, 14, 4, 24) - .hasRange(13, 7, 13, 26); - + .hasRange(11, 12, 22) + .hasRange(12, 12, 28) + .hasRange(13, 7, 17) + .hasRange(14, 14, 24) + .hasRange(23, 7, 26) + .hasRange(25, 87, 97) + .hasRange(26, 80, 90) + .hasRange(26, 92, 102) + .hasRange(27, 22, 32) + .hasRange(28, 19, 35) + .hasRange(29, 10, 26) + .hasRange(29, 29, 39) + .hasRange(31, 64, 80) + .hasRange(58, 17, 27) + .hasRange(58, 29, 45) + .hasRange(58, 47, 63) + .hasRange(60, 19, 29) + .hasRange(65, 22, 32); } @Test void testConfigure() { Map configuration = diagnosticInstance.getInfo().getDefaultConfiguration(); - configuration.put("authorizedDates", "00010101,00010101000000,000101010000,12340101, 00020101 ,,"); + configuration.put("authorizedDates", "00010101,00010101000000,000101010000,00050101,00020501121314,12340101, 00020101 ,,"); diagnosticInstance.configure(configuration); List diagnostics = getDiagnostics(); - assertThat(diagnostics).hasSize(3); + assertThat(diagnostics).hasSize(10); assertThat(diagnostics, true) - .hasRange(2, 12, 2, 28) - .hasRange(3, 7, 3, 17) - .hasRange(13, 7, 13, 26); - + .hasRange(12, 12, 28) + .hasRange(13, 7, 17) + .hasRange(23, 7, 26) + .hasRange(27, 22, 32) + .hasRange(29, 29, 39) + .hasRange(31, 64, 80) + .hasRange(58, 17, 27) + .hasRange(58, 29, 45) + .hasRange(58, 47, 63) + .hasRange(65, 22, 32); } } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicNumberDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicNumberDiagnosticTest.java index 804f9c0b66d..8883d91a698 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicNumberDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicNumberDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -42,15 +42,20 @@ void runTest() { List diagnostics = getDiagnostics(); // then - assertThat(diagnostics).hasSize(7); + assertThat(diagnostics).hasSize(12); assertThat(diagnostics, true) - .hasRange(3, 18, 3, 20) - .hasRange(3, 23, 3, 25) - .hasRange(7, 31, 7, 33) - .hasRange(11, 20, 11, 21) - .hasRange(20, 21, 20, 23) - .hasRange(23, 24, 23, 26) - .hasRange(27, 34, 27, 35); + .hasRange(3, 18, 20) + .hasRange(3, 23, 25) + .hasRange(7, 31, 33) + .hasRange(11, 20, 21) + .hasRange(20, 21, 23) + .hasRange(23, 24, 26) + .hasRange(27, 34, 35) + .hasRange(33, 37, 38) + .hasRange(34, 37, 38) + .hasRange(36, 87, 88) + .hasRange(37, 55, 56) + .hasRange(41, 16, 19); } @Test @@ -64,12 +69,17 @@ void testConfigure() { List diagnostics = getDiagnostics(); // then - assertThat(diagnostics).hasSize(4); + assertThat(diagnostics).hasSize(9); assertThat(diagnostics, true) - .hasRange(7, 31, 7, 33) - .hasRange(11, 20, 11, 21) - .hasRange(20, 21, 20, 23) - .hasRange(23, 24, 23, 26); + .hasRange(7, 31, 33) + .hasRange(11, 20, 21) + .hasRange(20, 21, 23) + .hasRange(23, 24, 26) + .hasRange(33, 37, 38) + .hasRange(34, 37, 38) + .hasRange(36, 87, 88) + .hasRange(37, 55, 56) + .hasRange(41, 16, 19); } @Test @@ -83,17 +93,22 @@ void testIndexes() { List diagnostics = getDiagnostics(); // then - assertThat(diagnostics).hasSize(9); + assertThat(diagnostics).hasSize(14); assertThat(diagnostics, true) - .hasRange(3, 18, 3, 20) - .hasRange(3, 23, 3, 25) - .hasRange(7, 31, 7, 33) - .hasRange(11, 20, 11, 21) - .hasRange(20, 21, 20, 23) - .hasRange(23, 24, 23, 26) - .hasRange(27, 34, 27, 35) - .hasRange(53, 32, 53, 34) - .hasRange(54, 18, 54, 20); + .hasRange(3, 18, 20) + .hasRange(3, 23, 25) + .hasRange(7, 31, 33) + .hasRange(11, 20, 21) + .hasRange(20, 21, 23) + .hasRange(23, 24, 26) + .hasRange(27, 34, 35) + .hasRange(33, 37, 38) + .hasRange(34, 37, 38) + .hasRange(36, 87, 88) + .hasRange(37, 55, 56) + .hasRange(41, 16, 19) + .hasRange(52, 32, 34) + .hasRange(53, 18, 20); } } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MetadataObjectNameLengthDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MetadataObjectNameLengthDiagnosticTest.java index dff2d4f769a..240d37b3bac 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MetadataObjectNameLengthDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MetadataObjectNameLengthDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -23,8 +23,10 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; +import com.github._1c_syntax.bsl.mdo.CommonModule; +import com.github._1c_syntax.bsl.mdo.MD; +import com.github._1c_syntax.bsl.mdo.children.ObjectModule; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; import lombok.SneakyThrows; import org.eclipse.lsp4j.Diagnostic; import org.junit.jupiter.api.Test; @@ -35,12 +37,11 @@ import org.springframework.test.annotation.DirtiesContext; import java.io.File; -import java.util.HashSet; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.Set; import java.util.stream.Stream; import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat; @@ -53,7 +54,7 @@ class MetadataObjectNameLengthDiagnosticTest extends AbstractDiagnosticTest children = new HashSet<>(); + List children = new ArrayList<>(); List.of("CommandGroup.ГруппаКоманд1", "EventSubscription.ВерсионированиеПриЗаписи", "Role.ПолныеПрава").forEach((String mdoName) -> { - var mdObjectBase = spy(context.getConfiguration().getChildren().stream() + var spyMdo = spy(context.getConfiguration().getChildren().stream() .filter(mdo -> mdo.getMdoReference().getMdoRef().equalsIgnoreCase(mdoName)) .findFirst() .get()); // given - when(mdObjectBase.getName()).thenReturn(LONG_NAME); - children.add(mdObjectBase); + when(spyMdo.getName()).thenReturn(LONG_NAME); + children.add(spyMdo); }); var configuration = spy(context.getConfiguration()); @@ -190,7 +191,14 @@ void getDocumentContextFromFile(String modulePath, String content) { initServerContext(PATH_TO_METADATA); var testFile = new File(PATH_TO_METADATA, modulePath).getAbsoluteFile(); documentContext = spy(TestUtils.getDocumentContext(testFile.toURI(), content, context)); - module = spy((AbstractMDObjectBase) Objects.requireNonNull(context).getConfiguration().getModulesByObject().get(documentContext.getUri())); + var moduleByUri = Objects.requireNonNull(context).getConfiguration() + .getModuleByUri(documentContext.getUri()).get(); + if (moduleByUri instanceof CommonModule) { + module = spy((CommonModule) moduleByUri); + } else { + module = spy(Objects.requireNonNull(context).getConfiguration().findChild(((ObjectModule) moduleByUri).getOwner()) + .get()); + } } static Stream contentProvider() { diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MethodSizeDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MethodSizeDiagnosticTest.java index a9c83d5316e..85eca3c7b35 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MethodSizeDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MethodSizeDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnosticTest.java index 893f558e7b9..9a069e9e6ec 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCodeTryCatchExDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCodeTryCatchExDiagnosticTest.java index 5d53697876b..13d1bb7d4da 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCodeTryCatchExDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCodeTryCatchExDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCommonModuleMethodDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCommonModuleMethodDiagnosticTest.java index b7d8484c08b..1340b3c106b 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCommonModuleMethodDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingCommonModuleMethodDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingEventSubscriptionHandlerDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingEventSubscriptionHandlerDiagnosticTest.java index 581aad5e26a..8bdc47ac188 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingEventSubscriptionHandlerDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingEventSubscriptionHandlerDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingParameterDescriptionDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingParameterDescriptionDiagnosticTest.java index 9d8942816e9..e2150a2fd37 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingParameterDescriptionDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingParameterDescriptionDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingReturnedValueDescriptionDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingReturnedValueDescriptionDiagnosticTest.java index 55659bc6057..1ea8452c645 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingReturnedValueDescriptionDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingReturnedValueDescriptionDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingSpaceDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingSpaceDiagnosticTest.java index a31c590031c..c4d909aee64 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingSpaceDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingSpaceDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTempStorageDeletionDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTempStorageDeletionDiagnosticTest.java index 748826a77cf..63e8731127c 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTempStorageDeletionDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTempStorageDeletionDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -66,9 +66,10 @@ void testFileCodeBlock() { void testFileCodeBlockWithoutError() { var diagnostics = getDiagnosticList( - "ПодобранныеТоварыТело2 = ПолучитьИзВременногоХранилища(АдресТоваровВХранилищеТело2); // не ошибка\n" + - "Объект.Товары.Загрузить(ПодобранныеТоварыТело2);\n" + - "УдалитьИзВременногоХранилища(АдресТоваровВХранилищеТело2)"); + """ + ПодобранныеТоварыТело2 = ПолучитьИзВременногоХранилища(АдресТоваровВХранилищеТело2); // не ошибка + Объект.Товары.Загрузить(ПодобранныеТоварыТело2); + УдалитьИзВременногоХранилища(АдресТоваровВХранилищеТело2)"""); assertThat(diagnostics).isEmpty(); @@ -78,21 +79,22 @@ void testFileCodeBlockWithoutError() { void testTryBlockWithoutError() { var diagnostics = getDiagnosticList( - "&НаСервере\n" + - "Процедура ПолучитьТоварыИзХранилища_Успешно1()\n" + - "\n" + - " Адрес = \"\";\n" + - " Попытка\n" + - " ОбщийМодуль.ПолучитьАдрес(Адрес);\n" + - "\n" + - " ПодобранныеТовары = ПолучитьИзВременногоХранилища(Адрес); // не ошибка\n" + - " Результат = ПодобранныеТовары.ВыгрузитьКолонку(\"Наименование\");\n" + - "\n" + - " УдалитьИзВременногоХранилища(Адрес);\n" + - " Исключение\n" + - " КонецПопытки;\n" + - "\n" + - "КонецПроцедуры"); + """ + &НаСервере + Процедура ПолучитьТоварыИзХранилища_Успешно1() + + Адрес = ""; + Попытка + ОбщийМодуль.ПолучитьАдрес(Адрес); + + ПодобранныеТовары = ПолучитьИзВременногоХранилища(Адрес); // не ошибка + Результат = ПодобранныеТовары.ВыгрузитьКолонку("Наименование"); + + УдалитьИзВременногоХранилища(Адрес); + Исключение + КонецПопытки; + + КонецПроцедуры"""); assertThat(diagnostics).isEmpty(); @@ -102,11 +104,12 @@ void testTryBlockWithoutError() { void testFileBlockBeforeSubForTester() { var diagnostics = getDiagnosticList( - "Данные = ПолучитьИзВременногоХранилища( тут.Адрес );\n" + - "Данные.Записать ( \"c:\\mydata.txt\" );\n" + - "&НаСервере\n" + - "Процедура Обработать ()\n" + - "КонецПроцедуры"); + """ + Данные = ПолучитьИзВременногоХранилища( тут.Адрес ); + Данные.Записать ( "c:\\mydata.txt" ); + &НаСервере + Процедура Обработать () + КонецПроцедуры"""); assertThat(diagnostics, true) .hasRange(0, 9, 51) @@ -119,12 +122,13 @@ void testFileBlockBeforeSubForTester() { void testTryFileBlockBeforeSubForTesterWithoutError() { var diagnostics = getDiagnosticList( - "Данные = ПолучитьИзВременногоХранилища( тут.Адрес );\n" + - "Данные.Записать ( \"c:\\mydata.txt\" );\n" + - "УдалитьИзВременногоХранилища( тут.Адрес );\n" + - "&НаСервере\n" + - "Процедура Обработать ()\n" + - "КонецПроцедуры"); + """ + Данные = ПолучитьИзВременногоХранилища( тут.Адрес ); + Данные.Записать ( "c:\\mydata.txt" ); + УдалитьИзВременногоХранилища( тут.Адрес ); + &НаСервере + Процедура Обработать () + КонецПроцедуры"""); assertThat(diagnostics).isEmpty(); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTemporaryFileDeletionDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTemporaryFileDeletionDiagnosticTest.java index b4f61ba0925..ba39a7c3741 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTemporaryFileDeletionDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTemporaryFileDeletionDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingVariablesDescriptionDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingVariablesDescriptionDiagnosticTest.java index 73a7018fa03..aeffac15871 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingVariablesDescriptionDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingVariablesDescriptionDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilineStringInQueryDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilineStringInQueryDiagnosticTest.java index c0a5e9e7aeb..63fc6ceaed7 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilineStringInQueryDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilineStringInQueryDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringHasAllDeclaredLanguagesDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringHasAllDeclaredLanguagesDiagnosticTest.java index 7f931f159e0..f15662ffcca 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringHasAllDeclaredLanguagesDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringHasAllDeclaredLanguagesDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringUsingWithTemplateDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringUsingWithTemplateDiagnosticTest.java index 67aae2a0224..868c7dec6c4 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringUsingWithTemplateDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MultilingualStringUsingWithTemplateDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedConstructorsInStructureDeclarationDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedConstructorsInStructureDeclarationDiagnosticTest.java index 27ae347cfcb..1473ee36600 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedConstructorsInStructureDeclarationDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedConstructorsInStructureDeclarationDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedFunctionInParametersDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedFunctionInParametersDiagnosticTest.java index 96ee1415b91..c1b440eb4cc 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedFunctionInParametersDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedFunctionInParametersDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedStatementsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedStatementsDiagnosticTest.java index bebab9dd4d7..be33707d6d2 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedStatementsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedStatementsDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedTernaryOperatorDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedTernaryOperatorDiagnosticTest.java index 082bbc358c1..bcb545ebdac 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedTernaryOperatorDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NestedTernaryOperatorDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonExportMethodsInApiRegionDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonExportMethodsInApiRegionDiagnosticTest.java index 600efb5ad23..4cb8433335c 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonExportMethodsInApiRegionDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonExportMethodsInApiRegionDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonStandardRegionDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonStandardRegionDiagnosticTest.java index 94b16cd4a01..af5ba534150 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonStandardRegionDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NonStandardRegionDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfOptionalParamsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfOptionalParamsDiagnosticTest.java index 93d7f7cf155..5d3c64d23e5 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfOptionalParamsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfOptionalParamsDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfParamsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfParamsDiagnosticTest.java index f7845704109..18c90d03b31 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfParamsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfParamsDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfValuesInStructureConstructorDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfValuesInStructureConstructorDiagnosticTest.java index bb386f4c5ee..5810515e82f 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfValuesInStructureConstructorDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/NumberOfValuesInStructureConstructorDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OSUsersMethodDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OSUsersMethodDiagnosticTest.java index de47a3fc16d..a24832d55ef 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OSUsersMethodDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OSUsersMethodDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OneStatementPerLineDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OneStatementPerLineDiagnosticTest.java index 751023eccda..fbcf9eb209a 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OneStatementPerLineDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OneStatementPerLineDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrderOfParamsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrderOfParamsDiagnosticTest.java index cd7de3c68d5..ffd96e5cc15 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrderOfParamsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrderOfParamsDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrdinaryAppSupportDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrdinaryAppSupportDiagnosticTest.java index 44b4af35293..93510c29631 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrdinaryAppSupportDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/OrdinaryAppSupportDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PairingBrokenTransactionDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PairingBrokenTransactionDiagnosticTest.java index 692a9784a63..e77bce9c021 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PairingBrokenTransactionDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PairingBrokenTransactionDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ParseErrorDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ParseErrorDiagnosticTest.java index b1575566981..b7e72773beb 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ParseErrorDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ParseErrorDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnosticTest.java new file mode 100644 index 00000000000..3ea86d9376a --- /dev/null +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PrivilegedModuleMethodCallDiagnosticTest.java @@ -0,0 +1,91 @@ +/* + * This file is a part of BSL Language Server. + * + * Copyright (c) 2018-2024 + * Alexey Sosnoviy , Nikita Fedkin and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * BSL Language Server is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * BSL Language Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with BSL Language Server. + */ +package com.github._1c_syntax.bsl.languageserver.diagnostics; + +import org.eclipse.lsp4j.Diagnostic; +import org.junit.jupiter.api.Test; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Map; + +import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + +class PrivilegedModuleMethodCallDiagnosticTest extends AbstractDiagnosticTest { + private static final String PATH_TO_METADATA = "src/test/resources/metadata/privilegedModules"; + private static final String PATH_TO_MODULE_FILE = PATH_TO_METADATA + "/CommonModules/ПривилегированныйМодуль1/Ext/Module.bsl"; + + PrivilegedModuleMethodCallDiagnosticTest() { + super(PrivilegedModuleMethodCallDiagnostic.class); + } + + @Test + void testWithoutMetadata() { + var diagnostics = getDiagnostics(); + assertThat(diagnostics).isEmpty(); + } + + @Test + void test() { + initServerContext(PATH_TO_METADATA); + + var diagnostics = getDiagnostics(); + + assertThat(diagnostics).hasSize(2); + assertThat(diagnostics, true) + .hasMessageOnRange("Проверьте обращение к методу ПубличнаяФункция привилегированного модуля", 3, 40, 56) + .hasMessageOnRange("Проверьте обращение к методу ПубличнаяПроцедура привилегированного модуля", 4, 29, 47); + } + + @Test + void getNestedCalls() { + var diagnostics = getDiagnosticsAsCommonModule(); + assertThat(diagnostics).hasSize(2); + assertThat(diagnostics, true) + .hasMessageOnRange("Проверьте обращение к методу ПубличнаяФункция привилегированного модуля", 15, 15, 31) + .hasMessageOnRange("Проверьте обращение к методу ПубличнаяПроцедура привилегированного модуля", 19, 4, 22); + } + + @Test + void testParameterValidateNestedCalls() { + Map configuration = diagnosticInstance.getInfo().getDefaultConfiguration(); + configuration.put("validateNestedCalls", false); + diagnosticInstance.configure(configuration); + + var diagnostics = getDiagnosticsAsCommonModule(); + assertThat(diagnostics).isEmpty(); + } + + private List getDiagnosticsAsCommonModule() { + Path moduleFile = Paths.get(PATH_TO_MODULE_FILE).toAbsolutePath(); + + initServerContext(PATH_TO_METADATA); + + var documentContext = spy(getDocumentContext(diagnosticInstance.getClass().getSimpleName())); + when(documentContext.getUri()).thenReturn(moduleFile.toUri()); + + return getDiagnostics(documentContext); + } +} diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProcedureReturnsValueDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProcedureReturnsValueDiagnosticTest.java index 83c088a1926..232d6e3d4cb 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProcedureReturnsValueDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProcedureReturnsValueDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PublicMethodsDescriptionDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PublicMethodsDescriptionDiagnosticTest.java index afe70e8e526..41a6af8777e 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PublicMethodsDescriptionDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/PublicMethodsDescriptionDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryParseErrorDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryParseErrorDiagnosticTest.java index 9f942545ac5..a45661f5c39 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryParseErrorDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryParseErrorDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryToMissingMetadataDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryToMissingMetadataDiagnosticTest.java index f64bbdcefbd..14eb0150085 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryToMissingMetadataDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/QueryToMissingMetadataDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RedundantAccessToObjectDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RedundantAccessToObjectDiagnosticTest.java index 3e4f5578e35..0153c0fe57f 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RedundantAccessToObjectDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RedundantAccessToObjectDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -24,8 +24,8 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterEachTestMethod; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; +import com.github._1c_syntax.bsl.mdo.CommonModule; import com.github._1c_syntax.bsl.mdo.support.ReturnValueReuse; -import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; import com.github._1c_syntax.utils.Absolute; import lombok.SneakyThrows; import org.apache.commons.io.FileUtils; @@ -86,7 +86,7 @@ void testCommonModuleCached() { ); var configuration = context.getConfiguration(); - var module = spy((MDCommonModule) configuration.getModulesByObject().get(documentContext.getUri())); + var module = spy((CommonModule) configuration.findChild(documentContext.getUri()).get()); when(module.getReturnValuesReuse()).thenReturn(ReturnValueReuse.DURING_SESSION); when(documentContext.getMdObject()).thenReturn(Optional.of(module)); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RefOveruseDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RefOveruseDiagnosticTest.java index 9747deb6c47..b151c79dc2a 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RefOveruseDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RefOveruseDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnosticTest.java index 16a6c6e2047..503d0c4cbb0 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/RewriteMethodParameterDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SameMetadataObjectAndChildNamesDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SameMetadataObjectAndChildNamesDiagnosticTest.java index 761a8bbf3bb..b87c7c4dc62 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SameMetadataObjectAndChildNamesDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SameMetadataObjectAndChildNamesDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -21,12 +21,14 @@ */ package com.github._1c_syntax.bsl.languageserver.diagnostics; +import com.github._1c_syntax.bsl.mdo.Attribute; +import com.github._1c_syntax.bsl.mdo.AttributeOwner; +import com.github._1c_syntax.bsl.mdo.Catalog; +import com.github._1c_syntax.bsl.mdo.MD; +import com.github._1c_syntax.bsl.mdo.ModuleOwner; +import com.github._1c_syntax.bsl.mdo.TabularSection; +import com.github._1c_syntax.bsl.mdo.TabularSectionOwner; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectComplex; -import com.github._1c_syntax.mdclasses.mdo.attributes.AbstractMDOAttribute; -import com.github._1c_syntax.mdclasses.mdo.attributes.TabularSection; -import com.github._1c_syntax.mdclasses.mdo.metadata.AttributeType; import com.github._1c_syntax.utils.Absolute; import org.eclipse.lsp4j.Diagnostic; import org.junit.jupiter.api.BeforeEach; @@ -34,10 +36,8 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Optional; -import java.util.Set; import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat; import static org.mockito.Mockito.spy; @@ -59,38 +59,37 @@ void beforeTest() { void testCatalog() { var documentContext = spy(getDocumentContext()); - var mdObjectBase = spy(context.getConfiguration().getChildren().stream() + var spyMDO = (Catalog) spy(context.getConfiguration().getChildren().stream() .filter(mdo -> mdo.getMdoReference().getMdoRefRu().equalsIgnoreCase("Справочник.Справочник1")) .findFirst() .get()); when(documentContext.getModuleType()).thenReturn(ModuleType.ManagerModule); - List attributes = new ArrayList<>(); + List attributes = new ArrayList<>(); + List tabularSections = new ArrayList<>(); - var attribute = spy(((AbstractMDObjectComplex) mdObjectBase).getAttributes().stream() - .filter(mdo -> mdo.getAttributeType() == AttributeType.ATTRIBUTE) + var attribute = spy(spyMDO.getAllAttributes().stream() .findFirst() .get()); when(attribute.getName()).thenReturn("Справочник1"); attributes.add(attribute); - var tabularSection = spy(((AbstractMDObjectComplex) mdObjectBase).getAttributes().stream() - .filter(mdo -> mdo.getAttributeType() == AttributeType.TABULAR_SECTION) - .map(TabularSection.class::cast) + var tabularSection = spy(spyMDO.getTabularSections().stream() .findFirst() .get()); when(tabularSection.getName()).thenReturn("Тара"); - attributes.add(tabularSection); + tabularSections.add(tabularSection); var tabAttribute = spy(tabularSection.getAttributes().get(0)); when(tabAttribute.getName()).thenReturn("Тара"); when(tabularSection.getAttributes()).thenReturn(List.of(tabAttribute)); - when(((AbstractMDObjectComplex) mdObjectBase).getAttributes()).thenReturn(attributes); - when(documentContext.getMdObject()).thenReturn(Optional.of(mdObjectBase)); + when(spyMDO.getAllAttributes()).thenReturn(attributes); + when(spyMDO.getTabularSections()).thenReturn(tabularSections); + when(documentContext.getMdObject()).thenReturn(Optional.of(spyMDO)); List diagnostics = diagnosticInstance.getDiagnostics(documentContext); @@ -105,25 +104,35 @@ void testCatalog() { void testOtherMDO() { var documentContext = spy(getDocumentContext()); - Set children = new HashSet<>(); + List children = new ArrayList<>(); context.getConfiguration().getChildren().forEach(mdo -> { - if (mdo instanceof AbstractMDObjectComplex) { - var spyMDO = spy(mdo); - List attributes = new ArrayList<>(); - ((AbstractMDObjectComplex) mdo).getAttributes().forEach(mdoAttribute -> { - var attribute = spy(mdoAttribute); - when(attribute.getName()).thenReturn(mdo.getName()); - attributes.add(attribute); - }); - when(((AbstractMDObjectComplex) spyMDO).getAttributes()).thenReturn(attributes); + var spyMDO = spy(mdo); - if (!mdo.getName().equalsIgnoreCase("Справочник1")) { - when(((AbstractMDObjectComplex) spyMDO).getModules()).thenReturn(Collections.emptyList()); - } + if (!(mdo instanceof ModuleOwner || mdo instanceof AttributeOwner || mdo instanceof TabularSectionOwner) + || mdo.getName().equalsIgnoreCase("Справочник1") + ) { + return; + } - children.add(spyMDO); + if (mdo instanceof ModuleOwner) { + when(((ModuleOwner) spyMDO).getModules()).thenReturn(Collections.emptyList()); } + + mockAttributes(mdo, spyMDO, mdo.getName()); + + if (mdo instanceof TabularSectionOwner tabularSectionOwner) { + List tabularSections = new ArrayList<>(); + tabularSectionOwner.getTabularSections().forEach(tabularSection -> { + var spyTabularSection = spy(tabularSection); + when(spyTabularSection.getName()).thenReturn(mdo.getName()); + mockAttributes(tabularSection, spyTabularSection, mdo.getName()); + tabularSections.add(spyTabularSection); + }); + when(((TabularSectionOwner) spyMDO).getTabularSections()).thenReturn(tabularSections); + } + + children.add(spyMDO); }); var configuration = spy(context.getConfiguration()); @@ -136,11 +145,23 @@ void testOtherMDO() { List diagnostics = diagnosticInstance.getDiagnostics(documentContext); assertThat(diagnostics) - .hasSize(5) + .hasSize(6) .noneMatch(diagnostic -> diagnostic.getMessage().contains("имя `Справочник.Справочник1")) .anyMatch(diagnostic -> diagnostic.getMessage().contains("имя `Документ.Документ1.Реквизит")) .anyMatch(diagnostic -> diagnostic.getMessage().contains("имя `Документ.Документ1.ТабличнаяЧасть")) .anyMatch(diagnostic -> diagnostic.getMessage().contains("имя `РегистрСведений.РегистрСведений1.Измерение")) ; } + + private static void mockAttributes(MD mdo, MD spyMDO, String parentName) { + if (mdo instanceof AttributeOwner attributeOwner) { + List attributes = new ArrayList<>(); + attributeOwner.getAllAttributes().forEach(attribute -> { + var spyAttribute = spy(attribute); + when(spyAttribute.getName()).thenReturn(parentName); + attributes.add(spyAttribute); + }); + when(((AttributeOwner) spyMDO).getAllAttributes()).thenReturn(attributes); + } + } } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ScheduledJobHandlerDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ScheduledJobHandlerDiagnosticTest.java index d8bdeb2480f..fc31dc182d8 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ScheduledJobHandlerDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ScheduledJobHandlerDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -23,23 +23,22 @@ import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterEachTestMethod; import com.github._1c_syntax.bsl.languageserver.utils.Ranges; +import com.github._1c_syntax.bsl.mdo.MD; +import com.github._1c_syntax.bsl.mdo.Module; +import com.github._1c_syntax.bsl.mdo.ModuleOwner; +import com.github._1c_syntax.bsl.mdo.ScheduledJob; import com.github._1c_syntax.bsl.mdo.support.Handler; import com.github._1c_syntax.bsl.types.MDOType; import com.github._1c_syntax.bsl.types.MdoReference; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectBase; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDObjectComplex; -import com.github._1c_syntax.mdclasses.mdo.MDScheduledJob; -import com.github._1c_syntax.mdclasses.mdo.support.MDOModule; import com.github._1c_syntax.utils.Absolute; import org.eclipse.lsp4j.Diagnostic; import org.eclipse.lsp4j.Range; import org.junit.jupiter.api.Test; -import java.util.HashSet; +import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.Set; import java.util.stream.Collectors; import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat; @@ -168,21 +167,21 @@ private List checkMockHandler(String methodPath) { var documentContext = spy(getDocumentContext()); when(documentContext.getModuleType()).thenReturn(ModuleType.SessionModule); - Set children = new HashSet<>(); + List children = new ArrayList<>(); context.getConfiguration().getChildren().forEach(mdo -> { var spyMDO = spy(mdo); - if (mdo instanceof MDScheduledJob) { - when(((MDScheduledJob) spyMDO).getHandler()).thenReturn(new Handler(methodPath)); + if (mdo instanceof ScheduledJob) { + when(((ScheduledJob) spyMDO).getMethodName()).thenReturn(new Handler(methodPath)); if (mdo.getName().equalsIgnoreCase("РегламентноеЗадание1")) { children.add(spyMDO); } - } else if (mdo instanceof AbstractMDObjectComplex) { - List modules = ((AbstractMDObjectComplex) mdo).getModules().stream() + } else if (mdo instanceof ModuleOwner moduleOwner) { + List modules = moduleOwner.getModules().stream() .filter(mdoModule -> mdoModule.getModuleType() == ModuleType.ManagerModule) .collect(Collectors.toList()); - when(((AbstractMDObjectComplex) spyMDO).getModules()).thenReturn(modules); + when(((ModuleOwner) spyMDO).getModules()).thenReturn(modules); } }); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelectTopWithoutOrderByDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelectTopWithoutOrderByDiagnosticTest.java index 20515a0c4e2..5e779913ee8 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelectTopWithoutOrderByDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelectTopWithoutOrderByDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfAssignDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfAssignDiagnosticTest.java index 299231d7987..8fb98f8369c 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfAssignDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfAssignDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfInsertionDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfInsertionDiagnosticTest.java index 55e2786862c..8e179e382d0 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfInsertionDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SelfInsertionDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SemicolonPresenceDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SemicolonPresenceDiagnosticTest.java index c9b4a084b4e..0cc447d61b5 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SemicolonPresenceDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SemicolonPresenceDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ServerSideExportFormMethodDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ServerSideExportFormMethodDiagnosticTest.java index 0d577472d8c..235af7ee9c1 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ServerSideExportFormMethodDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ServerSideExportFormMethodDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -21,9 +21,9 @@ */ package com.github._1c_syntax.bsl.languageserver.diagnostics; +import com.github._1c_syntax.bsl.mdo.Form; import com.github._1c_syntax.bsl.mdo.support.FormType; import com.github._1c_syntax.bsl.types.ModuleType; -import com.github._1c_syntax.mdclasses.mdo.AbstractMDOForm; import com.github._1c_syntax.utils.Absolute; import org.eclipse.lsp4j.Diagnostic; import org.junit.jupiter.api.BeforeEach; @@ -42,12 +42,12 @@ class ServerSideExportFormMethodDiagnosticTest extends AbstractDiagnosticTest mdo.getName().equalsIgnoreCase("ФормаЭлемента")) .findFirst() .get()); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPermissionsForNewObjectsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPermissionsForNewObjectsDiagnosticTest.java index 8ff86bf1f25..86822dccb56 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPermissionsForNewObjectsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPermissionsForNewObjectsDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPrivilegedModeDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPrivilegedModeDiagnosticTest.java index b98005b192d..6329fedabd3 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPrivilegedModeDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SetPrivilegedModeDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SeveralCompilerDirectivesDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SeveralCompilerDirectivesDiagnosticTest.java index f5a8d1c6151..18eafc4e606 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SeveralCompilerDirectivesDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SeveralCompilerDirectivesDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SmokyTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SmokyTest.java index 9188319ec95..f2c792b75a6 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SmokyTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SmokyTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -143,4 +143,13 @@ void testIAllDiagnostics() { assertThat(diagnosticErrors).isEmpty(); } + @Test + void testExtraMinForComplexity() { + // нельзя ставить отрицательное значение + diagnosticInfos.forEach(diagnosticInfo -> + assertThat(diagnosticInfo.getExtraMinForComplexity()) + .as(diagnosticInfo.getCode().getStringValue()) + .isNotNegative() + ); + } } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SpaceAtStartCommentDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SpaceAtStartCommentDiagnosticTest.java index e7c24fd7b9a..908c42d49fb 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SpaceAtStartCommentDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SpaceAtStartCommentDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/StyleElementConstructorsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/StyleElementConstructorsDiagnosticTest.java index a97906a67e7..f8a30423389 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/StyleElementConstructorsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/StyleElementConstructorsDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TempFilesDirDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TempFilesDirDiagnosticTest.java index 229ee0c698d..bc519a98463 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TempFilesDirDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TempFilesDirDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TernaryOperatorUsageDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TernaryOperatorUsageDiagnosticTest.java index b553e9c6332..795ca4e431e 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TernaryOperatorUsageDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TernaryOperatorUsageDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ThisObjectAssignDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ThisObjectAssignDiagnosticTest.java index 9500c2b7977..1382c8b68eb 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ThisObjectAssignDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ThisObjectAssignDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TimeoutsInExternalResourcesDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TimeoutsInExternalResourcesDiagnosticTest.java index 68122baf275..57f982e1c76 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TimeoutsInExternalResourcesDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TimeoutsInExternalResourcesDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TooManyReturnsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TooManyReturnsDiagnosticTest.java index a229f9cebd7..22fb8523588 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TooManyReturnsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TooManyReturnsDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnosticTest.java index 7bbab1e4d24..e5af57f977d 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TryNumberDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TryNumberDiagnosticTest.java index 0693f650638..8a297d06376 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TryNumberDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TryNumberDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TypoDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TypoDiagnosticTest.java index 802a57b140c..cd7c74d41ee 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TypoDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TypoDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnaryPlusInConcatenationDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnaryPlusInConcatenationDiagnosticTest.java index 190ec801545..ad77a7d903e 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnaryPlusInConcatenationDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnaryPlusInConcatenationDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnionAllDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnionAllDiagnosticTest.java index 5cc18454d52..30f8c6955fd 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnionAllDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnionAllDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnknownPreprocessorSymbolDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnknownPreprocessorSymbolDiagnosticTest.java index a7247f05f6a..c5c1877c582 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnknownPreprocessorSymbolDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnknownPreprocessorSymbolDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnreachableCodeDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnreachableCodeDiagnosticTest.java index fe132ed2f58..7dd72bba081 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnreachableCodeDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnreachableCodeDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnsafeSafeModeMethodCallDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnsafeSafeModeMethodCallDiagnosticTest.java index 6f64dc50a3f..de422ac7761 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnsafeSafeModeMethodCallDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnsafeSafeModeMethodCallDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnosticTest.java index 747bf7b8243..8c4d11227f0 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalMethodDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -21,30 +21,59 @@ */ package com.github._1c_syntax.bsl.languageserver.diagnostics; +import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; +import com.github._1c_syntax.bsl.languageserver.util.TestUtils; +import com.github._1c_syntax.bsl.mdo.CommonModule; +import com.github._1c_syntax.bsl.types.ModuleType; +import com.github._1c_syntax.utils.Absolute; +import lombok.SneakyThrows; +import org.apache.commons.io.FileUtils; import org.eclipse.lsp4j.Diagnostic; import org.junit.jupiter.api.Test; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.List; import java.util.Map; +import java.util.Optional; import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; class UnusedLocalMethodDiagnosticTest extends AbstractDiagnosticTest { + private static final String PATH_TO_METADATA = "src/test/resources/metadata/designer"; + private static final String PATH_TO_MODULE_FILE = PATH_TO_METADATA + "/CommonModules/ПервыйОбщийМодуль/Ext/Module.bsl"; + private static final String PATH_TO_MODULE_CONTENT = "src/test/resources/diagnostics/UnusedLocalMethodDiagnostic.bsl"; + + private CommonModule module; + private DocumentContext documentContext; + UnusedLocalMethodDiagnosticTest() { super(UnusedLocalMethodDiagnostic.class); } @Test void test() { - List diagnostics = getDiagnostics(); + checkByDefault(diagnostics); + } + private static void checkByDefault(List diagnostics) { assertThat(diagnostics).hasSize(2); assertThat(diagnostics, true) .hasRange(1, 10, 24) .hasRange(70, 10, 41) ; + } + + @Test + void testObjectModuleByDefault() { + getObjectModuleDocumentContext(); + List diagnostics = getDiagnostics(documentContext); + assertThat(diagnostics).isEmpty(); } @Test @@ -65,4 +94,44 @@ void testConfigure() { .hasRange(63, 10, 39) ; } + + @Test + void testObjectModuleWithEnabledConfiguration() { + // given + getObjectModuleDocumentContext(); + + Map configuration = diagnosticInstance.getInfo().getDefaultConfiguration(); + configuration.put("checkObjectModule", true); + diagnosticInstance.configure(configuration); + + // when + List diagnostics = getDiagnostics(documentContext); + + // then + checkByDefault(diagnostics); + } + + private void getObjectModuleDocumentContext() { + Path testFile = Paths.get(PATH_TO_MODULE_CONTENT).toAbsolutePath(); + getDocumentContextFromFile(testFile); + when(documentContext.getModuleType()).thenReturn(ModuleType.ObjectModule); + when(documentContext.getMdObject()).thenReturn(Optional.of(module)); + } + + @SneakyThrows + void getDocumentContextFromFile(Path testFile) { + + Path path = Absolute.path(PATH_TO_METADATA); + Path moduleFile = 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((CommonModule) configuration.findChild(moduleFile.toUri()).get()); + } } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnosticTest.java index c36838fee18..8c61095685c 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedParametersDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedParametersDiagnosticTest.java index 3be7e52bc83..629abe62dae 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedParametersDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedParametersDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsageWriteLogEventDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsageWriteLogEventDiagnosticTest.java index 9c2aadb8cdc..55fc6306e0b 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsageWriteLogEventDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsageWriteLogEventDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseLessForEachDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseLessForEachDiagnosticTest.java index a88cdcff6b0..ffece868557 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseLessForEachDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseLessForEachDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseSystemInformationDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseSystemInformationDiagnosticTest.java index 80cc76b6110..7d8de6bdc89 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseSystemInformationDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UseSystemInformationDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingCancelParameterDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingCancelParameterDiagnosticTest.java index 634ee0a731f..2f957b638aa 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingCancelParameterDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingCancelParameterDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingExternalCodeToolsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingExternalCodeToolsDiagnosticTest.java index 8f6b86178ea..f0b295d7a6f 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingExternalCodeToolsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingExternalCodeToolsDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnosticTest.java index 617e91e0408..e31696a1ffb 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingFindElementByStringDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -42,7 +42,7 @@ void runTest() { List diagnostics = getDiagnostics(); // then - assertThat(diagnostics).hasSize(6); + assertThat(diagnostics).hasSize(9); assertThat(diagnostics, true) .hasRange(7, 38, 7, 78) .hasRange(9, 40, 9, 61) @@ -50,8 +50,9 @@ void runTest() { .hasRange(24, 35, 24, 53) .hasRange(27, 35, 27, 51) .hasRange(30, 27, 30, 53) + .hasRange(39, 67, 110) + .hasRange(41, 35, 53) + .hasRange(44, 29, 49) ; - } - } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingGotoDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingGotoDiagnosticTest.java index 56eeead3d87..846fa3574db 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingGotoDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingGotoDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeNetworkAddressDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeNetworkAddressDiagnosticTest.java index 3fecb5c4c35..fbb9b3c428f 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeNetworkAddressDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeNetworkAddressDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodePathDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodePathDiagnosticTest.java index 397e2c5705f..a490ccc1d98 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodePathDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodePathDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeSecretInformationDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeSecretInformationDiagnosticTest.java index a8e0c065178..a139a13ec7f 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeSecretInformationDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingHardcodeSecretInformationDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingLikeInQueryDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingLikeInQueryDiagnosticTest.java index ae31c68300f..5981fbab684 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingLikeInQueryDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingLikeInQueryDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingModalWindowsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingModalWindowsDiagnosticTest.java index 4c2d9f5cf8e..3b0b902cf92 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingModalWindowsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingModalWindowsDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -25,6 +25,7 @@ import com.github._1c_syntax.bsl.languageserver.context.ServerContext; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; import com.github._1c_syntax.bsl.languageserver.utils.Ranges; +import com.github._1c_syntax.bsl.mdclasses.Configuration; import com.github._1c_syntax.bsl.mdo.support.UseMode; import com.github._1c_syntax.utils.Absolute; import org.eclipse.lsp4j.Diagnostic; @@ -119,11 +120,9 @@ private DocumentContext getDocumentContextWithUseFlag(UseMode useMode) { initServerContext(path); var configuration = spy(context.getConfiguration()); - when(configuration.getModalityUseMode()).thenReturn(useMode); + when(((Configuration) configuration).getModalityUseMode()).thenReturn(useMode); when(context.getConfiguration()).thenReturn(configuration); return TestUtils.getDocumentContext(testFile.toUri(), getText()); } - } - diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingObjectNotAvailableUnixDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingObjectNotAvailableUnixDiagnosticTest.java index a034ce6c4af..85a923aad00 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingObjectNotAvailableUnixDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingObjectNotAvailableUnixDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingServiceTagDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingServiceTagDiagnosticTest.java index 54e1edb8e53..f98c5d73bd3 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingServiceTagDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingServiceTagDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnosticTest.java index 25196d5a402..6afaa9194aa 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingSynchronousCallsDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -24,6 +24,7 @@ import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; import com.github._1c_syntax.bsl.languageserver.utils.Ranges; +import com.github._1c_syntax.bsl.mdclasses.Configuration; import com.github._1c_syntax.bsl.mdo.support.UseMode; import com.github._1c_syntax.utils.Absolute; import org.eclipse.lsp4j.Diagnostic; @@ -114,7 +115,6 @@ void testDontUse() { @Test void testUse() { - var documentContext = getDocumentContextWithUseFlag(UseMode.USE); List diagnostics = getDiagnostics(documentContext); assertThat(diagnostics).isEmpty(); @@ -127,7 +127,7 @@ private DocumentContext getDocumentContextWithUseFlag(UseMode useMode) { initServerContext(path); var serverContext = spy(context); var configuration = spy(serverContext.getConfiguration()); - when(configuration.getSynchronousExtensionAndAddInCallUseMode()).thenReturn(useMode); + when(((Configuration) configuration).getSynchronousExtensionAndAddInCallUseMode()).thenReturn(useMode); when(serverContext.getConfiguration()).thenReturn(configuration); var documentContext = spy(TestUtils.getDocumentContext(testFile.toUri(), getText(), serverContext)); @@ -135,5 +135,4 @@ private DocumentContext getDocumentContextWithUseFlag(UseMode useMode) { return documentContext; } - } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingThisFormDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingThisFormDiagnosticTest.java index 6dbabf8d58c..132abca9734 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingThisFormDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingThisFormDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/VirtualTableCallWithoutParametersDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/VirtualTableCallWithoutParametersDiagnosticTest.java index 991046308fc..f5955b37502 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/VirtualTableCallWithoutParametersDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/VirtualTableCallWithoutParametersDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnosticTest.java index 60d460032e2..dfb7077d122 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongDataPathForFormElementsDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -22,8 +22,8 @@ package com.github._1c_syntax.bsl.languageserver.diagnostics; import com.github._1c_syntax.bsl.languageserver.util.TestUtils; -import com.github._1c_syntax.mdclasses.Configuration; -import com.github._1c_syntax.mdclasses.mdo.children.Form; +import com.github._1c_syntax.bsl.mdclasses.CF; +import com.github._1c_syntax.bsl.mdo.Form; import com.github._1c_syntax.utils.Absolute; import org.eclipse.lsp4j.Diagnostic; import org.junit.jupiter.api.BeforeEach; @@ -33,8 +33,6 @@ import java.nio.file.Paths; import java.util.Collections; import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat; import static com.github._1c_syntax.bsl.languageserver.util.TestUtils.PATH_TO_METADATA; @@ -64,9 +62,8 @@ void testNoFormModule() { context = spy(context); final var configuration = spy(context.getConfiguration()); - when(context.getConfiguration()).thenReturn(configuration); - fillConfigChildrenByFormsWithoutModule(configuration); + when(context.getConfiguration()).thenReturn(configuration); List diagnostics = getDiagnosticListForMockedFile(pathToManagedApplicationModuleFile); @@ -100,21 +97,24 @@ void testDynamicListFormModule() { } - private void fillConfigChildrenByFormsWithoutModule(Configuration configuration) { - final var childrenByMdoRefFromConfig = configuration.getChildrenByMdoRef(); - var childrenByMdoRef = childrenByMdoRefFromConfig.entrySet().stream() - .filter(entry -> entry.getValue() instanceof Form) - .collect(Collectors.toMap(Map.Entry::getKey, entry -> { - ((Form) entry.getValue()).setModules(Collections.emptyList()); - return entry.getValue(); - })); - when(configuration.getChildrenByMdoRef()).thenReturn(childrenByMdoRef); + private void fillConfigChildrenByFormsWithoutModule(CF configuration) { + var plainChildren = configuration.getPlainChildren().stream() + .filter(md -> md instanceof Form) + .map(md -> { + var mockMD = spy(md); + when(((Form) mockMD).getModules()).thenReturn(Collections.emptyList()); + return mockMD; + }) + .toList(); + + when(configuration.getPlainChildren()).thenReturn(plainChildren); } private List getDiagnosticListForMockedFile(String pathToDynamicListModuleFile) { var testFile = Paths.get(PATH_TO_METADATA + pathToDynamicListModuleFile).toAbsolutePath(); - var documentContext = TestUtils.getDocumentContext(testFile.toUri(), getText()); + var documentContext = spy(TestUtils.getDocumentContext(testFile.toUri(), getText())); + when(documentContext.getServerContext()).thenReturn(context); return getDiagnostics(documentContext); } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongHttpServiceHandlerDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongHttpServiceHandlerDiagnosticTest.java index 88dea8cc172..4e6014399f8 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongHttpServiceHandlerDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongHttpServiceHandlerDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseFunctionProceedWithCallDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseFunctionProceedWithCallDiagnosticTest.java index dbbac77d2a2..456f545d057 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseFunctionProceedWithCallDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseFunctionProceedWithCallDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseOfRollbackTransactionMethodDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseOfRollbackTransactionMethodDiagnosticTest.java index 24c298b245b..d6ee17a7775 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseOfRollbackTransactionMethodDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongUseOfRollbackTransactionMethodDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongWebServiceHandlerDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongWebServiceHandlerDiagnosticTest.java index 5c14ca22284..70824ba16a0 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongWebServiceHandlerDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/WrongWebServiceHandlerDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/YoLetterUsageDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/YoLetterUsageDiagnosticTest.java index 13604aa5a6b..6039a031912 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/YoLetterUsageDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/YoLetterUsageDiagnosticTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticInfoTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticInfoTest.java index fd3026a5802..be97c5ec967 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticInfoTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticInfoTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -25,6 +25,7 @@ import com.github._1c_syntax.bsl.languageserver.configuration.LanguageServerConfiguration; import com.github._1c_syntax.bsl.languageserver.diagnostics.DeprecatedAttributes8312Diagnostic; import com.github._1c_syntax.bsl.languageserver.diagnostics.EmptyCodeBlockDiagnostic; +import com.github._1c_syntax.bsl.languageserver.diagnostics.ForbiddenMetadataNameDiagnostic; import com.github._1c_syntax.bsl.languageserver.diagnostics.MultilingualStringHasAllDeclaredLanguagesDiagnostic; import com.github._1c_syntax.bsl.languageserver.diagnostics.UnusedLocalMethodDiagnostic; import com.github._1c_syntax.bsl.languageserver.util.CleanupContextBeforeClassAndAfterClass; @@ -36,8 +37,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import java.util.Optional; - import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat; @SpringBootTest @@ -52,7 +51,7 @@ class DiagnosticInfoTest { @Test void testParameter() { - DiagnosticInfo diagnosticInfo = new DiagnosticInfo(EmptyCodeBlockDiagnostic.class, configuration, stringInterner); + var diagnosticInfo = new DiagnosticInfo(EmptyCodeBlockDiagnostic.class, configuration, stringInterner); Assertions.assertThat(diagnosticInfo.getCode()).isEqualTo(Either.forLeft("EmptyCodeBlock")); Assertions.assertThat(diagnosticInfo.getName()).isNotEmpty(); @@ -66,25 +65,25 @@ void testParameter() { Assertions.assertThat(diagnosticInfo.getScope()).isEqualTo(DiagnosticScope.ALL); Assertions.assertThat(diagnosticInfo.getMinutesToFix()).isEqualTo(5); Assertions.assertThat(diagnosticInfo.isActivatedByDefault()).isTrue(); - Assertions.assertThat(diagnosticInfo.getTags().size()).isPositive(); + Assertions.assertThat(diagnosticInfo.getTags()).isNotEmpty(); Assertions.assertThat(diagnosticInfo.getLSPTags()).isEmpty(); + Assertions.assertThat(diagnosticInfo.canLocateOnProject()).isFalse(); - Assertions.assertThat(diagnosticInfo.getDefaultConfiguration().size()).isPositive(); - + Assertions.assertThat(diagnosticInfo.getDefaultConfiguration()).isNotEmpty(); - DiagnosticParameterInfo parameter = diagnosticInfo.getParameters().get(0); + var parameter = diagnosticInfo.getParameters().get(0); assertThat(parameter.getDescription()) .isEqualTo("Считать комментарий в блоке кодом"); assertThat(parameter.getDefaultValue()).isEqualTo(false); assertThat(parameter.getType()).isEqualTo(Boolean.class); - Optional maybeParameter = diagnosticInfo.getParameter(parameter.getName()); + var maybeParameter = diagnosticInfo.getParameter(parameter.getName()); assertThat(maybeParameter) .isPresent() .hasValue(parameter); - Optional maybeFakeParameter = diagnosticInfo.getParameter("fakeParameterName"); + var maybeFakeParameter = diagnosticInfo.getParameter("fakeParameterName"); assertThat(maybeFakeParameter).isEmpty(); } @@ -102,10 +101,11 @@ void testLSPTags() { // then assertThat(diagnosticInfo.getLSPTags()).contains(DiagnosticTag.Deprecated); } + @Test void testParameterSuper() { - DiagnosticInfo diagnosticInfo = new DiagnosticInfo(MultilingualStringHasAllDeclaredLanguagesDiagnostic.class, configuration, stringInterner); + var diagnosticInfo = new DiagnosticInfo(MultilingualStringHasAllDeclaredLanguagesDiagnostic.class, configuration, stringInterner); Assertions.assertThat(diagnosticInfo.getCode()).isEqualTo(Either.forLeft("MultilingualStringHasAllDeclaredLanguages")); Assertions.assertThat(diagnosticInfo.getName()).isNotEmpty(); @@ -118,28 +118,46 @@ void testParameterSuper() { Assertions.assertThat(diagnosticInfo.getScope()).isEqualTo(DiagnosticScope.BSL); Assertions.assertThat(diagnosticInfo.getMinutesToFix()).isEqualTo(2); Assertions.assertThat(diagnosticInfo.isActivatedByDefault()).isTrue(); - Assertions.assertThat(diagnosticInfo.getTags().size()).isNotZero(); - - Assertions.assertThat(diagnosticInfo.getDefaultConfiguration().size()).isNotZero(); - Assertions.assertThat(diagnosticInfo.getParameters().size()).isEqualTo(1); + Assertions.assertThat(diagnosticInfo.getTags()).isNotEmpty(); + Assertions.assertThat(diagnosticInfo.getDefaultConfiguration()).isNotEmpty(); + Assertions.assertThat(diagnosticInfo.getParameters()).hasSize(1); + Assertions.assertThat(diagnosticInfo.canLocateOnProject()).isFalse(); - DiagnosticParameterInfo parameter = diagnosticInfo.getParameters().get(0); + var parameter = diagnosticInfo.getParameters().get(0); assertThat(parameter.getDescription()) .isEqualTo("Заявленные языки"); assertThat(parameter.getDefaultValue()).isEqualTo("ru"); assertThat(parameter.getType()).isEqualTo(String.class); - Optional maybeParameter = diagnosticInfo.getParameter(parameter.getName()); + var maybeParameter = diagnosticInfo.getParameter(parameter.getName()); assertThat(maybeParameter) .isPresent() .hasValue(parameter); - Optional maybeFakeParameter = diagnosticInfo.getParameter("fakeParameterName"); + var maybeFakeParameter = diagnosticInfo.getParameter("fakeParameterName"); assertThat(maybeFakeParameter).isEmpty(); } + @Test + void testCanLocateOnProject() { + var diagnosticInfo = new DiagnosticInfo(ForbiddenMetadataNameDiagnostic.class, configuration, stringInterner); + Assertions.assertThat(diagnosticInfo.getCode()).isEqualTo(Either.forLeft("ForbiddenMetadataName")); + Assertions.assertThat(diagnosticInfo.getName()).isNotEmpty(); + Assertions.assertThat(diagnosticInfo.getMessage()).isNotEmpty(); + Assertions.assertThat(diagnosticInfo.getType()).isEqualTo(DiagnosticType.ERROR); + Assertions.assertThat(diagnosticInfo.getSeverity()).isEqualTo(DiagnosticSeverity.BLOCKER); + Assertions.assertThat(diagnosticInfo.getLSPSeverity()).isEqualTo(org.eclipse.lsp4j.DiagnosticSeverity.Error); + Assertions.assertThat(diagnosticInfo.getCompatibilityMode()).isEqualTo(DiagnosticCompatibilityMode.UNDEFINED); + Assertions.assertThat(diagnosticInfo.getScope()).isEqualTo(DiagnosticScope.BSL); + Assertions.assertThat(diagnosticInfo.getMinutesToFix()).isEqualTo(30); + Assertions.assertThat(diagnosticInfo.isActivatedByDefault()).isTrue(); + Assertions.assertThat(diagnosticInfo.getTags()).isNotEmpty(); + Assertions.assertThat(diagnosticInfo.canLocateOnProject()).isTrue(); + Assertions.assertThat(diagnosticInfo.getExtraMinForComplexity()).isZero(); + } + @Test void testParameterEn() { @@ -147,12 +165,10 @@ void testParameterEn() { configuration.setLanguage(Language.EN); // when - DiagnosticInfo diagnosticEnInfo = new DiagnosticInfo(EmptyCodeBlockDiagnostic.class, configuration, stringInterner); + var diagnosticEnInfo = new DiagnosticInfo(EmptyCodeBlockDiagnostic.class, configuration, stringInterner); // then assertThat(diagnosticEnInfo.getParameters().get(0).getDescription()) .isEqualTo("Comment as code"); - } - -} \ No newline at end of file +} diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/documentlink/DiagnosticDescriptionDocumentLinkSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/documentlink/DiagnosticDescriptionDocumentLinkSupplierTest.java index d5bd0c672ad..9a0da59293a 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/documentlink/DiagnosticDescriptionDocumentLinkSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/documentlink/DiagnosticDescriptionDocumentLinkSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryCommentFoldingRangeSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryCommentFoldingRangeSupplierTest.java index 8c12ffb3496..9c371868882 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryCommentFoldingRangeSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryCommentFoldingRangeSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryPackageFoldingRangeSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryPackageFoldingRangeSupplierTest.java index ae2c64937fc..3336b6584cb 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryPackageFoldingRangeSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/folding/QueryPackageFoldingRangeSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/hover/MethodSymbolMarkupContentBuilderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/hover/MethodSymbolMarkupContentBuilderTest.java index 6b806066aca..da295eb3092 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/hover/MethodSymbolMarkupContentBuilderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/hover/MethodSymbolMarkupContentBuilderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -68,43 +68,52 @@ void testContentFromDirectFile() { var blocks = Arrays.asList(content.split("---\n?")); assertThat(blocks).hasSize(5); - assertThat(blocks.get(0)).isEqualTo("```bsl\n" + - "Функция ИмяФункции(Знач П1: Дата | Число, П2: Число = -10, П2_5, Знач П3: Структура = \"\", " + - "П4: Массив | СписокЗначений, ПДата: См. ОбщийМодуль.СуперМетод() = '20100101', ПДатаВремя = '20110101121212', " + - "П6 = Ложь, П7 = Истина, П8 = Неопределено, П9 = NULL) Экспорт: Строка | Структура\n```\n\n"); + assertThat(blocks.get(0)).isEqualTo(""" + ```bsl + Функция ИмяФункции(Знач П1: Дата | Число, П2: Число = -10, П2_5, Знач П3: Структура = "", П4: Массив | СписокЗначений, ПДата: См. ОбщийМодуль.СуперМетод() = '20100101', ПДатаВремя = '20110101121212', П6 = Ложь, П7 = Истина, П8 = Неопределено, П9 = NULL) Экспорт: Строка | Структура + ``` + + """); assertThat(blocks.get(1)).matches("\\[file://.*/src/test/resources/hover/methodSymbolMarkupContentBuilder.bsl]\\(.*src/test/resources/hover/methodSymbolMarkupContentBuilder.bsl#\\d+\\)\n\n"); assertThat(blocks.get(2)).isEqualTo("Описание функции.\nМногострочное.\n\n"); - assertThat(blocks.get(3)).isEqualTo("**Параметры:**\n\n" + - "* **П1**: `Дата` | `Число` - Описание даты/числа \n" + - "* **П2**: `Число` - Описание числа \n" + - "* **П2_5**: \n" + - "* **П3**: `Структура` - Описание строки
  продолжается на следующей строкке: \n" + - " * **Поле1**: `Число` - Описание поле1 \n" + - " * **Поле2**: `Строка` - Описание поле2 \n" + - " * **Поле3**: `Структура` : \n" + - " * **Поле31**: `строка` \n" + - " * **Поле32**: `Структура` : \n" + - " * **Поле321**: `Число` - Описание поля 321 \n" + - " * **Поле33**: `строка` \n" + - " * **Поле4**: `строка` \n" + - "* **П4**: \n" + - "  `Массив` - Описание Массива \n" + - "  `СписокЗначений` - Описание списка \n" + - "* **ПДата**: [См. ОбщийМодуль.СуперМетод()](ОбщийМодуль.СуперМетод()) \n" + - "* **ПДатаВремя**: \n" + - "* **П6**: \n" + - "* **П7**: \n" + - "* **П8**: \n" + - "* **П9**: \n" + - "\n"); - assertThat(blocks.get(4)).isEqualTo("**Возвращаемое значение:**\n\n" + - "  `Строка` - вернувшаяся строка \n" + - "  `Структура` - Описание строки
  продолжается на следующей строкке: \n" + - " * **Поле1**: `Число` - Описание поле1 \n" + - " * **Поле2**: `Строка` - Описание поле2 \n" + - " * **Поле3**: `Структура` : \n" + - " * **Поле31**: `строка` \n" + - " * **Поле32**: `Структура`\n\n"); + assertThat(blocks.get(3)).isEqualTo(""" + **Параметры:** + + * **П1**: `Дата` | `Число` - Описание даты/числа \s + * **П2**: `Число` - Описание числа \s + * **П2_5**: \s + * **П3**: `Структура` - Описание строки
  продолжается на следующей строкке: \s + * **Поле1**: `Число` - Описание поле1 \s + * **Поле2**: `Строка` - Описание поле2 \s + * **Поле3**: `Структура` : \s + * **Поле31**: `строка` \s + * **Поле32**: `Структура` : \s + * **Поле321**: `Число` - Описание поля 321 \s + * **Поле33**: `строка` \s + * **Поле4**: `строка` \s + * **П4**: \s +   `Массив` - Описание Массива \s +   `СписокЗначений` - Описание списка \s + * **ПДата**: [См. ОбщийМодуль.СуперМетод()](ОбщийМодуль.СуперМетод()) \s + * **ПДатаВремя**: \s + * **П6**: \s + * **П7**: \s + * **П8**: \s + * **П9**:\s + + """); + assertThat(blocks.get(4)).isEqualTo(""" + **Возвращаемое значение:** + +   `Строка` - вернувшаяся строка \s +   `Структура` - Описание строки
  продолжается на следующей строкке: \s + * **Поле1**: `Число` - Описание поле1 \s + * **Поле2**: `Строка` - Описание поле2 \s + * **Поле3**: `Структура` : \s + * **Поле31**: `строка` \s + * **Поле32**: `Структура` + + """); } @Test @@ -123,8 +132,12 @@ void testContentFromManagerModule() { var blocks = Arrays.asList(content.split("---\n?")); assertThat(blocks).hasSize(2); - assertThat(blocks.get(0)).isEqualTo("```bsl\n" + - "Процедура ТестЭкспортная() Экспорт\n```\n\n"); + assertThat(blocks.get(0)).isEqualTo(""" + ```bsl + Процедура ТестЭкспортная() Экспорт + ``` + + """); assertThat(blocks.get(1)).matches("\\[Catalog.Справочник1]\\(.*Catalogs/.*/Ext/ManagerModule.bsl#\\d+\\)\n\n"); } @@ -143,8 +156,12 @@ void testMethodsFromCommonModule() { var blocks = Arrays.asList(content.split("---\n?")); assertThat(blocks).hasSize(3); - assertThat(blocks.get(0)).isEqualTo("```bsl\n" + - "Процедура УстаревшаяПроцедура() Экспорт\n```\n\n"); + assertThat(blocks.get(0)).isEqualTo(""" + ```bsl + Процедура УстаревшаяПроцедура() Экспорт + ``` + + """); assertThat(blocks.get(1)).matches("\\[CommonModule.ПервыйОбщийМодуль]\\(.*CommonModules/.*/Ext/Module.bsl#\\d+\\)\n\n"); assertThat(blocks.get(2)).isEqualTo("Процедура - Устаревшая процедура\n\n"); } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/hover/VariableSymbolMarkupContentBuilderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/hover/VariableSymbolMarkupContentBuilderTest.java index 66ab7b5e4c4..b8ade4cb595 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/hover/VariableSymbolMarkupContentBuilderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/hover/VariableSymbolMarkupContentBuilderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -69,12 +69,16 @@ void testFileVarContentFromDirectFile_NoComments() { var blocks = Arrays.asList(content.split("---\n?")); assertThat(blocks).hasSize(2); - assertThat(blocks.get(0)).isEqualTo("```bsl\n" + - "Перем ИмяБезОписания\n" + - "```\n" + - "\n"); - assertThat(blocks.get(1)).matches("\\[file://.*/src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl]\\(.*src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl#\\d+\\)\n" + - "\n"); + assertThat(blocks.get(0)).isEqualTo(""" + ```bsl + Перем ИмяБезОписания + ``` + + """); + assertThat(blocks.get(1)).matches(""" + \\[file://.*/src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl]\\(.*src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl#\\d+\\) + + """); } @Test @@ -92,14 +96,20 @@ void testFileVarContentFromDirectFile_OneCommentsStringFromRight() { var blocks = Arrays.asList(content.split("---\n?")); assertThat(blocks).hasSize(3); - assertThat(blocks.get(0)).isEqualTo("```bsl\n" + - "Перем Имя_ОписаниеСправаОднойСтрокой\n" + - "```\n" + - "\n"); - assertThat(blocks.get(1)).matches("\\[file://.*/src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl]\\(.*src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl#\\d+\\)\n" + - "\n"); - assertThat(blocks.get(2)).matches("описание\n" + - "\n"); + assertThat(blocks.get(0)).isEqualTo(""" + ```bsl + Перем Имя_ОписаниеСправаОднойСтрокой + ``` + + """); + assertThat(blocks.get(1)).matches(""" + \\[file://.*/src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl]\\(.*src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl#\\d+\\) + + """); + assertThat(blocks.get(2)).matches(""" + описание + + """); } @Test @@ -118,15 +128,22 @@ void testMethodVarContentFromDirectFile_2_comments_strings() { var blocks = Arrays.asList(content.split("---\n?")); assertThat(blocks).hasSize(3); - assertThat(blocks.get(0)).isEqualTo("```bsl\n" + - "Перем Имя_ОписаниеСверхуДвеСтроки_Функция\n" + - "```\n" + - "\n"); - assertThat(blocks.get(1)).matches("\\[file://.*/src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl.ИмяФункции]\\(.*src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl#\\d+\\)\n" + - "\n"); + assertThat(blocks.get(0)).isEqualTo(""" + ```bsl + Перем Имя_ОписаниеСверхуДвеСтроки_Функция + ``` + + """); + assertThat(blocks.get(1)).matches(""" + \\[file://.*/src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl.ИмяФункции]\\(.*src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl#\\d+\\) + + """); // TODO баг - нет \n для многострочного описания переменной - assertThat(blocks.get(2)).matches("описание 1 строка\n2 строка\n" + - "\n"); + assertThat(blocks.get(2)).matches(""" + описание 1 строка + 2 строка + + """); } @Test @@ -145,14 +162,21 @@ void testMethodVarContentFromDirectFile_3_comments_strings() { var blocks = Arrays.asList(content.split("---\n?")); assertThat(blocks).hasSize(3); - assertThat(blocks.get(0)).isEqualTo("```bsl\n" + - "Перем Имя_ОписаниеСверхуТриСтрокиПоследняяПустая_Функция\n" + - "```\n" + - "\n"); - assertThat(blocks.get(1)).matches("\\[file://.*/src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl.ИмяФункции]\\(.*src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl#\\d+\\)\n" + - "\n"); - assertThat(blocks.get(2)).matches("описание 1 строка\n2 строка\n" + - "\n"); + assertThat(blocks.get(0)).isEqualTo(""" + ```bsl + Перем Имя_ОписаниеСверхуТриСтрокиПоследняяПустая_Функция + ``` + + """); + assertThat(blocks.get(1)).matches(""" + \\[file://.*/src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl.ИмяФункции]\\(.*src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl#\\d+\\) + + """); + assertThat(blocks.get(2)).matches(""" + описание 1 строка + 2 строка + + """); } @Test @@ -172,8 +196,12 @@ void testContentFromObjectModule() { var blocks = Arrays.asList(content.split("---\n?")); assertThat(blocks).hasSize(2); - assertThat(blocks.get(0)).isEqualTo("```bsl\n" + - "Перем ВалютаУчета\n```\n\n"); + assertThat(blocks.get(0)).isEqualTo(""" + ```bsl + Перем ВалютаУчета + ``` + + """); assertThat(blocks.get(1)).matches("\\[Catalog.Справочник1]\\(.*Catalogs/.*/Ext/ObjectModule.bsl#\\d+\\)\n\n"); } diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CognitiveComplexityInlayHintSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CognitiveComplexityInlayHintSupplierTest.java index 07461f8c334..50382b7cc02 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CognitiveComplexityInlayHintSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CognitiveComplexityInlayHintSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CyclomaticComplexityInlayHintSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CyclomaticComplexityInlayHintSupplierTest.java index 41d9159582b..9bd8183c3fc 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CyclomaticComplexityInlayHintSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/CyclomaticComplexityInlayHintSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplierTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplierTest.java index d4dcfd89d26..125d5875e71 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplierTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/inlayhints/SourceDefinedMethodCallInlayHintSupplierTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CallHierarchyProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CallHierarchyProviderTest.java index a883237c6c2..5138aa28389 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CallHierarchyProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CallHierarchyProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeActionProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeActionProviderTest.java index 452aaaeffb9..d3d6a3fc3a8 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeActionProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeActionProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProviderTest.java index c9705bc4b4b..f0e1508bff1 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CodeLensProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/ColorProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/ColorProviderTest.java index c4ad181a211..bf3cdabd3a0 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/ColorProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/ColorProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CommandProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CommandProviderTest.java index 57529f1cdd6..fac98c343c6 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CommandProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/CommandProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DefinitionProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DefinitionProviderTest.java index 2757fc207d4..65174720c63 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DefinitionProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DefinitionProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DiagnosticProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DiagnosticProviderTest.java index 851dd471ee0..98c60a42cd3 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DiagnosticProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DiagnosticProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentLinkProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentLinkProviderTest.java index 7c2faf8f71f..432f6e3edc9 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentLinkProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentLinkProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentSymbolProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentSymbolProviderTest.java index 6f5169ec0a9..a65d315d4ae 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentSymbolProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/DocumentSymbolProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/FoldingRangeProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/FoldingRangeProviderTest.java index 99e3d3040be..3dc86b95a28 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/FoldingRangeProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/FoldingRangeProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/FormatProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/FormatProviderTest.java index 7b4316d6990..6e8bc70e423 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/FormatProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/FormatProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -31,7 +31,6 @@ import org.eclipse.lsp4j.DocumentRangeFormattingParams; import org.eclipse.lsp4j.FormattingOptions; import org.eclipse.lsp4j.TextDocumentIdentifier; -import org.eclipse.lsp4j.TextDocumentItem; import org.eclipse.lsp4j.TextEdit; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -216,7 +215,7 @@ void testFormatEngKeywords() throws IOException { URI.create(params.getTextDocument().getUri()), fileContent ); - + var configuration = new LanguageServerConfiguration(); configuration.setLanguage(Language.EN); documentContext.setConfiguration(configuration); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/HoverProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/HoverProviderTest.java index 867131115ac..8797a8b35f4 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/HoverProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/HoverProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/InlayHintProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/InlayHintProviderTest.java index 261cb9b8e38..655222ba63b 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/InlayHintProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/InlayHintProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/ReferencesProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/ReferencesProviderTest.java index 84d93ebb31e..68b92f76b85 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/ReferencesProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/ReferencesProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProviderTest.java index cbeda44ea2f..d5dde16cf24 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/RenameProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/SelectionRangeProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/SelectionRangeProviderTest.java index c3b47788891..f711f153482 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/SelectionRangeProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/SelectionRangeProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/SymbolProviderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/SymbolProviderTest.java index 9d4c02bde52..71df84d6e0a 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/SymbolProviderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/providers/SymbolProviderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/CamelCaseDetectorTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/CamelCaseDetectorTest.java index 758fe576b6f..f72d7b4c3a6 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/CamelCaseDetectorTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/CamelCaseDetectorTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/ContainsDetectorTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/ContainsDetectorTest.java index 45490f9d654..a24e9797576 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/ContainsDetectorTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/ContainsDetectorTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/EndWithDetectorTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/EndWithDetectorTest.java index 7ea8423e9c8..9bdd05c3032 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/EndWithDetectorTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/EndWithDetectorTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/KeywordsDetectorTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/KeywordsDetectorTest.java index b0af654828c..97048c58bea 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/KeywordsDetectorTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/KeywordsDetectorTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/PatternDetectorTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/PatternDetectorTest.java index 508caa5bce4..6c4ae4d292e 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/PatternDetectorTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/recognizer/PatternDetectorTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFillerTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFillerTest.java index 53889897000..be6915a60fd 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFillerTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexFillerTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexReferenceFinderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexReferenceFinderTest.java index cb902d6ce24..9ed49ea2175 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexReferenceFinderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexReferenceFinderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexTest.java index 41eb02f2126..d4180b561c6 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndexTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -82,7 +82,9 @@ void getReferencesToLocalMethod() { @Test void getReferencesToLocalMethodFromFormModule() { // given - var documentContext = serverContext.getDocument("Catalog.Справочник1.Form.ФормаСписка", ModuleType.FormModule).orElseThrow(); + var documentContext = serverContext + .getDocument("Catalog.Справочник1.Form.ФормаСписка", ModuleType.FormModule) + .orElseThrow(); var method = documentContext.getSymbolTree().getMethodSymbol("ЛокальнаяПроцедура").orElseThrow(); var module = documentContext.getSymbolTree().getModule(); diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolverTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolverTest.java index ba405e9804d..9ef76818c36 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolverTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceResolverTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -90,8 +90,7 @@ ReferenceResolver referenceResolver( ReferenceFinder zeroLineReferenceFinder, ReferenceFinder firstLineReferenceFinder ) { - var referenceResolver = new ReferenceResolver(List.of(zeroLineReferenceFinder, firstLineReferenceFinder)); - return referenceResolver; + return new ReferenceResolver(List.of(zeroLineReferenceFinder, firstLineReferenceFinder)); } @Bean diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinderTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinderTest.java index 6ca826ff843..0345b70c08e 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinderTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/SourceDefinedSymbolDeclarationReferenceFinderTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/model/ReferenceTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/model/ReferenceTest.java index aae599e33a0..77777fc8797 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/model/ReferenceTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/references/model/ReferenceTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/ConsoleReporterTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/ConsoleReporterTest.java index eace9708d02..c2f70da74d7 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/ConsoleReporterTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/ConsoleReporterTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/GenericReporterTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/GenericReporterTest.java index dff134193a5..8f72749c7ce 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/GenericReporterTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/GenericReporterTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/JUnitReporterTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/JUnitReporterTest.java index bb8456d2bca..439e2b572b4 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/JUnitReporterTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/JUnitReporterTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/JsonReporterTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/JsonReporterTest.java index 30de1d0d099..924bcb74043 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/JsonReporterTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/JsonReporterTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/ReportersAggregatorTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/ReportersAggregatorTest.java index 8ab17dd1c6e..90169623e5b 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/ReportersAggregatorTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/ReportersAggregatorTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/SarifReporterTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/SarifReporterTest.java index 6c9ff4c8fd0..70fa787d47e 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/SarifReporterTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/SarifReporterTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReportEntryTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReportEntryTest.java index 42101bcf05e..91d7e339012 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReportEntryTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReportEntryTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReporterTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReporterTest.java index 2f9342ff53d..8d8cc4bc123 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReporterTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/reporters/TSLintReporterTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/AbstractDirtyContextTestExecutionListener.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/AbstractDirtyContextTestExecutionListener.java index 3c2eb9a41aa..4da82e3c194 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/AbstractDirtyContextTestExecutionListener.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/AbstractDirtyContextTestExecutionListener.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/Assertions.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/Assertions.java index 79e6a89eb61..486f16ca10a 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/Assertions.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/Assertions.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/CleanupContextBeforeClassAndAfterClass.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/CleanupContextBeforeClassAndAfterClass.java index e8e0f9ef596..08547ba17af 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/CleanupContextBeforeClassAndAfterClass.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/CleanupContextBeforeClassAndAfterClass.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/CleanupContextBeforeClassAndAfterEachTestMethod.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/CleanupContextBeforeClassAndAfterEachTestMethod.java index 0ab17962c00..9f2b7d96113 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/CleanupContextBeforeClassAndAfterEachTestMethod.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/CleanupContextBeforeClassAndAfterEachTestMethod.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/DirtyContextBeforeClassAndAfterClassTestExecutionListener.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/DirtyContextBeforeClassAndAfterClassTestExecutionListener.java index 60ffa65f10b..077e097a991 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/DirtyContextBeforeClassAndAfterClassTestExecutionListener.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/DirtyContextBeforeClassAndAfterClassTestExecutionListener.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/DirtyContextBeforeClassAndAfterTestMethodTestExecutionListener.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/DirtyContextBeforeClassAndAfterTestMethodTestExecutionListener.java index b5f6c92cc04..11bba48de60 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/DirtyContextBeforeClassAndAfterTestMethodTestExecutionListener.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/DirtyContextBeforeClassAndAfterTestMethodTestExecutionListener.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/RefreshContextTestExecutionListener.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/RefreshContextTestExecutionListener.java index 8d267472c2f..eb2f08a9cab 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/RefreshContextTestExecutionListener.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/RefreshContextTestExecutionListener.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/TestApplicationContext.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/TestApplicationContext.java index 0a447d60b5c..a47395e793c 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/TestApplicationContext.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/TestApplicationContext.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/TestUtils.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/TestUtils.java index f5472365863..196c7672c2c 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/TestUtils.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/TestUtils.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/CodeActionAssert.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/CodeActionAssert.java index 404bbd7b48c..d3f86bdbfa4 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/CodeActionAssert.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/CodeActionAssert.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorInformationAssert.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorInformationAssert.java index acdcc737773..0a373c378a8 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorInformationAssert.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorInformationAssert.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorInformationAssertFactory.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorInformationAssertFactory.java index 8194c9cc324..7e8871341bc 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorInformationAssertFactory.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorInformationAssertFactory.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorInformationsAssert.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorInformationsAssert.java index 97c849857c0..73020d05ae5 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorInformationsAssert.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorInformationsAssert.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorPresentationAssert.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorPresentationAssert.java index f4379dc0dbf..6afed5f52a1 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorPresentationAssert.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorPresentationAssert.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorPresentationAssertFactory.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorPresentationAssertFactory.java index 2832c2d8c13..524bb8858f5 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorPresentationAssertFactory.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorPresentationAssertFactory.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorPresentationsAssert.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorPresentationsAssert.java index 0894114c60b..646f347c635 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorPresentationsAssert.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/ColorPresentationsAssert.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/DiagnosticAssert.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/DiagnosticAssert.java index 674f04d4e59..e9e9bd4fcad 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/DiagnosticAssert.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/DiagnosticAssert.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/DiagnosticAssertFactory.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/DiagnosticAssertFactory.java index a74ee69dc3a..ce51fde1a2a 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/DiagnosticAssertFactory.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/DiagnosticAssertFactory.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/DiagnosticsAssert.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/DiagnosticsAssert.java index 3bd6d855d87..6f6402d5a08 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/DiagnosticsAssert.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/DiagnosticsAssert.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/FoldingRangeAssert.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/FoldingRangeAssert.java index ed4a9d02b54..2006c2a7353 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/FoldingRangeAssert.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/FoldingRangeAssert.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/FoldingRangeAssertFactory.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/FoldingRangeAssertFactory.java index 205ed9a837c..a9b94372c2a 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/FoldingRangeAssertFactory.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/FoldingRangeAssertFactory.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/FoldingRangesAssert.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/FoldingRangesAssert.java index 7ee19c149fb..7bd38c250b1 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/FoldingRangesAssert.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/FoldingRangesAssert.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/SelectionRangeAssert.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/SelectionRangeAssert.java index df57277a099..03d93e1b59d 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/SelectionRangeAssert.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/SelectionRangeAssert.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/SelectionRangeAssertFactory.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/SelectionRangeAssertFactory.java index 94aa3f13b0f..b1fd50de182 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/SelectionRangeAssertFactory.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/SelectionRangeAssertFactory.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/SelectionRangesAssert.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/SelectionRangesAssert.java index 12d9509a642..fef0f9b29d3 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/SelectionRangesAssert.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/SelectionRangesAssert.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/package-info.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/package-info.java index d5a1c0c10e6..bbcf6275af2 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/package-info.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/assertions/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/package-info.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/package-info.java index 51178e30325..f31ea669672 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/package-info.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/util/package-info.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/ExpressionParseTreeRewriterTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/ExpressionParseTreeRewriterTest.java index 76bf6182105..01b2415ae2d 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/ExpressionParseTreeRewriterTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/ExpressionParseTreeRewriterTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later @@ -295,9 +295,10 @@ BSLParser.ExpressionContext parse(String code) { @Test void realLifeHardExpression() { - var code = "СодержитПоля = ВложенныеЭлементы.Количество() > 0\n" + - "И Не (ВложенныеЭлементы.Количество() = 1\n" + - "И ТипЗнч(ВложенныеЭлементы[0]) = Тип(\"АвтоВыбранноеПолеКомпоновкиДанных\"));"; + var code = """ + СодержитПоля = ВложенныеЭлементы.Количество() > 0 + И Не (ВложенныеЭлементы.Количество() = 1 + И ТипЗнч(ВложенныеЭлементы[0]) = Тип("АвтоВыбранноеПолеКомпоновкиДанных"));"""; var expressionTree = getExpressionTree(code); var binary = (BinaryOperationNode) expressionTree; diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/ExpressionTreeComparersTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/ExpressionTreeComparersTest.java index dce5c977097..0a654d5fdb9 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/ExpressionTreeComparersTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/ExpressionTreeComparersTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/RangesTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/RangesTest.java index 505838b082c..17c02f539d2 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/RangesTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/RangesTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/StringsTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/StringsTest.java index c500fd88498..aadc9eb7c87 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/StringsTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/utils/StringsTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/websocket/WebsocketLauncherTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/websocket/WebsocketLauncherTest.java index 14db896fb42..b7759bf2684 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/websocket/WebsocketLauncherTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/websocket/WebsocketLauncherTest.java @@ -1,7 +1,7 @@ /* * This file is a part of BSL Language Server. * - * Copyright (c) 2018-2023 + * Copyright (c) 2018-2024 * Alexey Sosnoviy , Nikita Fedkin and contributors * * SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/test/resources/context/symbol/variableSymbolTest.bsl b/src/test/resources/context/symbol/variableSymbolTest.bsl index de17b2730e2..bf6e7ce5f32 100644 --- a/src/test/resources/context/symbol/variableSymbolTest.bsl +++ b/src/test/resources/context/symbol/variableSymbolTest.bsl @@ -55,4 +55,20 @@ ПеременнаяСоздаваемаяВКодеВнеМетода = Неопределенно; ПеременнаяСоздаваемаяВКодеВнеМетодаВторойПример = МойМетод(); -А.ЭтоНеПеременная = Неопределенно; \ No newline at end of file +А.ЭтоНеПеременная = Неопределенно; + +Для Каждого МетодБезКоментария Из Методы Цикл + МойМетод(Метод); +КонецЦикла; + +Для Каждого МетодСКоментарием Из Методы Цикл // Висячий комментарий для цикла + МойМетод(Метод); +КонецЦикла; + +Для СчДляБезКоментария = 1 По 100 Цикл + МойМетод(Метод); +КонецЦикла; + +Для СчДляСКоментарием = 1 По 100 Цикл // Висячий комментарий для цикла + МойМетод(Метод); +КонецЦикла; \ No newline at end of file diff --git a/src/test/resources/diagnostics/DisableSafeModeDiagnostic.bsl b/src/test/resources/diagnostics/DisableSafeModeDiagnostic.bsl new file mode 100644 index 00000000000..e51acd2d709 --- /dev/null +++ b/src/test/resources/diagnostics/DisableSafeModeDiagnostic.bsl @@ -0,0 +1,16 @@ +&НаСервере +Процедура Метод() + УстановитьБезопасныйРежим(Ложь); // есть замечание + + Значение = Ложь; + УстановитьБезопасныйРежим(Значение); // есть замечание + + УстановитьБезопасныйРежим(Истина); // нет замечания + + УстановитьОтключениеБезопасногоРежима(Истина); // есть замечание + + Значение = Истина; + УстановитьОтключениеБезопасногоРежима(Значение); // есть замечание + + УстановитьОтключениеБезопасногоРежима(Ложь); // нет замечания +КонецПроцедуры diff --git a/src/test/resources/diagnostics/ExternalAppStartingDiagnostic.bsl b/src/test/resources/diagnostics/ExternalAppStartingDiagnostic.bsl new file mode 100644 index 00000000000..80924867e83 --- /dev/null +++ b/src/test/resources/diagnostics/ExternalAppStartingDiagnostic.bsl @@ -0,0 +1,58 @@ + +Процедура Метод() + СтрокаКоманды = ""; + ТекущийКаталог = ""; + ДождатьсяЗавершения = Истина; + ОписаниеОповещения = Неопределено; + ПараметрыКоманды = Новый Структура; + + КомандаСистемы(СтрокаКоманды, ТекущийКаталог); // есть замечание + ЗапуститьПриложение(СтрокаКоманды, ТекущийКаталог); // есть замечание + ЗапуститьПриложение(СтрокаКоманды, ТекущийКаталог, Истина); // есть замечание + + НачатьЗапускПриложения(ОписаниеОповещения, СтрокаКоманды, ТекущийКаталог, ДождатьсяЗавершения); // есть замечание + + ПерейтиПоНавигационнойСсылке(СтрокаКоманды); // есть замечание + ФайловаяСистемаКлиент.ОткрытьНавигационнуюСсылку(СтрокаКоманды); // есть замечание + ФайловаяСистемаКлиент.ОткрытьНавигационнуюСсылку(СтрокаКоманды, ОписаниеОповещения); // есть замечание + + ФайловаяСистемаКлиент.ЗапуститьПрограмму("ping 127.0.0.1 -n 5", ПараметрыКоманды); // есть замечание + ФайловаяСистемаКлиент.ЗапуститьПрограмму(СтрокаКоманды, ПараметрыКоманды); // есть замечание + ФайловаяСистема.ЗапуститьПрограмму(СтрокаКоманды); // есть замечание + ФайловаяСистема.ЗапуститьПрограмму(СтрокаКоманды, ПараметрыКоманды); // есть замечание + + ФайловаяСистемаКлиент.ОткрытьПроводник("C:\Users"); // есть замечание + ФайловаяСистемаКлиент.ОткрытьФайл(СтрокаКоманды); // есть замечание + ФайловаяСистемаКлиент.ОткрытьФайл(СтрокаКоманды, ОписаниеОповещения); // есть замечание + +КонецПроцедуры + +&НаКлиенте +Асинх Процедура Подключить() + СтрокаКоманды = ""; + ТекущийКаталог = ""; + ДождатьсяЗавершения = Истина; + + Ждать ЗапуститьПриложениеАсинх(СтрокаКоманды, ТекущийКаталог, ДождатьсяЗавершения); // есть замечание +КонецПроцедуры + +&НаСервере +Процедура ПараметрНаИмяВнешнегоПриложения() + СтрокаКоманды = ""; + ТекущийКаталог = ""; + ДождатьсяЗавершения = Истина; + + МойОбщийМодуль.ЗапуститьВнешнееПриложение(СтрокаКоманды, ТекущийКаталог, ДождатьсяЗавершения); // есть замечание +КонецПроцедуры + +&НаКлиенте +Процедура ПроверкаЗапуститьСистему() + ДополнительныеПараметрыКоманднойСтроки = ""; + ДождатьсяЗавершения = Истина; + КодВозврата = Неопределено; + + ЗапуститьСистему(); // есть замечание + ЗапуститьСистему(ДополнительныеПараметрыКоманднойСтроки); // есть замечание + ЗапуститьСистему(ДополнительныеПараметрыКоманднойСтроки, ДождатьсяЗавершения); // есть замечание + ЗапуститьСистему(ДополнительныеПараметрыКоманднойСтроки, ДождатьсяЗавершения, КодВозврата); // есть замечание +КонецПроцедуры diff --git a/src/test/resources/diagnostics/FileSystemAccessDiagnostic.bsl b/src/test/resources/diagnostics/FileSystemAccessDiagnostic.bsl new file mode 100644 index 00000000000..84333a26b2c --- /dev/null +++ b/src/test/resources/diagnostics/FileSystemAccessDiagnostic.bsl @@ -0,0 +1,41 @@ +Процедура Метод1() + Значение = Новый File(ИмяФайла); // есть ошибка + Значение = Новый xBase("C:\temp.dbf"); // есть ошибка + Значение = Новый HTMLWriter; // есть ошибка + Значение = Новый HTMLReader; // есть ошибка + Значение = Новый FastInfosetReader; // есть ошибка + Значение = Новый FastInfosetWriter; // есть ошибка + Значение = Новый XSLTransform; // есть ошибка + Значение = Новый ZipFileWriter(ИмяФайла); // есть ошибка + Значение = Новый ZipFileReader(ИмяФайла); // есть ошибка + Значение = Новый TextReader(ИмяФайла); // есть ошибка + Значение = Новый TextWriter(ИмяФайла); // есть ошибка + Значение = Новый TextExtraction(ИмяФайла); // есть ошибка + Значение = Новый BinaryData(ИмяФайла); // есть ошибка + Значение = Новый FileStream(ИмяФайла, РежимОткрытия); // есть ошибка +КонецПроцедуры + +&НаСервере +Процедура Метод2() + Значение = Новый xBase("C:\temp.dbf"); // есть ошибка +КонецПроцедуры + +&НаСервереБезКонтекста +Процедура Метод3() + Значение = Новый xBase; // есть ошибка +КонецПроцедуры + +&НаКлиенте +Процедура Метод4() + ЗначениеВФайл("C:\Temp\PersonalData.txt", ЛичныеДанные); // есть ошибка + КопироватьФайл("C:\Temp\Order.htm", "C:\My Documents\Order.htm"); // есть ошибка + + МассивИмен = Новый Массив(); + МассивИмен.Добавить("C:\Windows\Temp\Presentation.ppt.1"); + ОбъединитьФайлы(МассивИмен, "C:\Windows\Temp\Presentation.ppt"); // есть ошибка + + ПереместитьФайл("C:\Temp\Order.htm", "C:\My Documents\Order.htm"); // есть ошибка + РазделитьФайл("C:\Windows\Temp\Presentation.ppt", 1024 * 1024 ); // есть ошибка + СоздатьКаталог("C:\Temp"); // есть ошибка + УдалитьФайлы("C:\temp\Works"); // есть ошибка +КонецПроцедуры diff --git a/src/test/resources/diagnostics/InternetAccessDiagnostic.bsl b/src/test/resources/diagnostics/InternetAccessDiagnostic.bsl new file mode 100644 index 00000000000..f556f167b3a --- /dev/null +++ b/src/test/resources/diagnostics/InternetAccessDiagnostic.bsl @@ -0,0 +1,35 @@ +Процедура Тест1() + FTPСоединение = Новый FTPСоединение(Сервер, Порт, Пользователь, Пароль); // ошибка + + Определения = Новый WSОпределения("http://localhost/test.asmx?WSDL"); // ошибка + + ПроксиДва = Новый WSПрокси(Определения, "http://localhost/", "test", "test"); // ошибка + + Определения = + Новый WSОпределения("http://localhost/test.asmx?WSDL", "Пользователь", "Пароль", Неопределено, Таймаут); // ошибка + +КонецПроцедуры + +Процедура HTTP() + HTTPСоединение = Новый HTTPСоединение("zabbix.localhost", 80); // ошибка + HTTPЗапрос = Новый HTTPЗапрос(); // ошибка + HTTPЗапрос = Новый HTTPЗапрос("zabbix", 80); // ошибка + HTTPЗапрос = Новый HTTPЗапрос("zabbix"); // ошибка + ИнтернетПрокси = Новый ИнтернетПрокси("zabbix"); // ошибка +КонецПроцедуры + +Функция НовыйИнтернетПочтовыйПрофильБезТаймАута() + Профиль = Новый ИнтернетПочтовыйПрофиль; // ошибка + Профиль.Пользователь = "admin"; + Возврат Профиль; +КонецФункции + +Функция InternetMail() + Профиль = Новый InternetMail; // ошибка +КонецФункции + +Функция InternetMail_НовыйИмя() + Профиль = Новый("InternetMail"); // ошибка +КонецФункции + +Профиль = Новый Почта; // ошибка diff --git a/src/test/resources/diagnostics/MagicDateDiagnostic.bsl b/src/test/resources/diagnostics/MagicDateDiagnostic.bsl index 044f4133257..201c9c8311c 100644 --- a/src/test/resources/diagnostics/MagicDateDiagnostic.bsl +++ b/src/test/resources/diagnostics/MagicDateDiagnostic.bsl @@ -1,3 +1,13 @@ +Функция МаксимальнаяДата() Экспорт + Возврат '39991231235959'; +КонецФункции + +Функция МаксимальнаяДатаПриПродолжении() + Возврат '99990101000000'; +КонецФункции + +Процедура Тест3() + День = Дата("00020101"); День = Дата("00020101") + Шаг; // ошибка День = Дата("00020101121314") + Шаг; // ошибка @@ -11,4 +21,47 @@ КонецЦикла; День = Дата("00010101") + Шаг; // исключение День = '0001-01why not?01' + Шаг; // исключение -День = '0001-01why not?02' + Шаг; // ошибка \ No newline at end of file +День = '0001-01why not?02' + Шаг; // ошибка + +ИменаПараметров = СтроковыеФункции.РазложитьСтрокуВМассивПодстрок(ИмяПараметра, , Дата("00050101")); // замечание +ИменаПараметров = СтроковыеФункции.РазложитьСтрокуВМассивПодстрок(ИмяПараметра, "00050101", "00050101"); // замечание +Настройки = Настройки('12350101'); // замечание +Настройки.Свойство("00020501121314", ЗначениеЕдиничногоПараметра); // замечание +Выполнить("00020501121314" + '12350101'); // замечание + +ОтборЭлемента.ПравоеЗначение = Новый СтандартнаяДатаНачала(Дата('19800101000000')); + +Значение = Метод("%1/%2"); +Если Условие Тогда + ВызватьИсключение "Не указано значение константы ХХХ"; +КонецЕсли; + +УИДЗамера = Новый УникальныйИдентификатор("00000000-0000-0000-0000-000000000000"); +ПосторонниеСимволы = СтрСоединить(СтрРазделить(СтрокаСЧислом, "0123456789", Ложь), ""); +Объект.GetStringValue("2147483649","Software\Buhphone","ProgramPath", Значение); +НедопустимыеСимволы = НедопустимыеСимволыВСтроке(СтрАдрес.АдресСервера, + "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ_-.:*?"); +НедопустимыеСимволы = НедопустимыеСимволы + "1234567890 "; + +Дата = Метод("04937803-5dba-11df-a1d4-005056c00008"); +Набор.Идентификатор = Новый УникальныйИдентификатор("70425541-23e3-4e5a-8bd3-9587cc949dfa"); + +НецифровыеСимволы = СтрСоединить(СтрРазделить(Значение, "1234567890,.")); +Результат = Сред("0123456789abcdef", ОстатокОтДеления + 1, 1) + Результат; + +Результат.Добавить(СтрокаОбъектаАдресации("10100000", НСтр("ru = 'Почтовый индекс'"))); +КодСтроки = КодРодителя + Прав("00000000" + Формат(Счетчик, "ЧГ="), ЧислоЦифр); +КлючНаборовСвойств = НачалоКлюча + Лев(КлючНазначения + "00000000000000000000000000000000", 32); + +КодыКЛАДР.Регион = Лев(КодКЛАДР, 2) + "00000000000"; +КодыКЛАДР.Район = Лев(КодКЛАДР, 5) + "00000000"; + +Значение = ?(А = '39990202', '39991231235959', '39990101000000'); + +Если Сейчас < Дата("12340101") Тогда +КонецЕсли; + +КонецПроцедуры + +Функция Метод(Дата1 = '39990202') +КонецФункции diff --git a/src/test/resources/diagnostics/MagicNumberDiagnostic.bsl b/src/test/resources/diagnostics/MagicNumberDiagnostic.bsl index b522921512d..d64f41dbb9f 100644 --- a/src/test/resources/diagnostics/MagicNumberDiagnostic.bsl +++ b/src/test/resources/diagnostics/MagicNumberDiagnostic.bsl @@ -1,7 +1,7 @@ Процедура ПроверкаЧисел() ПонятнаяПеременная = 6; // Нет ошибки - СекундВЧасе = 60 * 60; // Ошибкат на двух числах + СекундВЧасе = 60 * 60; // Ошибка на двух числах Если ТекущаяДатаИВремя > СекундВЧасе Тогда // Нет ошибки @@ -25,22 +25,21 @@ КонецЕсли; - ЭтоВоскресенье = ДеньНедели = 7; // Тут ошибка, хоть и вглядит нормально. + ЭтоВоскресенье = ДеньНедели = 7; // Тут ошибка, хоть и выглядит нормально. ДеньНеделиВоскресенье = 7; ЭтоВоскресенье = ДеньНедели = ДеньНеделиВоскресенье; // А вот тут уже ошибки нет - // Далеше без ошибок ПроверочноеПеречисление = Новый Массив; - ПроверочноеПеречисление.Добавить(1); - ПроверочноеПеречисление.Добавить(2); - ПроверочноеПеречисление.Добавить(3); + ПроверочноеПеречисление.Добавить(1); // Нет ошибки из-за исключения + ПроверочноеПеречисление.Добавить(2); // ошибка + ПроверочноеПеречисление.Добавить(3); // ошибка - ПроверочнаяСтруктура = Новый Структура("Авто,ПростойВариант,СложныйВариант", 0, 1, 2); - ПроверочнаяСтруктура.Добавить("ЭкспертныйВариант", 3); + ПроверочнаяСтруктура = Новый Структура("Авто,ПростойВариант,СложныйВариант", 0, 1, 2); // ошибка только на 2 + ПроверочнаяСтруктура.Добавить("ЭкспертныйВариант", 3); // ошибка КонецПроцедуры -Процедура А(А = 566) +Процедура А(А = 566) // пропущенная ошибка КонецПроцедуры @@ -51,6 +50,6 @@ КонецФункции Процедура Индексы() - Индекс1 = Коллекция.Индексы[20]; - Метод(Индексы[21]) + Индекс1 = Коллекция.Индексы[20]; // замечание при allowMagicIndexes = false + Метод(Индексы[21]) // замечание при allowMagicIndexes = false КонецПроцедуры \ No newline at end of file diff --git a/src/test/resources/diagnostics/PrivilegedModuleMethodCallDiagnostic.bsl b/src/test/resources/diagnostics/PrivilegedModuleMethodCallDiagnostic.bsl new file mode 100644 index 00000000000..7058aac790b --- /dev/null +++ b/src/test/resources/diagnostics/PrivilegedModuleMethodCallDiagnostic.bsl @@ -0,0 +1,17 @@ +#Область ПрограммныйИнтерфейс + +Функция Тест1() + Значение = ПривилегированныйМодуль1.ПубличнаяФункция(); // ошибка + ПривилегированныйМодуль1.ПубличнаяПроцедура(); // ошибка +КонецФункции + +Процедура Тест2() + Значение = ПривилегированныйМодуль1.ПриватнаяФункция(); // не ошибка в данном правиле + ПривилегированныйМодуль1.ПриватнаяПроцедура(); // не ошибка в данном правиле +КонецПроцедуры + +#КонецОбласти + +#Область СлужебныеПроцедурыИФункции + +#КонецОбласти diff --git a/src/test/resources/diagnostics/UsingFindElementByStringDiagnostic.bsl b/src/test/resources/diagnostics/UsingFindElementByStringDiagnostic.bsl index 2f6d4784cac..8b0ac99391e 100644 --- a/src/test/resources/diagnostics/UsingFindElementByStringDiagnostic.bsl +++ b/src/test/resources/diagnostics/UsingFindElementByStringDiagnostic.bsl @@ -30,4 +30,18 @@ А = Справочники.Валюты.Функция( Справочники.Валюты.НайтиПоНаименованию("777") // сработает ); -КонецПроцедуры \ No newline at end of file +КонецПроцедуры + +Процедура Тест3() + + Наименование = "333"; // Пока не сработает + Значение = Документы.Реализация.НайтиПоНомеру(Наименование); + + ОбъектНазначения = Документы.ПередачаТоваровМеждуОрганизациями.НайтиПоНомеру("0000-000001", ТекущаяДата()); // замечание + + Значение3 = БизнесПроцессы.БП1.НайтиПоНомеру(333); // замечание + + А = Документы.Реализация.Функция( + Документы.Реализация.НайтиПоНомеру("333") // замечание + ); +КонецПроцедуры diff --git "a/src/test/resources/metadata/privilegedModules/CommonModules/\320\236\320\261\321\211\320\270\320\271\320\234\320\276\320\264\321\203\320\273\321\2142.xml" "b/src/test/resources/metadata/privilegedModules/CommonModules/\320\236\320\261\321\211\320\270\320\271\320\234\320\276\320\264\321\203\320\273\321\2142.xml" new file mode 100644 index 00000000000..fab8cc555db --- /dev/null +++ "b/src/test/resources/metadata/privilegedModules/CommonModules/\320\236\320\261\321\211\320\270\320\271\320\234\320\276\320\264\321\203\320\273\321\2142.xml" @@ -0,0 +1,18 @@ + + + + + ОбщийМодуль2 + + + false + false + true + false + false + false + false + DontUse + + + \ No newline at end of file diff --git "a/src/test/resources/metadata/privilegedModules/CommonModules/\320\236\320\261\321\211\320\270\320\271\320\234\320\276\320\264\321\203\320\273\321\2142/Ext/Module.bsl" "b/src/test/resources/metadata/privilegedModules/CommonModules/\320\236\320\261\321\211\320\270\320\271\320\234\320\276\320\264\321\203\320\273\321\2142/Ext/Module.bsl" new file mode 100644 index 00000000000..291d5ad6c4b --- /dev/null +++ "b/src/test/resources/metadata/privilegedModules/CommonModules/\320\236\320\261\321\211\320\270\320\271\320\234\320\276\320\264\321\203\320\273\321\2142/Ext/Module.bsl" @@ -0,0 +1,90 @@ + +/////Описание +///// +///// + +#Область ОписаниеПеременных + + + + +#КонецОбласти + +#Область ПрограммныйИнтерфейс +// Код процедур и функций +#КонецОбласти + +#Область СлужебныйПрограммныйИнтерфейс +// Код процедур и функций +#КонецОбласти + +#Область СлужебныеПроцедурыИФункции +// Код процедур и функций +#КонецОбласти + + +#Region EventHandlers +// Enter code here. +#EndRegion + +#Region Internal +// Enter code here. +#EndRegion + +#Область ОбработчикиСобытийФормы +// Код процедур и функций +#КонецОбласти + +#Область ОбработчикиСобытийЭлементовШапкиФормы +// Код процедур и функций +#КонецОбласти + +#Область ОбработчикиСобытийЭлементовТаблицыФормыИмяТаблицыФормы +// Код процедур и функций +#КонецОбласти + +#Область ОбработчикиКомандФормы +// Код процедур и функций +#КонецОбласти + +#Область ОбработчикиСобытий +// Код процедур и функций +#КонецОбласти + +#Область СлужебныеПроцедурыИФункции +Функция Тест() + РегистрыСведений.РегистрСведений1.УстаревшаяПроцедура(); +КонецФункции + +#КонецОбласти + +Процедура НеУстаревшаяПроцедура() Экспорт + +КонецПроцедуры + +// Устарела. См. НеУстаревшаяПроцедура. +// Процедура - Устаревшая процедура +Процедура УстаревшаяПроцедура() Экспорт + +КонецПроцедуры + +Функция НеУстаревшаяФункция() Экспорт + +КонецФункции + +// Устарела. См. НеУстаревшаяФункция. +// Функция - Устаревшая функция +Функция УстаревшаяФункция() Экспорт + + ПервыйОбщийМодуль.НеУстаревшаяФункция(); + НеУстаревшаяФункция(); + +КонецФункции + +Процедура ВерсионированиеПриЗаписи(Источник, Отказ) Экспорт + +КонецПроцедуры + +Процедура РегистрацияИзмененийПередУдалением(Источник, Отказ) + +КонецПроцедуры diff --git "a/src/test/resources/metadata/privilegedModules/CommonModules/\320\236\320\261\321\211\320\270\320\271\320\234\320\276\320\264\321\203\320\273\321\2143.xml" "b/src/test/resources/metadata/privilegedModules/CommonModules/\320\236\320\261\321\211\320\270\320\271\320\234\320\276\320\264\321\203\320\273\321\2143.xml" new file mode 100644 index 00000000000..c3d3f9e69b1 --- /dev/null +++ "b/src/test/resources/metadata/privilegedModules/CommonModules/\320\236\320\261\321\211\320\270\320\271\320\234\320\276\320\264\321\203\320\273\321\2143.xml" @@ -0,0 +1,18 @@ + + + + + ОбщийМодуль3 + + + false + false + true + false + false + false + false + DontUse + + + \ No newline at end of file diff --git "a/src/test/resources/metadata/privilegedModules/CommonModules/\320\236\320\261\321\211\320\270\320\271\320\234\320\276\320\264\321\203\320\273\321\2143/Ext/Module.bsl" "b/src/test/resources/metadata/privilegedModules/CommonModules/\320\236\320\261\321\211\320\270\320\271\320\234\320\276\320\264\321\203\320\273\321\2143/Ext/Module.bsl" new file mode 100644 index 00000000000..291d5ad6c4b --- /dev/null +++ "b/src/test/resources/metadata/privilegedModules/CommonModules/\320\236\320\261\321\211\320\270\320\271\320\234\320\276\320\264\321\203\320\273\321\2143/Ext/Module.bsl" @@ -0,0 +1,90 @@ + +/////Описание +///// +///// + +#Область ОписаниеПеременных + + + + +#КонецОбласти + +#Область ПрограммныйИнтерфейс +// Код процедур и функций +#КонецОбласти + +#Область СлужебныйПрограммныйИнтерфейс +// Код процедур и функций +#КонецОбласти + +#Область СлужебныеПроцедурыИФункции +// Код процедур и функций +#КонецОбласти + + +#Region EventHandlers +// Enter code here. +#EndRegion + +#Region Internal +// Enter code here. +#EndRegion + +#Область ОбработчикиСобытийФормы +// Код процедур и функций +#КонецОбласти + +#Область ОбработчикиСобытийЭлементовШапкиФормы +// Код процедур и функций +#КонецОбласти + +#Область ОбработчикиСобытийЭлементовТаблицыФормыИмяТаблицыФормы +// Код процедур и функций +#КонецОбласти + +#Область ОбработчикиКомандФормы +// Код процедур и функций +#КонецОбласти + +#Область ОбработчикиСобытий +// Код процедур и функций +#КонецОбласти + +#Область СлужебныеПроцедурыИФункции +Функция Тест() + РегистрыСведений.РегистрСведений1.УстаревшаяПроцедура(); +КонецФункции + +#КонецОбласти + +Процедура НеУстаревшаяПроцедура() Экспорт + +КонецПроцедуры + +// Устарела. См. НеУстаревшаяПроцедура. +// Процедура - Устаревшая процедура +Процедура УстаревшаяПроцедура() Экспорт + +КонецПроцедуры + +Функция НеУстаревшаяФункция() Экспорт + +КонецФункции + +// Устарела. См. НеУстаревшаяФункция. +// Функция - Устаревшая функция +Функция УстаревшаяФункция() Экспорт + + ПервыйОбщийМодуль.НеУстаревшаяФункция(); + НеУстаревшаяФункция(); + +КонецФункции + +Процедура ВерсионированиеПриЗаписи(Источник, Отказ) Экспорт + +КонецПроцедуры + +Процедура РегистрацияИзмененийПередУдалением(Источник, Отказ) + +КонецПроцедуры diff --git "a/src/test/resources/metadata/privilegedModules/CommonModules/\320\237\321\200\320\270\320\262\320\270\320\273\320\265\320\263\320\270\321\200\320\276\320\262\320\260\320\275\320\275\321\213\320\271\320\234\320\276\320\264\321\203\320\273\321\2141.xml" "b/src/test/resources/metadata/privilegedModules/CommonModules/\320\237\321\200\320\270\320\262\320\270\320\273\320\265\320\263\320\270\321\200\320\276\320\262\320\260\320\275\320\275\321\213\320\271\320\234\320\276\320\264\321\203\320\273\321\2141.xml" new file mode 100644 index 00000000000..24a9c1248c1 --- /dev/null +++ "b/src/test/resources/metadata/privilegedModules/CommonModules/\320\237\321\200\320\270\320\262\320\270\320\273\320\265\320\263\320\270\321\200\320\276\320\262\320\260\320\275\320\275\321\213\320\271\320\234\320\276\320\264\321\203\320\273\321\2141.xml" @@ -0,0 +1,18 @@ + + + + + ПривилегированныйМодуль1 + + + false + false + true + false + false + false + true + DontUse + + + \ No newline at end of file diff --git "a/src/test/resources/metadata/privilegedModules/CommonModules/\320\237\321\200\320\270\320\262\320\270\320\273\320\265\320\263\320\270\321\200\320\276\320\262\320\260\320\275\320\275\321\213\320\271\320\234\320\276\320\264\321\203\320\273\321\2141/Ext/Module.bsl" "b/src/test/resources/metadata/privilegedModules/CommonModules/\320\237\321\200\320\270\320\262\320\270\320\273\320\265\320\263\320\270\321\200\320\276\320\262\320\260\320\275\320\275\321\213\320\271\320\234\320\276\320\264\321\203\320\273\321\2141/Ext/Module.bsl" new file mode 100644 index 00000000000..f7d88c16cfd --- /dev/null +++ "b/src/test/resources/metadata/privilegedModules/CommonModules/\320\237\321\200\320\270\320\262\320\270\320\273\320\265\320\263\320\270\321\200\320\276\320\262\320\260\320\275\320\275\321\213\320\271\320\234\320\276\320\264\321\203\320\273\321\2141/Ext/Module.bsl" @@ -0,0 +1,23 @@ +#Область ПрограммныйИнтерфейс + +Функция ПубличнаяФункция() Экспорт + +КонецФункции + +Процедура ПубличнаяПроцедура() Экспорт + +КонецПроцедуры + +#КонецОбласти + +#Область СлужебныеПроцедурыИФункции + +Функция ПриватнаяФункция() + Значение = ПубличнаяФункция(); +КонецФункции + +Процедура ПриватнаяПроцедура() + ПубличнаяПроцедура(); +КонецПроцедуры + +#КонецОбласти diff --git a/src/test/resources/metadata/privilegedModules/Configuration.xml b/src/test/resources/metadata/privilegedModules/Configuration.xml new file mode 100644 index 00000000000..35e55b12302 --- /dev/null +++ b/src/test/resources/metadata/privilegedModules/Configuration.xml @@ -0,0 +1,209 @@ + + + + + + 9cd510cd-abfc-11d4-9434-004095e12fc7 + f47a8858-7778-47e9-9a9f-4eb4daedec56 + + + 9fcd25a0-4822-11d4-9414-008048da11f9 + 38996962-4abe-4c75-b3fe-8d2fa95cf83c + + + e3687481-0a87-462c-a166-9f34594f9bba + 5af4c67d-90e8-46b7-bff3-009df1043aee + + + 9de14907-ec23-4a07-96f0-85521cb6b53b + c519e804-03e1-428c-b447-9d7682802dcf + + + 51f2d5d8-ea4d-4064-8892-82951750031e + 842dca23-a50c-4a90-99dc-d0b8fa46d6bd + + + e68182ea-4237-4383-967f-90c1e3370bc7 + 1ef3f7d7-1891-4c7e-80b2-497689df7a80 + + + fb282519-d103-4dd3-bc12-cb271d631dfc + d625341b-aef8-4049-888c-681733b130fb + + + + privilegedModules + + + + Version8_3_18 + ManagedApplication + + PlatformApplication + + Russian + + + + + false + false + false + + + + + + + + + + + + + + + + + + + + Biometrics + true + + + Location + false + + + BackgroundLocation + false + + + BluetoothPrinters + false + + + WiFiPrinters + false + + + Contacts + false + + + Calendars + false + + + PushNotifications + false + + + LocalNotifications + false + + + InAppPurchases + false + + + PersonalComputerFileExchange + false + + + Ads + false + + + NumberDialing + false + + + CallProcessing + false + + + CallLog + false + + + AutoSendSMS + false + + + ReceiveSMS + false + + + SMSLog + false + + + Camera + false + + + Microphone + false + + + MusicLibrary + false + + + PictureAndVideoLibraries + false + + + AudioPlaybackAndVibration + false + + + BackgroundAudioPlaybackAndVibration + false + + + InstallPackages + false + + + OSBackup + true + + + ApplicationUsageStatistics + false + + + BarcodeScanning + false + + + + + Normal + + + Language.Русский + + + + + + Managed + NotAutoFree + DontUse + DontUse + Taxi + Version8_3_18 + + + + Русский + ПривилегированныйМодуль1 + ОбщийМодуль2 + ОбщийМодуль3 + + + \ No newline at end of file diff --git "a/src/test/resources/metadata/privilegedModules/Languages/\320\240\321\203\321\201\321\201\320\272\320\270\320\271.xml" "b/src/test/resources/metadata/privilegedModules/Languages/\320\240\321\203\321\201\321\201\320\272\320\270\320\271.xml" new file mode 100644 index 00000000000..a46e619fe47 --- /dev/null +++ "b/src/test/resources/metadata/privilegedModules/Languages/\320\240\321\203\321\201\321\201\320\272\320\270\320\271.xml" @@ -0,0 +1,16 @@ + + + + + Русский + + + ru + Русский + + + + ru + + + \ No newline at end of file