Skip to content

Commit 9cddaae

Browse files
authored
Merge pull request #3581 from 1c-syntax/copilot/support-method-module-references
Support reference tracking for common module methods
2 parents fa75eac + b5ee7fb commit 9cddaae

23 files changed

+1394
-5
lines changed

docs/en/features/ConfigurationFile.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ If there is no configuration file, an attempt will be made to find the ".bsl-lan
4242
| `traceLog` | `String` | To log all requests *(incoming and outgoing)* between **BSL Language Server** and **Language Client** from used editor/IDE, this parameter sets log file path. The path can set either absolute or relative *(from project root)*, by default the value is not set.<br/><br/>**WARNING**<br/><br/>* When starting **BSL Language Server** overwrites this file <br/>* Speed of interaction between client and server **DRAMATICALLY REDUCED** |
4343
| `configurationRoot` | `String` | This parameter is intended to indicate the root directory the 1C configuration files are located in the project directory. It can be useful if there are several configuration directories in the same project directory or when the structure of the project directory is so complex. By default, the parameter is empty and `BSL Language Server` determines the location of the configuration root directory independently |
4444
| `sendErrors` | `String` | Mode for sending error messages to BSL Language Server developers. More [Monitoring](Monitoring.md).Possible values:<br/>* `ask` - ask permission on every error *(set by default)*. <br/>* `send` - always send error messages.<br/>* `never` - never send error messages. |
45+
| `references` | `JSON-Object` | Contains reference index settings |
46+
|&nbsp;&nbsp;&nbsp;`commonModuleAccessors` | `Array` `String` | List of 'Module.Method' patterns for methods returning common module references (e.g. `CommonUse.CommonModule("ModuleName")`). Supports both format with module name (`CommonUse.CommonModule`) and local call (`CommonModule`). By default, includes standard BSL patterns: `ОбщийМодуль`, `CommonModule`, `ОбщегоНазначения.ОбщийМодуль`, `ОбщегоНазначенияКлиент.ОбщийМодуль`, `ОбщегоНазначенияСервер.ОбщийМодуль`, `ОбщегоНазначенияКлиентСервер.ОбщийМодуль`, `ОбщегоНазначенияПовтИсп.ОбщийМодуль` and their English equivalents. |
4547

4648
You can use the following JSON schema to make it easier to compile and edit a configuration file:
4749

docs/features/ConfigurationFile.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ BSL Language Server предоставляет возможность измен
4646
| `traceLog` | `Строка` | Для логирования всех запросов *(входящих и исходящих)* между **BSL Language Server** и **Language Client** из используемого редактора/IDE, в этом параметре можно указать путь к файлу лога. Путь можно указывать как абсолютный, так и относительный *(от корня анализируемого проекта)*, по умолчанию значение не заполнено.<br/><br/>**ВНИМАНИЕ**<br/><br/>* При запуске **BSL Language Server** перезаписывает указанный файл<br/>* Скорость взаимодействия между клиентом и сервером **ЗНАЧИТЕЛЬНО ЗАМЕДЛЯЕТСЯ** |
4747
| `configurationRoot` | `Строка` | Данный параметр предназначен для указания корневого каталога, в котором находятся файлы конфигурации 1С в каталоге проекта. Может быть полезен в случае нахождения нескольких каталогов конфигураций в одном каталоге проекта либо при сложной структуре каталога проекта. По умолчанию параметр не заполнен и `BSL Language Server` самостоятельно определяет расположение корневого каталога конфигурации |
4848
| `sendErrors` | `Строка` | Режим отправки сообщений об ошибках разработчикам BSL Language Server. Подробнее - на странице [Мониторинг и отправка ошибок](Monitoring.md). Возможные значения:<br/>* `ask` - спрашивать разрешение при каждой ошибке *(установлен по умолчанию)*. <br/>* `send` - всегда отправлять сообщения об ошибках. <br/>* `never` - никогда не отправлять сообщения об ошибках. |
49+
| `references` | `JSON-Объект` | Содержит настройки построения индекса ссылок |
50+
| ⤷&nbsp;&nbsp;&nbsp;`commonModuleAccessors` | `Массив` `Строка` | Список паттернов "Модуль.Метод" для методов, возвращающих ссылку на общий модуль (например, `ОбщегоНазначения.ОбщийМодуль("ИмяМодуля")`). Поддерживается как формат с указанием модуля (`ОбщегоНазначения.ОбщийМодуль`), так и локальный вызов (`ОбщийМодуль`). По умолчанию включает стандартные варианты из БСП: `ОбщийМодуль`, `CommonModule`, `ОбщегоНазначения.ОбщийМодуль`, `ОбщегоНазначенияКлиент.ОбщийМодуль`, `ОбщегоНазначенияСервер.ОбщийМодуль`, `ОбщегоНазначенияКлиентСервер.ОбщийМодуль`, `ОбщегоНазначенияПовтИсп.ОбщийМодуль` и их английские эквиваленты. |
4951

5052
Для облегчения составления и редактирования конфигурационного файла можно использовать следующую JSON-схему:
5153

src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/LanguageServerConfiguration.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.github._1c_syntax.bsl.languageserver.configuration.documentlink.DocumentLinkOptions;
3333
import com.github._1c_syntax.bsl.languageserver.configuration.formating.FormattingOptions;
3434
import com.github._1c_syntax.bsl.languageserver.configuration.inlayhints.InlayHintOptions;
35+
import com.github._1c_syntax.bsl.languageserver.configuration.references.ReferencesOptions;
3536
import com.github._1c_syntax.utils.Absolute;
3637
import org.jspecify.annotations.Nullable;
3738
import jakarta.annotation.PostConstruct;
@@ -97,6 +98,10 @@ public class LanguageServerConfiguration {
9798
@Setter(value = AccessLevel.NONE)
9899
private FormattingOptions formattingOptions = new FormattingOptions();
99100

101+
@JsonProperty("references")
102+
@Setter(value = AccessLevel.NONE)
103+
private ReferencesOptions referencesOptions = new ReferencesOptions();
104+
100105
private String siteRoot = "https://1c-syntax.github.io/bsl-language-server";
101106
private boolean useDevSite;
102107

@@ -211,5 +216,6 @@ private void copyPropertiesFrom(LanguageServerConfiguration configuration) {
211216
PropertyUtils.copyProperties(this.diagnosticsOptions, configuration.diagnosticsOptions);
212217
PropertyUtils.copyProperties(this.documentLinkOptions, configuration.documentLinkOptions);
213218
PropertyUtils.copyProperties(this.formattingOptions, configuration.formattingOptions);
219+
PropertyUtils.copyProperties(this.referencesOptions, configuration.referencesOptions);
214220
}
215221
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* This file is a part of BSL Language Server.
3+
*
4+
* Copyright (c) 2018-2025
5+
* Alexey Sosnoviy <[email protected]>, Nikita Fedkin <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* BSL Language Server is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* BSL Language Server is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with BSL Language Server.
21+
*/
22+
package com.github._1c_syntax.bsl.languageserver.configuration.references;
23+
24+
import com.fasterxml.jackson.annotation.JsonCreator;
25+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
26+
import lombok.AllArgsConstructor;
27+
import lombok.Data;
28+
import lombok.NoArgsConstructor;
29+
30+
import java.util.ArrayList;
31+
import java.util.List;
32+
33+
/**
34+
* Настройки для построения индекса ссылок.
35+
* <p>
36+
* Позволяет указать список модулей и методов, возвращающих ссылку на общий модуль
37+
* (например, ОбщегоНазначения.ОбщийМодуль("ИмяМодуля")).
38+
*/
39+
@Data
40+
@AllArgsConstructor(onConstructor = @__({@JsonCreator(mode = JsonCreator.Mode.DISABLED)}))
41+
@NoArgsConstructor
42+
@JsonIgnoreProperties(ignoreUnknown = true)
43+
public class ReferencesOptions {
44+
45+
/**
46+
* Список паттернов "Модуль.Метод" для методов, возвращающих ссылку на общий модуль.
47+
* <p>
48+
* Формат: "ИмяМодуля.ИмяМетода", например:
49+
* <ul>
50+
* <li>"ОбщегоНазначения.ОбщийМодуль"</li>
51+
* <li>"ОбщегоНазначенияКлиент.ОбщийМодуль"</li>
52+
* <li>"CommonUse.CommonModule"</li>
53+
* <li>"ОбщийМодуль" - для локального вызова без указания модуля</li>
54+
* </ul>
55+
* <p>
56+
* По умолчанию включает стандартные варианты из БСП.
57+
*/
58+
private List<String> commonModuleAccessors = new ArrayList<>(List.of(
59+
// Локальный вызов
60+
"ОбщийМодуль",
61+
"CommonModule",
62+
// Стандартные модули БСП
63+
"ОбщегоНазначения.ОбщийМодуль",
64+
"ОбщегоНазначенияКлиент.ОбщийМодуль",
65+
"ОбщегоНазначенияСервер.ОбщийМодуль",
66+
"ОбщегоНазначенияКлиентСервер.ОбщийМодуль",
67+
"ОбщегоНазначенияПовтИсп.ОбщийМодуль",
68+
// Английские варианты
69+
"CommonUse.CommonModule",
70+
"CommonUseClient.CommonModule",
71+
"CommonUseServer.CommonModule",
72+
"CommonUseClientServer.CommonModule"
73+
));
74+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* This file is a part of BSL Language Server.
3+
*
4+
* Copyright (c) 2018-2025
5+
* Alexey Sosnoviy <[email protected]>, Nikita Fedkin <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* BSL Language Server is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* BSL Language Server is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with BSL Language Server.
21+
*/
22+
/**
23+
* Пакет содержит настройки для построения индекса ссылок.
24+
*/
25+
@NullMarked
26+
package com.github._1c_syntax.bsl.languageserver.configuration.references;
27+
28+
import org.jspecify.annotations.NullMarked;

src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/DescriptionFormatter.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import com.github._1c_syntax.bsl.languageserver.context.symbol.AnnotationSymbol;
2525
import com.github._1c_syntax.bsl.languageserver.context.symbol.MethodSymbol;
26+
import com.github._1c_syntax.bsl.languageserver.context.symbol.ModuleSymbol;
2627
import com.github._1c_syntax.bsl.languageserver.context.symbol.ParameterDefinition;
2728
import com.github._1c_syntax.bsl.languageserver.context.symbol.VariableSymbol;
2829
import com.github._1c_syntax.bsl.languageserver.context.symbol.description.MethodDescription;
@@ -137,6 +138,23 @@ public String getSectionWithCodeFences(Collection<String> codeBlocks, String res
137138
return codeFences;
138139
}
139140

141+
public String getLocation(ModuleSymbol symbol) {
142+
var documentContext = symbol.getOwner();
143+
var uri = documentContext.getUri();
144+
145+
var mdObject = documentContext.getMdObject();
146+
String mdoRefLocal = mdObject.map(md -> documentContext.getServerContext()
147+
.getConfiguration()
148+
.getMdoRefLocal(md)
149+
).orElseGet(documentContext::getMdoRef);
150+
151+
return String.format(
152+
"[%s](%s)",
153+
mdoRefLocal,
154+
uri
155+
);
156+
}
157+
140158
public String getLocation(MethodSymbol symbol) {
141159
var documentContext = symbol.getOwner();
142160
var startPosition = symbol.getSelectionRange().getStart();

0 commit comments

Comments
 (0)