Documentation ¶
Index ¶
- func EnsureURL(uri lsp.DocumentURI, pathType string) (url lsp.DocumentURI, err error)
- 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 IsURL(uri lsp.DocumentURI) bool
- 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 TrimQuotes(str string) string
- type Analyzer
- 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) BuildDefsFromURI(ctx context.Context, uri lsp.DocumentURI) (map[string]*BuildDef, error)
- func (a *Analyzer) BuildFileURIFromPackage(packageDir string) lsp.DocumentURI
- func (a *Analyzer) BuildLabelFromString(ctx context.Context, currentURI lsp.DocumentURI, labelStr string) (*BuildLabel, error)
- func (a *Analyzer) IsBuildFile(uri lsp.DocumentURI) bool
- func (a *Analyzer) StatementFromPos(uri lsp.DocumentURI, position lsp.Position) (*Statement, error)
- type Argument
- type BuildDef
- type BuildLabel
- type Identifier
- type LsHandler
- type RuleDef
- type Statement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 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 IsURL ¶
func IsURL(uri lsp.DocumentURI) bool
IsURL checks if the documentUri passed has 'file://' prefix
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 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) 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) 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) BuildLabelFromString ¶
func (a *Analyzer) BuildLabelFromString(ctx context.Context, currentURI lsp.DocumentURI, labelStr string) (*BuildLabel, error)
BuildLabelFromString returns a BuildLabel object,
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) StatementFromPos ¶
StatementFromPos returns a Statement struct with either an Identifier or asp.Expression
type Argument ¶
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 Visibility []string // The content of the build definition Content 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 content of the build definition Definition string }
BuildLabel is a wrapper around core.BuildLabel Including the path of the buildFile
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