aboutsummaryrefslogtreecommitdiffstats
path: root/abi-check-plugin/src/main/java/com/yahoo/abicheck/collector/AnnotationCollector.java
blob: a68fe955cc074484749578705e5f64f8015cdfbe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.abicheck.collector;

import java.util.HashSet;
import java.util.Set;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;

public class AnnotationCollector extends ClassVisitor {

  private final Set<String> annotations = new HashSet<>();

  public AnnotationCollector() {
    super(Opcodes.ASM9);
  }

  @Override
  public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
    annotations.add(Type.getType(descriptor).getClassName());
    return null;
  }

  public Set<String> getAnnotations() {
    return annotations;
  }
}