aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/checker_framework_javacutil/java/org/checkerframework/javacutil/trees/DetachedVarSymbol.java
blob: 0edf3944e3c3d7c8e40ab71ad87b992023c3d7b5 (plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package org.checkerframework.javacutil.trees;

import com.sun.source.tree.VariableTree;
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.util.Name;

/*>>>
import org.checkerframework.checker.nullness.qual.Nullable;
*/

/**
 * A DetachedVarSymbol represents a variable that is not part of any
 * AST Tree.  DetachedVarSymbols are created when desugaring source
 * code constructs and they carry important type information, but some
 * methods such as TreeInfo.declarationFor do not work on them.
 */

public class DetachedVarSymbol extends Symbol.VarSymbol {

    protected /*@Nullable*/ VariableTree decl;

    /**
     * Construct a detached variable symbol, given its flags, name,
     * type and owner.
     */
    public DetachedVarSymbol(long flags, Name name, Type type, Symbol owner) {
        super(flags, name, type, owner);
        this.decl = null;
    }

    /**
     * Set the declaration tree for the variable.
     */
    public void setDeclaration(VariableTree decl) {
        this.decl = decl;
    }

    /**
     * Get the declaration tree for the variable.
     */
    public /*@Nullable*/ VariableTree getDeclaration() {
        return decl;
    }
}