Remove empty annotations node from PrintAST

This commit is contained in:
Tamas Vajk 2022-04-12 16:04:29 +02:00 коммит произвёл Chris Smowton
Родитель 3b09cb2224
Коммит b5ae43a887
2 изменённых файлов: 6 добавлений и 5 удалений

Просмотреть файл

@ -120,7 +120,12 @@ private newtype TPrintAstNode =
shouldPrint(lvde, _) and lvde.getParent() instanceof SingleLocalVarDeclParent
} or
TAnnotationsNode(Annotatable ann) {
shouldPrint(ann, _) and ann.hasDeclaredAnnotation() and not partOfAnnotation(ann)
shouldPrint(ann, _) and
ann.hasDeclaredAnnotation() and
not partOfAnnotation(ann) and
// The Kotlin compiler might add annotations that are only present in byte code, although the annotatable element is
// present in source code.
exists(Annotation a | a.getAnnotatedElement() = ann and shouldPrint(a, _))
} or
TParametersNode(Callable c) { shouldPrint(c, _) and not c.hasNoParameters() } or
TBaseTypesNode(ClassOrInterface ty) { shouldPrint(ty, _) } or

Просмотреть файл

@ -11,15 +11,11 @@ def.kt:
# 14| 0: [MethodAccess] abc(...)
# 14| -1: [VarAccess] a
# 1| 2: [Interface] SomeAnnotation
#-----| -3: (Annotations)
# 1| 1: [Method] abc
#-----| 1: (Annotations)
# 1| 2: [Method] y
# 3| 3: [Interface] ReplaceWith
#-----| -3: (Annotations)
# 3| 1: [Method] expression
# 5| 4: [Interface] Deprecated
#-----| -3: (Annotations)
# 6| 1: [Method] message
# 7| 2: [Method] replaceWith
# 9| 5: [Class] X