Documentation ¶
Overview ¶
srg package defines methods for interacting with the Source Representation Graph.
Index ¶
- Constants
- Variables
- func GetUniqueId(srgNode compilergraph.GraphNode) string
- func IdentifierPathString(node compilergraph.GraphNode) (string, bool)
- func InSamePackage(first compilercommon.InputSource, second compilercommon.InputSource) bool
- func PackagePath(modulePath compilercommon.InputSource) string
- func ParseExpression(expressionString string, source compilercommon.InputSource, startRune int) (compilergraph.GraphNode, bool)
- type ContainingImplementedOption
- type MemberKind
- type ModuleResolutionOption
- type NamedScopeKind
- type SRG
- func (g *SRG) AllComments() compilergraph.NodeIterator
- func (g *SRG) AsImplementable(node compilergraph.GraphNode) (SRGImplementable, bool)
- func (g *SRG) EntrypointImplementations() SRGImplementableIterator
- func (g *SRG) EntrypointVariables() SRGMemberIterator
- func (g *SRG) FindComment(commentValue string) (SRGComment, bool)
- func (g *SRG) FindCommentedNode(commentValue string) (compilergraph.GraphNode, bool)
- func (g *SRG) FindModuleBySource(source compilercommon.InputSource) (SRGModule, bool)
- func (g *SRG) FindNameInScope(name string, node compilergraph.GraphNode) (SRGScopeOrImport, bool)
- func (g *SRG) FindNearbyNodeForPosition(sourcePosition compilercommon.SourcePosition) (compilergraph.GraphNode, bool)
- func (g *SRG) FindNodeForPosition(sourcePosition compilercommon.SourcePosition) (compilergraph.GraphNode, bool)
- func (g *SRG) FindReferencesInScope(name string, node compilergraph.GraphNode) compilergraph.NodeIterator
- func (g *SRG) Freeze()
- func (g *SRG) GetDefinedTypeReference(node compilergraph.GraphNode) SRGType
- func (g *SRG) GetGenericTypes() []SRGType
- func (g *SRG) GetImport(importNode compilergraph.GraphNode) SRGImport
- func (g *SRG) GetMemberReference(node compilergraph.GraphNode) SRGMember
- func (g *SRG) GetModules() []SRGModule
- func (g *SRG) GetNamedScope(nodeId compilergraph.GraphNodeId) SRGNamedScope
- func (g *SRG) GetNode(nodeId compilergraph.GraphNodeId) compilergraph.GraphNode
- func (g *SRG) GetPackageImport(packageNode compilergraph.GraphNode) SRGPackageImport
- func (g *SRG) GetParameterReference(node compilergraph.GraphNode) SRGParameter
- func (g *SRG) GetTypeGenerics() []SRGGeneric
- func (g *SRG) GetTypeRef(node compilergraph.GraphNode) SRGTypeRef
- func (g *SRG) GetTypeReferences() []SRGTypeRef
- func (g *SRG) GetTypes() []SRGType
- func (g *SRG) ImplicitLambdaExpressions() compilergraph.NodeIterator
- func (g *SRG) NewSourceStructureFinder() *SourceStructureFinder
- func (g *SRG) ResolveAliasedType(name string) (SRGType, bool)
- func (g *SRG) ScopeNameForNode(srgNode compilergraph.GraphNode) SRGNamedScope
- func (g *SRG) SourceHandler() packageloader.SourceHandler
- func (g *SRG) SourceRangeOf(node compilergraph.GraphNode) (compilercommon.SourceRange, bool)
- func (g *SRG) TryGetNode(nodeId compilergraph.GraphNodeId) (compilergraph.GraphNode, bool)
- type SRGComment
- type SRGComposedAgent
- type SRGContextScopeName
- type SRGDocumentation
- type SRGExternalPackageImport
- func (ns SRGExternalPackageImport) AsNamedScope() SRGNamedScope
- func (ns SRGExternalPackageImport) AsPackageImport() SRGExternalPackageImport
- func (ns SRGExternalPackageImport) ImportedName() string
- func (ns SRGExternalPackageImport) IsNamedScope() bool
- func (ns SRGExternalPackageImport) Name() (string, bool)
- func (ns SRGExternalPackageImport) Package() packageloader.PackageInfo
- type SRGGeneric
- func (t SRGGeneric) Code() (compilercommon.CodeSummary, bool)
- func (t SRGGeneric) Documentation() (SRGDocumentation, bool)
- func (t SRGGeneric) GetConstraint() (SRGTypeRef, bool)
- func (t SRGGeneric) HasConstraint() bool
- func (t SRGGeneric) Name() (string, bool)
- func (t SRGGeneric) Node() compilergraph.GraphNode
- func (t SRGGeneric) SourceRange() (compilercommon.SourceRange, bool)
- type SRGImplementable
- func (m SRGImplementable) Body() (compilergraph.GraphNode, bool)
- func (m SRGImplementable) ContainingMember() SRGMember
- func (m SRGImplementable) IsMember() bool
- func (m SRGImplementable) IsPropertySetter() bool
- func (m SRGImplementable) Name() (string, bool)
- func (m SRGImplementable) Node() compilergraph.GraphNode
- func (m SRGImplementable) Parameters() []SRGParameter
- type SRGImplementableIterator
- type SRGImport
- func (i SRGImport) Code() (compilercommon.CodeSummary, bool)
- func (i SRGImport) PackageImports() []SRGPackageImport
- func (i SRGImport) ParsedSource() (string, shared.ParsedImportType, error)
- func (i SRGImport) Source() (string, bool)
- func (i SRGImport) SourceRange() (compilercommon.SourceRange, bool)
- type SRGMember
- func (m SRGMember) AsImplementable() SRGImplementable
- func (m SRGMember) AsNamedScope() SRGNamedScope
- func (m SRGMember) Body() (compilergraph.GraphNode, bool)
- func (m SRGMember) Code() (compilercommon.CodeSummary, bool)
- func (m SRGMember) ContainingType() (SRGType, bool)
- func (m SRGMember) DeclaredType() (SRGTypeRef, bool)
- func (m SRGMember) DefinedReturnType() (SRGTypeRef, bool)
- func (m SRGMember) Documentation() (SRGDocumentation, bool)
- func (m SRGMember) Generics() []SRGGeneric
- func (m SRGMember) Getter() (SRGImplementable, bool)
- func (m SRGMember) HasImplementation() bool
- func (m SRGMember) HasSetter() bool
- func (m SRGMember) Initializer() (compilergraph.GraphNode, bool)
- func (m SRGMember) IsAsyncFunction() bool
- func (m SRGMember) IsConstant() bool
- func (m SRGMember) IsExported() bool
- func (m SRGMember) IsOperator() bool
- func (m SRGMember) IsReadOnly() bool
- func (m SRGMember) IsStatic() bool
- func (m SRGMember) MemberKind() MemberKind
- func (m SRGMember) Module() SRGModule
- func (m SRGMember) Name() (string, bool)
- func (m SRGMember) Node() compilergraph.GraphNode
- func (m SRGMember) Parameters() []SRGParameter
- func (m SRGMember) Setter() (SRGImplementable, bool)
- func (m SRGMember) SourceRange() (compilercommon.SourceRange, bool)
- func (m SRGMember) Tags() map[string]string
- func (m SRGMember) UniqueId() string
- type SRGMemberIterator
- type SRGModule
- func (m SRGModule) FindTypeByName(typeName string, option ModuleResolutionOption) (SRGType, bool)
- func (m SRGModule) FindTypeOrMemberByName(name string, option ModuleResolutionOption) (SRGTypeOrMember, bool)
- func (m SRGModule) GetImports() []SRGImport
- func (m SRGModule) GetMembers() []SRGMember
- func (m SRGModule) GetTypes() []SRGType
- func (m SRGModule) InputSource() compilercommon.InputSource
- func (m SRGModule) Name() string
- func (m SRGModule) Node() compilergraph.GraphNode
- func (m SRGModule) ResolveImportedPackage(packageName string) (importedPackage, bool)
- func (m SRGModule) ResolveType(path string, option ModuleResolutionOption) (TypeResolutionResult, bool)
- func (m SRGModule) ResolveTypePath(path string) (TypeResolutionResult, bool)
- type SRGNamedScope
- func (ns SRGNamedScope) AccessIsUsage() bool
- func (ns SRGNamedScope) AsNamedScope() SRGNamedScope
- func (ns SRGNamedScope) AsPackageImport() SRGExternalPackageImport
- func (ns SRGNamedScope) Code() (compilercommon.CodeSummary, bool)
- func (ns SRGNamedScope) DeclaredType() (SRGTypeRef, bool)
- func (ns SRGNamedScope) DefinedReturnType() (SRGTypeRef, bool)
- func (ns SRGNamedScope) Documentation() (SRGDocumentation, bool)
- func (ns SRGNamedScope) GetMember() (SRGMember, bool)
- func (ns SRGNamedScope) GetParameter() (SRGParameter, bool)
- func (ns SRGNamedScope) IsAssignable() bool
- func (ns SRGNamedScope) IsFunction() bool
- func (ns SRGNamedScope) IsNamedScope() bool
- func (ns SRGNamedScope) IsStatic() bool
- func (ns SRGNamedScope) Name() (string, bool)
- func (ns SRGNamedScope) Node() compilergraph.GraphNode
- func (ns SRGNamedScope) ResolveNameUnderScope(name string) (SRGScopeOrImport, bool)
- func (ns SRGNamedScope) ScopeKind() NamedScopeKind
- func (ns SRGNamedScope) SourceRange() (compilercommon.SourceRange, bool)
- func (ns SRGNamedScope) Title() string
- type SRGPackageImport
- func (i SRGPackageImport) Alias() (string, bool)
- func (i SRGPackageImport) Code() (compilercommon.CodeSummary, bool)
- func (i SRGPackageImport) ResolveType() (TypeResolutionResult, bool)
- func (i SRGPackageImport) ResolvedTypeOrMember() (SRGTypeOrMember, bool)
- func (i SRGPackageImport) SourceRange() (compilercommon.SourceRange, bool)
- func (i SRGPackageImport) Subsource() (string, bool)
- type SRGParameter
- func (p SRGParameter) AsNamedScope() SRGNamedScope
- func (p SRGParameter) Code() (compilercommon.CodeSummary, bool)
- func (p SRGParameter) DeclaredType() (SRGTypeRef, bool)
- func (p SRGParameter) Documentation() (SRGDocumentation, bool)
- func (p SRGParameter) Name() (string, bool)
- func (p SRGParameter) Node() compilergraph.GraphNode
- func (p SRGParameter) SourceRange() (compilercommon.SourceRange, bool)
- type SRGScopeOrImport
- type SRGType
- func (t SRGType) Alias() (string, bool)
- func (t SRGType) AsNamedScope() SRGNamedScope
- func (t SRGType) Code() (compilercommon.CodeSummary, bool)
- func (t SRGType) ComposedAgents() []SRGComposedAgent
- func (t SRGType) Documentation() (SRGDocumentation, bool)
- func (t SRGType) FindMember(name string) (SRGMember, bool)
- func (t SRGType) FindOperator(name string) (SRGMember, bool)
- func (t SRGType) Generics() []SRGGeneric
- func (t SRGType) GetMembers() []SRGMember
- func (t SRGType) HasComposedAgents() bool
- func (t SRGType) IsExported() bool
- func (t SRGType) Module() SRGModule
- func (t SRGType) Name() (string, bool)
- func (t SRGType) Node() compilergraph.GraphNode
- func (t SRGType) PrincipalType() (SRGTypeRef, bool)
- func (t SRGType) SourceRange() (compilercommon.SourceRange, bool)
- func (t SRGType) TypeKind() TypeKind
- func (m SRGType) UniqueId() string
- func (t SRGType) WrappedType() (SRGTypeRef, bool)
- type SRGTypeOrGeneric
- type SRGTypeOrMember
- func (t SRGTypeOrMember) AsMember() (SRGMember, bool)
- func (t SRGTypeOrMember) AsType() (SRGType, bool)
- func (t SRGTypeOrMember) ContainingModule() SRGModule
- func (t SRGTypeOrMember) Generics() []SRGGeneric
- func (t SRGTypeOrMember) IsType() bool
- func (t SRGTypeOrMember) Name() (string, bool)
- func (t SRGTypeOrMember) Node() compilergraph.GraphNode
- func (t SRGTypeOrMember) SourceRange() (compilercommon.SourceRange, bool)
- type SRGTypeRef
- func (t SRGTypeRef) Generics() []SRGTypeRef
- func (t SRGTypeRef) HasGenerics() bool
- func (t SRGTypeRef) HasParameters() bool
- func (t SRGTypeRef) InnerReference() (SRGTypeRef, bool)
- func (t SRGTypeRef) Parameters() []SRGTypeRef
- func (t SRGTypeRef) RefKind() TypeRefKind
- func (t SRGTypeRef) ResolutionName() string
- func (t SRGTypeRef) ResolutionPath() string
- func (t SRGTypeRef) ResolveType() (TypeResolutionResult, bool)
- func (t SRGTypeRef) SourceRange() (compilercommon.SourceRange, bool)
- func (t SRGTypeRef) String() string
- type SourceStructureFinder
- func (f *SourceStructureFinder) ScopeInContext(node compilergraph.GraphNode) []SRGContextScopeName
- func (f *SourceStructureFinder) TryGetContainingImplemented(node compilergraph.GraphNode) (SRGImplementable, bool)
- func (f *SourceStructureFinder) TryGetContainingImplementedWithOption(node compilergraph.GraphNode, option ContainingImplementedOption) (SRGImplementable, bool)
- func (f *SourceStructureFinder) TryGetContainingMemberOrType(node compilergraph.GraphNode) (SRGTypeOrMember, bool)
- func (f *SourceStructureFinder) TryGetContainingModule(node compilergraph.GraphNode) (SRGModule, bool)
- func (f *SourceStructureFinder) TryGetContainingNode(node compilergraph.GraphNode, nodeTypes ...sourceshape.NodeType) (compilergraph.GraphNode, bool)
- func (f *SourceStructureFinder) TryGetContainingType(node compilergraph.GraphNode) (SRGType, bool)
- func (f *SourceStructureFinder) TryGetNearestContainingNode(node compilergraph.GraphNode, nodeTypes ...sourceshape.NodeType) (compilergraph.GraphNode, bool)
- type TypeKind
- type TypeRefKind
- type TypeResolutionResult
Constants ¶
const ( // ContainingImplementedInclusive indicates that if the node itself is an implemented, it will be // returned. ContainingImplementedInclusive = "inclusive" // ContainingImplementedExclusive indicates that if the node itself is an implemented, its *containing // implemented will be returned (if any). ContainingImplementedExclusive = "excluse" )
const ASYNC_SUFFIX = "Async"
Variables ¶
var MEMBER_OR_TYPE_KINDS = append(TYPE_MEMBER_KINDS, TYPE_KINDS...)
var MODULE_MEMBER_KINDS_TAGGED = append(TYPE_KINDS_TAGGED, []compilergraph.TaggedValue{ sourceshape.NodeTypeVariable, sourceshape.NodeTypeFunction, }...)
var TYPE_KINDS = []sourceshape.NodeType{ sourceshape.NodeTypeClass, sourceshape.NodeTypeInterface, sourceshape.NodeTypeNominal, sourceshape.NodeTypeStruct, sourceshape.NodeTypeAgent, }
var TYPE_KINDS_TAGGED = []compilergraph.TaggedValue{ sourceshape.NodeTypeClass, sourceshape.NodeTypeInterface, sourceshape.NodeTypeNominal, sourceshape.NodeTypeStruct, sourceshape.NodeTypeAgent, }
var TYPE_MEMBER_KINDS = []sourceshape.NodeType{ sourceshape.NodeTypeFunction, sourceshape.NodeTypeVariable, sourceshape.NodeTypeConstructor, sourceshape.NodeTypeProperty, sourceshape.NodeTypeOperator, }
Functions ¶
func GetUniqueId ¶
func GetUniqueId(srgNode compilergraph.GraphNode) string
GetUniqueId returns a unique hash ID for the SRG node that is stable across compilations.
func IdentifierPathString ¶
func IdentifierPathString(node compilergraph.GraphNode) (string, bool)
IdentifierPathString returns the string form of the identifier path referenced by the given node. Will return false if the node is not an identifier path.
func InSamePackage ¶
func InSamePackage(first compilercommon.InputSource, second compilercommon.InputSource) bool
InSamePackage returns true if the given input source paths are found *directly* under the same package (no subpackages).
func PackagePath ¶ added in v0.2.0
func PackagePath(modulePath compilercommon.InputSource) string
PackagePath returns the path of the package that holds the specified module path.
func ParseExpression ¶ added in v0.0.2
func ParseExpression(expressionString string, source compilercommon.InputSource, startRune int) (compilergraph.GraphNode, bool)
ParseExpression parses the given expression string and returns its node. Note that the expression will be added to *its own layer*, which means it will not be accessible from the normal SRG layer.
Types ¶
type ContainingImplementedOption ¶
type ContainingImplementedOption string
ContainingImplementedOption defines options for the TryGetContainingImplemented function.
type MemberKind ¶
type MemberKind int
TypeMemberKind defines the various supported kinds of members in the SRG.
const ( ConstructorMember MemberKind = iota VarMember FunctionMember PropertyMember OperatorMember )
func (MemberKind) String ¶
func (i MemberKind) String() string
type ModuleResolutionOption ¶
type ModuleResolutionOption int
const ( ModuleResolveExportedOnly ModuleResolutionOption = iota ModuleResolveAll ModuleResolutionOption = iota )
type NamedScopeKind ¶
type NamedScopeKind int
NamedScopeKind defines the various kinds of named scope in the SRG.
const ( NamedScopeType NamedScopeKind = iota // The named scope refers to a type. NamedScopeMember // The named scope refers to a module member. NamedScopeImport // The named scope refers to an import. NamedScopeParameter // The named scope refers to a parameter. NamedScopeValue // The named scope refers to a read-only value exported by a statement. NamedScopeVariable // The named scope refers to a variable statement. )
func (NamedScopeKind) String ¶
func (i NamedScopeKind) String() string
type SRG ¶
type SRG struct { Graph compilergraph.SerulianGraph // The root graph. // contains filtered or unexported fields }
SRG represents the SRG layer and all its associated helper methods.
func NewSRG ¶
func NewSRG(graph compilergraph.SerulianGraph) *SRG
NewSRG returns a new SRG for populating the graph with parsed source.
func (*SRG) AllComments ¶
func (g *SRG) AllComments() compilergraph.NodeIterator
AllComments returns an iterator over all the comment nodes found in the SRG.
func (*SRG) AsImplementable ¶
func (g *SRG) AsImplementable(node compilergraph.GraphNode) (SRGImplementable, bool)
AsImplementable returns the given node as an SRGImplementable (if applicable).
func (*SRG) EntrypointImplementations ¶
func (g *SRG) EntrypointImplementations() SRGImplementableIterator
EntrypointImplementations returns an iterator of all SRG members/impls in the SRG with bodies.
func (*SRG) EntrypointVariables ¶
func (g *SRG) EntrypointVariables() SRGMemberIterator
EntrypointVariables returns an iterator of all vars in the SRG that are entrypoints for scoping (currently variables and fields).
func (*SRG) FindComment ¶
func (g *SRG) FindComment(commentValue string) (SRGComment, bool)
FindComment attempts to find the comment in the SRG with the given value.
func (*SRG) FindCommentedNode ¶
func (g *SRG) FindCommentedNode(commentValue string) (compilergraph.GraphNode, bool)
FindCommentedNode attempts to find the node in the SRG with the given comment attached.
func (*SRG) FindModuleBySource ¶
func (g *SRG) FindModuleBySource(source compilercommon.InputSource) (SRGModule, bool)
FindModuleBySource returns the module with the given input source, if any.
func (*SRG) FindNameInScope ¶
func (g *SRG) FindNameInScope(name string, node compilergraph.GraphNode) (SRGScopeOrImport, bool)
FindNameInScope finds the given name accessible from the scope under which the given node exists, if any.
func (*SRG) FindNearbyNodeForPosition ¶
func (g *SRG) FindNearbyNodeForPosition(sourcePosition compilercommon.SourcePosition) (compilergraph.GraphNode, bool)
FindNearbyNodeForPosition finds a node near to matching the given position in the SRG. The exact location is tried first, followed by looking upwards and downwards by lines.
func (*SRG) FindNodeForPosition ¶
func (g *SRG) FindNodeForPosition(sourcePosition compilercommon.SourcePosition) (compilergraph.GraphNode, bool)
FindNodeForPosition finds the node matching the given position in the SRG. As multiple nodes may *contain* the position, the node with the smallest range is returned (if any).
func (*SRG) FindReferencesInScope ¶
func (g *SRG) FindReferencesInScope(name string, node compilergraph.GraphNode) compilergraph.NodeIterator
FindReferencesInScope finds all identifier expressions that refer to the given name, under the given scope.
func (*SRG) Freeze ¶ added in v0.0.2
func (g *SRG) Freeze()
Freeze freezes the source graph so that no additional changes can be applied to it.
func (*SRG) GetDefinedTypeReference ¶
func (g *SRG) GetDefinedTypeReference(node compilergraph.GraphNode) SRGType
GetDefinedTypeReference returns an SRGType wrapper around the given SRG type node. Panics if the node is not a type node.
func (*SRG) GetGenericTypes ¶
GetGenericTypes returns all the generic types defined in the SRG.
func (*SRG) GetImport ¶
func (g *SRG) GetImport(importNode compilergraph.GraphNode) SRGImport
GetImport returns an SRGImport wrapper around the given import node. Will panic if the node is not an import node.
func (*SRG) GetMemberReference ¶
func (g *SRG) GetMemberReference(node compilergraph.GraphNode) SRGMember
GetMemberReference returns an SRGMember wrapper around the given SRG member node. Panics if the node is not a member node.
func (*SRG) GetModules ¶
GetModules returns all the modules defined in the SRG.
func (*SRG) GetNamedScope ¶
func (g *SRG) GetNamedScope(nodeId compilergraph.GraphNodeId) SRGNamedScope
GetNamedScope returns SRGNamedScope for the given SRG node. Panics on failure to lookup.
func (*SRG) GetNode ¶
func (g *SRG) GetNode(nodeId compilergraph.GraphNodeId) compilergraph.GraphNode
GetNode returns the node with the given ID in this layer or panics.
func (*SRG) GetPackageImport ¶
func (g *SRG) GetPackageImport(packageNode compilergraph.GraphNode) SRGPackageImport
GetPackageImport returns an SRGPackageImport wrapper around the given import package node. Will panic if the node is not an import package node.
func (*SRG) GetParameterReference ¶
func (g *SRG) GetParameterReference(node compilergraph.GraphNode) SRGParameter
GetParameterReference returns an SRGParameter wrapper around the given SRG parameter node. Panics if the node is not a member node.
func (*SRG) GetTypeGenerics ¶
func (g *SRG) GetTypeGenerics() []SRGGeneric
GetTypeGenerics returns all the generics defined under types in the SRG.
func (*SRG) GetTypeRef ¶
func (g *SRG) GetTypeRef(node compilergraph.GraphNode) SRGTypeRef
GetTypeRef returns an SRGTypeRef wrapper for the given type reference node.
func (*SRG) GetTypeReferences ¶
func (g *SRG) GetTypeReferences() []SRGTypeRef
GetTypeReferences returns all the type references in the SRG.
func (*SRG) ImplicitLambdaExpressions ¶
func (g *SRG) ImplicitLambdaExpressions() compilergraph.NodeIterator
ImplicitLambdaExpressions returns an iterator of all implicit lambda expressions defined in the SRG.
func (*SRG) NewSourceStructureFinder ¶
func (g *SRG) NewSourceStructureFinder() *SourceStructureFinder
NewSourceStructureFinder returns a new source structural finder for the current SRG.
func (*SRG) ResolveAliasedType ¶
ResolveAliasedType returns the type with the global alias, if any.
func (*SRG) ScopeNameForNode ¶ added in v0.1.0
func (g *SRG) ScopeNameForNode(srgNode compilergraph.GraphNode) SRGNamedScope
ScopeNameForNode returns an SRGNamedScope for the given SRG node. Note that the node must be a named node in the SRG or this can cause a panic.
func (*SRG) SourceHandler ¶
func (g *SRG) SourceHandler() packageloader.SourceHandler
SourceHandler returns a SourceHandler for populating the SRG via a package loader.
func (*SRG) SourceRangeOf ¶
func (g *SRG) SourceRangeOf(node compilergraph.GraphNode) (compilercommon.SourceRange, bool)
SourceRangeOf returns a SourceRange for the given graph node.
func (*SRG) TryGetNode ¶
func (g *SRG) TryGetNode(nodeId compilergraph.GraphNodeId) (compilergraph.GraphNode, bool)
TryGetNode attempts to return the node with the given ID in this layer, if any.
type SRGComment ¶
type SRGComment struct { compilergraph.GraphNode // contains filtered or unexported fields }
SRGComment wraps a comment node with helpers for accessing documentation.
func (SRGComment) Contents ¶
func (c SRGComment) Contents() string
Contents returns the trimmed contents of the comment.
func (SRGComment) Documentation ¶
func (c SRGComment) Documentation() (SRGDocumentation, bool)
Documentation returns the documentation found in this comment, if any.
func (SRGComment) IsDocComment ¶
func (c SRGComment) IsDocComment() bool
IsDocComment returns true if the comment is a doc comment, instead of a normal comment.
func (SRGComment) ParentNode ¶
func (c SRGComment) ParentNode() compilergraph.GraphNode
ParentNode returns the node that contains this comment.
type SRGComposedAgent ¶
type SRGComposedAgent struct { compilergraph.GraphNode // contains filtered or unexported fields }
SRGComposedAgent wraps an agent that is being composed under another type in the SRG.
func (SRGComposedAgent) AgentType ¶
func (a SRGComposedAgent) AgentType() SRGTypeRef
AgentType returns the type of the agent being composed into the parent type.
func (SRGComposedAgent) CompositionAlias ¶
func (a SRGComposedAgent) CompositionAlias() (string, bool)
CompositionAlias returns the alias used for composition of the agent under the parent type, if any.
func (SRGComposedAgent) CompositionName ¶
func (a SRGComposedAgent) CompositionName() string
CompositionName returns the name used for composition of the agent under the parent type. If an alias is defined, the alias is used. Otherwise, the name of the type is used.
type SRGContextScopeName ¶
type SRGContextScopeName struct { compilergraph.GraphNode // contains filtered or unexported fields }
SRGContextScopeName represents a name found in the scope.
func (SRGContextScopeName) LocalName ¶
func (cn SRGContextScopeName) LocalName() (string, bool)
LocalName returns the locally accessible name of the scope in context.
func (SRGContextScopeName) NamedScope ¶
func (cn SRGContextScopeName) NamedScope() SRGNamedScope
NamedScope returns the named scope for this context name.
type SRGDocumentation ¶
type SRGDocumentation struct {
// contains filtered or unexported fields
}
SRGDocumentation represents documentation found on an SRG node. It is distinct from a comment in that it can be *part* of another comment.
func (SRGDocumentation) ForParameter ¶
func (d SRGDocumentation) ForParameter(paramName string) (SRGDocumentation, bool)
ForParameter returns the documentation associated with the given parameter name, if any.
func (SRGDocumentation) IsDocComment ¶
func (d SRGDocumentation) IsDocComment() bool
IsDocComment returns true if the documentation was found in a doc-comment style comment (instead of a standard comment).
func (SRGDocumentation) String ¶
func (d SRGDocumentation) String() string
String returns the human-readable documentation string.
type SRGExternalPackageImport ¶
type SRGExternalPackageImport struct {
// contains filtered or unexported fields
}
SRGExternalPackageImport represents a reference to an imported name from another package within the SRG.
func (SRGExternalPackageImport) AsNamedScope ¶
func (ns SRGExternalPackageImport) AsNamedScope() SRGNamedScope
func (SRGExternalPackageImport) AsPackageImport ¶
func (ns SRGExternalPackageImport) AsPackageImport() SRGExternalPackageImport
func (SRGExternalPackageImport) ImportedName ¶
func (ns SRGExternalPackageImport) ImportedName() string
ImportedName returns the name being accessed under the package.
func (SRGExternalPackageImport) IsNamedScope ¶
func (ns SRGExternalPackageImport) IsNamedScope() bool
func (SRGExternalPackageImport) Name ¶
func (ns SRGExternalPackageImport) Name() (string, bool)
Name returns the name of the imported member.
func (SRGExternalPackageImport) Package ¶
func (ns SRGExternalPackageImport) Package() packageloader.PackageInfo
Package returns the package under which the name is being imported.
type SRGGeneric ¶
type SRGGeneric struct { compilergraph.GraphNode // contains filtered or unexported fields }
SRGGeneric represents a generic declaration on a type or type member.
func (SRGGeneric) Code ¶
func (t SRGGeneric) Code() (compilercommon.CodeSummary, bool)
Code returns a code-like summarization of the generic, for human consumption.
func (SRGGeneric) Documentation ¶
func (t SRGGeneric) Documentation() (SRGDocumentation, bool)
Documentation returns the documentation associated with this generic, if any.
func (SRGGeneric) GetConstraint ¶
func (t SRGGeneric) GetConstraint() (SRGTypeRef, bool)
GetConstraint returns the constraint for this generic, if any.
func (SRGGeneric) HasConstraint ¶
func (t SRGGeneric) HasConstraint() bool
HasConstraint returns whether this generic has a type constraint.
func (SRGGeneric) Name ¶
func (t SRGGeneric) Name() (string, bool)
Name returns the name of this generic. May not existing in the partial-parsing case for tooling.
func (SRGGeneric) Node ¶
func (t SRGGeneric) Node() compilergraph.GraphNode
Node returns the underlying node.
func (SRGGeneric) SourceRange ¶
func (t SRGGeneric) SourceRange() (compilercommon.SourceRange, bool)
SourceRange returns the source range for this generic.
type SRGImplementable ¶
type SRGImplementable struct { compilergraph.GraphNode // contains filtered or unexported fields }
SRGImplementable wraps a node that can have a body.
func (SRGImplementable) Body ¶
func (m SRGImplementable) Body() (compilergraph.GraphNode, bool)
Body returns the statement block forming the implementation body for this implementable, if any.
func (SRGImplementable) ContainingMember ¶
func (m SRGImplementable) ContainingMember() SRGMember
ContainingMember returns the containing member of this implementable. If the node is, itself, a member, itself is returned.
func (SRGImplementable) IsMember ¶
func (m SRGImplementable) IsMember() bool
IsMember returns true if this implementable is an SRGMember.
func (SRGImplementable) IsPropertySetter ¶
func (m SRGImplementable) IsPropertySetter() bool
IsPropertySetter returns true if this implementable is a property setter.
func (SRGImplementable) Name ¶
func (m SRGImplementable) Name() (string, bool)
Name returns the name of the implementable, if any.
func (SRGImplementable) Node ¶
func (m SRGImplementable) Node() compilergraph.GraphNode
Node returns the underlying node for this implementable in the SRG.
func (SRGImplementable) Parameters ¶
func (m SRGImplementable) Parameters() []SRGParameter
Parameters returns the parameters defined on this implementable, if any.
type SRGImplementableIterator ¶
type SRGImplementableIterator struct {
// contains filtered or unexported fields
}
SRGImplementableIterator is an iterator of SRGImplementable's.
func (SRGImplementableIterator) Implementable ¶
func (sii SRGImplementableIterator) Implementable() SRGImplementable
func (SRGImplementableIterator) Next ¶
func (sii SRGImplementableIterator) Next() bool
type SRGImport ¶
type SRGImport struct { compilergraph.GraphNode // contains filtered or unexported fields }
SRGImport represents an import node.
func (SRGImport) Code ¶
func (i SRGImport) Code() (compilercommon.CodeSummary, bool)
Code returns a code-like summarization of the import, for human consumption.
func (SRGImport) PackageImports ¶
func (i SRGImport) PackageImports() []SRGPackageImport
PackageImports returns the package imports for this import statement, if any.
func (SRGImport) ParsedSource ¶
func (i SRGImport) ParsedSource() (string, shared.ParsedImportType, error)
ParsedSource returns the source for this import, parsed.
func (SRGImport) SourceRange ¶
func (i SRGImport) SourceRange() (compilercommon.SourceRange, bool)
SourceRange returns the source range for this import.
type SRGMember ¶
type SRGMember struct { compilergraph.GraphNode // contains filtered or unexported fields }
SRGMember wraps a member declaration or definition in the SRG.
func (SRGMember) AsImplementable ¶
func (m SRGMember) AsImplementable() SRGImplementable
func (SRGMember) AsNamedScope ¶
func (m SRGMember) AsNamedScope() SRGNamedScope
AsNamedScope returns the member as a named scope reference.
func (SRGMember) Body ¶
func (m SRGMember) Body() (compilergraph.GraphNode, bool)
Body returns the statement block forming the implementation body for this member, if any.
func (SRGMember) Code ¶
func (m SRGMember) Code() (compilercommon.CodeSummary, bool)
Code returns a code-like summarization of the member, for human consumption.
func (SRGMember) ContainingType ¶
ContainingType returns the type containing this member, if any.
func (SRGMember) DeclaredType ¶
func (m SRGMember) DeclaredType() (SRGTypeRef, bool)
DeclaredType returns a type reference to the declared type of this member, if any.
func (SRGMember) DefinedReturnType ¶ added in v0.2.0
func (m SRGMember) DefinedReturnType() (SRGTypeRef, bool)
DefinedReturnType returns a type reference to the defined return type of this member, if any.
func (SRGMember) Documentation ¶
func (m SRGMember) Documentation() (SRGDocumentation, bool)
Documentation returns the documentation on the member, if any.
func (SRGMember) Generics ¶
func (m SRGMember) Generics() []SRGGeneric
Generics returns the generics on this member.
func (SRGMember) Getter ¶
func (m SRGMember) Getter() (SRGImplementable, bool)
Getter returns the defined getter for this property. Panics if this is not a property.
func (SRGMember) HasImplementation ¶
HasImplementation returns whether the given member has a defined implementation.
func (SRGMember) HasSetter ¶
HasSetter returns true if the property has a setter defined. Will always return false for non-properties.
func (SRGMember) Initializer ¶
func (m SRGMember) Initializer() (compilergraph.GraphNode, bool)
Initializer returns the expression forming the initializer for this variable or field, if any.
func (SRGMember) IsAsyncFunction ¶
IsAsync returns whether the given member is an async function.
func (SRGMember) IsConstant ¶ added in v0.3.0
IsConstant returns whether the member is marked as explicitly constant. Only applies to variables under modules.
func (SRGMember) IsExported ¶
IsExported returns whether the given member is exported for use outside its package.
func (SRGMember) IsOperator ¶
IsOperator returns whether the given member is an operator.
func (SRGMember) IsReadOnly ¶
IsReadOnly returns whether the member is marked as explicitly read-only. Only applies to properties.
func (SRGMember) MemberKind ¶
func (m SRGMember) MemberKind() MemberKind
MemberKind returns the kind matching the member definition/declaration node type.
func (SRGMember) Name ¶
Name returns the name of this member. Can not exist in the partial-parsing case for tooling.
func (SRGMember) Node ¶
func (m SRGMember) Node() compilergraph.GraphNode
Node returns the underlying member node for this member.
func (SRGMember) Parameters ¶
func (m SRGMember) Parameters() []SRGParameter
Parameters returns the parameters on this member.
func (SRGMember) Setter ¶
func (m SRGMember) Setter() (SRGImplementable, bool)
Setter returns the defined setter for this property. Panics if this is not a property.
func (SRGMember) SourceRange ¶
func (m SRGMember) SourceRange() (compilercommon.SourceRange, bool)
SourceRange returns the source range for this member.
type SRGMemberIterator ¶
type SRGMemberIterator struct {
// contains filtered or unexported fields
}
SRGMemberIterator is an iterator of SRGMembers's.
func (SRGMemberIterator) Member ¶
func (smi SRGMemberIterator) Member() SRGMember
func (SRGMemberIterator) Next ¶
func (smi SRGMemberIterator) Next() bool
type SRGModule ¶
type SRGModule struct { compilergraph.GraphNode // contains filtered or unexported fields }
SRGModule wraps a module defined in the SRG.
func (SRGModule) FindTypeByName ¶
func (m SRGModule) FindTypeByName(typeName string, option ModuleResolutionOption) (SRGType, bool)
FindTypeByName searches for the type definition or declaration with the given name under this module and returns it (if found).
func (SRGModule) FindTypeOrMemberByName ¶
func (m SRGModule) FindTypeOrMemberByName(name string, option ModuleResolutionOption) (SRGTypeOrMember, bool)
FindTypeOrMemberByName searches for the type definition, declaration or module member with the given name under this module and returns it (if found). Note that this method does not handle imports.
func (SRGModule) GetImports ¶
GetImports returns the imports declared under the module.
func (SRGModule) GetMembers ¶
GetMembers returns the members declared directly under the module.
func (SRGModule) InputSource ¶
func (m SRGModule) InputSource() compilercommon.InputSource
InputSource returns the input source for this module.
func (SRGModule) Node ¶
func (m SRGModule) Node() compilergraph.GraphNode
Node returns the underlying node.
func (SRGModule) ResolveImportedPackage ¶
ResolveImportedPackage attempts to find a package imported by this module under the given packageName.
func (SRGModule) ResolveType ¶
func (m SRGModule) ResolveType(path string, option ModuleResolutionOption) (TypeResolutionResult, bool)
ResolveType attempts to resolve the type with the given name, under this module.
func (SRGModule) ResolveTypePath ¶
func (m SRGModule) ResolveTypePath(path string) (TypeResolutionResult, bool)
ResolveTypePath attempts to resolve the type at the given path under this module and its imports.
type SRGNamedScope ¶
type SRGNamedScope struct { compilergraph.GraphNode // contains filtered or unexported fields }
SRGNamedScope represents a reference to a named scope in the SRG (import, variable, etc).
func (SRGNamedScope) AccessIsUsage ¶
func (ns SRGNamedScope) AccessIsUsage() bool
AccessIsUsage returns true if the named scope refers to a member or variable that is used immediately via the access. For example, a variable or property access will "use" that member, while a function or constructor is not used until invoked.
func (SRGNamedScope) AsNamedScope ¶
func (ns SRGNamedScope) AsNamedScope() SRGNamedScope
AsNamedScope returns the named scope as a named scope object.
func (SRGNamedScope) AsPackageImport ¶
func (ns SRGNamedScope) AsPackageImport() SRGExternalPackageImport
AsPackageImport returns the named scope as a package import (always panics).
func (SRGNamedScope) Code ¶
func (ns SRGNamedScope) Code() (compilercommon.CodeSummary, bool)
Code returns a code-like summarization of the referenced scope, for human consumption.
func (SRGNamedScope) DeclaredType ¶
func (ns SRGNamedScope) DeclaredType() (SRGTypeRef, bool)
DeclaredType returns the declared type of the scoped node, if any.
func (SRGNamedScope) DefinedReturnType ¶ added in v0.2.0
func (ns SRGNamedScope) DefinedReturnType() (SRGTypeRef, bool)
DefinedReturnType returns the defined return type of the scoped node, if any.
func (SRGNamedScope) Documentation ¶
func (ns SRGNamedScope) Documentation() (SRGDocumentation, bool)
Documentation returns the documentation comment found on the scoped node, if any.
func (SRGNamedScope) GetMember ¶
func (ns SRGNamedScope) GetMember() (SRGMember, bool)
GetMember returns the member pointed to by this scope, if any.
func (SRGNamedScope) GetParameter ¶
func (ns SRGNamedScope) GetParameter() (SRGParameter, bool)
GetParameter returns the parameter pointed to by this scope, if any.
func (SRGNamedScope) IsAssignable ¶
func (ns SRGNamedScope) IsAssignable() bool
IsAssignable returns whether the scoped node is assignable.
func (SRGNamedScope) IsFunction ¶ added in v0.2.0
func (ns SRGNamedScope) IsFunction() bool
IsFunction returns whether the named scope refers to a function.
func (SRGNamedScope) IsNamedScope ¶
func (ns SRGNamedScope) IsNamedScope() bool
IsNamedScope returns true if this is a named scope (always returns true).
func (SRGNamedScope) IsStatic ¶
func (ns SRGNamedScope) IsStatic() bool
IsStatic returns whether the scoped node is static.
func (SRGNamedScope) Name ¶
func (ns SRGNamedScope) Name() (string, bool)
Name returns the name of the scoped node.
func (SRGNamedScope) Node ¶
func (ns SRGNamedScope) Node() compilergraph.GraphNode
Node returns the underlying node.
func (SRGNamedScope) ResolveNameUnderScope ¶
func (ns SRGNamedScope) ResolveNameUnderScope(name string) (SRGScopeOrImport, bool)
ResolveNameUnderScope attempts to resolve the given name under this scope. Only applies to imports.
func (SRGNamedScope) ScopeKind ¶
func (ns SRGNamedScope) ScopeKind() NamedScopeKind
ScopeKind returns the kind of the scoped node.
func (SRGNamedScope) SourceRange ¶
func (ns SRGNamedScope) SourceRange() (compilercommon.SourceRange, bool)
SourceRange returns the range of the named scope in source, if any.
func (SRGNamedScope) Title ¶
func (ns SRGNamedScope) Title() string
Title returns a nice title for the given named scope.
type SRGPackageImport ¶
type SRGPackageImport struct { compilergraph.GraphNode // contains filtered or unexported fields }
SRGPackageImport represents the package under an import.
func (SRGPackageImport) Alias ¶
func (i SRGPackageImport) Alias() (string, bool)
Alias returns the local alias for this package import, if any.
func (SRGPackageImport) Code ¶
func (i SRGPackageImport) Code() (compilercommon.CodeSummary, bool)
Code returns a code-like summarization of the import, for human consumption.
func (SRGPackageImport) ResolveType ¶ added in v0.3.2
func (i SRGPackageImport) ResolveType() (TypeResolutionResult, bool)
ResolveType returns the resolved type of this import, if any.
func (SRGPackageImport) ResolvedTypeOrMember ¶
func (i SRGPackageImport) ResolvedTypeOrMember() (SRGTypeOrMember, bool)
ResolvedTypeOrMember returns the SRG type or member referenced by this import, if any.
func (SRGPackageImport) SourceRange ¶
func (i SRGPackageImport) SourceRange() (compilercommon.SourceRange, bool)
SourceRange returns the source range for this import.
func (SRGPackageImport) Subsource ¶
func (i SRGPackageImport) Subsource() (string, bool)
Subsource returns the subsource for this package import, if any.
type SRGParameter ¶
type SRGParameter struct { compilergraph.GraphNode // contains filtered or unexported fields }
SRGParameter represents a parameter on a function, constructor or operator.
func (SRGParameter) AsNamedScope ¶
func (p SRGParameter) AsNamedScope() SRGNamedScope
AsNamedScope returns the parameter as a named scope reference.
func (SRGParameter) Code ¶
func (p SRGParameter) Code() (compilercommon.CodeSummary, bool)
Code returns a code-like summarization of the parameter, for human consumption.
func (SRGParameter) DeclaredType ¶
func (p SRGParameter) DeclaredType() (SRGTypeRef, bool)
DeclaredType returns the declared type for this parameter, if any.
func (SRGParameter) Documentation ¶
func (p SRGParameter) Documentation() (SRGDocumentation, bool)
Documentation returns the documentation associated with this parameter, if any.
func (SRGParameter) Name ¶
func (p SRGParameter) Name() (string, bool)
Name returns the name of this parameter. May not exist in the partial-parsing case for tooling.
func (SRGParameter) Node ¶
func (p SRGParameter) Node() compilergraph.GraphNode
Node returns the underlying node.
func (SRGParameter) SourceRange ¶
func (p SRGParameter) SourceRange() (compilercommon.SourceRange, bool)
SourceRange returns the source range for this parameter.
type SRGScopeOrImport ¶
type SRGScopeOrImport interface { Name() (string, bool) IsNamedScope() bool // Whether this is a named scope. AsNamedScope() SRGNamedScope AsPackageImport() SRGExternalPackageImport }
SRGScopeOrImport represents a named scope or an external package import.
type SRGType ¶
type SRGType struct { compilergraph.GraphNode // contains filtered or unexported fields }
SRGType wraps a type declaration or definition in the SRG.
func (SRGType) AsNamedScope ¶
func (t SRGType) AsNamedScope() SRGNamedScope
AsNamedScope returns the type as a named scope reference.
func (SRGType) Code ¶
func (t SRGType) Code() (compilercommon.CodeSummary, bool)
Code returns a code-like summarization of the type, for human consumption.
func (SRGType) ComposedAgents ¶
func (t SRGType) ComposedAgents() []SRGComposedAgent
ComposedAgents returns references to the agents composed by this type, if any.
func (SRGType) Documentation ¶
func (t SRGType) Documentation() (SRGDocumentation, bool)
Documentation returns the documentation on the type, if any.
func (SRGType) FindMember ¶
FindMember returns the type member with the given name under this type, if any.
func (SRGType) FindOperator ¶
FindOperator returns the operator with the given name under this type, if any.
func (SRGType) Generics ¶
func (t SRGType) Generics() []SRGGeneric
Generics returns the generics on this type.
func (SRGType) GetMembers ¶
GetMembers returns the members on this type.
func (SRGType) HasComposedAgents ¶
HasComposedAgents returns true if this SRG type composes any agents.
func (SRGType) IsExported ¶ added in v0.2.0
IsExported returns whether the given type is exported for use outside its package.
func (SRGType) Name ¶
Name returns the name of this type. Can not exist in the partial-parsing case in tooling.
func (SRGType) Node ¶
func (t SRGType) Node() compilergraph.GraphNode
Node returns the underlying type node for this type.
func (SRGType) PrincipalType ¶
func (t SRGType) PrincipalType() (SRGTypeRef, bool)
PrincipalType returns a type reference to the principal type for this agent. Will only return a valid reference for AgentTypes.
func (SRGType) SourceRange ¶
func (t SRGType) SourceRange() (compilercommon.SourceRange, bool)
SourceRange returns the source range for this type.
func (SRGType) TypeKind ¶
GetTypeKind returns the kind matching the type definition/declaration node type.
func (SRGType) UniqueId ¶
UniqueId returns a unique hash ID for the node that is stable across compilations.
func (SRGType) WrappedType ¶
func (t SRGType) WrappedType() (SRGTypeRef, bool)
WrappedType returns a type reference to the wrapped type, if any. Will only return a valid reference for NominalTypes.
type SRGTypeOrGeneric ¶
type SRGTypeOrGeneric struct { compilergraph.GraphNode // contains filtered or unexported fields }
SRGTypeOrGeneric represents a resolved reference to a type or generic.
func (SRGTypeOrGeneric) AsType ¶
func (t SRGTypeOrGeneric) AsType() SRGType
AsType returns this type or generic as a type. Panics if not a type.
func (SRGTypeOrGeneric) IsGeneric ¶
func (t SRGTypeOrGeneric) IsGeneric() bool
IsGeneric returns whether this represents a reference to a generic.
func (SRGTypeOrGeneric) Name ¶
func (t SRGTypeOrGeneric) Name() (string, bool)
Name returns the name of the referenced type or generic.
func (SRGTypeOrGeneric) Node ¶
func (t SRGTypeOrGeneric) Node() compilergraph.GraphNode
Node returns the underlying node.
func (SRGTypeOrGeneric) SourceRange ¶
func (t SRGTypeOrGeneric) SourceRange() (compilercommon.SourceRange, bool)
SourceRange returns the source range for this resolved type or generic.
type SRGTypeOrMember ¶
type SRGTypeOrMember struct { compilergraph.GraphNode // contains filtered or unexported fields }
SRGTypeOrMember represents a resolved reference to a type or module member.
func (SRGTypeOrMember) AsMember ¶
func (t SRGTypeOrMember) AsMember() (SRGMember, bool)
AsMember returns the type or member as a member, if applicable.
func (SRGTypeOrMember) AsType ¶
func (t SRGTypeOrMember) AsType() (SRGType, bool)
AsType returns the type or member as a type, if applicable.
func (SRGTypeOrMember) ContainingModule ¶
func (t SRGTypeOrMember) ContainingModule() SRGModule
ContainingModule returns the module containing this type or member.
func (SRGTypeOrMember) Generics ¶
func (t SRGTypeOrMember) Generics() []SRGGeneric
Generics returns the generics of this type or member.
func (SRGTypeOrMember) IsType ¶
func (t SRGTypeOrMember) IsType() bool
IsType returns whether this represents a reference to a type.
func (SRGTypeOrMember) Name ¶
func (t SRGTypeOrMember) Name() (string, bool)
Name returns the name of the referenced type or member.
func (SRGTypeOrMember) Node ¶
func (t SRGTypeOrMember) Node() compilergraph.GraphNode
Node returns the underlying node.
func (SRGTypeOrMember) SourceRange ¶
func (t SRGTypeOrMember) SourceRange() (compilercommon.SourceRange, bool)
SourceRange returns the source range for this resolved type or member.
type SRGTypeRef ¶
type SRGTypeRef struct { compilergraph.GraphNode // contains filtered or unexported fields }
SRGTypeRef represents a type reference defined in the SRG.
func (SRGTypeRef) Generics ¶
func (t SRGTypeRef) Generics() []SRGTypeRef
Generics returns the generics defined on this type ref. Panics if this is not a RefKind of TypeRefPath.
func (SRGTypeRef) HasGenerics ¶
func (t SRGTypeRef) HasGenerics() bool
HasGenerics returns whether this type reference has generics.
func (SRGTypeRef) HasParameters ¶
func (t SRGTypeRef) HasParameters() bool
HasParameters returns whether this type reference has parameters.
func (SRGTypeRef) InnerReference ¶
func (t SRGTypeRef) InnerReference() (SRGTypeRef, bool)
InnerReference returns the inner type reference, if this is a nullable or stream.
func (SRGTypeRef) Parameters ¶
func (t SRGTypeRef) Parameters() []SRGTypeRef
Parameters returns the parameters defined on this type ref. Panics if this is not a RefKind of TypeRefPath.
func (SRGTypeRef) RefKind ¶
func (t SRGTypeRef) RefKind() TypeRefKind
RefKind returns the kind of this type reference.
func (SRGTypeRef) ResolutionName ¶
func (t SRGTypeRef) ResolutionName() string
ResolutionName returns the last piece of the ResolutionPath. Panics if this is not a RefKind of TypeRefPath.
func (SRGTypeRef) ResolutionPath ¶
func (t SRGTypeRef) ResolutionPath() string
ResolutionPath returns the full resolution path for this type reference. Panics if this is not a RefKind of TypeRefPath.
func (SRGTypeRef) ResolveType ¶
func (t SRGTypeRef) ResolveType() (TypeResolutionResult, bool)
ResolveType attempts to resolve the type path referenced by this type ref. Panics if this is not a RefKind of TypeRefPath.
func (SRGTypeRef) SourceRange ¶
func (t SRGTypeRef) SourceRange() (compilercommon.SourceRange, bool)
SourceRange returns the source range for this type ref.
func (SRGTypeRef) String ¶
func (t SRGTypeRef) String() string
String returns the human-readable string form of this type reference.
type SourceStructureFinder ¶
type SourceStructureFinder struct {
// contains filtered or unexported fields
}
SourceStructureFinder defines a helper type for looking up various structure within the source represented by an SRG.
func (*SourceStructureFinder) ScopeInContext ¶
func (f *SourceStructureFinder) ScopeInContext(node compilergraph.GraphNode) []SRGContextScopeName
ScopeInContext returns all the named scope thats available in the context as defined by the given SRG node.
func (*SourceStructureFinder) TryGetContainingImplemented ¶
func (f *SourceStructureFinder) TryGetContainingImplemented(node compilergraph.GraphNode) (SRGImplementable, bool)
TryGetContainingImplemented returns the member, property or function lambda node that contains the given node, if any.
func (*SourceStructureFinder) TryGetContainingImplementedWithOption ¶
func (f *SourceStructureFinder) TryGetContainingImplementedWithOption(node compilergraph.GraphNode, option ContainingImplementedOption) (SRGImplementable, bool)
TryGetContainingImplementedWithOption returns the containing implemented of the given node with the given option, if any.
func (*SourceStructureFinder) TryGetContainingMemberOrType ¶
func (f *SourceStructureFinder) TryGetContainingMemberOrType(node compilergraph.GraphNode) (SRGTypeOrMember, bool)
TryGetContainingMemberOrType returns the member or type that contains the given node, if any.
func (*SourceStructureFinder) TryGetContainingModule ¶
func (f *SourceStructureFinder) TryGetContainingModule(node compilergraph.GraphNode) (SRGModule, bool)
TryGetContainingModule returns the containing module of the given SRG node, if any.
func (*SourceStructureFinder) TryGetContainingNode ¶
func (f *SourceStructureFinder) TryGetContainingNode(node compilergraph.GraphNode, nodeTypes ...sourceshape.NodeType) (compilergraph.GraphNode, bool)
TryGetContainingNode returns the containing node of the given node that is one of the given types, if any.
func (*SourceStructureFinder) TryGetContainingType ¶
func (f *SourceStructureFinder) TryGetContainingType(node compilergraph.GraphNode) (SRGType, bool)
TryGetContainingType returns the type that contains the given node, if any.
func (*SourceStructureFinder) TryGetNearestContainingNode ¶
func (f *SourceStructureFinder) TryGetNearestContainingNode(node compilergraph.GraphNode, nodeTypes ...sourceshape.NodeType) (compilergraph.GraphNode, bool)
TryGetNearestContainingNode returns the containing node of the given node that is one of the given types, if any. If there are multiple such nodes, the node which is closest (by rune position) is returned.
type TypeRefKind ¶
type TypeRefKind int
const ( TypeRefNullable TypeRefKind // A nullable type. TypeRefStream // A stream type. TypeRefSlice // A slice type. TypeRefMapping // A mapping type. TypeRefPath // A normal path type. May have generics. TypeRefVoid // A void type reference. TypeRefStruct // A struct type reference. TypeRefAny // An any type reference. )
type TypeResolutionResult ¶
type TypeResolutionResult struct { // IsExternalPackage returns whether the resolved type is, in fact, an external package. IsExternalPackage bool ResolvedType SRGTypeOrGeneric ExternalPackage packageloader.PackageInfo ExternalPackageTypePath string }
TypeResolutionResult defines the result of resolving a type or package.
Source Files ¶
- agents.go
- ast_node.go
- comments.go
- entrypoints.go
- generics.go
- implementable.go
- imports.go
- memberkind_string.go
- members.go
- modules.go
- modules_typeresolver.go
- namedscopekind_string.go
- names.go
- nodetypes.go
- packages.go
- parameters.go
- parsing.go
- scopename.go
- sourcehandler.go
- srg.go
- srg_query.go
- structure.go
- testutil.go
- typekind_string.go
- typeorgeneric.go
- typeormember.go
- typeref.go
- types.go
- util.go