Emit Tokens in Symbol Stringer.String functions
It's generally more useful to have the fully qualified symbol token in logs, error messages, etc. So this is a better default than name.
This commit is contained in:
parent
6db3d0b687
commit
110ecdc734
5 changed files with 16 additions and 16 deletions
|
@ -43,7 +43,7 @@ func (node *Class) Sealed() bool { return node.Node.Seale
|
|||
func (node *Class) Abstract() bool { return node.Node.Abstract != nil && *node.Node.Abstract }
|
||||
func (node *Class) Record() bool { return node.Node.Record != nil && *node.Node.Record }
|
||||
func (node *Class) Interface() bool { return node.Node.Interface != nil && *node.Node.Interface }
|
||||
func (node *Class) String() string { return string(node.Name()) }
|
||||
func (node *Class) String() string { return string(node.Token()) }
|
||||
|
||||
// HasInit returns true if this module has an initialzer associated with it.
|
||||
func (node *Class) HasInit() bool { return node.GetInit() != nil }
|
||||
|
@ -139,7 +139,7 @@ func (node *ClassProperty) MemberName() tokens.ClassMemberName {
|
|||
}
|
||||
func (node *ClassProperty) MemberParent() *Class { return node.Parent }
|
||||
func (node *ClassProperty) VarNode() ast.Variable { return node.Node }
|
||||
func (node *ClassProperty) String() string { return string(node.Name()) }
|
||||
func (node *ClassProperty) String() string { return string(node.Token()) }
|
||||
|
||||
// NewClassPropertySym returns a new ClassProperty symbol with the given node and parent.
|
||||
func NewClassPropertySym(node *ast.ClassProperty, parent *Class, ty Type) *ClassProperty {
|
||||
|
@ -184,7 +184,7 @@ func (node *ClassMethod) Constructor() bool {
|
|||
}
|
||||
func (node *ClassMethod) Function() ast.Function { return node.Node }
|
||||
func (node *ClassMethod) Signature() *FunctionType { return node.Sig }
|
||||
func (node *ClassMethod) String() string { return string(node.Name()) }
|
||||
func (node *ClassMethod) String() string { return string(node.Token()) }
|
||||
|
||||
// NewClassMethodSym returns a new ClassMethod symbol with the given node and parent.
|
||||
func NewClassMethodSym(node *ast.ClassMethod, parent *Class, sig *FunctionType) *ClassMethod {
|
||||
|
|
|
@ -30,7 +30,7 @@ func (node *Module) Token() tokens.Token {
|
|||
}
|
||||
func (node *Module) Tree() diag.Diagable { return node.Node }
|
||||
func (node *Module) Special() bool { return false }
|
||||
func (node *Module) String() string { return string(node.Name()) }
|
||||
func (node *Module) String() string { return string(node.Token()) }
|
||||
|
||||
// HasInit returns true if this module has an initialzer associated with it.
|
||||
func (node *Module) HasInit() bool { return node.GetInit() != nil }
|
||||
|
@ -80,7 +80,7 @@ func (node *Export) Token() tokens.Token {
|
|||
}
|
||||
func (node *Export) Special() bool { return false }
|
||||
func (node *Export) Tree() diag.Diagable { return node.Node }
|
||||
func (node *Export) String() string { return string(node.Name()) }
|
||||
func (node *Export) String() string { return string(node.Token()) }
|
||||
|
||||
// NewExportSym returns a new Export symbol with the given node, parent, and referent. The referent may be a fully
|
||||
// resolved module member or it might just point to yet another export symbol, in the case of chaining.
|
||||
|
@ -144,7 +144,7 @@ func (node *ModuleProperty) Default() *interface{} { return node.Node.Default }
|
|||
func (node *ModuleProperty) Readonly() bool { return node.Node.Readonly != nil && *node.Node.Readonly }
|
||||
func (node *ModuleProperty) Type() Type { return node.Ty }
|
||||
func (node *ModuleProperty) VarNode() ast.Variable { return node.Node }
|
||||
func (node *ModuleProperty) String() string { return string(node.Name()) }
|
||||
func (node *ModuleProperty) String() string { return string(node.Token()) }
|
||||
|
||||
// NewModulePropertySym returns a new ModuleProperty symbol with the given node and parent.
|
||||
func NewModulePropertySym(node *ast.ModuleProperty, parent *Module, ty Type) *ModuleProperty {
|
||||
|
@ -187,7 +187,7 @@ func (node *ModuleMethod) ModuleMemberProperty() {}
|
|||
func (node *ModuleMethod) MemberType() Type { return node.Sig }
|
||||
func (node *ModuleMethod) Function() ast.Function { return node.Node }
|
||||
func (node *ModuleMethod) Signature() *FunctionType { return node.Sig }
|
||||
func (node *ModuleMethod) String() string { return string(node.Name()) }
|
||||
func (node *ModuleMethod) String() string { return string(node.Token()) }
|
||||
|
||||
// NewModuleMethodSym returns a new ModuleMethod symbol with the given node and parent.
|
||||
func NewModuleMethodSym(node *ast.ModuleMethod, parent *Module, sig *FunctionType) *ModuleMethod {
|
||||
|
|
|
@ -22,7 +22,7 @@ func (node *Package) Token() tokens.Token { return tokens.Token(node.Node.Name)
|
|||
func (node *Package) Special() bool { return false }
|
||||
func (node *Package) Tree() diag.Diagable { return node.Node }
|
||||
func (node *Package) Default() *Module { return node.Modules[tokens.DefaultModule] }
|
||||
func (node *Package) String() string { return string(node.Name()) }
|
||||
func (node *Package) String() string { return string(node.Token()) }
|
||||
|
||||
// NewPackageSym returns a new Package symbol with the given node.
|
||||
func NewPackageSym(node *pack.Package) *Package {
|
||||
|
|
|
@ -39,7 +39,7 @@ func (node *PrimitiveType) TypeToken() tokens.Type { return tokens.Type(nod
|
|||
func (node *PrimitiveType) TypeMembers() ClassMemberMap { return noClassMembers }
|
||||
func (node *PrimitiveType) Record() bool { return false }
|
||||
func (node *PrimitiveType) Interface() bool { return false }
|
||||
func (node *PrimitiveType) String() string { return string(node.Name()) }
|
||||
func (node *PrimitiveType) String() string { return string(node.Token()) }
|
||||
|
||||
func NewPrimitiveType(nm tokens.TypeName) *PrimitiveType {
|
||||
return &PrimitiveType{nm}
|
||||
|
@ -65,7 +65,7 @@ func (node *PointerType) TypeToken() tokens.Type { return node.Tok }
|
|||
func (node *PointerType) TypeMembers() ClassMemberMap { return noClassMembers }
|
||||
func (node *PointerType) Record() bool { return false }
|
||||
func (node *PointerType) Interface() bool { return false }
|
||||
func (node *PointerType) String() string { return string(node.Name()) }
|
||||
func (node *PointerType) String() string { return string(node.Token()) }
|
||||
|
||||
// pointerTypeCache is a cache keyed by token, helping to avoid creating superfluous symbol objects.
|
||||
var pointerTypeCache = make(map[tokens.Type]*PointerType)
|
||||
|
@ -103,7 +103,7 @@ func (node *ArrayType) TypeToken() tokens.Type { return node.Tok }
|
|||
func (node *ArrayType) TypeMembers() ClassMemberMap { return noClassMembers }
|
||||
func (node *ArrayType) Record() bool { return false }
|
||||
func (node *ArrayType) Interface() bool { return false }
|
||||
func (node *ArrayType) String() string { return string(node.Name()) }
|
||||
func (node *ArrayType) String() string { return string(node.Token()) }
|
||||
|
||||
// arrayTypeCache is a cache keyed by token, helping to avoid creating superfluous symbol objects.
|
||||
var arrayTypeCache = make(map[tokens.Type]*ArrayType)
|
||||
|
@ -142,7 +142,7 @@ func (node *MapType) TypeToken() tokens.Type { return node.Tok }
|
|||
func (node *MapType) TypeMembers() ClassMemberMap { return noClassMembers }
|
||||
func (node *MapType) Record() bool { return false }
|
||||
func (node *MapType) Interface() bool { return false }
|
||||
func (node *MapType) String() string { return string(node.Name()) }
|
||||
func (node *MapType) String() string { return string(node.Token()) }
|
||||
|
||||
// mapTypeCache is a cache keyed by token, helping to avoid creating superfluous symbol objects.
|
||||
var mapTypeCache = make(map[tokens.Type]*MapType)
|
||||
|
@ -181,7 +181,7 @@ func (node *FunctionType) TypeToken() tokens.Type { return node.Tok }
|
|||
func (node *FunctionType) TypeMembers() ClassMemberMap { return noClassMembers }
|
||||
func (node *FunctionType) Record() bool { return false }
|
||||
func (node *FunctionType) Interface() bool { return false }
|
||||
func (node *FunctionType) String() string { return string(node.Name()) }
|
||||
func (node *FunctionType) String() string { return string(node.Token()) }
|
||||
|
||||
// functionTypeCache is a cache keyed by token, helping to avoid creating superfluous symbol objects.
|
||||
var functionTypeCache = make(map[tokens.Type]*FunctionType)
|
||||
|
@ -223,7 +223,7 @@ var _ Symbol = (*PrototypeType)(nil)
|
|||
var _ Type = (*PrototypeType)(nil)
|
||||
|
||||
func (node *PrototypeType) Name() tokens.Name { return tokens.Name(node.TypeName()) }
|
||||
func (node *PrototypeType) Token() tokens.Token { return tokens.Token(node.TypeName()) }
|
||||
func (node *PrototypeType) Token() tokens.Token { return tokens.Token(node.TypeToken()) }
|
||||
func (node *PrototypeType) Special() bool { return false }
|
||||
func (node *PrototypeType) Tree() diag.Diagable { return nil }
|
||||
func (node *PrototypeType) Base() Type { return nil }
|
||||
|
@ -236,7 +236,7 @@ func (node *PrototypeType) TypeToken() tokens.Type {
|
|||
func (node *PrototypeType) TypeMembers() ClassMemberMap { return noClassMembers }
|
||||
func (node *PrototypeType) Record() bool { return false }
|
||||
func (node *PrototypeType) Interface() bool { return false }
|
||||
func (node *PrototypeType) String() string { return string(node.Name()) }
|
||||
func (node *PrototypeType) String() string { return string(node.Token()) }
|
||||
|
||||
// prototypeTypeCache is a cache keyed by token, helping to avoid creating superfluous symbol objects.
|
||||
var prototypeTypeCache = make(map[Type]*PrototypeType)
|
||||
|
|
|
@ -38,7 +38,7 @@ func (node *LocalVariable) Readonly() bool { return node.Node.Readonly !=
|
|||
func (node *LocalVariable) Type() Type { return node.Ty }
|
||||
func (node *LocalVariable) Default() *interface{} { return nil }
|
||||
func (node *LocalVariable) VarNode() ast.Variable { return node.Node }
|
||||
func (node *LocalVariable) String() string { return string(node.Name()) }
|
||||
func (node *LocalVariable) String() string { return string(node.Token()) }
|
||||
|
||||
// NewLocalVariableSym returns a new LocalVariable symbol associated with the given AST node.
|
||||
func NewLocalVariableSym(node *ast.LocalVariable, ty Type) *LocalVariable {
|
||||
|
|
Loading…
Reference in a new issue