Search in sources :

Example 1 with Nullable

use of com.facebook.buck.util.liteinfersupport.Nullable in project buck by facebook.

the class TreeContextScanner method scan.

@Override
@Nullable
public R scan(Tree tree, @Nullable P p) {
    if (tree == null) {
        return null;
    }
    TreePath previousPath = currentPath;
    Element previousEnclosingElement = enclosingElement;
    currentPath = new TreePath(currentPath, tree);
    switch(tree.getKind()) {
        case ANNOTATION_TYPE:
        case CLASS:
        case COMPILATION_UNIT:
        case ENUM:
        case INTERFACE:
        case METHOD:
        case VARIABLE:
        case TYPE_PARAMETER:
            enclosingElement = Preconditions.checkNotNull(trees.getElement(currentPath));
            break;
        // $CASES-OMITTED$
        default:
            break;
    }
    try {
        // This super call will actually visit the tree, now with all the context set up
        return super.scan(tree, p);
    } finally {
        currentPath = previousPath;
        enclosingElement = previousEnclosingElement;
    }
}
Also used : TreePath(com.sun.source.util.TreePath) Element(javax.lang.model.element.Element) Nullable(com.facebook.buck.util.liteinfersupport.Nullable)

Example 2 with Nullable

use of com.facebook.buck.util.liteinfersupport.Nullable in project buck by facebook.

the class TreeResolver method getType.

@Nullable
public TypeMirror getType(TreePath path) {
    Tree tree = path.getLeaf();
    TypeMirror result = treesToTypes.get(tree);
    if (result != null) {
        return result;
    }
    treesToTypes.put(tree, resolveType(path));
    return treesToTypes.get(tree);
}
Also used : TypeMirror(javax.lang.model.type.TypeMirror) ArrayTypeTree(com.sun.source.tree.ArrayTypeTree) MethodTree(com.sun.source.tree.MethodTree) VariableTree(com.sun.source.tree.VariableTree) TypeParameterTree(com.sun.source.tree.TypeParameterTree) ParameterizedTypeTree(com.sun.source.tree.ParameterizedTypeTree) IdentifierTree(com.sun.source.tree.IdentifierTree) Tree(com.sun.source.tree.Tree) ClassTree(com.sun.source.tree.ClassTree) MemberSelectTree(com.sun.source.tree.MemberSelectTree) PrimitiveTypeTree(com.sun.source.tree.PrimitiveTypeTree) WildcardTree(com.sun.source.tree.WildcardTree) Nullable(com.facebook.buck.util.liteinfersupport.Nullable)

Aggregations

Nullable (com.facebook.buck.util.liteinfersupport.Nullable)2 ArrayTypeTree (com.sun.source.tree.ArrayTypeTree)1 ClassTree (com.sun.source.tree.ClassTree)1 IdentifierTree (com.sun.source.tree.IdentifierTree)1 MemberSelectTree (com.sun.source.tree.MemberSelectTree)1 MethodTree (com.sun.source.tree.MethodTree)1 ParameterizedTypeTree (com.sun.source.tree.ParameterizedTypeTree)1 PrimitiveTypeTree (com.sun.source.tree.PrimitiveTypeTree)1 Tree (com.sun.source.tree.Tree)1 TypeParameterTree (com.sun.source.tree.TypeParameterTree)1 VariableTree (com.sun.source.tree.VariableTree)1 WildcardTree (com.sun.source.tree.WildcardTree)1 TreePath (com.sun.source.util.TreePath)1 Element (javax.lang.model.element.Element)1 TypeMirror (javax.lang.model.type.TypeMirror)1