Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 20, 2025

Implements LSP document link provider for "см." (see) references found in method and variable description comments, making them clickable in editors.

Changes

  • New DescriptionDocumentLinkSupplier - Scans method/variable description ranges for "см." references using regex (?:см|См)\.\\s+([А-Яа-яA-Za-z0-9_.()]+)
  • Integrated with ReferenceResolver - Uses ReferenceResolver to resolve references to actual symbols
  • Auto-registered as Spring @Component - Works alongside existing DiagnosticDescriptionDocumentLinkSupplier
  • Smart resolution - Creates DocumentLink only when reference successfully resolves to a source-defined symbol

Example

// См. ВспомогательнаяПроцедура
Процедура ИмяПроцедуры()
    для каждого А из т цикл
        Сообщить(А)
    конецЦикла;
КонецПроцедуры

// Вспомогательная процедура
Процедура ВспомогательнаяПроцедура()
КонецПроцедуры

"См." references become clickable links in LSP clients, navigating to the referenced symbol's definition.

How It Works

  1. Finds methods/variables with descriptions containing "см." references (identified by non-empty link field)
  2. Searches description text for "см." or "См." pattern
  3. Uses ReferenceResolver to attempt resolving the reference at that position
  4. If resolved to a SourceDefinedSymbol, creates DocumentLink with target URI pointing to the symbol's file

Testing

  • 3 unit tests covering "см." reference resolution, empty files, and complex descriptions
  • Integration test verifying both suppliers work together
  • All existing tests pass
Original prompt

This section details on the original issue you should resolve

<issue_title>documentLink для ссылок в описаниях методов и переменных</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 20, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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

Copilot AI changed the title [WIP] Add documentLink support for method and variable descriptions Add document link support for URLs in method and variable descriptions Dec 20, 2025
Copilot AI requested a review from nixel2007 December 20, 2025 08:26
@nixel2007
Copy link
Member

@copilot Вот именно ссылки см и интересовали в первую очередь. А https были не нужны.

Copy link
Contributor Author

Copilot AI commented Dec 20, 2025

@copilot Вот именно ссылки см и интересовали в первую очередь. А https были не нужны.

Понял, моя ошибка - я реализовал поддержку HTTP/HTTPS URL вместо "см." ссылок.

Для реализации "см." ссылок как documentLink нужно:

  1. Парсить "см." ссылки из описаний (это уже есть в поле link)
  2. Находить позицию текста ссылки в исходном коде
  3. Резолвить ссылку в символ (например "ОбщийМодуль.Метод()" -> найти файл и метод)
  4. Создать DocumentLink с URI на файл

Это более сложная задача, требующая интеграции с ReferenceResolver и ServerContext для поиска модулей/методов по имени.

Вопросы:

  • Нужна ли поддержка всех видов "см." ссылок (модуль.метод, справочник.реквизит, вложенные структуры)?
  • Или достаточно базовой поддержки только для модуль.метод?
  • Как должен работать documentLink если символ не найден?

@nixel2007
Copy link
Member

@copilot Сделай попытку поиска ссылки через reference resolver. Если что-то вернулось, тогда рисуй Document link

Copy link
Contributor Author

Copilot AI commented Dec 20, 2025

@copilot Сделай попытку поиска ссылки через reference resolver. Если что-то вернулось, тогда рисуй Document link

Готово. Изменил реализацию на использование ReferenceResolver для "см." ссылок:

  • Ищет "см." или "См." в описаниях методов и переменных
  • Вызывает ReferenceResolver.findReference() для резолва символа
  • Создает DocumentLink только если ссылка успешно разрешилась
  • Все тесты проходят

Коммит: d759aab

Copilot AI changed the title Add document link support for URLs in method and variable descriptions Add document link support for "см." references in method and variable descriptions Dec 20, 2025
@nixel2007 nixel2007 force-pushed the copilot/add-document-link-support branch from d759aab to e93b40b Compare December 21, 2025 19:35
@github-actions
Copy link
Contributor

github-actions bot commented Dec 21, 2025

Test Results

2 790 files  + 9  2 790 suites  +9   50m 21s ⏱️ + 1m 50s
1 073 tests + 3  1 073 ✅ + 3  0 💤 ±0  0 ❌ ±0 
9 657 runs  +27  9 657 ✅ +27  0 💤 ±0  0 ❌ ±0 

Results for commit d759aab. ± Comparison against base commit d80ae40.

This pull request removes 8 and adds 7 tests. Note that renamed tests count towards both.
#, count=1
, count=0
, count=1
A, count=1
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [2] content=
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [6] content=
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [7] content=#
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [8] content=
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [2] content=
, count=0
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [6] content=
A, count=1
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [7] content=#
, count=1
com.github._1c_syntax.bsl.languageserver.diagnostics.MetadataObjectNameLengthDiagnosticTest ‑ [8] content=
#, count=1
com.github._1c_syntax.bsl.languageserver.documentlink.DescriptionDocumentLinkSupplierTest ‑ testEmptyDescriptions()
com.github._1c_syntax.bsl.languageserver.documentlink.DescriptionDocumentLinkSupplierTest ‑ testFileWithSeeReferencesInMethodDescription()
com.github._1c_syntax.bsl.languageserver.documentlink.DescriptionDocumentLinkSupplierTest ‑ testGetDocumentLinksForSeeReferences()

♻️ This comment has been updated with latest results.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
73.1% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

documentLink для ссылок в описаниях методов и переменных

2 participants