Skip to content

Commit 59bb95c

Browse files
committed
Описание у асинх методов и с аннотациями
1 parent 907f387 commit 59bb95c

File tree

8 files changed

+76
-14
lines changed

8 files changed

+76
-14
lines changed

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ dependencies {
7070
api("org.eclipse.lsp4j", "org.eclipse.lsp4j", "0.14.0")
7171

7272
// 1c-syntax
73-
api("com.github.1c-syntax", "bsl-parser", "0.21.0") {
73+
api("com.github.1c-syntax", "bsl-parser", "24a5789e241") {
7474
exclude("com.tunnelvisionlabs", "antlr4-annotations")
7575
exclude("com.ibm.icu", "*")
7676
exclude("org.antlr", "ST4")

src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public ParseTree visitFunction(BSLParser.FunctionContext ctx) {
9090
}
9191

9292
MethodSymbol methodSymbol = createMethodSymbol(
93+
declaration.getStart(),
9394
startNode,
9495
stopNode,
9596
declaration.subName().getStart(),
@@ -120,6 +121,7 @@ public ParseTree visitProcedure(BSLParser.ProcedureContext ctx) {
120121
}
121122

122123
MethodSymbol methodSymbol = createMethodSymbol(
124+
declaration.getStart(),
123125
startNode,
124126
stopNode,
125127
declaration.subName().getStart(),
@@ -180,6 +182,7 @@ private static Optional<CompilerDirectiveKind> getCompilerDirective(
180182
}
181183

182184
private MethodSymbol createMethodSymbol(
185+
Token startToken,
183186
TerminalNode startNode,
184187
TerminalNode stopNode,
185188
Token subName,
@@ -189,7 +192,7 @@ private MethodSymbol createMethodSymbol(
189192
Optional<CompilerDirectiveKind> compilerDirective,
190193
List<Annotation> annotations
191194
) {
192-
Optional<MethodDescription> description = createDescription(startNode.getSymbol());
195+
Optional<MethodDescription> description = createDescription(startToken);
193196
boolean deprecated = description
194197
.map(MethodDescription::isDeprecated)
195198
.orElse(false);

src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Trees.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222
package com.github._1c_syntax.bsl.languageserver.utils;
2323

24+
import com.github._1c_syntax.bsl.parser.BSLLexer;
2425
import com.github._1c_syntax.bsl.parser.BSLParser;
2526
import com.github._1c_syntax.bsl.parser.BSLParserRuleContext;
2627
import lombok.experimental.UtilityClass;
@@ -49,16 +50,16 @@
4950
public final class Trees {
5051

5152
private static final Set<Integer> VALID_TOKEN_TYPES_FOR_COMMENTS_SEARCH = Set.of(
52-
BSLParser.ANNOTATION_ATCLIENT_SYMBOL,
53-
BSLParser.ANNOTATION_ATSERVERNOCONTEXT_SYMBOL,
54-
BSLParser.ANNOTATION_ATCLIENTATSERVERNOCONTEXT_SYMBOL,
55-
BSLParser.ANNOTATION_ATCLIENTATSERVER_SYMBOL,
56-
BSLParser.ANNOTATION_ATSERVER_SYMBOL,
57-
BSLParser.ANNOTATION_CUSTOM_SYMBOL,
58-
BSLParser.ANNOTATION_UNKNOWN,
59-
BSLParser.LINE_COMMENT,
60-
BSLParser.WHITE_SPACE,
61-
BSLParser.AMPERSAND
53+
BSLLexer.ANNOTATION_ATCLIENT_SYMBOL,
54+
BSLLexer.ANNOTATION_ATSERVERNOCONTEXT_SYMBOL,
55+
BSLLexer.ANNOTATION_ATCLIENTATSERVERNOCONTEXT_SYMBOL,
56+
BSLLexer.ANNOTATION_ATCLIENTATSERVER_SYMBOL,
57+
BSLLexer.ANNOTATION_ATSERVER_SYMBOL,
58+
BSLLexer.ANNOTATION_CUSTOM_SYMBOL,
59+
BSLLexer.ANNOTATION_UNKNOWN,
60+
BSLLexer.LINE_COMMENT,
61+
BSLLexer.WHITE_SPACE,
62+
BSLLexer.AMPERSAND
6263
);
6364

6465
/**

src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputerTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ void testAnnotation() {
192192
// AROUND
193193
methodSymbol = methods.get(22);
194194
assertThat(methodSymbol.getName()).isEqualTo("Р_Вместо");
195+
assertThat(methodSymbol.getDescription()).isNotEmpty();
195196
assertThat(methodSymbol.getAnnotations().get(0).getName()).isEqualTo("Вместо");
196197
assertThat(methodSymbol.getAnnotations().get(0).getKind()).isEqualTo(AnnotationKind.AROUND);
197198
assertThat(methodSymbol.getAnnotations().get(0).getParameters().get(0).getValue()).isEqualTo("Вместо");

src/test/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/MethodDescriptionTest.java

+31-2
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,47 @@ void prepare() {
4444
var documentContext = TestUtils.getDocumentContextFromFile("./src/test/resources/context/symbol/MethodDescription.bsl");
4545
var methods = documentContext.getSymbolTree().getMethods();
4646

47-
assertThat(methods.size()).isEqualTo(14);
47+
assertThat(methods.size()).isEqualTo(18);
4848

4949
methodsWithDescription = methods.stream()
5050
.map(MethodSymbol::getDescription)
5151
.filter(Optional::isPresent)
5252
.map(Optional::get)
5353
.collect(Collectors.toList());
5454

55-
assertThat(methodsWithDescription.size()).isEqualTo(13);
55+
assertThat(methodsWithDescription.size()).isEqualTo(15);
5656
}
5757
}
5858

59+
@Test
60+
void testMethod15() {
61+
var method = methodsWithDescription.get(14);
62+
assertThat(method.getPurposeDescription())
63+
.isNotEmpty()
64+
.isEqualTo("См. ОбщийМодуль.ОписаниеСсылкойАсинх");
65+
assertThat(method.isDeprecated()).isFalse();
66+
assertThat(method.getDeprecationInfo()).isEmpty();
67+
assertThat(method.getExamples()).isEmpty();
68+
assertThat(method.getCallOptions()).isEmpty();
69+
assertThat(method.getParameters()).isEmpty();
70+
assertThat(method.getReturnedValue()).isEmpty();
71+
assertThat(method.getLink()).isNotEmpty();
72+
}
73+
@Test
74+
void testMethod14() {
75+
var method = methodsWithDescription.get(13);
76+
assertThat(method.getPurposeDescription())
77+
.isNotEmpty()
78+
.isEqualTo("См. ОбщийМодуль.Метод()");
79+
assertThat(method.isDeprecated()).isFalse();
80+
assertThat(method.getDeprecationInfo()).isEmpty();
81+
assertThat(method.getExamples()).isEmpty();
82+
assertThat(method.getCallOptions()).isEmpty();
83+
assertThat(method.getParameters()).isEmpty();
84+
assertThat(method.getReturnedValue()).isEmpty();
85+
assertThat(method.getLink()).isNotEmpty();
86+
}
87+
5988
@Test
6089
void testMethod13() {
6190
var method = methodsWithDescription.get(12);

src/test/resources/context/computer/MethodSymbolComputerTest.bsl

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
Процедура Р_После()
109109
КонецПроцедуры
110110

111+
// Описание метода
111112
&Вместо("Вместо")
112113
Функция Р_Вместо()
113114
КонецФункции

src/test/resources/context/symbol/MethodDescription.bsl

+12
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,15 @@
143143
//
144144
Функция BUG_1495(Ссылки, Знач Реквизиты, ВыбратьРазрешенные = Ложь) Экспорт
145145
КонецФункции
146+
147+
// См. ОбщийМодуль.Метод()
148+
&Перед("ОписаниеСсылкойВРасширении")
149+
Функция ОписаниеСсылкойВРасширении(Параметр1, Знач Параметр2 = 3)
150+
КонецФункции
151+
Функция НаписанаБезПробела()
152+
КонецФункции Процедура НаписанаВоднуСтроку() КонецПроцедуры
153+
154+
// См. ОбщийМодуль.ОписаниеСсылкойАсинх
155+
&НаКлиенте
156+
Асинх Функция ОписаниеСсылкойАсинх()
157+
КонецФункции

src/test/resources/diagnostics/PublicMethodsDescriptionDiagnostic.bsl

+15
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,19 @@
107107

108108
КонецФункции
109109

110+
// см. КакойтоМодуль.Метод
111+
Функция ОписаниеСм() Экспорт
112+
113+
Возврат Неопределено;
114+
115+
КонецФункции
116+
117+
// см. КакойтоМодуль.Метод
118+
&Перед("ОписаниеСмПеред")
119+
Функция ОписаниеСмПеред() Экспорт
120+
121+
Возврат Неопределено;
122+
123+
КонецФункции
124+
110125
#КонецОбласти

0 commit comments

Comments
 (0)