You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/contributing/DiagnosticStructure.md
+23-23Lines changed: 23 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -11,21 +11,21 @@ This article contains rules of diagnostics usage, creation and information about
11
11
-[Diagnostics class, inherits from AbstractListenerDiagnostic **(Work in Progress)**](#%d0%9a%d0%bb%d0%b0%d1%81%d1%81-%d0%b4%d0%b8%d0%b0%d0%b3%d0%bd%d0%be%d1%81%d1%82%d0%b8%d0%ba%d0%b8-%d1%83%d0%bd%d0%b0%d1%81%d0%bb%d0%b5%d0%b4%d0%be%d0%b2%d0%b0%d0%bd%d0%bd%d1%8b%d0%b9-%d0%be%d1%82-abstractlistenerdiagnostic-%d0%92-%d0%a0%d0%90%d0%97%d0%a0%d0%90%d0%91%d0%9e%d0%a2%d0%9a%d0%95)
12
12
-[Diagnostics test class](#%d0%9a%d0%bb%d0%b0%d1%81%d1%81-%d1%82%d0%b5%d1%81%d1%82%d0%b0-%d0%b4%d0%b8%d0%b0%d0%b3%d0%bd%d0%be%d1%81%d1%82%d0%b8%d0%ba%d0%b8)
-[Test of configuration method for parametrized diagnostics](#%d0%a2%d0%b5%d1%81%d1%82-%d0%bc%d0%b5%d1%82%d0%be%d0%b4%d0%b0-%d0%ba%d0%be%d0%bd%d1%84%d0%b8%d0%b3%d1%83%d1%80%d0%b8%d1%80%d0%be%d0%b2%d0%b0%d0%bd%d0%b8%d1%8f-%d0%b4%d0%bb%d1%8f-%d0%bf%d0%b0%d1%80%d0%b0%d0%bc%d0%b5%d1%82%d1%80%d0%b8%d0%b7%d0%be%d0%b2%d0%b0%d0%bd%d0%bd%d1%8b%d1%85-%d0%b4%d0%b8%d0%b0%d0%b3%d0%bd%d0%be%d1%81%d1%82%d0%b8%d0%ba)
14
+
-[Test of configuration method for parameterized diagnostics](#%d0%a2%d0%b5%d1%81%d1%82-%d0%bc%d0%b5%d1%82%d0%be%d0%b4%d0%b0-%d0%ba%d0%be%d0%bd%d1%84%d0%b8%d0%b3%d1%83%d1%80%d0%b8%d1%80%d0%be%d0%b2%d0%b0%d0%bd%d0%b8%d1%8f-%d0%b4%d0%bb%d1%8f-%d0%bf%d0%b0%d1%80%d0%b0%d0%bc%d0%b5%d1%82%d1%80%d0%b8%d0%b7%d0%be%d0%b2%d0%b0%d0%bd%d0%bd%d1%8b%d1%85-%d0%b4%d0%b8%d0%b0%d0%b3%d0%bd%d0%be%d1%81%d1%82%d0%b8%d0%ba)
15
15
-[Quick fixes test **(Work in progress)**](#%d0%a2%d0%b5%d1%81%d1%82-%22%d0%b1%d1%8b%d1%81%d1%82%d1%80%d1%8b%d1%85-%d0%b7%d0%b0%d0%bc%d0%b5%d0%bd%22-%d0%92-%d0%a0%d0%90%d0%97%d0%a0%d0%90%d0%91%d0%9e%d0%a2%d0%9a%d0%95)
-[Diagnostics test resources](#%d0%a0%d0%b5%d1%81%d1%83%d1%80%d1%81%d1%8b-%d1%82%d0%b5%d1%81%d1%82%d0%b0-%d0%b4%d0%b8%d0%b0%d0%b3%d0%bd%d0%be%d1%81%d1%82%d0%b8%d0%ba%d0%b8)
Diagnostics consists of a set of files, which are described in detail in the sections below.
22
+
Diagnostics consists of a set of files, which are described in detail in the sections below.
23
23
The required set of files as part of the diagnostics at the time of this writing and the rules for their naming
24
24
25
-
- Diagnostic implementation class. The file name is formed according to the principle `% Diagnostic Key%` + `Diagnosctic.java`
26
-
- Diagnostics test class. The file name is generated according to the principle `% Diagnostic Key% ` + `DiagnoscticTest.java`
27
-
- Diagnostic resource file in Russian. The file name is formed according to the principle `% Diagnostic Key% ` + `Diagnosctic_en.properties`
28
-
- Diagnostic resource file in English. The file name is formed according to the principle `% Diagnostic Key% ` + `Diagnosctic_en.properties`
25
+
- Diagnostic implementation class. The file name is formed according to the principle `% Diagnostic Key%` + `Diagnosctic.java`
26
+
- Diagnostics test class. The file name is generated according to the principle `%DiagnosticKey%` + `DiagnoscticTest.java`
27
+
- Diagnostic resource file in Russian. The file name is formed according to the principle `%DiagnosticKey%` + `Diagnosctic_en.properties`
28
+
- Diagnostic resource file in English. The file name is formed according to the principle `%DiagnosticKey%` + `Diagnosctic_en.properties`
29
29
- Resource file (fixture) test. The file name is formed according to the principle `%DiagnosticKey%` + `Diagnosctic.bsl`
30
30
- Diagnostic description file in Russian. The file name is formed according to the principle `%DiagnosticKey%` + `.md`
31
31
- Diagnostic resource file in English. The file name is formed according to the principle `%DiagnosticKey%` + `.md`
@@ -37,20 +37,20 @@ To create necessary files in right places, should run command `gradlew newDiagno
37
37
38
38
Diagnostics is implemented by adding a java class to the `com.github._1c_syntax.bsl.languageserver.diagnostics` package in the `src/main/java` directory.
39
39
40
-
In the body of the file, you need to specify the package to which the class and the import block_ are added (when using ide, the import list is updated automatically)_. It is necessary to ensure that **only** is imported that is necessary for implementation, everything unused should be **removed** _(if [settings](EnvironmentSetting.md) are correct, then ide will do everything automatically)_.
40
+
In the body of the file, you need to specify the package to which the class and the import block are added _(when using ide, the import list is updated automatically)_. It is necessary to ensure that **only** is imported that is necessary for implementation, everything unused should be **removed**_(if [settings](EnvironmentSetting.md) are correct, then ide will do everything automatically)_.
41
41
42
42
Each diagnostic must have a `@DiagnosticMetadata`, class annotation containing diagnostic metadata. The actual content can always be obtained by examining the [file](https://github.com/1c-syntax/bsl-language-server/blob/develop/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticMetadata.java).
43
43
44
-
На момент написания статьи имеются следующие свойства:
44
+
At the time of this writing, the following properties are available:
45
45
46
-
- The type of diagnostics is `type` and its importance is `severity`, for each diagnostics it is necessary to define them. Для того, чтобы правильно выбрать тип и важность диагностики, можно обратиться к [статье](DiagnosticTypeAndSeverity.md).
47
-
-Время на исправление замечания`minutesToFix` (по умолчанию 0). Данное значение используется при расчете общего техдолга проекта в трудозатрах на исправление всех замечаний (сумма времени на исправление по всем обнаруженным замечаниям). Стоит указывать время, максимально реалистичное, которое разработчик должен потратить на исправление.
48
-
-Набор тэгов `tag`диагностики, указывающих группы, к котором она относится. Read more about tags in the [article](DiagnosticTag.md).
49
-
-Границы применимости`scope` (по умолчанию`ALL`, т.е. без ограничения). BSL LS поддерживает несколько языков (oscript и bsl) и диагностики могут применяться как к одному конкретному языку, так и ко всем сразу.
50
-
- Default diagnostic active `activatedByDefault` (default `True`). При разработке экспериментальных, спорных либо не применимых в большинстве проектов, стоит по умолчанию отключать диагностику, активацию выполнит конечный пользователь решения.
51
-
-Режим совместимости`compatibilityMode`, по которому фильтруются диагностики при использовании метаданных. The default is `UNDEFINED`.
46
+
- 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).
47
+
-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.
48
+
-A set of diagnostics tags `tag`that indicate the group to which it belongs. Read more about tags in the [article](DiagnosticTag.md).
49
+
-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.
50
+
- 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.
51
+
-Compatibility mode`compatibilityMode`, by which diagnostics are filtered when using metadata. The default is `UNDEFINED`.
52
52
53
-
Последние два могут быть опущены.
53
+
The last two can be omitted.
54
54
55
55
Annotation example
56
56
@@ -68,11 +68,11 @@ Annotation example
68
68
)
69
69
```
70
70
71
-
Класс должен реализовывать интерфейс `BSLDiagnostic`. Если диагностика основывается на AST дереве, то класс реализации должен быть унаследован от одного из классов ниже, реализующих `BSLDiagnostic`:
71
+
Class should implement the interface `BSLDiagnostic`. If diagnostic bases on AST, that class should extends at one of classes, that implement `BSLDiagnostic` below:
72
72
73
-
-для простых диагностик (проверка контекста модуля) стоит использовать наследование `AbstractVisitor`с реализацией единственного метода `check`
74
-
-при необходимости анализа посещения узла / последовательности узлов, использовать стратегию `слушателя` нужно наследовать класс от`AbstractListenerDiagnostic`
75
-
-в остальных случаях нужно использовать стратегию `визитера` и
73
+
-for simple diagnostics (module context checking) it is worth using inheritance `AbstractVisitor`with the implementation of a single `check` method
74
+
-if you need to analyze a visit to a node / sequence of nodes, use the `listener` strategy, you need to inherit the class from`AbstractListenerDiagnostic`
75
+
-in other cases, you need to use the strategy `visitor` and
76
76
-`AbstractVisitorDiagnostic` for diagnostics of 1C code
77
77
-`AbstractSDBLVisitorDiagnostic` for diagnostics of 1C query
78
78
@@ -98,7 +98,7 @@ public class TemplateDiagnostic extends AbstractListenerDiagnostic
98
98
public class TemplateDiagnostic extends AbstractSDBLVisitorDiagnostic
99
99
```
100
100
101
-
Диагностика может предоставлять т.н. `быстрые исправления`, для чего класс диагностики должен реализовывать интерфейс `QuickFixProvider`. Подробно о добавлении `быстрых исправлений` в диагностику написано [статье](DiagnosticQuickFix.md).
101
+
Diagnostic may provide so-called `quick fixes`. In order to provide quick fixes the diagnostic class must implement `QuickFixProvider` interface. See this [article](DiagnosticQuickFix.md) on adding a `quick fix` to diagnostic.
102
102
103
103
Examples
104
104
@@ -122,9 +122,9 @@ public class TemplateDiagnostic extends AbstractListenerDiagnostic implements Qu
122
122
public class TemplateDiagnosticextendsAbstractSDBLVisitorDiagnosticimplementsQuickFixProvider
123
123
```
124
124
125
-
После объявления класса, для параметризуемых диагностик располагается блок с их параметрами. Подробно о параметрах диагностик написано в [статье](DiagnostcAddSettings.md).
125
+
After the declaration of the class, a block with their parameters is located for parameterizable diagnostics. For details on the diagnostic parameters, see the [article](DiagnostcAddSettings.md).
126
126
127
-
Ниже приведены отличия в реализации классов диагностик.
127
+
Below are the differences in the implementation of diagnostic classes.
### Test of configuration method for parametrized diagnostics
303
+
### Test of configuration method for parameterized diagnostics
304
304
305
305
Тесты для метода конфигурирования должны покрывать все возможные варианты настроек и их комбинаций. Тест имеет практически ту же структуру, что и тест диагностики, за исключение установки параметров диагностики перед получением спсика замечаний.
306
306
Перед установкой новых значений параметров диагностики, необходимо получить настройки диагностики по умолчанию методом `getDefaultDiagnosticConfiguration()`, используя информацию текущего объекта диагностики `diagnosticInstance.getInfo()`. Полученный результат представляет собой соответствие, в котором, методом `put`, необходимо изменить значения нужных параметров. Применение измененных настроек выполняется методом `configure()` текущего объекта диагностики `diagnosticInstance`.
Copy file name to clipboardExpand all lines: docs/en/contributing/EventsApi.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,7 @@ public class LanguageServerConfigurationChangedEvent extends ApplicationEvent {
47
47
48
48
Для публикации событий используется аспект `EventPublisherAspect` пакета `com.github._1c_syntax.bsl.languageserver.aop`
49
49
50
-
> Brief information about acpect-oriented orogramming you can find in page https://www.baeldung.com/aspectj.
50
+
> Brief information about aspect-oriented programming you can find in page https://www.baeldung.com/aspectj.
51
51
52
52
Для перехвата событий в аспекте может быть объявлен advice с перехватом вызовов методов и/или обращений к свойствам объекта. В теле advice должен быть создан объект события и опубликован через [`ApplicationEventPublisher`](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/ApplicationEventPublisher.html).
|`loopsExecutedAtLeastOnce`|`Boolean`|`Assume loops are executed at least once`|`true`|
13
-
|`ignoreMissingElseOnExit`|`Boolean`|`Ignore ElIf clauses which has no Else branch. Disable to detect exits from ElIf condition which results to False`|`false`|
|`loopsExecutedAtLeastOnce`|`Boolean`|`Assume loops are executed at least once`|`true`|
13
+
|`ignoreMissingElseOnExit`|`Boolean`|`Ignore ElIf clauses which has no Else branch. Disable to detect exits from ElIf condition which results to False.`|`false`|
14
14
<!-- Блоки выше заполняются автоматически, не трогать -->
15
15
## Description
16
-
Functions should not have an implicit return. All returned values must be shown excplicitly.
16
+
Functions should not have an implicit return. If control reaches the EndFunction line function returns an Undefined value.
17
+
18
+
As a rule, this is not a normal operation; the programmer must explicitly describe all return values of the function. However, it is quite easy to overlook a situation in which control reaches the EndFunction line and returns an unexpected Undefined value.
19
+
20
+
This diagnostics checks that all possible paths of the function execution have an explicit Return statement and the function does not return unexpected values.
17
21
18
22
## Examples
23
+
24
+
### Incorrect
25
+
26
+
```bsl
27
+
// if the rate is full, but not Tax10 not Tax10 - returns Undefined
28
+
// this could be error or planned behavior.
29
+
Function DefineTaxRate(Val Rate)
30
+
If Rate = Enums.TaxRates.Tax20 Then
31
+
Return 20;
32
+
ElsIf Rate = Enums.TaxRates.Tax10 Then
33
+
Return 10;
34
+
ElsIf Not ValueIsFilled(Rate) Then
35
+
Return Constants.DefaultTaxRate.Get();
36
+
EndIf;
37
+
38
+
// implicit return Undefined
39
+
EndFunction
40
+
```
41
+
42
+
### Correct
43
+
44
+
```
45
+
// explicitly specify the intention to return the result in the end of the function.
0 commit comments