Skip to content

perf(diagnostics): резолв типа конструктора через терминальный путь ReferenceFinder#4256

Merged
nixel2007 merged 2 commits into
developfrom
claude/perf-missed-required-parameter-terminal
Jul 10, 2026
Merged

perf(diagnostics): резолв типа конструктора через терминальный путь ReferenceFinder#4256
nixel2007 merged 2 commits into
developfrom
claude/perf-missed-required-parameter-terminal

Conversation

@nixel2007

@nixel2007 nixel2007 commented Jul 10, 2026

Copy link
Copy Markdown
Member

Описание

MissedRequiredParameterDiagnostic.checkConstructorCall резолвил тип конструктора, вычисляя Position из идентификатора typeName и вызывая ReferenceResolver.findReference(uri, Position). Позиционный путь резолвера спускается по AST от корня файла к этой позиции — на каждом выражении Новый Тип(...).

Идентификатор-терминал typeName.IDENTIFIER() уже под рукой (и проверен на null выше), поэтому переключаемся на терминальный оверлоуд findReference(uri, TerminalNode), который поднимается по AST от самого терминала, а не спускается от корня к вычисленной позиции. Удалён ставший ненужным хелпер typeNamePosition и импорт Position; идентификатор вынесен в локальную переменную (снимает повторный вызов IDENTIFIER() и SonarCloud java:S4449).

Замеры

Модуль SSL УправлениеДоступомСлужебный (~48k строк), один и тот же харнесс, best-of-10 после прогрева:

best avg
develop (спуск по позиции) 594.5 ms 632.6 ms
после (подъём от терминала) 163.2 ms 169.8 ms

Ускорение ×3.6. Вывод диагностики идентичен (parity, diags=0 на модуле).

Связанные задачи

Продолжение серии перф-оптимизаций движка резолюции типов/ссылок (#4249#4254, #4255). Использует терминальный оверлоуд ReferenceFinder, добавленный в #4253.

Closes

Чеклист

Общие

  • Ветка PR обновлена из develop
  • Отладочные, закомментированные и прочие, не имеющие смысла участки кода удалены
  • Изменения покрыты тестами (изменённый путь checkConstructorCall покрыт существующими тестами конструкторов: testConstructorCallResolvedToOScriptMethod, …OScriptModule, платформенный РегулярноеВыражение)

Дополнительно

Затронут только один метод; семантика (первое совпадение резолвера, тот же порядок finder'ов) сохранена — терминальный и позиционный пути дают один результат. Прогнан зелёным MissedRequiredParameterDiagnosticTest (6/6).

…der path

MissedRequiredParameterDiagnostic.checkConstructorCall resolved the
constructor's type by computing a Position from the typeName identifier and
calling ReferenceResolver.findReference(uri, Position), which re-descends the
AST from the file root to that position on every Новый expression.

Since the typeName IDENTIFIER terminal is already in hand, switch to the
terminal-aware overload findReference(uri, TerminalNode), which ascends from
the terminal to the enclosing newExpression instead of descending from the
root. Drops the now-unused typeNamePosition helper and Position import.

Measured on the SSL module УправлениеДоступомСлужебный (~48k lines), same
harness, best-of-10: 594.5ms -> 163.2ms (x3.6), diagnostic output identical
(parity). The changed path is covered by the existing constructor-call tests.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BSiRGLm633B4EmvG3vkk4V
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Constructor-call reference resolution now uses the terminal identifier token directly. The obsolete position-calculation helper and unused import were removed; missed-parameter detection remains otherwise unchanged.

Changes

Missed required parameter diagnostics

Layer / File(s) Summary
Direct constructor identifier resolution
src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissedRequiredParameterDiagnostic.java
checkConstructorCall resolves references through typeName.IDENTIFIER(), removing the former position helper and its unused import.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title clearly matches the main change: constructor type resolution was optimized to use the terminal ReferenceFinder path.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/perf-missed-required-parameter-terminal

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.

Extract typeName.IDENTIFIER() into a null-checked local before passing it to
findReference. Resolves SonarCloud java:S4449 (the analyzer could not prove
the second IDENTIFIER() call was non-null) and drops the redundant comment
and the double IDENTIFIER() call.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BSiRGLm633B4EmvG3vkk4V
@nixel2007
nixel2007 merged commit b09bee9 into develop Jul 10, 2026
33 checks passed
@nixel2007
nixel2007 deleted the claude/perf-missed-required-parameter-terminal branch July 10, 2026 09:58
@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants