Skip to main content

tsgo_client/
symbolflags.rs

1use bitflags::bitflags;
2
3// SymbolFlags definition from TypeScript
4// Reference: typescript-go/internal/ast/symbolflags.go
5bitflags! {
6    /// Symbol flags from TypeScript compiler
7    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
8    pub struct SymbolFlags: u32 {
9        /// None
10        const NONE = 0;
11        /// Variable (var) or parameter
12        const FUNCTION_SCOPED_VARIABLE = 1 << 0;
13        /// A block-scoped variable (let or const)
14        const BLOCK_SCOPED_VARIABLE = 1 << 1;
15        /// Property or enum member
16        const PROPERTY = 1 << 2;
17        /// Enum member
18        const ENUM_MEMBER = 1 << 3;
19        /// Function
20        const FUNCTION = 1 << 4;
21        /// Class
22        const CLASS = 1 << 5;
23        /// Interface
24        const INTERFACE = 1 << 6;
25        /// Const enum
26        const CONST_ENUM = 1 << 7;
27        /// Enum
28        const REGULAR_ENUM = 1 << 8;
29        /// Instantiated module
30        const VALUE_MODULE = 1 << 9;
31        /// Uninstantiated module
32        const NAMESPACE_MODULE = 1 << 10;
33        /// Type Literal or mapped type
34        const TYPE_LITERAL = 1 << 11;
35        /// Object Literal
36        const OBJECT_LITERAL = 1 << 12;
37        /// Method
38        const METHOD = 1 << 13;
39        /// Constructor
40        const CONSTRUCTOR = 1 << 14;
41        /// Get accessor
42        const GET_ACCESSOR = 1 << 15;
43        /// Set accessor
44        const SET_ACCESSOR = 1 << 16;
45        /// Call, construct, or index signature
46        const SIGNATURE = 1 << 17;
47        /// Type parameter
48        const TYPE_PARAMETER = 1 << 18;
49        /// Type alias
50        const TYPE_ALIAS = 1 << 19;
51        /// Exported value marker
52        const EXPORT_VALUE = 1 << 20;
53        /// An alias for another symbol
54        const ALIAS = 1 << 21;
55        /// Prototype property (no source representation)
56        const PROTOTYPE = 1 << 22;
57        /// Export * declaration
58        const EXPORT_STAR = 1 << 23;
59        /// Optional property
60        const OPTIONAL = 1 << 24;
61        /// Transient symbol (created during type check)
62        const TRANSIENT = 1 << 25;
63        /// Assignment to property on function acting as declaration
64        const ASSIGNMENT = 1 << 26;
65        /// Symbol for CommonJS `module` of `module.exports`
66        const MODULE_EXPORTS = 1 << 27;
67        /// Module contains only const enums or other modules with only const enums
68        const CONST_ENUM_ONLY_MODULE = 1 << 28;
69        /// Replaceable by method
70        const REPLACEABLE_BY_METHOD = 1 << 29;
71        /// Flag to signal this is a global lookup
72        const GLOBAL_LOOKUP = 1 << 30;
73
74        // Composite flags
75        /// Enum = RegularEnum | ConstEnum
76        const ENUM = Self::REGULAR_ENUM.bits() | Self::CONST_ENUM.bits();
77        /// Variable = FunctionScopedVariable | BlockScopedVariable
78        const VARIABLE = Self::FUNCTION_SCOPED_VARIABLE.bits() | Self::BLOCK_SCOPED_VARIABLE.bits();
79        /// Value flags
80        const VALUE = Self::VARIABLE.bits() | Self::PROPERTY.bits() | Self::ENUM_MEMBER.bits()
81            | Self::OBJECT_LITERAL.bits() | Self::FUNCTION.bits() | Self::CLASS.bits()
82            | Self::ENUM.bits() | Self::VALUE_MODULE.bits() | Self::METHOD.bits()
83            | Self::GET_ACCESSOR.bits() | Self::SET_ACCESSOR.bits();
84        /// Type flags
85        const TYPE = Self::CLASS.bits() | Self::INTERFACE.bits() | Self::ENUM.bits()
86            | Self::ENUM_MEMBER.bits() | Self::TYPE_LITERAL.bits() | Self::TYPE_PARAMETER.bits()
87            | Self::TYPE_ALIAS.bits();
88        /// Namespace flags
89        const NAMESPACE = Self::VALUE_MODULE.bits() | Self::NAMESPACE_MODULE.bits() | Self::ENUM.bits();
90        /// Module flags
91        const MODULE = Self::VALUE_MODULE.bits() | Self::NAMESPACE_MODULE.bits();
92        /// Accessor flags
93        const ACCESSOR = Self::GET_ACCESSOR.bits() | Self::SET_ACCESSOR.bits();
94        /// Module member flags
95        const MODULE_MEMBER = Self::VARIABLE.bits() | Self::FUNCTION.bits() | Self::CLASS.bits()
96            | Self::INTERFACE.bits() | Self::ENUM.bits() | Self::MODULE.bits()
97            | Self::TYPE_ALIAS.bits() | Self::ALIAS.bits();
98        /// Export has local flags
99        const EXPORT_HAS_LOCAL = Self::FUNCTION.bits() | Self::CLASS.bits() | Self::ENUM.bits()
100            | Self::VALUE_MODULE.bits();
101        /// Block scoped flags
102        const BLOCK_SCOPED = Self::BLOCK_SCOPED_VARIABLE.bits() | Self::CLASS.bits() | Self::ENUM.bits();
103        /// Property or accessor flags
104        const PROPERTY_OR_ACCESSOR = Self::PROPERTY.bits() | Self::ACCESSOR.bits();
105        /// Class member flags
106        const CLASS_MEMBER = Self::METHOD.bits() | Self::ACCESSOR.bits() | Self::PROPERTY.bits();
107        /// Export supports default modifier
108        const EXPORT_SUPPORTS_DEFAULT_MODIFIER = Self::CLASS.bits() | Self::FUNCTION.bits()
109            | Self::INTERFACE.bits();
110        /// Classifiable flags
111        const CLASSIFIABLE = Self::CLASS.bits() | Self::ENUM.bits() | Self::TYPE_ALIAS.bits()
112            | Self::INTERFACE.bits() | Self::TYPE_PARAMETER.bits() | Self::MODULE.bits()
113            | Self::ALIAS.bits();
114        /// Late binding container flags
115        const LATE_BINDING_CONTAINER = Self::CLASS.bits() | Self::INTERFACE.bits()
116            | Self::TYPE_LITERAL.bits() | Self::OBJECT_LITERAL.bits() | Self::FUNCTION.bits();
117    }
118}