Documentation ¶
Index ¶
- Variables
- func EnsureURL(uri lsp.DocumentURI, pathType string) (url lsp.DocumentURI, err error)
- func ExtractBuildLabel(str string) string
- func ExtractLiteral(str string) string
- func ExtractStrTail(str string) string
- func GetLineContent(ctx context.Context, uri lsp.DocumentURI, position lsp.Position) ([]string, error)
- func GetPathFromURL(uri lsp.DocumentURI, pathType string) (documentPath string, err error)
- func GetValType(valExpr *asp.ValueExpression) string
- func IsURL(uri lsp.DocumentURI) bool
- func JoinLines(text []string, hasEnds bool) string
- func LocalFilesFromURI(uri lsp.DocumentURI) ([]string, error)
- func LooksLikeAttribute(str string) bool
- func LooksLikeCONFIGAttr(str string) bool
- func LooksLikeDictAttr(str string) bool
- func LooksLikeString(str string) bool
- func LooksLikeStringAttr(str string) bool
- func NewHandler() jsonrpc2.Handler
- func PackageLabelFromURI(uri lsp.DocumentURI) (string, error)
- func ReadFile(ctx context.Context, uri lsp.DocumentURI) ([]string, error)
- func SplitLines(content string, keepEnds bool) []string
- func StringInSlice(strSlice []string, needle string) bool
- func TrimQuotes(str string) string
- type Analyzer
- func (a *Analyzer) AspStatementFromContent(content string) []*asp.Statement
- func (a *Analyzer) AspStatementFromFile(uri lsp.DocumentURI) ([]*asp.Statement, error)
- func (a *Analyzer) BuildDefFromLabel(ctx context.Context, label *core.BuildLabel, path string) (*BuildDef, error)
- func (a *Analyzer) BuildDefsFromPos(ctx context.Context, uri lsp.DocumentURI, pos lsp.Position) (*BuildDef, error)
- func (a *Analyzer) BuildDefsFromStatements(ctx context.Context, labelURI lsp.DocumentURI, stmts []*asp.Statement) (map[string]*BuildDef, error)
- func (a *Analyzer) BuildDefsFromURI(ctx context.Context, uri lsp.DocumentURI) (map[string]*BuildDef, error)
- func (a *Analyzer) BuildFileURIFromPackage(packageDir string) lsp.DocumentURI
- func (a *Analyzer) BuildLabelFromAST(ctx context.Context, val interface{}, uri lsp.DocumentURI, pos lsp.Position) *BuildLabel
- func (a *Analyzer) BuildLabelFromContentAndPos(ctx context.Context, content string, uri lsp.DocumentURI, pos lsp.Position) *BuildLabel
- func (a *Analyzer) BuildLabelFromCoreBuildLabel(ctx context.Context, label core.BuildLabel) (buildLabel *BuildLabel, err error)
- func (a *Analyzer) BuildLabelFromString(ctx context.Context, currentURI lsp.DocumentURI, labelStr string) (*BuildLabel, error)
- func (a *Analyzer) CallFromAST(val interface{}, pos lsp.Position) *Call
- func (a *Analyzer) CallFromContentAndPos(content string, pos lsp.Position) *Call
- func (a *Analyzer) GetBuildRuleByName(name string, subincludes map[string]*RuleDef) *RuleDef
- func (a *Analyzer) GetConfigNames() []string
- func (a *Analyzer) GetSubinclude(ctx context.Context, stmts []*asp.Statement, uri lsp.DocumentURI) map[string]*RuleDef
- func (a *Analyzer) IdentsFromContent(content string, pos *lsp.Position) chan *Identifier
- func (a *Analyzer) IdentsFromStatement(stmts []*asp.Statement, pos *lsp.Position) chan *Identifier
- func (a *Analyzer) IsBuildFile(uri lsp.DocumentURI) bool
- func (a *Analyzer) RevDepsFromBuildDef(def *BuildDef, uri lsp.DocumentURI) (core.BuildLabels, error)
- func (a *Analyzer) RevDepsFromCoreBuildLabel(label core.BuildLabel, uri lsp.DocumentURI) (core.BuildLabels, error)
- func (a *Analyzer) StatementFromPos(stmts []*asp.Statement, position lsp.Position) *Statement
- func (a *Analyzer) VariableFromIdent(ident *Identifier) *Variable
- func (a *Analyzer) VariablesFromContent(content string, pos *lsp.Position) map[string]Variable
- func (a *Analyzer) VariablesFromStatements(stmts []*asp.Statement, pos *lsp.Position) map[string]Variable
- func (a *Analyzer) VariablesFromURI(uri lsp.DocumentURI, pos *lsp.Position) (map[string]Variable, error)
- type Argument
- type BuildDef
- type BuildLabel
- type Call
- type Identifier
- type LsHandler
- type RuleDef
- type Statement
- type Variable
Constants ¶
This section is empty.
Variables ¶
var BuiltInsWithIrregularArgs = []string{"format", "zip", "package", "join_path"}
BuiltInsWithIrregularArgs is the list of builtin functions which arguments not matching the declared arguments Used in diagnostics.go: diagnoseFuncCall
var LocalSrcsArgs = []string{"srcs", "src", "main", "data", "hdrs", "private_hdrs"}
LocalSrcsArgs is the list of arguments within build rules that may yield to local source files
Functions ¶
func EnsureURL ¶
func EnsureURL(uri lsp.DocumentURI, pathType string) (url lsp.DocumentURI, err error)
EnsureURL ensures that the documentURI is a valid path in the filesystem and a valid 'file://' URI
func ExtractBuildLabel ¶
ExtractBuildLabel extracts build label from a string. Beginning of the buildlabel must have a quote end of the string must not be anything other than quotes or characters
func ExtractLiteral ¶
ExtractLiteral extra a literal expression such as function name, variable name from a content line
func ExtractStrTail ¶
ExtractStrTail extracts the string value from a string, **the string value must be at the end of the string passed in**
func GetLineContent ¶
func GetLineContent(ctx context.Context, uri lsp.DocumentURI, position lsp.Position) ([]string, error)
GetLineContent returns a []string contraining a single string value respective to position.Line
func GetPathFromURL ¶
func GetPathFromURL(uri lsp.DocumentURI, pathType string) (documentPath string, err error)
GetPathFromURL returns the absolute path of the file which documenURI relates to it also checks if the file path is valid
func GetValType ¶
func GetValType(valExpr *asp.ValueExpression) string
GetValType returns a string representation of the type a asp.ValueExpression struct
func IsURL ¶
func IsURL(uri lsp.DocumentURI) bool
IsURL checks if the documentUri passed has 'file://' prefix
func JoinLines ¶
JoinLines concatenate a slice of string, removes the trailing "\n" if hadEnds is true
func LocalFilesFromURI ¶
func LocalFilesFromURI(uri lsp.DocumentURI) ([]string, error)
LocalFilesFromURI returns a slices of file path of the files in current directory where the document is
func LooksLikeAttribute ¶
LooksLikeAttribute returns true if the input string looks like an attribute: "hello".
func LooksLikeCONFIGAttr ¶
LooksLikeCONFIGAttr returns true if the input string looks like an attribute of CONFIG object: CONFIG.PLZ_VERSION
func LooksLikeDictAttr ¶
LooksLikeDictAttr returns true if the input string looks like an attribute of dict e.g. {"foo": 1, "bar": "baz"}.keys()
func LooksLikeString ¶
LooksLikeString returns true if the input string looks like a string
func LooksLikeStringAttr ¶
LooksLikeStringAttr returns true if the input string looks like an attribute of string: "hello".format()
func NewHandler ¶
NewHandler creates a BUILD file language server handler
func PackageLabelFromURI ¶
func PackageLabelFromURI(uri lsp.DocumentURI) (string, error)
PackageLabelFromURI returns a build label of a package
func SplitLines ¶
SplitLines splits a content with \n characters, and returns a slice of string if keepEnds is true, all lines will keep it's original splited character
func StringInSlice ¶
StringInSlice checks if an item is in a string slice
func TrimQuotes ¶
TrimQuotes is used to trim the qouted string This is usually used to trim the quoted string in BUILD files, such as a BuildLabel this will also work for string with any extra characters outside of qoutes like so: "//src/core",
Types ¶
type Analyzer ¶
type Analyzer struct { State *core.BuildState BuiltIns map[string]*RuleDef Attributes map[string][]*RuleDef // contains filtered or unexported fields }
Analyzer is a wrapper around asp.parser This is being loaded into a handler on initialization
func (*Analyzer) AspStatementFromContent ¶
AspStatementFromContent returns a slice of asp.Statement given content string(usually workSpaceStore.doc.TextInEdit)
func (*Analyzer) AspStatementFromFile ¶
AspStatementFromFile gets all the Asp.Statement from a given BUILD file *reads complete files only*
func (*Analyzer) BuildDefFromLabel ¶
func (a *Analyzer) BuildDefFromLabel(ctx context.Context, label *core.BuildLabel, path string) (*BuildDef, error)
BuildDefFromLabel returns a BuildDef struct given an *core.BuildLabel and the path of the label
func (*Analyzer) BuildDefsFromPos ¶
func (a *Analyzer) BuildDefsFromPos(ctx context.Context, uri lsp.DocumentURI, pos lsp.Position) (*BuildDef, error)
BuildDefsFromPos returns the BuildDef object from the position given if it exists
func (*Analyzer) BuildDefsFromStatements ¶
func (a *Analyzer) BuildDefsFromStatements(ctx context.Context, labelURI lsp.DocumentURI, stmts []*asp.Statement) (map[string]*BuildDef, error)
BuildDefsFromStatements takes in the uri of the label, stmts of the build file returns a map of buildDefname : *BuildDef
func (*Analyzer) BuildDefsFromURI ¶
func (a *Analyzer) BuildDefsFromURI(ctx context.Context, uri lsp.DocumentURI) (map[string]*BuildDef, error)
BuildDefsFromURI returns a map of buildDefname : *BuildDef
func (*Analyzer) BuildFileURIFromPackage ¶
func (a *Analyzer) BuildFileURIFromPackage(packageDir string) lsp.DocumentURI
BuildFileURIFromPackage takes a relative(to the reporoot) package directory, and returns a build file path
func (*Analyzer) BuildLabelFromAST ¶
func (a *Analyzer) BuildLabelFromAST(ctx context.Context, val interface{}, uri lsp.DocumentURI, pos lsp.Position) *BuildLabel
BuildLabelFromAST returns the BuildLabel object from the AST if it's within the range of the position
func (*Analyzer) BuildLabelFromContentAndPos ¶
func (a *Analyzer) BuildLabelFromContentAndPos(ctx context.Context, content string, uri lsp.DocumentURI, pos lsp.Position) *BuildLabel
BuildLabelFromContentAndPos returns the BuildLabel object from the AST if it's within the range of the position Given the content
func (*Analyzer) BuildLabelFromCoreBuildLabel ¶
func (a *Analyzer) BuildLabelFromCoreBuildLabel(ctx context.Context, label core.BuildLabel) (buildLabel *BuildLabel, err error)
BuildLabelFromCoreBuildLabel returns a BuildLabel object given a core.BuildLabel
func (*Analyzer) BuildLabelFromString ¶
func (a *Analyzer) BuildLabelFromString(ctx context.Context, currentURI lsp.DocumentURI, labelStr string) (*BuildLabel, error)
BuildLabelFromString returns a BuildLabel object given a label string
func (*Analyzer) CallFromAST ¶
CallFromAST returns the Call object from the AST if it's within the range of the position
func (*Analyzer) CallFromContentAndPos ¶
CallFromContentAndPos returns a Identifier object represents function call, Only returns the not nil object when the Identifier is within the range specified by the position
func (*Analyzer) GetBuildRuleByName ¶
GetBuildRuleByName takes the name and subincludes ruleDefs, and return the appropriate ruleDef
func (*Analyzer) GetConfigNames ¶
GetConfigNames returns a slice of strings config variable names
func (*Analyzer) GetSubinclude ¶
func (a *Analyzer) GetSubinclude(ctx context.Context, stmts []*asp.Statement, uri lsp.DocumentURI) map[string]*RuleDef
GetSubinclude returns a Subinclude object based on the statement and uri passed in.
func (*Analyzer) IdentsFromContent ¶
func (a *Analyzer) IdentsFromContent(content string, pos *lsp.Position) chan *Identifier
IdentsFromContent returns a channel of Identifier object
func (*Analyzer) IdentsFromStatement ¶
IdentsFromStatement returns a channel of Identifier object given the slice of statement and position
func (*Analyzer) IsBuildFile ¶
func (a *Analyzer) IsBuildFile(uri lsp.DocumentURI) bool
IsBuildFile takes a uri path and check if it's a valid build file
func (*Analyzer) RevDepsFromBuildDef ¶
func (a *Analyzer) RevDepsFromBuildDef(def *BuildDef, uri lsp.DocumentURI) (core.BuildLabels, error)
RevDepsFromBuildDef returns a a slice of core.BuildLabel object represent the reverse dependency of the BuildDef object passed in
func (*Analyzer) RevDepsFromCoreBuildLabel ¶
func (a *Analyzer) RevDepsFromCoreBuildLabel(label core.BuildLabel, uri lsp.DocumentURI) (core.BuildLabels, error)
RevDepsFromCoreBuildLabel returns a slice of core.BuildLabel object represent the reverse dependency of the core.BuildLabel object passed in
func (*Analyzer) StatementFromPos ¶
StatementFromPos returns a Statement struct with either an Identifier or asp.Expression
func (*Analyzer) VariableFromIdent ¶
func (a *Analyzer) VariableFromIdent(ident *Identifier) *Variable
VariableFromIdent returns Variable object passing in an single Identifier
func (*Analyzer) VariablesFromContent ¶
VariablesFromContent returns a map of variable name to Variable objects given string content
func (*Analyzer) VariablesFromStatements ¶
func (a *Analyzer) VariablesFromStatements(stmts []*asp.Statement, pos *lsp.Position) map[string]Variable
VariablesFromStatements returns a map of variable name to Variable objects given an slice of asp.Statements
func (*Analyzer) VariablesFromURI ¶
func (a *Analyzer) VariablesFromURI(uri lsp.DocumentURI, pos *lsp.Position) (map[string]Variable, error)
VariablesFromURI returns a map of variable name to Variable objects given an URI
type Argument ¶
type Argument struct { *asp.Argument // the definition string when hover over the argument, e.g. src type:list, required:false Definition string // string representation of the original argument definition Repr string Required bool }
Argument is a wrapper around asp.Argument, this is used to store the argument information for specific rules, and it also tells you if the argument is required
type BuildDef ¶
type BuildDef struct { *Identifier BuildDefName string // The content of the build definition Content string Visibility []string }
BuildDef is the definition for a build target. often a function call using a specific build rule
type BuildLabel ¶
type BuildLabel struct { *core.BuildLabel // Path of the build file Path string // IdentStatement for the build definition, // usually the call to the specific buildrule, such as "go_library()" BuildDef *BuildDef // The definition of the buildlabel, e.g: BUILD Label: //src/core Definition string // Reverse Dependency of this build label RevDeps core.BuildLabels }
BuildLabel is a wrapper around core.BuildLabel Including the path of the buildFile
type Call ¶
type Call struct { Arguments []asp.CallArgument Name string }
Call represent a function call
type Identifier ¶
Identifier is a wrapper around asp.Identifier Including the starting line and the ending line number
type LsHandler ¶
type LsHandler struct { IsServerDown bool // contains filtered or unexported fields }
LsHandler is the main handler struct of the language server handler
type RuleDef ¶
type RuleDef struct { *asp.FuncDef Header string ArgMap map[string]*Argument // This applies when the FuncDef is a attribute of an object Object string }
RuleDef is a wrapper around asp.FuncDef, it also includes a Header(function definition) And Argument map stores the name and the information of the arguments this rule has
type Statement ¶
type Statement struct { Ident *Identifier Expression *asp.Expression }
Statement is a simplified version of asp.Statement Here we only care about Idents and Expressions