Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Исправление поиска начала метода при наличии аннотаций #3359

Merged
merged 5 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(Ссылки, Знач Реквизиты, ВыбратьРазрешенные = Ложь) Экспорт
КонецФункции

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