From 9faef4b29b993ff33adf8af415db3414b8824a20 Mon Sep 17 00:00:00 2001 From: Nikita Fedkin Date: Sun, 3 Nov 2024 00:19:26 +0100 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BD=D0=B0=D1=87=D0=B0=D0=BB=D0=B0=20=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0=20=D0=BF=D1=80=D0=B8=20=D0=BD=D0=B0=D0=BB?= =?UTF-8?q?=D0=B8=D1=87=D0=B8=D0=B8=20=D0=B0=D0=BD=D0=BD=D0=BE=D1=82=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../context/computer/MethodSymbolComputer.java | 8 ++++++++ .../symbol/description/MethodDescriptionTest.java | 12 +++++++++--- .../resources/context/symbol/MethodDescription.bsl | 5 +++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.java index 0fd1d55c87e..ea4b58c43f4 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/MethodSymbolComputer.java @@ -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, @@ -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, diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/MethodDescriptionTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/MethodDescriptionTest.java index 339f8f752af..6865eca7aae 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/MethodDescriptionTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/description/MethodDescriptionTest.java @@ -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); diff --git a/src/test/resources/context/symbol/MethodDescription.bsl b/src/test/resources/context/symbol/MethodDescription.bsl index 1abed2994d4..0fa49e789be 100644 --- a/src/test/resources/context/symbol/MethodDescription.bsl +++ b/src/test/resources/context/symbol/MethodDescription.bsl @@ -143,3 +143,8 @@ // Функция BUG_1495(Ссылки, Знач Реквизиты, ВыбратьРазрешенные = Ложь) Экспорт КонецФункции + +// Описание процедуры +&Аннотация("Параметр") +Процедура ПроцедураСАннотацией() +КонецПроцедуры