Documentation ¶
Index ¶
- Variables
- func InstallBuiltinTypes()
- func IsQualifiedType(tnm string) bool
- func PrefixType(pfx, nm string) string
- func QualifyType(pkgnm, tnm string) string
- func SplitType(nm string) (pkgnm, tnm string)
- func SymTypeNameForPkg(ty *syms.Type, pkg *syms.Symbol) string
- type GoLang
- func (gl *GoLang) AddImportToExts(fs *pi.FileState, im string, lock bool)
- func (gl *GoLang) AddImportsToExts(fss *pi.FileStates, pfs *pi.FileState, pkg *syms.Symbol)
- func (gl *GoLang) AddPathToExts(fs *pi.FileState, path string)
- func (gl *GoLang) AddPathToSyms(fs *pi.FileState, path string)
- func (gl *GoLang) AddPkgToExts(fs *pi.FileState, pkg *syms.Symbol) bool
- func (gl *GoLang) AddPkgToSyms(fs *pi.FileState, pkg *syms.Symbol) bool
- func (gl *GoLang) AstTypeName(tyast *parse.Ast) string
- func (gl *GoLang) AutoBracket(fs *pi.FileStates, bra rune, pos lex.Pos, curLn []rune) (match, newLine bool)
- func (gl *GoLang) CompleteAstStart(ast *parse.Ast, scope token.Tokens) (start, last *parse.Ast)
- func (gl *GoLang) CompleteBuiltins(fs *pi.FileState, seed string, md *complete.Matches)
- func (gl *GoLang) CompleteEdit(fss *pi.FileStates, text string, cp int, comp complete.Completion, seed string) (ed complete.Edit)
- func (gl *GoLang) CompleteLine(fss *pi.FileStates, str string, pos lex.Pos) (md complete.Matches)
- func (gl *GoLang) CompletePkgSyms(fs *pi.FileState, pkg *syms.Symbol, seed string, md *complete.Matches)
- func (gl *GoLang) CompletePosScope(fs *pi.FileState, pos lex.Pos, fpath string, scopes *syms.SymMap) token.Tokens
- func (gl *GoLang) CompleteTypeName(fs *pi.FileState, pkg *syms.Symbol, seed string, md *complete.Matches)
- func (gl *GoLang) DeleteExternalTypes(sy *syms.Symbol)
- func (gl *GoLang) DeleteUnexported(sy *syms.Symbol, pkgsc string)
- func (gl *GoLang) FindImportPkg(fs *pi.FileState, psyms syms.SymMap, nm string) (*syms.Symbol, bool)
- func (gl *GoLang) FindTypeName(tynm string, fs *pi.FileState, pkg *syms.Symbol) (*syms.Type, *syms.Symbol)
- func (gl *GoLang) FuncParams(fsym *syms.Symbol) []string
- func (gl *GoLang) FuncTypeFromAst(fs *pi.FileState, pkg *syms.Symbol, ast *parse.Ast, fty *syms.Type) *syms.Type
- func (gl *GoLang) HiLine(fss *pi.FileStates, line int, txt []rune) lex.Line
- func (gl *GoLang) ImportPathPkg(im string) (path, base, pkg string)
- func (gl *GoLang) IndentLine(fs *pi.FileStates, src [][]rune, tags []lex.Line, ln int, tabSz int) (pInd, delInd, pLn int, ichr indent.Char)
- func (gl *GoLang) InferEmptySymbolType(sym *syms.Symbol, fs *pi.FileState, pkg *syms.Symbol) bool
- func (gl *GoLang) InferForRangeSymbolType(sy *syms.Symbol, fs *pi.FileState, pkg *syms.Symbol)
- func (gl *GoLang) InferSymbolType(sy *syms.Symbol, fs *pi.FileState, pkg *syms.Symbol, funInternal bool)
- func (gl *GoLang) InitTypeFromAst(fs *pi.FileState, pkg *syms.Symbol, ty *syms.Type)
- func (gl *GoLang) LexLine(fs *pi.FileState, line int, txt []rune) lex.Line
- func (gl *GoLang) Lookup(fss *pi.FileStates, str string, pos lex.Pos) (ld complete.Lookup)
- func (gl *GoLang) LookupString(fs *pi.FileState, pkg *syms.Symbol, scopes syms.SymMap, str string) (ld complete.Lookup)
- func (gl *GoLang) NamesFromAst(fs *pi.FileState, pkg *syms.Symbol, ast *parse.Ast, idx int) []string
- func (gl *GoLang) ParamsFromAst(fs *pi.FileState, pkg *syms.Symbol, pars *parse.Ast, fty *syms.Type, ...)
- func (gl *GoLang) ParseDir(fs *pi.FileState, path string, opts pi.LangDirOpts) *syms.Symbol
- func (gl *GoLang) ParseDirImpl(fs *pi.FileState, path string, opts pi.LangDirOpts) *syms.Symbol
- func (gl *GoLang) ParseFile(fss *pi.FileStates, txt []byte)
- func (gl *GoLang) ParseLine(fs *pi.FileState, line int) *pi.FileState
- func (gl *GoLang) Parser() *pi.Parser
- func (gl *GoLang) PkgSyms(fs *pi.FileState, psyms syms.SymMap, pnm string) (*syms.Symbol, bool)
- func (gl *GoLang) ResolveTypes(fs *pi.FileState, pkg *syms.Symbol, funInternal bool)
- func (gl *GoLang) RvalsFromAst(fs *pi.FileState, pkg *syms.Symbol, rvals *parse.Ast, fty *syms.Type)
- func (gl *GoLang) StructInheritEls(fs *pi.FileState, pkg *syms.Symbol, ty *syms.Type, etynm string)
- func (gl *GoLang) SubTypeFromAst(fs *pi.FileState, pkg *syms.Symbol, ast *parse.Ast, idx int) (*syms.Type, bool)
- func (gl *GoLang) TypeFromAst(fs *pi.FileState, pkg *syms.Symbol, ty *syms.Type, tyast *parse.Ast) (*syms.Type, bool)
- func (gl *GoLang) TypeFromAstComp(fs *pi.FileState, pkg *syms.Symbol, ty *syms.Type, tyast *parse.Ast) (*syms.Type, bool)
- func (gl *GoLang) TypeFromAstExpr(fs *pi.FileState, origPkg, pkg *syms.Symbol, tyast, last *parse.Ast) (*syms.Type, *parse.Ast, bool)
- func (gl *GoLang) TypeFromAstExprStart(fs *pi.FileState, origPkg, pkg *syms.Symbol, tyast *parse.Ast) (*syms.Type, *parse.Ast, bool)
- func (gl *GoLang) TypeFromAstLit(fs *pi.FileState, pkg *syms.Symbol, ty *syms.Type, tyast *parse.Ast) (*syms.Type, bool)
- func (gl *GoLang) TypeFromAstName(fs *pi.FileState, origPkg, pkg *syms.Symbol, tyast, last *parse.Ast, ...) (*syms.Type, *parse.Ast, bool)
- func (gl *GoLang) TypeFromAstPrim(fs *pi.FileState, pkg *syms.Symbol, ty *syms.Type, tyast *parse.Ast) (*syms.Type, bool)
- func (gl *GoLang) TypeFromAstSym(fs *pi.FileState, origPkg, pkg *syms.Symbol, tyast, last *parse.Ast, ...) (*syms.Type, *parse.Ast, bool)
- func (gl *GoLang) TypeFromAstType(fs *pi.FileState, origPkg, pkg *syms.Symbol, tyast, last *parse.Ast, ...) (*syms.Type, *parse.Ast, bool)
- func (gl *GoLang) TypeFromFuncCall(fs *pi.FileState, origPkg, pkg *syms.Symbol, tyast, last *parse.Ast, ...) (*syms.Type, *parse.Ast, bool)
- func (gl *GoLang) TypeMeths(fs *pi.FileState, pkg *syms.Symbol, ty *syms.Type)
- func (gl *GoLang) TypesFromAst(fs *pi.FileState, pkg *syms.Symbol)
- type ParseDirLock
- type ParseDirLocks
Constants ¶
This section is empty.
Variables ¶
var BuiltinFuncs = []string{
"append",
"copy",
"delete",
"len",
"cap",
"make",
"new",
"complex",
"real",
"imag",
"close",
"panic",
"recover",
}
BuiltinFuncs are functions builtin to the Go language
var BuiltinKeywords = []string{
"break",
"case",
"chan",
"const",
"continue",
"default",
"defer",
"else",
"fallthrough",
"for",
"func",
"go",
"goto",
"if",
"import",
"interface",
"map",
"package",
"range",
"return",
"select",
"struct",
"switch",
"type",
"var",
}
BuiltinKeywords are keywords built into Go -- for, range, etc
var BuiltinMisc = []string{
"true",
"false",
}
BuiltinMisc are misc builtin items
var BuiltinPackages = []string{}/* 134 elements not displayed */
BuiltinPackages are the standard library packages
var BuiltinTypeKind = []syms.TypeKindSize{ {"int", syms.Int, int(unsafe.Sizeof(int(0)))}, {"int8", syms.Int8, 1}, {"int16", syms.Int16, 2}, {"int32", syms.Int32, 4}, {"int64", syms.Int64, 8}, {"uint", syms.Uint, int(unsafe.Sizeof(uint(0)))}, {"uint8", syms.Uint8, 1}, {"uint16", syms.Uint16, 2}, {"uint32", syms.Uint32, 4}, {"uint64", syms.Uint64, 8}, {"uintptr", syms.Uintptr, 8}, {"byte", syms.Uint8, 1}, {"rune", syms.Int32, 4}, {"float32", syms.Float32, 4}, {"float64", syms.Float64, 8}, {"complex64", syms.Complex64, 8}, {"complex128", syms.Complex128, 16}, {"bool", syms.Bool, 1}, {"string", syms.String, 0}, {"error", syms.Interface, 0}, {"struct{}", syms.Struct, 0}, {"interface{}", syms.Interface, 0}, }
BuiltinTypeKind are the type names and kinds for builtin Go primitive types (i.e., those with names)
var BuiltinTypes syms.TypeMap
var CompleteTrace = false
var ParseDirExcludes = []string{
"/image/font/gofont/",
"zerrors_",
"unicode/tables.go",
"filecat/mimetype.go",
"/html/entity.go",
"/draw/impl.go",
"/truetype/hint.go",
"/runtime/proc.go",
}
ParseDirExcludes are files to exclude in processing directories because they take a long time and aren't very useful (data files). Any file that contains one of these strings is excluded.
var TheGoLang = GoLang{}
TheGoLang is the instance variable providing support for the Go language
var TraceTypes = false
var TypeErr = "<err>"
TypeErr indicates is the type name we use to indicate that the type could not be inferred
var TypeInProcess = "<in-process>"
TypeInProcess indicates is the type name we use to indicate that the type is currently being processed -- prevents loops
var TypeToKindMap = map[string]syms.Kinds{ "BasicType": syms.Primitive, "TypeNm": syms.Primitive, "QualType": syms.Primitive, "PointerType": syms.Primitive, "MapType": syms.Composite, "SliceType": syms.Composite, "ArrayType": syms.Composite, "StructType": syms.Composite, "InterfaceType": syms.Composite, "FuncType": syms.Composite, "StringDbl": syms.KindsN, "StringTicks": syms.KindsN, "Rune": syms.KindsN, "NumInteger": syms.KindsN, "NumFloat": syms.KindsN, "NumImag": syms.KindsN, }
TypeToKindMap maps Ast type names to syms.Kind basic categories for how we treat them for subsequent processing. Basically: Primitive or Composite
Functions ¶
func InstallBuiltinTypes ¶
func InstallBuiltinTypes()
InstallBuiltinTypes initializes the BuiltinTypes map
func IsQualifiedType ¶ added in v0.9.11
IsQualifiedType returns true if type is qualified by a package prefix is sensitive to [] or map[ prefix so it does NOT report as a qualified type in that case -- it is a compound local type defined in terms of a qualified type.
func PrefixType ¶ added in v0.9.11
PrefixType returns the type name prefixed with given prefix -- keeps any package name as the outer scope.
func QualifyType ¶ added in v0.9.11
QualifyType returns the type name tnm qualified by pkgnm if it is non-empty and only if tnm is not a basic type name
Types ¶
type GoLang ¶
GoLang implements the Lang interface for the Go language
func (*GoLang) AddImportToExts ¶
AddImportToExts adds given import into pi.FileState.ExtSyms list assumed to be called as a separate goroutine
func (*GoLang) AddImportsToExts ¶
AddImportsToExts adds imports from given package into pi.FileState.ExtSyms list imports are coded as NameLibrary symbols with names = import path
func (*GoLang) AddPathToExts ¶
AddPathToExts adds given path into pi.FileState.ExtSyms list assumed to be called as a separate goroutine
func (*GoLang) AddPathToSyms ¶
AddPathToSyms adds given path into pi.FileState.Syms list Is called as a separate goroutine in ParseFile with WaitGp
func (*GoLang) AddPkgToExts ¶
AddPkgToExts adds given package symbol, with children from package to pi.FileState.ExtSyms map -- merges with anything already there does NOT add imports -- that is an optional second step. Returns true if there was an existing entry for this package.
func (*GoLang) AddPkgToSyms ¶
AddPkgToSyms adds given package symbol, with children from package to pi.FileState.Syms map -- merges with anything already there does NOT add imports -- that is an optional second step. Returns true if there was an existing entry for this package.
func (*GoLang) AstTypeName ¶ added in v0.9.11
AstTypeName returns the effective type name from ast node dropping the "Lit" for example.
func (*GoLang) AutoBracket ¶ added in v0.9.15
func (gl *GoLang) AutoBracket(fs *pi.FileStates, bra rune, pos lex.Pos, curLn []rune) (match, newLine bool)
AutoBracket returns what to do when a user types a starting bracket character (bracket, brace, paren) while typing. pos = position where bra will be inserted, and curLn is the current line match = insert the matching ket, and newLine = insert a new line.
func (*GoLang) CompleteAstStart ¶ added in v0.9.11
CompleteAstStart finds the best starting point in the given current-line Ast to start completion process, which walks back down from that starting point
func (*GoLang) CompleteBuiltins ¶ added in v0.9.11
func (*GoLang) CompleteEdit ¶
func (gl *GoLang) CompleteEdit(fss *pi.FileStates, text string, cp int, comp complete.Completion, seed string) (ed complete.Edit)
CompleteEdit returns the completion edit data for integrating the selected completion into the source
func (*GoLang) CompleteLine ¶
CompleteLine is the main api called by completion code in giv/complete.go
func (*GoLang) CompletePkgSyms ¶ added in v0.9.11
func (gl *GoLang) CompletePkgSyms(fs *pi.FileState, pkg *syms.Symbol, seed string, md *complete.Matches)
CompletePkgSyms matches all package symbols using seed
func (*GoLang) CompletePosScope ¶ added in v0.9.11
func (gl *GoLang) CompletePosScope(fs *pi.FileState, pos lex.Pos, fpath string, scopes *syms.SymMap) token.Tokens
CompletePosScope returns the scope for given position in given filename, and fills in the scoping symbol(s) in scMap
func (*GoLang) CompleteTypeName ¶ added in v0.9.11
func (gl *GoLang) CompleteTypeName(fs *pi.FileState, pkg *syms.Symbol, seed string, md *complete.Matches)
CompleteTypeName matches builtin and package type names to seed
func (*GoLang) DeleteExternalTypes ¶ added in v0.9.11
DeleteExternalTypes deletes types from outside current package scope. These can be created during ResolveTypes but should be deleted before saving symbol type.
func (*GoLang) DeleteUnexported ¶
DeleteUnexported deletes lower-case unexported items from map, and children of symbols on map
func (*GoLang) FindImportPkg ¶ added in v0.9.11
func (gl *GoLang) FindImportPkg(fs *pi.FileState, psyms syms.SymMap, nm string) (*syms.Symbol, bool)
FindImportPkg attempts to find an import package based on symbols in an existing package. For indirect loading of packages from other packages that we don't direct import.
func (*GoLang) FindTypeName ¶
func (gl *GoLang) FindTypeName(tynm string, fs *pi.FileState, pkg *syms.Symbol) (*syms.Type, *syms.Symbol)
FindTypeName finds given type name in pkg and in broader context returns new package symbol if type name is in a different package else returns pkg arg.
func (*GoLang) FuncParams ¶ added in v0.9.11
FuncParams returns the parameters of given function / method symbol, in proper order, name type for each param space separated in string
func (*GoLang) FuncTypeFromAst ¶
func (gl *GoLang) FuncTypeFromAst(fs *pi.FileState, pkg *syms.Symbol, ast *parse.Ast, fty *syms.Type) *syms.Type
FuncTypeFromAst initializes a function type from ast -- type can either be anon or a named type -- if anon then the name is the full type signature without param names
func (*GoLang) ImportPathPkg ¶ added in v0.9.11
ImportPathPkg returns the package (last dir) and base of import path from import path string -- removes any quotes around path first.
func (*GoLang) IndentLine ¶ added in v0.9.15
func (gl *GoLang) IndentLine(fs *pi.FileStates, src [][]rune, tags []lex.Line, ln int, tabSz int) (pInd, delInd, pLn int, ichr indent.Char)
IndentLine returns the indentation level for given line based on previous line's indentation level, and any delta change based on e.g., brackets starting or ending the previous or current line, or other language-specific keywords. See lex.BracketIndentLine for example. Indent level is in increments of tabSz for spaces, and tabs for tabs. Operates on rune source with markup lex tags per line.
func (*GoLang) InferEmptySymbolType ¶ added in v0.9.11
InferEmptySymbolType ensures that any empty symbol type is resolved during processing of other type information -- returns true if was able to resolve
func (*GoLang) InferForRangeSymbolType ¶ added in v0.9.15
InferForRangeSymbolType infers the type of a ForRange expr gets the container type properly
func (*GoLang) InferSymbolType ¶
func (gl *GoLang) InferSymbolType(sy *syms.Symbol, fs *pi.FileState, pkg *syms.Symbol, funInternal bool)
InferSymbolType infers the symbol types for given symbol and all of its children funInternal determines whether to include function-internal symbols (e.g., variables within function scope -- only for local files).
func (*GoLang) InitTypeFromAst ¶ added in v0.9.11
InitTypeFromAst initializes given type from ast
func (*GoLang) Lookup ¶ added in v0.9.11
Lookup is the main api called by completion code in giv/complete.go to lookup item
func (*GoLang) LookupString ¶ added in v0.9.11
func (gl *GoLang) LookupString(fs *pi.FileState, pkg *syms.Symbol, scopes syms.SymMap, str string) (ld complete.Lookup)
LookupString attempts to lookup a string, which could be a type name, (with package qualifier), could be partial, etc
func (*GoLang) NamesFromAst ¶
func (gl *GoLang) NamesFromAst(fs *pi.FileState, pkg *syms.Symbol, ast *parse.Ast, idx int) []string
NamesFromAst returns a slice of name(s) from namelist nodes
func (*GoLang) ParamsFromAst ¶
func (gl *GoLang) ParamsFromAst(fs *pi.FileState, pkg *syms.Symbol, pars *parse.Ast, fty *syms.Type, name string)
ParamsFromAst sets params as Els for given function type (also for return types)
func (*GoLang) ParseDirImpl ¶ added in v0.9.11
ParseDirImpl does the actual work of parsing a directory. Path is assumed to be a package import path or a local file name
func (*GoLang) ParseFile ¶
func (gl *GoLang) ParseFile(fss *pi.FileStates, txt []byte)
ParseFile is the main point of entry for external calls into the parser
func (*GoLang) PkgSyms ¶ added in v0.9.11
PkgSyms attempts to find package symbols for given package name. Is also passed any current package symbol context in psyms which might be different from default filestate context.
func (*GoLang) ResolveTypes ¶
ResolveTypes initializes all user-defined types from Ast data and then resolves types of symbols. The pkg must be a single package symbol i.e., the children there are all the elements of the package and the types are all the global types within the package. funInternal determines whether to include function-internal symbols (e.g., variables within function scope -- only for local files).
func (*GoLang) RvalsFromAst ¶ added in v0.9.11
func (gl *GoLang) RvalsFromAst(fs *pi.FileState, pkg *syms.Symbol, rvals *parse.Ast, fty *syms.Type)
RvalsFromAst sets return value(s) as Els for given function type
func (*GoLang) StructInheritEls ¶ added in v0.9.11
StructInheritEls inherits struct fields and meths from given embedded type. Ensures that copied values are properly qualified if from another package.
func (*GoLang) SubTypeFromAst ¶
func (gl *GoLang) SubTypeFromAst(fs *pi.FileState, pkg *syms.Symbol, ast *parse.Ast, idx int) (*syms.Type, bool)
SubTypeFromAst returns a subtype from child ast at given index, nil if failed
func (*GoLang) TypeFromAst ¶
func (gl *GoLang) TypeFromAst(fs *pi.FileState, pkg *syms.Symbol, ty *syms.Type, tyast *parse.Ast) (*syms.Type, bool)
TypeFromAst returns type from Ast parse -- returns true if successful. This is used both for initialization of global types via TypesFromAst and also for online type processing in the course of tracking down other types while crawling the Ast. In the former case, ty is non-nil and the goal is to fill out the type information -- the ty will definitely have a name already. In the latter case, the ty will be nil, but the tyast node may have a Src name that will first be looked up to determine if a previously-processed type is already available. The tyast.Name is the parser categorization of the type (BasicType, StructType, etc).
func (*GoLang) TypeFromAstComp ¶ added in v0.9.11
func (gl *GoLang) TypeFromAstComp(fs *pi.FileState, pkg *syms.Symbol, ty *syms.Type, tyast *parse.Ast) (*syms.Type, bool)
TypeFromAstComp handles composite type processing
func (*GoLang) TypeFromAstExpr ¶ added in v0.9.11
func (gl *GoLang) TypeFromAstExpr(fs *pi.FileState, origPkg, pkg *syms.Symbol, tyast, last *parse.Ast) (*syms.Type, *parse.Ast, bool)
TypeFromAstExpr walks the ast expression to find the type. It returns the type, any Ast node that remained unprocessed at the end, and bool if found.
func (*GoLang) TypeFromAstExprStart ¶ added in v0.9.15
func (gl *GoLang) TypeFromAstExprStart(fs *pi.FileState, origPkg, pkg *syms.Symbol, tyast *parse.Ast) (*syms.Type, *parse.Ast, bool)
TypeFromAstExprStart starts walking the ast expression to find the type. This computes the last ast point as the stopping point for processing and then calls TypeFromAstExpr. It returns the type, any Ast node that remained unprocessed at the end, and bool if found.
func (*GoLang) TypeFromAstLit ¶ added in v0.9.11
func (gl *GoLang) TypeFromAstLit(fs *pi.FileState, pkg *syms.Symbol, ty *syms.Type, tyast *parse.Ast) (*syms.Type, bool)
TypeFromAstLit gets type from literals
func (*GoLang) TypeFromAstName ¶ added in v0.9.11
func (gl *GoLang) TypeFromAstName(fs *pi.FileState, origPkg, pkg *syms.Symbol, tyast, last *parse.Ast, conts syms.SymMap) (*syms.Type, *parse.Ast, bool)
TypeFromAstName gets type from a Name in a given context (conts)
func (*GoLang) TypeFromAstPrim ¶ added in v0.9.11
func (gl *GoLang) TypeFromAstPrim(fs *pi.FileState, pkg *syms.Symbol, ty *syms.Type, tyast *parse.Ast) (*syms.Type, bool)
TypeFromAstPrim handles primitive (non composite) type processing
func (*GoLang) TypeFromAstSym ¶ added in v0.9.11
func (gl *GoLang) TypeFromAstSym(fs *pi.FileState, origPkg, pkg *syms.Symbol, tyast, last *parse.Ast, sym *syms.Symbol) (*syms.Type, *parse.Ast, bool)
TypeFromAstSym attempts to get the type from given symbol as part of expression. It returns the type, any Ast node that remained unprocessed at the end, and bool if found.
func (*GoLang) TypeFromAstType ¶ added in v0.9.11
func (gl *GoLang) TypeFromAstType(fs *pi.FileState, origPkg, pkg *syms.Symbol, tyast, last *parse.Ast, tnm string) (*syms.Type, *parse.Ast, bool)
TypeFromAstType walks the ast expression to find the type, starting from current type name. It returns the type, any Ast node that remained unprocessed at the end, and bool if found.
func (*GoLang) TypeFromFuncCall ¶ added in v0.9.11
func (gl *GoLang) TypeFromFuncCall(fs *pi.FileState, origPkg, pkg *syms.Symbol, tyast, last *parse.Ast, ftyp *syms.Type) (*syms.Type, *parse.Ast, bool)
TypeFromAstFuncCall gets return type of function call as return value, and returns the sibling node to continue parsing in, skipping over everything in the function call
type ParseDirLock ¶ added in v0.9.11
type ParseDirLock struct { // logical import path Path string `desc:"logical import path"` // mutex protecting processing of this path Mu sync.Mutex `json:"-" xml:"-" desc:"mutex protecting processing of this path"` }
ParseDirLock provides a lock protecting parsing of a package directory
type ParseDirLocks ¶ added in v0.9.11
type ParseDirLocks struct { // map of paths with processing status Dirs map[string]*ParseDirLock `desc:"map of paths with processing status"` // mutex protecting access to Dirs Mu sync.Mutex `json:"-" xml:"-" desc:"mutex protecting access to Dirs"` }
ParseDirLocks manages locking for parsing package directories
var TheParseDirs ParseDirLocks
TheParseDirs is the parse dirs locking manager
func (*ParseDirLocks) ParseDir ¶ added in v0.9.11
func (pd *ParseDirLocks) ParseDir(gl *GoLang, fs *pi.FileState, path string, opts pi.LangDirOpts) *syms.Symbol
ParseDir is how you call ParseDir on a given path in a secure way that is managed for multiple accesses. If dir is currently being parsed, then the mutex is locked and caller will wait until that is done -- at which point the next one should be able to load parsed symbols instead of parsing fresh. Once the symbols are returned, then the local FileState SymsMu lock must be used when integrating any external symbols back into another filestate. As long as all the symbol resolution etc is all happening outside of the external syms linking, then it does not need to be protected.