Search in sources :

Example 1 with Kind

use of org.checkerframework.dataflow.cfg.UnderlyingAST.Kind in project checker-framework by typetools.

the class LockTransfer method initialStore.

@Override
public LockStore initialStore(UnderlyingAST underlyingAST, List<LocalVariableNode> parameters) {
    LockStore store = super.initialStore(underlyingAST, parameters);
    Kind astKind = underlyingAST.getKind();
    // Handle synchronized methods and constructors.
    if (astKind == Kind.METHOD) {
        CFGMethod method = (CFGMethod) underlyingAST;
        MethodTree methodTree = method.getMethod();
        ExecutableElement methodElement = TreeUtils.elementFromDeclaration(methodTree);
        if (methodElement.getModifiers().contains(Modifier.SYNCHRONIZED)) {
            final ClassTree classTree = method.getClassTree();
            TypeMirror classType = TreeUtils.typeOf(classTree);
            if (methodElement.getModifiers().contains(Modifier.STATIC)) {
                store.insertValue(new FlowExpressions.ClassName(classType), atypeFactory.LOCKHELD);
            } else {
                store.insertThisValue(atypeFactory.LOCKHELD, classType);
            }
        } else if (methodElement.getKind() == ElementKind.CONSTRUCTOR) {
            store.setInConstructorOrInitializer();
        }
    } else if (astKind == Kind.ARBITRARY_CODE) {
        // Handle initializers
        store.setInConstructorOrInitializer();
    }
    return store;
}
Also used : CFGMethod(org.checkerframework.dataflow.cfg.UnderlyingAST.CFGMethod) MethodTree(com.sun.source.tree.MethodTree) TypeMirror(javax.lang.model.type.TypeMirror) ElementKind(javax.lang.model.element.ElementKind) Kind(org.checkerframework.dataflow.cfg.UnderlyingAST.Kind) ExecutableElement(javax.lang.model.element.ExecutableElement) ClassTree(com.sun.source.tree.ClassTree) FlowExpressions(org.checkerframework.dataflow.analysis.FlowExpressions)

Aggregations

ClassTree (com.sun.source.tree.ClassTree)1 MethodTree (com.sun.source.tree.MethodTree)1 ElementKind (javax.lang.model.element.ElementKind)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 TypeMirror (javax.lang.model.type.TypeMirror)1 FlowExpressions (org.checkerframework.dataflow.analysis.FlowExpressions)1 CFGMethod (org.checkerframework.dataflow.cfg.UnderlyingAST.CFGMethod)1 Kind (org.checkerframework.dataflow.cfg.UnderlyingAST.Kind)1