Documentation ¶
Overview ¶
Example (NewScalaScope_String) ¶
package main import ( "fmt" "log" sppb "github.com/stackb/scala-gazelle/build/stack/gazelle/scala/parse" "github.com/stackb/scala-gazelle/pkg/resolver" ) func main() { scope := resolver.NewTrieScope() for _, symbol := range []*resolver.Symbol{ { Type: sppb.ImportType_PACKAGE, Name: "java.lang", Provider: "java", }, { Type: sppb.ImportType_CLASS, Name: "java.lang.String", Provider: "java", }, { Type: sppb.ImportType_PACKAGE, Name: "scala", Provider: "java", }, { Type: sppb.ImportType_CLASS, Name: "scala.Any", Provider: "java", }, } { if err := scope.PutSymbol(symbol); err != nil { log.Fatal(err) } } scala, _ := resolver.NewScalaScope(scope) fmt.Println(scala) }
Output: --- layer 0 --- java <nil> └ lang (java.lang<PACKAGE> //:<java>) └ String (java.lang.String<CLASS> //:<java>) scala (scala<PACKAGE> //:<java>) └ Any (scala.Any<CLASS> //:<java>) --- layer 1 --- Any (scala.Any<CLASS> //:<java>) --- layer 2 --- String (java.lang.String<CLASS> //:<java>) --- layer 3 --- java <nil> └ lang (java.lang<PACKAGE> //:<java>) └ String (java.lang.String<CLASS> //:<java>) scala (scala<PACKAGE> //:<java>) └ Any (scala.Any<CLASS> //:<java>)
Index ¶
- Variables
- func IsSelfImport(symbol *Symbol, repo, pkg, name string) bool
- func IsWildcardImport(imp string) (string, bool)
- func PutImportIfNotSelf(imports ImportMap, from label.Label) func(*Import)
- func SymbolConfictMessage(symbol *Symbol, imp *Import, from label.Label) string
- type ChainScope
- type ChainSymbolResolver
- type ConflictResolver
- type ConflictResolverRegistry
- type CrossSymbolResolver
- type DepsCleaner
- type DepsCleanerRegistry
- type Import
- func NewDirectImport(imp string, source *sppb.File) *Import
- func NewErrorImport(imp string, source *sppb.File, src string, err error) *Import
- func NewExtendsImport(imp string, source *sppb.File, src string, symbol *Symbol) *Import
- func NewImplicitImport(imp, src string) *Import
- func NewMainClassImport(imp string) *Import
- func NewResolvedNameImport(imp string, source *sppb.File, name string, symbol *Symbol) *Import
- func NewSemanticImport(imp string, source *sppb.File) *Import
- func NewTransitiveImport(imp string, name string, symbol *Symbol) *Import
- type ImportLabel
- type ImportMap
- type KnownRuleRegistry
- type LabelNameRewriteSpec
- type MemoSymbolResolver
- type OrderedImportMap
- func (imports *OrderedImportMap) Annotate(comments *build.Comments, accept func(imp *Import) bool)
- func (imports *OrderedImportMap) Deps(from label.Label) map[label.Label]*ImportLabel
- func (imports *OrderedImportMap) Get(key string) (*Import, bool)
- func (imports *OrderedImportMap) Keys() []string
- func (imports *OrderedImportMap) Put(imp *Import)
- func (imports *OrderedImportMap) Values() []*Import
- type OverrideSymbolResolver
- type PredefinedLabelConflictResolver
- func (s *PredefinedLabelConflictResolver) CheckFlags(fs *flag.FlagSet, c *config.Config) error
- func (s *PredefinedLabelConflictResolver) Name() string
- func (s *PredefinedLabelConflictResolver) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config)
- func (s *PredefinedLabelConflictResolver) ResolveConflict(universe Universe, r *rule.Rule, imports ImportMap, imp *Import, ...) (*Symbol, bool)
- type ScalaGrpcZioConflictResolver
- func (s *ScalaGrpcZioConflictResolver) CheckFlags(fs *flag.FlagSet, c *config.Config) error
- func (s *ScalaGrpcZioConflictResolver) Name() string
- func (s *ScalaGrpcZioConflictResolver) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config)
- func (s *ScalaGrpcZioConflictResolver) ResolveConflict(universe Universe, r *rule.Rule, imports ImportMap, imp *Import, ...) (*Symbol, bool)
- type ScalaProtoPackageConflictResolver
- func (s *ScalaProtoPackageConflictResolver) CheckFlags(fs *flag.FlagSet, c *config.Config) error
- func (s *ScalaProtoPackageConflictResolver) Name() string
- func (s *ScalaProtoPackageConflictResolver) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config)
- func (s *ScalaProtoPackageConflictResolver) ResolveConflict(universe Universe, r *rule.Rule, imports ImportMap, imp *Import, ...) (*Symbol, bool)
- type ScalaScope
- type ScalaSymbolResolver
- type Scope
- type ScopeSymbolResolver
- type Symbol
- type SymbolMap
- type SymbolProvider
- type SymbolProviderRegistry
- type SymbolResolver
- type TrieScope
- func (r *TrieScope) GetScope(name string) (Scope, bool)
- func (r *TrieScope) GetSymbol(imp string) (*Symbol, bool)
- func (r *TrieScope) GetSymbols(prefix string) (symbols []*Symbol)
- func (r *TrieScope) Lines() string
- func (r *TrieScope) Put(name string, symbol *Symbol) error
- func (r *TrieScope) PutSymbol(symbol *Symbol) error
- func (r *TrieScope) String() string
- func (r *TrieScope) Symbols() (symbols []*Symbol)
- type TrimPrefixScope
- type Universe
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSymbolNotFound = fmt.Errorf("symbol not found")
ErrSymbolNotFound is an error value assigned to an Import when the name could not be resolved.
Functions ¶
func IsSelfImport ¶
func IsWildcardImport ¶
func PutImportIfNotSelf ¶
Types ¶
type ChainScope ¶
type ChainScope struct {
// contains filtered or unexported fields
}
ChainScope implements Scope over a chain of registries.
func NewChainScope ¶
func NewChainScope(chain ...Scope) *ChainScope
func (*ChainScope) GetScope ¶
func (r *ChainScope) GetScope(imp string) (Scope, bool)
GetScope implements part of the resolver.Scope interface.
func (*ChainScope) GetSymbol ¶
func (r *ChainScope) GetSymbol(imp string) (*Symbol, bool)
GetSymbol implements part of the Scope interface
func (*ChainScope) GetSymbols ¶
func (r *ChainScope) GetSymbols(prefix string) []*Symbol
GetSymbols implements part of the Scope interface
func (*ChainScope) PutSymbol ¶
func (r *ChainScope) PutSymbol(known *Symbol) error
PutSymbol is not supported and will panic.
func (*ChainScope) String ¶
func (r *ChainScope) String() string
String implements the fmt.Stringer interface
type ChainSymbolResolver ¶
type ChainSymbolResolver struct {
// contains filtered or unexported fields
}
ChainSymbolResolver implements SymbolResolver over a chain of resolvers.
func NewChainSymbolResolver ¶
func NewChainSymbolResolver(chain ...SymbolResolver) *ChainSymbolResolver
type ConflictResolver ¶
type ConflictResolver interface { // Name is the canonical name for the resolver Name() string // RegisterFlags configures the flags. RegisterFlags is called for all // resolvers whether they are enabled or not. RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config) // CheckFlags asserts that the flags are correct. CheckFlags is only called // if the resolver is enabled. CheckFlags(fs *flag.FlagSet, c *config.Config) error // ResolveConflict takes the context rule and imports, and the target symbol // with conflicts to resolve. ResolveConflict(universe Universe, r *rule.Rule, imports ImportMap, imp *Import, symbol *Symbol) (*Symbol, bool) }
ConflictResolver implementations are capable of applying a conflict resolution strategy for conflicting resolved import symbols.
func GlobalConflictResolvers ¶
func GlobalConflictResolvers() []ConflictResolver
GlobalConflictResolvers returns a sorted list of known conflict resolvers
type ConflictResolverRegistry ¶
type ConflictResolverRegistry interface { // GetConflictResolver returns the named resolver. If not known `(nil, // false)` is returned. GetConflictResolver(name string) (ConflictResolver, bool) // PutConflictResolver adds the given known rule to the registry. It is an // error to attempt duplicate registration of the same rule twice. // Implementations should use the google.golang.org/grpc/status.Errorf for // error types. PutConflictResolver(name string, r ConflictResolver) error }
ConflictResolverRegistry is an index of known conflict resolvers keyed by their name.
func GlobalConflictResolverRegistry ¶
func GlobalConflictResolverRegistry() ConflictResolverRegistry
GlobalConflictResolverRegistry returns a default symbol provider registry. Third-party gazelle extensions can append to this list and configure their own implementations.
type CrossSymbolResolver ¶
type CrossSymbolResolver struct {
// contains filtered or unexported fields
}
CrossSymbolResolver implements Resolver using the resolve.RuleIndex (which uses the gazelle cross resolver infrastructure).
func NewCrossSymbolResolver ¶
func NewCrossSymbolResolver(lang string) *CrossSymbolResolver
type DepsCleaner ¶
type DepsCleaner interface { // Name is the canonical name for the resolver Name() string // RegisterFlags configures the flags. RegisterFlags is called for all // resolvers whether they are enabled or not. RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config) // CheckFlags asserts that the flags are correct. CheckFlags is only called // if the resolver is enabled. CheckFlags(fs *flag.FlagSet, c *config.Config) error // CleanDeps takes the context rule and a map of labels that represent the // incoming deps. The cleaner implementation should assign the value under // the dep label as false if the dep is not wanted. CleanDeps(deps map[label.Label]bool, r *rule.Rule, from label.Label) }
DepsCleaner implementations are capable of applying some sort of cleanup strategy on the post-resolved deps of a rule.
func GlobalDepsCleaners ¶
func GlobalDepsCleaners() []DepsCleaner
GlobalDepsCleaners returns a sorted list of known conflict resolvers
type DepsCleanerRegistry ¶
type DepsCleanerRegistry interface { // GetDepsCleaner returns the named resolver. If not known `(nil, // false)` is returned. GetDepsCleaner(name string) (DepsCleaner, bool) // PutDepsCleaner adds the given known rule to the registry. It is an // error to attempt duplicate registration of the same rule twice. // Implementations should use the google.golang.org/grpc/status.Errorf for // error types. PutDepsCleaner(name string, r DepsCleaner) error }
DepsCleanerRegistry is an index of known conflict resolvers keyed by their name.
func GlobalDepsCleanerRegistry ¶
func GlobalDepsCleanerRegistry() DepsCleanerRegistry
GlobalDepsCleanerRegistry returns a default deps cleaner registry. Third-party gazelle extensions can append to this list and configure their own implementations.
type Import ¶
type Import struct { // Kind is the import type Kind sppb.ImportKind // Imp is the name of the import Imp string // File is the source file (when this is a direct import). Source *sppb.File // Src is the name of the parent import (when this is an implicit import) Src string // Symbol is the resolved symbol of the import, or nil if not resolved. Symbol *Symbol // Error is assiged if there is a resolution error. Error error }
Import is used to trace import provenance.
func NewDirectImport ¶
NewDirectImport creates a new direct import from the given file.
func NewErrorImport ¶
NewError creates a new err import from the given file, name, and symbol.
func NewExtendsImport ¶
NewExtendsImport creates a new extends import from the given requiring type.
func NewImplicitImport ¶
NewImplicitImport creates a new implicit import from the given parent src.
func NewMainClassImport ¶
NewMainClassImport creates a new main_class import.
func NewResolvedNameImport ¶
NewResolvedNameImport creates a new resolved import from the given file, name, and symbol. The 'name' is the token that resolved in the file scope.
func NewSemanticImport ¶
NewSemanticImport creates a new semantic import from the given file.
func NewTransitiveImport ¶
NewTransitiveImport creates a new resolved import from the given file, name, and symbol. The 'name' is the token that resolved in the file scope.
type ImportLabel ¶
ImportLabel is a pair of (Import,Label)
type ImportMap ¶
type ImportMap interface { Keys() []string Values() []*Import Deps(from label.Label) map[label.Label]*ImportLabel Put(imp *Import) Get(name string) (*Import, bool) Annotate(comments *build.Comments, accept func(imp *Import) bool) }
func NewImportMap ¶
NewImportMap initializes a new ImportMap with an optional list of Imports.
type KnownRuleRegistry ¶
type KnownRuleRegistry interface { // GetKnownRule does a lookup of the given label and returns the // known rule. If not known `(nil, false)` is returned. GetKnownRule(from label.Label) (*rule.Rule, bool) // PutKnownRule adds the given known rule to the registry. It is an // error to attempt duplicate registration of the same rule twice. // Implementations should use the google.golang.org/grpc/status.Errorf for // error types. PutKnownRule(from label.Label, r *rule.Rule) error }
KnownRuleRegistry is an index of known rules keyed by their label.
type LabelNameRewriteSpec ¶
type LabelNameRewriteSpec struct { // Src is the label name pattern to match Src string // Dst is the label name pattern to rewrite Dst string }
LabelNameRewriteSpec is a specification to rewrite a label name. For example, a bazel macro like `custom_scala_library` might be implemented such that the macro instantiates a "real" scala_library rule as `name + "_lib"`. In this case, we don't want to resolve the actual macro name but rather the lib name. Given this example, it would be `LabelNameRewriteSpec{Src:"%{name}", Dst:"%{name}_lib"}`, where `%{name}` is a special token used as a placeholder for the label.Name.
type MemoSymbolResolver ¶
type MemoSymbolResolver struct {
// contains filtered or unexported fields
}
MemoSymbolResolver implements SymbolResolver, memoizing results.
func NewMemoSymbolResolver ¶
func NewMemoSymbolResolver(next SymbolResolver) *MemoSymbolResolver
type OrderedImportMap ¶
type OrderedImportMap struct {
// contains filtered or unexported fields
}
OrderedImportMap is a map if imports keyed by the import string.
func (*OrderedImportMap) Annotate ¶
func (imports *OrderedImportMap) Annotate(comments *build.Comments, accept func(imp *Import) bool)
func (*OrderedImportMap) Deps ¶
func (imports *OrderedImportMap) Deps(from label.Label) map[label.Label]*ImportLabel
Deps returns a de-duplicated list of labels that represent the from-relative final deps. The list is not sorted under the expectation that sorting will be done elsewhere.
func (*OrderedImportMap) Get ¶
func (imports *OrderedImportMap) Get(key string) (*Import, bool)
Get the given import in the map, but only if it does not already exist in the map.
func (*OrderedImportMap) Keys ¶
func (imports *OrderedImportMap) Keys() []string
Keys returns a sorted list of imports.
func (*OrderedImportMap) Put ¶
func (imports *OrderedImportMap) Put(imp *Import)
Put the given import in the map, but only if it does not already exist in the map.
func (*OrderedImportMap) Values ¶
func (imports *OrderedImportMap) Values() []*Import
Values returns an ordered list of *Import reflecting the order in which it was added.
type OverrideSymbolResolver ¶
type OverrideSymbolResolver struct {
// contains filtered or unexported fields
}
OverrideSymbolResolver implements Resolver for gazelle:resolve directives.
func NewOverrideSymbolResolver ¶
func NewOverrideSymbolResolver(lang string) *OverrideSymbolResolver
type PredefinedLabelConflictResolver ¶
type PredefinedLabelConflictResolver struct { }
PredefinedLabelConflictResolver implements a strategy where
func (*PredefinedLabelConflictResolver) CheckFlags ¶
CheckFlags implements part of the resolver.ConflictResolver interface.
func (*PredefinedLabelConflictResolver) Name ¶
func (s *PredefinedLabelConflictResolver) Name() string
RegisterFlags implements part of the resolver.ConflictResolver interface.
func (*PredefinedLabelConflictResolver) RegisterFlags ¶
func (s *PredefinedLabelConflictResolver) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config)
RegisterFlags implements part of the resolver.ConflictResolver interface.
func (*PredefinedLabelConflictResolver) ResolveConflict ¶
func (s *PredefinedLabelConflictResolver) ResolveConflict(universe Universe, r *rule.Rule, imports ImportMap, imp *Import, symbol *Symbol) (*Symbol, bool)
ResolveConflict implements part of the resolver.ConflictResolver interface. This implementation chooses symbols that have symbol.Label == label.NoLabel, which is the scenario when a symbol is provided by the platform / compiler, like "java.lang.String".
type ScalaGrpcZioConflictResolver ¶
type ScalaGrpcZioConflictResolver struct { }
ScalaGrpcZioConflictResolver implements a strategy
func (*ScalaGrpcZioConflictResolver) CheckFlags ¶
CheckFlags implements part of the resolver.ConflictResolver interface.
func (*ScalaGrpcZioConflictResolver) Name ¶
func (s *ScalaGrpcZioConflictResolver) Name() string
RegisterFlags implements part of the resolver.ConflictResolver interface.
func (*ScalaGrpcZioConflictResolver) RegisterFlags ¶
func (s *ScalaGrpcZioConflictResolver) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config)
RegisterFlags implements part of the resolver.ConflictResolver interface.
func (*ScalaGrpcZioConflictResolver) ResolveConflict ¶
func (s *ScalaGrpcZioConflictResolver) ResolveConflict(universe Universe, r *rule.Rule, imports ImportMap, imp *Import, symbol *Symbol) (*Symbol, bool)
ResolveConflict implements part of the resolver.ConflictResolver interface. This implementation deals with the specific scenario where a PROTO_PACKAGE is being provided by two rules: one is the "foo_proto_scala_library", the other is the "foo_grpc_scala_library". The task is to determine if the rule is referencing *any* grpc-like symbols from the conflicting rule. If they are using grpc, always resolve to conflict in favor of the grpc label, because that rule will include the protos anyway. If they aren't using grpc, take the proto rule so that the rule does not take on additional unnecessary deps.
type ScalaProtoPackageConflictResolver ¶
type ScalaProtoPackageConflictResolver struct { }
ScalaProtoPackageConflictResolver implements a strategy where
func (*ScalaProtoPackageConflictResolver) CheckFlags ¶
CheckFlags implements part of the resolver.ConflictResolver interface.
func (*ScalaProtoPackageConflictResolver) Name ¶
func (s *ScalaProtoPackageConflictResolver) Name() string
RegisterFlags implements part of the resolver.ConflictResolver interface.
func (*ScalaProtoPackageConflictResolver) RegisterFlags ¶
func (s *ScalaProtoPackageConflictResolver) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config)
RegisterFlags implements part of the resolver.ConflictResolver interface.
func (*ScalaProtoPackageConflictResolver) ResolveConflict ¶
func (s *ScalaProtoPackageConflictResolver) ResolveConflict(universe Universe, r *rule.Rule, imports ImportMap, imp *Import, symbol *Symbol) (*Symbol, bool)
ResolveConflict implements part of the resolver.ConflictResolver interface. This implementation deals with the specific scenario where a PROTO_PACKAGE is being provided by two rules: one is the "foo_proto_scala_library", the other is the "foo_grpc_scala_library". The task is to determine if the rule is referencing *any* grpc-like symbols from the conflicting rule. If they are using grpc, always resolve to conflict in favor of the grpc label, because that rule will include the protos anyway. If they aren't using grpc, take the proto rule so that the rule does not take on additional unnecessary deps.
type ScalaScope ¶
type ScalaScope struct {
// contains filtered or unexported fields
}
func NewScalaScope ¶
func NewScalaScope(parent Scope) (*ScalaScope, error)
func (*ScalaScope) GetScope ¶
func (r *ScalaScope) GetScope(imp string) (Scope, bool)
GetScope implements part of the resolver.Scope interface.
func (*ScalaScope) GetSymbol ¶
func (r *ScalaScope) GetSymbol(imp string) (*Symbol, bool)
GetSymbol implements part of the Scope interface
func (*ScalaScope) GetSymbols ¶
func (r *ScalaScope) GetSymbols(prefix string) []*Symbol
GetSymbols implements part of the Scope interface
func (*ScalaScope) PutSymbol ¶
func (r *ScalaScope) PutSymbol(known *Symbol) error
PutSymbol is not supported and will panic.
func (*ScalaScope) String ¶
func (r *ScalaScope) String() string
String implements the fmt.Stringer interface
type ScalaSymbolResolver ¶
type ScalaSymbolResolver struct {
// contains filtered or unexported fields
}
ScalaSymbolResolver implements SymbolResolver for scala imports. Patterns like '_root_.' or "._" are stripped.
func NewScalaSymbolResolver ¶
func NewScalaSymbolResolver(next SymbolResolver) *ScalaSymbolResolver
NewScalaSymbolResolver constructs a new resolver that chains to the given resolver.
type Scope ¶
type Scope interface { fmt.Stringer // GetScope returns a scope for th symbol under the given prefix. GetScope(name string) (Scope, bool) // GetSymbol does a lookup of the given import symbol and returns the // known import. If not known `(nil, false)` is returned. GetSymbol(name string) (*Symbol, bool) // GetSymbols does a lookup of the given prefix and returns the // symbols. GetSymbols(prefix string) []*Symbol // PutSymbol adds the given known import to the registry. It is an // error to attempt duplicate registration of the same import twice. PutSymbol(known *Symbol) error }
Scope is an index of known symbols.
type ScopeSymbolResolver ¶
type ScopeSymbolResolver struct {
// contains filtered or unexported fields
}
ScopeSymbolResolver implements Resolver for symbols.
func NewScopeSymbolResolver ¶
func NewScopeSymbolResolver(scope Scope) *ScopeSymbolResolver
type Symbol ¶
type Symbol struct { // Type is the kind of symbol this is. Type sppb.ImportType // Name is the fully-qualified import name. Name string // Label is the bazel label where the symbol is provided from. Label label.Label // Provider is the name of the provider that supplied the symbol. Provider string // Conflicts is a list of symbols provided by another provider or label. Conflicts []*Symbol // Requires is a list of other symbols that are required by this one. Requires []*Symbol }
Symbol associates a name with the label that provides it, along with a type classifier that says what kind of symbol it is.
type SymbolMap ¶
SymbolMap is a map of symbols that are in a scope. For the import 'com.foo.Bar', the map key is 'Bar' and the map value is the known import for it.
type SymbolProvider ¶
type SymbolProvider interface { // Providers have canonical names Name() string // RegisterFlags configures the flags. RegisterFlags is called for all // providers whether they are enabled or not. RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config) // CheckFlags asserts that the flags are correct and provides a scope to // provide symbols to. CheckFlags is only called if the provider is // enabled. CheckFlags(fs *flag.FlagSet, c *config.Config, scope Scope) error // OnResolve is a lifecycle hook that gets called when the resolve phase has // started. OnResolve() error // OnEnd is a lifecycle hook that gets called when the resolve phase has // ended. OnEnd() error // Providers typically manage a particular sub-space of labels. For // example, the maven resolver may return true for labels like // "@maven//:junit_junit". The rule Index can be used to consult what type // of label from is, based on the rule characteristics. CanProvide(dep *ImportLabel, expr build.Expr, knownRule func(from label.Label) (*rule.Rule, bool)) bool }
SymbolProvider is a flag-configurable entity that supplies symbols to a registry.
func GetNamedSymbolProviders ¶
func GetNamedSymbolProviders(names []string) (want []SymbolProvider, err error)
type SymbolProviderRegistry ¶
type SymbolProviderRegistry interface { // SymbolProviders returns a list of all known providers. SymbolProviders() []SymbolProvider // AddSymbolProvider adds the given known import provider to the // registry. It is an error to add the same namedprovider twice. AddSymbolProvider(provider SymbolProvider) error }
SymbolProviderRegistry is an index of import providers.
func GlobalSymbolProviderRegistry ¶
func GlobalSymbolProviderRegistry() SymbolProviderRegistry
GlobalSymbolProviderRegistry returns a default symbol provider registry. Third-party gazelle extensions can append to this list and configure their own implementations.
type SymbolResolver ¶
type SymbolResolver interface { // ResolveSymbol takes the given config, gazelle rule index, and an // import to resolve. ResolveSymbol(c *config.Config, ix *resolve.RuleIndex, from label.Label, lang string, sym string) (*Symbol, bool) }
SymbolResolver knows how to resolve imports.
type TrieScope ¶
type TrieScope struct {
// contains filtered or unexported fields
}
TrieScope implements Scope using a trie.
func (*TrieScope) GetSymbols ¶
GetSymbols implements part of the resolver.Scope interface.
func (*TrieScope) Put ¶
Put gives the user control over the name of the symbol to be added to the trie.
func (*TrieScope) String ¶
String implements the fmt.Stringer interface.
Example ¶
scope := NewTrieScope() for _, symbol := range []*Symbol{ { Type: sppb.ImportType_PACKAGE, Name: "java.lang", Provider: "java", }, { Type: sppb.ImportType_CLASS, Name: "java.lang.String", Provider: "java", }, { Type: sppb.ImportType_PACKAGE, Name: "scala", Provider: "java", }, { Type: sppb.ImportType_CLASS, Name: "scala.Any", Provider: "java", }, } { if err := scope.PutSymbol(symbol); err != nil { log.Fatal(err) } } fmt.Println(scope)
Output: java <nil> └ lang (java.lang<PACKAGE> //:<java>) └ String (java.lang.String<CLASS> //:<java>) scala (scala<PACKAGE> //:<java>) └ Any (scala.Any<CLASS> //:<java>)
Example (Empty) ¶
scope := NewTrieScope() fmt.Println(scope)
Output:
type TrimPrefixScope ¶
type TrimPrefixScope struct {
// contains filtered or unexported fields
}
TrimPrefixScope implements Scope that trims a prefix from the lookup name.
func NewTrimPrefixScope ¶
func NewTrimPrefixScope(prefix string, next Scope) *TrimPrefixScope
func (*TrimPrefixScope) GetScope ¶
func (r *TrimPrefixScope) GetScope(name string) (Scope, bool)
GetScope implements part of the resolver.Scope interface.
func (*TrimPrefixScope) GetSymbol ¶
func (r *TrimPrefixScope) GetSymbol(name string) (*Symbol, bool)
GetSymbol implements part of the Scope interface
func (*TrimPrefixScope) GetSymbols ¶
func (r *TrimPrefixScope) GetSymbols(name string) []*Symbol
GetSymbols implements part of the Scope interface
func (*TrimPrefixScope) PutSymbol ¶
func (r *TrimPrefixScope) PutSymbol(known *Symbol) error
PutSymbol is not supported and will panic.
func (*TrimPrefixScope) String ¶
func (r *TrimPrefixScope) String() string
String implements the fmt.Stringer interface
type Universe ¶
type Universe interface { SymbolProviderRegistry KnownRuleRegistry ConflictResolverRegistry DepsCleanerRegistry Scope SymbolResolver }
Universe is a mashup of interfaces that represents all known symbols, rules, etc.
Source Files ¶
- chain_scope.go
- chain_symbol_resolver.go
- conflict_resolver.go
- conflict_resolver_registry.go
- cross_symbol_resolver.go
- deps_cleaner.go
- deps_cleaner_registry.go
- global_conflict_resolver_registry.go
- global_deps_cleaner_registry.go
- global_symbol_provider_registry.go
- import.go
- import_map.go
- known_rule_registry.go
- label_name_rewrite_spec.go
- memo_symbol_resolver.go
- override_symbol_resolver.go
- predefined_label_conflict_resolver.go
- scala_grpc_zio_conflict_resolver.go
- scala_proto_package_conflict_resolver.go
- scala_scope.go
- scala_symbol_resolver.go
- scope.go
- scope_symbol_resolver.go
- symbol.go
- symbol_map.go
- symbol_provider.go
- symbol_provider_registry.go
- symbol_resolver.go
- trie_scope.go
- trim_prefix_scope.go
- universe.go