@@ -296,6 +296,125 @@ void testAnnotateParams() {
296296 assertThat (annotation2 .annotationParams ().annotationParam ()).isNotNull ().hasSize (3 );
297297 }
298298
299+ @ Test
300+ void testNestedAnnotations () {
301+ var content = testParser .assertThat ("""
302+ &ДляКаждого(
303+ Значение = &Тип("Строка"),
304+ &Тип("Число", &Длина(10))
305+ )
306+ Перем Параметр;""" );
307+
308+ var file = testParser .parser ().file ();
309+ content .matches (file );
310+ assertThat (file .moduleVars ()).isNotNull ();
311+ assertThat (file .moduleVars ().moduleVar ())
312+ .isNotNull ()
313+ .hasSize (1 );
314+
315+ var moduleVar = file .moduleVars ().moduleVar (0 );
316+ assertThat (moduleVar .annotation ())
317+ .isNotNull ()
318+ .hasSize (1 );
319+
320+ var mainAnnotation = moduleVar .annotation ().get (0 );
321+ assertThat (mainAnnotation .annotationParams ()).isNotNull ();
322+ assertThat (mainAnnotation .annotationParams ().annotationParam ())
323+ .isNotNull ()
324+ .hasSize (2 );
325+
326+ // First param: Значение = &Тип("Строка")
327+ var param1 = mainAnnotation .annotationParams ().annotationParam (0 );
328+ assertThat (param1 .annotationParamName ()).isNotNull ();
329+ assertThat (param1 .annotationParamValue ()).isNotNull ();
330+ assertThat (param1 .annotationParamValue ().annotation ()).isNotNull ();
331+
332+ // Second param: &Тип("Число", &Длина(10))
333+ var param2 = mainAnnotation .annotationParams ().annotationParam (1 );
334+ assertThat (param2 .annotationParamValue ()).isNotNull ();
335+ assertThat (param2 .annotationParamValue ().annotation ()).isNotNull ();
336+ var nestedAnnotation = param2 .annotationParamValue ().annotation ();
337+ assertThat (nestedAnnotation .annotationParams ()).isNotNull ();
338+ assertThat (nestedAnnotation .annotationParams ().annotationParam ())
339+ .isNotNull ()
340+ .hasSize (2 );
341+
342+ // Check that the second param of the nested annotation is also an annotation
343+ var nestedParam2 = nestedAnnotation .annotationParams ().annotationParam (1 );
344+ assertThat (nestedParam2 .annotationParamValue ()).isNotNull ();
345+ assertThat (nestedParam2 .annotationParamValue ().annotation ()).isNotNull ();
346+ }
347+
348+ @ Test
349+ void testNestedAnnotationsInMethodDeclaration () {
350+ var content = testParser .assertThat ("""
351+ &Аннотация(&Тип("Строка"))
352+ Процедура Метод()
353+ КонецПроцедуры""" );
354+
355+ var file = testParser .parser ().file ();
356+ content .matches (file );
357+ assertThat (file .subs ()).isNotNull ();
358+ assertThat (file .subs ().sub ())
359+ .isNotNull ()
360+ .hasSize (1 );
361+
362+ var sub = file .subs ().sub (0 );
363+ var procDeclaration = sub .procedure ().procDeclaration ();
364+ assertThat (procDeclaration .annotation ())
365+ .isNotNull ()
366+ .hasSize (1 );
367+
368+ var annotation = procDeclaration .annotation ().get (0 );
369+ assertThat (annotation .annotationParams ()).isNotNull ();
370+ assertThat (annotation .annotationParams ().annotationParam ())
371+ .isNotNull ()
372+ .hasSize (1 );
373+
374+ var param = annotation .annotationParams ().annotationParam (0 );
375+ assertThat (param .annotationParamValue ()).isNotNull ();
376+ assertThat (param .annotationParamValue ().annotation ()).isNotNull ();
377+ }
378+
379+ @ Test
380+ void testNestedAnnotationsInMethodParameter () {
381+ var content = testParser .assertThat ("""
382+ Процедура Метод(
383+ &Тип(&Строка())
384+ Парам1
385+ )
386+ КонецПроцедуры""" );
387+
388+ var file = testParser .parser ().file ();
389+ content .matches (file );
390+ assertThat (file .subs ()).isNotNull ();
391+ assertThat (file .subs ().sub ())
392+ .isNotNull ()
393+ .hasSize (1 );
394+
395+ var sub = file .subs ().sub (0 );
396+ var procDeclaration = sub .procedure ().procDeclaration ();
397+ assertThat (procDeclaration .paramList ()).isNotNull ();
398+ assertThat (procDeclaration .paramList ().param ())
399+ .isNotNull ()
400+ .hasSize (1 );
401+
402+ var param = procDeclaration .paramList ().param (0 );
403+ assertThat (param .annotation ())
404+ .isNotNull ()
405+ .hasSize (1 );
406+
407+ var annotation = param .annotation ().get (0 );
408+ assertThat (annotation .annotationParams ()).isNotNull ();
409+ assertThat (annotation .annotationParams ().annotationParam ())
410+ .isNotNull ()
411+ .hasSize (1 );
412+
413+ var annotationParam = annotation .annotationParams ().annotationParam (0 );
414+ assertThat (annotationParam .annotationParamValue ()).isNotNull ();
415+ assertThat (annotationParam .annotationParamValue ().annotation ()).isNotNull ();
416+ }
417+
299418 @ Test
300419 void testRaise () {
301420 var content = testParser .assertThat ("ВызватьИсключение (\" Документ не может быть проведен\" , " +
0 commit comments