Skip to content

feat: new diagnostic DeprecatedHttpConnectionMethod - #4399

Open
pravets wants to merge 4 commits into
1c-syntax:developfrom
pravets:feat/new-diagnostic-deprecated-http-connection-method
Open

feat: new diagnostic DeprecatedHttpConnectionMethod#4399
pravets wants to merge 4 commits into
1c-syntax:developfrom
pravets:feat/new-diagnostic-deprecated-http-connection-method

Conversation

@pravets

@pravets pravets commented Aug 3, 2026

Copy link
Copy Markdown

Описание

Новая диагностика DeprecatedHttpConnectionMethod — находит вызовы устаревших методов объекта HTTPСоединение (платформа 8.3.21+).

Вместо синхронных методов следует использовать асинхронные аналоги с суффиксом Асинх / Async.

Closes #1934

Устаревшие методы

Синхронный (deprecated) Асинхронный
ВызватьHTTPМетод() / CallHTTPMethod() ВызватьHTTPМетодАсинх()
Записать() / Write() ЗаписатьАсинх()
Изменить() / Change() ИзменитьАсинх()
ОтправитьДляОбработки() / SendForProcessing() ОтправитьДляОбработкиАсинх()
Получить() / Get() ПолучитьАсинх()
ПолучитьЗаголовки() / GetHeaders() ПолучитьЗаголовкиАсинх()
Удалить() / Delete() УдалитьАсинх()

Метаданные

Параметр Значение
Тип Качество кода (CODE_SMELL)
Важность Важная (MAJOR)
Время исправления 5 минут
Режим совместимости 8.3.21
Тэги DEPRECATED, PERFORMANCE
scope BSL

Как работает (без FP!)

  1. AbstractVisitorDiagnostic обходит все вызовы методов (visitMethodCall)
  2. Имя метода сверяется с regex-паттерном устаревших методов
  3. TypeService.memberAt() резолвит тип-владелец метода
  4. Срабатывает только если владелец — HTTPСоединение / HTTPConnection

Это исключает ложные срабатывания на Получить() у Массива, Структуры и т.д.

Состав PR

  • Java-класс диагностики с TypeService-резолвингом
  • _ru.properties / _en.properties
  • Документация (ru + en) с таблицей методов
  • Тест (проверяет что на Массиве не срабатывает)

Чеклист

  • Тесты проходят локально
  • TypeService.memberAt() корректно фильтрует по типу владельца

Summary by CodeRabbit

  • New Features

    • Added a diagnostic that identifies deprecated synchronous HTTP connection methods in applicable client-side code.
    • Recommends corresponding asynchronous alternatives for affected methods.
    • Supports diagnostic messages in Russian and English.
    • Avoids false positives in server-only contexts and for unrelated methods.
  • Documentation

    • Added guidance with incorrect and correct usage examples.
    • Included a reference to the relevant platform changes.
  • Tests

    • Added coverage for context handling, directives, and similarly named methods on unrelated types.

Detects deprecated HTTPConnection methods in 1C:Enterprise 8.3.21+.
Uses TypeService to resolve owner type — fires only when method
is called on HTTPConnection object, eliminating false positives
on generic names like Get/Write/Delete.

Deprecated methods: CallHTTPMethod, Write, Change,
SendForProcessing, Get, GetHeaders, Delete (and Russian equivalents).

- Type: CODE_SMELL, Severity: MAJOR, minutesToFix: 5
- Compatibility mode: 8.3.21
- Tags: DEPRECATED, PERFORMANCE
- Uses AbstractVisitorDiagnostic + TypeService owner resolution
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a diagnostic for deprecated client-context HTTPСоединение/HTTPConnection methods. It resolves owner types, filters execution contexts, reports matching calls, adds localized messages, tests related cases, and documents asynchronous replacements.

Changes

Deprecated HTTP connection methods

Layer / File(s) Summary
HTTP method detection and reporting
src/main/java/.../DeprecatedHttpConnectionMethodDiagnostic.java
The diagnostic matches seven deprecated methods, filters server contexts, resolves the owner through TypeService, and reports calls on HTTP connection types.
Localization, validation, and replacement documentation
src/main/resources/.../DeprecatedHttpConnectionMethodDiagnostic_*.properties, src/test/java/.../DeprecatedHttpConnectionMethodDiagnosticTest.java, docs/diagnostics/DeprecatedHttpConnectionMethod.md, docs/en/diagnostics/DeprecatedHttpConnectionMethod.md
Adds Russian and English messages, validates Array method handling and server suppression, and documents asynchronous replacements with usage examples.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant BSLParser.MethodCallContext
  participant DeprecatedHttpConnectionMethodDiagnostic
  participant TypeService
  participant DiagnosticStorage
  BSLParser.MethodCallContext->>DeprecatedHttpConnectionMethodDiagnostic: visitMethodCall
  DeprecatedHttpConnectionMethodDiagnostic->>TypeService: resolve called member type
  TypeService-->>DeprecatedHttpConnectionMethodDiagnostic: return owner type
  DeprecatedHttpConnectionMethodDiagnostic->>DiagnosticStorage: record matching deprecated call
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding the DeprecatedHttpConnection diagnostic.
Linked Issues check ✅ Passed The implementation covers the seven deprecated methods, client-context limits, localization, documentation, tests, and the required diagnostic metadata.
Out of Scope Changes check ✅ Passed All reviewed changes support the diagnostic requested by issue #1934, including implementation, tests, documentation, and localization.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnostic.java (2)

48-48: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document the public diagnostic contract.

Add JavaDoc for the public diagnostic class and its overridden visitor method. Describe the supported method names, the HTTPConnection owner invariant, and the diagnostic side effect.

As per coding guidelines, “Javadoc классов и методов должен описывать контракт: параметры, результат, инварианты и побочные эффекты”.

Also applies to: 70-96

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnostic.java`
at line 48, Add Javadoc to DeprecatedHttpConnectionMethodDiagnostic and its
overridden visitor method, documenting supported method names, the requirement
that the owner is HTTPConnection, and the diagnostic side effect; include
parameter, result, invariant, and side-effect details required by the project
guidelines.

Source: Coding guidelines


64-68: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use Lombok for constructor injection.

Replace the handwritten constructor with @RequiredArgsConstructor. The final typeService field already defines the constructor contract.

As per coding guidelines, “use Lombok annotations to reduce boilerplate code”.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnostic.java`
around lines 64 - 68, Replace the handwritten constructor in
DeprecatedHttpConnectionMethodDiagnostic with Lombok’s `@RequiredArgsConstructor`,
retaining the final typeService field so Lombok generates the same constructor
injection contract. Add the required annotation/import and remove only the
redundant constructor.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnostic.java`:
- Around line 71-96: Update visitMethodCall in
DeprecatedHttpConnectionMethodDiagnostic so every early exit and the final
return delegates to super.visitMethodCall(ctx) instead of returning ctx, while
preserving the existing diagnostic checks and recording behavior.

In
`@src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnosticTest.java`:
- Around line 39-47: Add parameterized positive tests alongside
testOnArrayDoesNotFire for supported Russian and English HTTPConnection method
names, asserting both the diagnostic range and message. Reuse the existing
diagnostic setup and expected-value conventions, while preserving the current
non-HTTP Array negative case.

---

Nitpick comments:
In
`@src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnostic.java`:
- Line 48: Add Javadoc to DeprecatedHttpConnectionMethodDiagnostic and its
overridden visitor method, documenting supported method names, the requirement
that the owner is HTTPConnection, and the diagnostic side effect; include
parameter, result, invariant, and side-effect details required by the project
guidelines.
- Around line 64-68: Replace the handwritten constructor in
DeprecatedHttpConnectionMethodDiagnostic with Lombok’s `@RequiredArgsConstructor`,
retaining the final typeService field so Lombok generates the same constructor
injection contract. Add the required annotation/import and remove only the
redundant constructor.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 355b95bd-e02e-4f86-8e60-db53c2a5e19d

📥 Commits

Reviewing files that changed from the base of the PR and between 0b45e3b and 28c7707.

⛔ Files ignored due to path filters (1)
  • src/test/resources/diagnostics/DeprecatedHttpConnectionMethodDiagnostic.bsl is excluded by !src/test/resources/**
📒 Files selected for processing (6)
  • docs/diagnostics/DeprecatedHttpConnectionMethod.md
  • docs/en/diagnostics/DeprecatedHttpConnectionMethod.md
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnostic.java
  • src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnostic_en.properties
  • src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnostic_ru.properties
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnosticTest.java

Comment on lines +71 to +96
public ParseTree visitMethodCall(BSLParser.MethodCallContext ctx) {
var methodName = ctx.methodName();
if (methodName == null) {
return ctx;
}

if (!MESSAGE_PATTERN.matcher(methodName.getText()).matches()) {
return ctx;
}

var identifier = methodName.IDENTIFIER();
if (identifier == null) {
return ctx;
}

var typedMember = typeService.memberAt(documentContext, identifier);
if (typedMember.isEmpty()) {
return ctx;
}

var owner = typedMember.get().owner();
if (owner != null && HTTP_CONNECTION_PATTERN.matcher(owner.qualifiedName()).matches()) {
diagnosticStorage.addDiagnostic(methodName, info.getMessage(methodName.getText()));
}

return ctx;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Continue traversal after handling the current call.

Each return ctx stops the visitor at this method-call subtree. Nested deprecated calls in arguments or chained expressions are not inspected. Return super.visitMethodCall(ctx) on lines 74, 78, 83, 88, and 96.

Proposed fix
-      return ctx;
+      return super.visitMethodCall(ctx);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public ParseTree visitMethodCall(BSLParser.MethodCallContext ctx) {
var methodName = ctx.methodName();
if (methodName == null) {
return ctx;
}
if (!MESSAGE_PATTERN.matcher(methodName.getText()).matches()) {
return ctx;
}
var identifier = methodName.IDENTIFIER();
if (identifier == null) {
return ctx;
}
var typedMember = typeService.memberAt(documentContext, identifier);
if (typedMember.isEmpty()) {
return ctx;
}
var owner = typedMember.get().owner();
if (owner != null && HTTP_CONNECTION_PATTERN.matcher(owner.qualifiedName()).matches()) {
diagnosticStorage.addDiagnostic(methodName, info.getMessage(methodName.getText()));
}
return ctx;
public ParseTree visitMethodCall(BSLParser.MethodCallContext ctx) {
var methodName = ctx.methodName();
if (methodName == null) {
return super.visitMethodCall(ctx);
}
if (!MESSAGE_PATTERN.matcher(methodName.getText()).matches()) {
return super.visitMethodCall(ctx);
}
var identifier = methodName.IDENTIFIER();
if (identifier == null) {
return super.visitMethodCall(ctx);
}
var typedMember = typeService.memberAt(documentContext, identifier);
if (typedMember.isEmpty()) {
return super.visitMethodCall(ctx);
}
var owner = typedMember.get().owner();
if (owner != null && HTTP_CONNECTION_PATTERN.matcher(owner.qualifiedName()).matches()) {
diagnosticStorage.addDiagnostic(methodName, info.getMessage(methodName.getText()));
}
return super.visitMethodCall(ctx);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnostic.java`
around lines 71 - 96, Update visitMethodCall in
DeprecatedHttpConnectionMethodDiagnostic so every early exit and the final
return delegates to super.visitMethodCall(ctx) instead of returning ctx, while
preserving the existing diagnostic checks and recording behavior.

Comment on lines +39 to +47
@Test
void testOnArrayDoesNotFire() {
// Проверяем что на Массиве не срабатывает (owner не HTTPСоединение)
initServerContext(TestUtils.PATH_TO_METADATA);
List<Diagnostic> diagnostics = getDiagnostics();

// Массив.Получить и Массив.Удалить совпадают по имени,
// но владелец — Массив, не HTTPСоединение → не срабатывает
assertThat(diagnostics).isEmpty();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add positive diagnostic cases.

This test only verifies that diagnostics are absent for an Array method. It does not verify that a supported HTTPConnection method produces a diagnostic.

Add parameterized positive cases for the supported Russian and English method names. Assert the diagnostic range and message. Keep this non-HTTP owner case.

As per coding guidelines, “Write comprehensive unit tests for each diagnostic including test cases for edge cases”.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnosticTest.java`
around lines 39 - 47, Add parameterized positive tests alongside
testOnArrayDoesNotFire for supported Russian and English HTTPConnection method
names, asserting both the diagnostic range and message. Reuse the existing
diagnostic setup and expected-value conventions, while preserving the current
non-HTTP Array negative case.

Source: Coding guidelines

@pravets
pravets marked this pull request as draft August 3, 2026 16:21
…uctor

- Add class-level JavaDoc describing diagnostic contract and TypeService integration
- Replace handwritten constructor with Lombok @requiredargsconstructor
- Update fixture to demonstrate actual HTTPConnection code (not just Array)
@pravets
pravets marked this pull request as ready for review August 3, 2026 16:31
@sfaqer

sfaqer commented Aug 5, 2026

Copy link
Copy Markdown
Member

Я не уверен что реализовывать в лоб хорошая идея, Асинх методы доступны только на клиенте, для сервера ничего кроме "устаревших" методов не остаётся, так что я бы сказал что диагностика останется релевантной только в модулях с контекстом Клиент, а на сервере это просто шум ФП

Async HTTP methods are only available on the client. The diagnostic
would produce false positives on server modules where sync methods
are the only option.

Add modules = {FormModule, CommandModule, OrdinaryApplicationModule, ManagedApplicationModule}
to DiagnosticMetadata annotation.
severity = DiagnosticSeverity.MAJOR,
scope = DiagnosticScope.BSL,
modules = {
ModuleType.FormModule,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Форма может быть как НаКлиенте так и НаСервере, строго говоря ограничение по типу модуля наверное некорректно, а вывод доступности по видам доступности (Клиент\Сервер\etc) у нас я так понимаю ещё недоделан, возможно имеет смысл диагностику припарковать до момента когда появится понятный способ узнать что конкретная строка кода выполняется\может выполнятся именно на клиенте.

/cc @nixel2007

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У MethodSymbol есть CompilerDirectiveKind, можно по нему фильтровать

…r directive

Async HTTP methods are client-only. Filter by two layers:
1. Module type (visitFile): skip server-only modules, check
   CommonModule client flags via mdObject
2. Compiler directive (visitSub): skip methods with
   &НаСервере / &НаСервереБезКонтекста directives

Follows UsingSynchronousCallsDiagnostic pattern. Tests cover:
- Array owner does not fire
- Server module does not fire
- Client directive fires, server directives do not (mocked TypeService)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnostic.java`:
- Around line 149-164: Update isServerCommonModule to handle an empty
documentContext.getMdObject() safely: preserve the existing client-capability
check when CommonModule metadata exists, but return false when metadata is
missing so open common modules are not classified as strictly server-only. Add
regression coverage for a CommonModule with absent metadata and ensure
client-call checking still runs.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9573a464-f52b-48fe-ba2c-4dddd3bf5c34

📥 Commits

Reviewing files that changed from the base of the PR and between 3b252fc and 7b6ca36.

⛔ Files ignored due to path filters (1)
  • src/test/resources/diagnostics/DeprecatedHttpConnectionMethodDiagnostic.bsl is excluded by !src/test/resources/**
📒 Files selected for processing (4)
  • docs/diagnostics/DeprecatedHttpConnectionMethod.md
  • docs/en/diagnostics/DeprecatedHttpConnectionMethod.md
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnostic.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnosticTest.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/diagnostics/DeprecatedHttpConnectionMethod.md
  • docs/en/diagnostics/DeprecatedHttpConnectionMethod.md

Comment on lines +149 to +164
private static boolean isServerModule(DocumentContext documentContext) {
return switch (documentContext.getModuleType()) {
case ApplicationModule, CommandModule, FormModule, ManagedApplicationModule -> false;
case CommonModule -> isServerCommonModule(documentContext);
default -> true; // Все прочие модули — строго серверные
};
}

private static boolean isServerCommonModule(DocumentContext documentContext) {
var mdObject = documentContext.getMdObject();

return mdObject.map(CommonModule.class::cast)
.filter(commonModule -> !(commonModule.isClientManagedApplication()
|| commonModule.isClientOrdinaryApplication()))
.isPresent();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n -C 6 \
  'getMdObject\(\)|ModuleType\.CommonModule|isClientManagedApplication|isClientOrdinaryApplication' \
  src/main/java src/test/java

Repository: 1c-syntax/bsl-language-server

Length of output: 50386


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the diagnostic implementation and targeted tests.
sed -n '1,230p' src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnostic.java
printf '\n--- target tests ---\n'
fd -i 'DeprecatedHttpConnectionMethod.*Test\.java$' src/test/java -x sh -c 'echo "### $1"; sed -n "1,220p" "$1"' sh {}

# Inspect DocumentContext.getMdObject implementation(s) and CommonModule capability methods.
rg -n 'class DocumentContext|interface DocumentContext|Optional<MD> getMdObject|getMdObject\(' src/main/java/src/test/java 2>/dev/null || rg -n 'getMdObject|class DocumentContext|MdObject' src/main/java src/test/java --glob '*.java' | head -n 200
printf '\n--- CommonModule api declarations usages ---\n'
rg -n 'class CommonModule|interface CommonModule|isClientManagedApplication|isClientOrdinaryApplication|defaultModule|ModuleType\.(CommonModule|CommandModule|FormModule)' src/main/java --glob '*.java' | head -n 250

# Behavioral Java Optional probe if javac/javadoc is unavailable is not needed; use source and tests.

Repository: 1c-syntax/bsl-language-server

Length of output: 42262


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '--- DocumentContext.mdObject implementation ---\n'
sed -n '130,305p' src/main/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContext.java
printf '\n--- computeMdObject ---\n'
sed -n '430,475p' src/main/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContext.java

printf '\n--- DocumentContextTest relevant helpers ---\n'
sed -n '1,160p' src/test/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContextTest.java

printf '\n--- AbstractCommonModuleNameDiagnostic logic ---\n'
sed -n '1,125p' src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractCommonModuleNameDiagnostic.java

Repository: 1c-syntax/bsl-language-server

Length of output: 258


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- DocumentContext.mdObject implementation ---'
sed -n '130,305p' src/main/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContext.java
printf '%s\n' ''
printf '%s\n' '--- computeMdObject ---'
sed -n '430,475p' src/main/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContext.java

printf '%s\n' ''
printf '%s\n' '--- DocumentContextTest relevant helpers ---'
sed -n '1,160p' src	test/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContextTest.java

printf '%s\n' ''
printf '%s\n' '--- AbstractCommonModuleNameDiagnostic logic ---'
sed -n '1,125p' src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractCommonModuleNameDiagnostic.java

Repository: 1c-syntax/bsl-language-server

Length of output: 7886


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- DocumentContextTest relevant helpers ---'
sed -n '1,160p' src/test/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContextTest.java

printf '%s\n' ''
printf '%s\n' '--- AbstractCommonModuleNameDiagnostic logic ---'
sed -n '1,125p' src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractCommonModuleNameDiagnostic.java

printf '%s\n' ''
printf '%s\n' '--- findChild declarations/usages ---'
rg -n -C 5 'findChild|ConfigurationModule|findChildBy|findDocumentDocument|findDocument|getConfiguration\(' src/main/java --glob '*.java' | head -n 220

Repository: 1c-syntax/bsl-language-server

Length of output: 38408


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- Configuration findChild definitions ---'
rg -n -C 8 'interface Configuration|class .*Configuration|findChild|getModuleTypeByURI' src/main/java --glob '*.java' | sed -n '1,260p'

printf '%s\n' ''
printf '%s\n' '--- getModuleTypeByURI implementations/usages nearby ---'
rg -n -C 5 'getModuleTypeByURI' src/main/java --glob '*.java' | sed -n '1,260p'

Repository: 1c-syntax/bsl-language-server

Length of output: 36574


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- exact findChild/getModuleTypeByURI signatures/classes ---'
rg -n 'interface Configuration|class Abstract.*Configuration|class .*Configuration.*extends|Class<.*Configuration>|findChild\(URI|findChild\(MdoRef|findChild\(' src/main/java --glob '*.java' | head -n 120

printf '%s\n' ''
printf '%s\n' '--- computeConfiguration definitions/classes ---'
rg -n -C 6 'computeConfiguration|getModuleTypeByURI|getChildrenByMdoRef|getModuleTypeFor|ModuleTypeFor|MdoRefMap|mappings' src/main/java --glob '*.java' | head -n 300

Repository: 1c-syntax/bsl-language-server

Length of output: 27369


🌐 Web query:

GitHub com.github._1c_syntax bsl-language-server Configuration getModuleTypeByURI findChild

💡 Result:

In the bsl-language-server project, getModuleTypeByURI and findChild are distinct methods used within different parts of the codebase, primarily related to document context management and type resolution [1][2][3][4]. getModuleTypeByURI This method is primarily associated with resolving the type of a module (e.g., OScriptClass or OScriptModule) based on a document's URI [1][2]. It is notably used within the GlobalScopeProvider and as a fallback mechanism in DocumentContext to identify the module type when standard resolution is insufficient [1][3]. findChild In the context of bsl-language-server, findChild is an internal method used for looking up metadata objects (MD-objects) within the project's configuration structure based on a document's URI [4][5]. Specifically, it is implemented in DocumentContext (often via computeMdObject) to resolve an MD-object for a document [4][5]. Performance optimizations have been applied to this method—such as caching the result via a Lazy wrapper—because it is frequently called during indexing and reference resolution processes [4][5]. It is important to note that findChild is a common naming convention in many programming APIs (such as BeautifulSoup or Figma) [6][7], but in this specific GitHub repository, it refers to the server's internal logic for navigating the 1C configuration hierarchy [4][5].

Citations:


🌐 Web query:

site:github.com/1c-syntax/bsl-language-server "getModuleTypeByURI" ".getModuleTypeByURI" "Configuration"

💡 Result:

The term getModuleTypeByURI refers to an internal method used primarily within the context of the bsl-language-server, a language server project for BSL (1C:Enterprise) and OneScript development [1][2]. While it is not a public-facing configuration option, the method is used internally by the language server's type system and inference engines to determine the module type (such as BSL or OScript) of a document based on its URI [1][2]. Historically, this logic involved analyzing file extensions or paths to map a document to a specific ModuleType, which then influenced how the server provided features like autocompletion, type checking, and member lookup [1]. Recent architectural refactors in the bsl-language-server have evolved how type and module information is handled [3][2]. Modern implementations often rely on centralized services like TypeService or direct interactions with a TypeRegistry, moving away from explicit manual module type resolution where possible [3][2]. In many parts of the codebase, explicit references to ModuleType have been deprecated or reduced in favor of more dynamic or configuration-aware approaches [4][5][6]. In summary, getModuleTypeByURI is an internal programmatic helper method rather than a user-configurable setting. If you are encountering it, it is likely within the source code or debug logs of the language server, where it serves to identify the language context of the current file being processed [1][2].

Citations:


Handle missing common-module metadata before classifying client capability.

DocumentContext.getMdObject() comes from Configuration.findChild(getUri()) and can be empty for an open module without associated metadata. In that case, filter(...).isPresent() treats a client common module as strict server code and visitFile() skips it before client calls are checked. Use map(CommonModule.class::cast).map(common -> ...).orElse(true) or document why empty metadata is impossible for ModuleType.CommonModule, then add regression coverage for missing metadata.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DeprecatedHttpConnectionMethodDiagnostic.java`
around lines 149 - 164, Update isServerCommonModule to handle an empty
documentContext.getMdObject() safely: preserve the existing client-capability
check when CommonModule metadata exists, but return false when metadata is
missing so open common modules are not classified as strictly server-only. Add
regression coverage for a CommonModule with absent metadata and ensure
client-call checking still runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NEW] DeprecatedHttpConectionMethod

3 participants