Skip to content

Commit

Permalink
Исправление поиска начала метода при наличии аннотаций
Browse files Browse the repository at this point in the history
  • Loading branch information
nixel2007 committed Nov 2, 2024
1 parent 810c04a commit 9faef4b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public ParseTree visitFunction(BSLParser.FunctionContext ctx) {
return ctx;
}

if (!declaration.annotation().isEmpty()) {
startNode = declaration.annotation().get(0).AMPERSAND();
}

MethodSymbol methodSymbol = createMethodSymbol(
startNode,
stopNode,
Expand Down Expand Up @@ -119,6 +123,10 @@ public ParseTree visitProcedure(BSLParser.ProcedureContext ctx) {
return ctx;
}

if (!declaration.annotation().isEmpty()) {
startNode = declaration.annotation().get(0).AMPERSAND();
}

MethodSymbol methodSymbol = createMethodSymbol(
startNode,
stopNode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,24 @@ void prepare() {
var documentContext = TestUtils.getDocumentContextFromFile("./src/test/resources/context/symbol/MethodDescription.bsl");
var methods = documentContext.getSymbolTree().getMethods();

assertThat(methods.size()).isEqualTo(14);
assertThat(methods).hasSize(15);

methodsWithDescription = methods.stream()
.map(MethodSymbol::getDescription)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());
.toList();

assertThat(methodsWithDescription.size()).isEqualTo(13);
assertThat(methodsWithDescription.size()).isEqualTo(14);
}
}

@Test
void testMethodWithAnnotation() {
var method = methodsWithDescription.get(13);
assertThat(method.getDescription()).isEqualTo("// Описание процедуры");
}

@Test
void testMethod13() {
var method = methodsWithDescription.get(12);
Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/context/symbol/MethodDescription.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,8 @@
//
Функция BUG_1495(Ссылки, Знач Реквизиты, ВыбратьРазрешенные = Ложь) Экспорт
КонецФункции

// Описание процедуры
&Аннотация("Параметр")
Процедура ПроцедураСАннотацией()
КонецПроцедуры

0 comments on commit 9faef4b

Please sign in to comment.