Search in sources :

Example 1 with Kind

use of com.sun.btrace.annotations.Kind in project btrace by btraceio.

the class VerifierVisitor method checkSampling.

private boolean checkSampling(MethodTree node) {
    TreePath mPath = verifier.getTreeUtils().getPath(verifier.getCompilationUnit(), node);
    ExecutableElement ee = (ExecutableElement) verifier.getTreeUtils().getElement(mPath);
    Sampled s = ee.getAnnotation(Sampled.class);
    OnMethod om = ee.getAnnotation(OnMethod.class);
    if (s != null && om != null) {
        Kind k = om.location().value();
        switch(k) {
            case ENTRY:
            case RETURN:
            case ERROR:
            case CALL:
                {
                    return true;
                }
            default:
                {
                // noop
                }
        }
        reportError("sampler.invalid.location", node);
        return false;
    }
    return true;
}
Also used : TreePath(com.sun.source.util.TreePath) Sampled(com.sun.btrace.annotations.Sampled) OnMethod(com.sun.btrace.annotations.OnMethod) ExecutableElement(javax.lang.model.element.ExecutableElement) Kind(com.sun.btrace.annotations.Kind) ElementKind(javax.lang.model.element.ElementKind)

Aggregations

Kind (com.sun.btrace.annotations.Kind)1 OnMethod (com.sun.btrace.annotations.OnMethod)1 Sampled (com.sun.btrace.annotations.Sampled)1 TreePath (com.sun.source.util.TreePath)1 ElementKind (javax.lang.model.element.ElementKind)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1