Documentation
¶
Overview ¶
Package astimport can be used to import Nodes manually into an AST.
This is useful when an AST should be created manually.
Index ¶
- type Importer
- func (i *Importer) ImportArgument(ref int, from, to *ast.Document) int
- func (i *Importer) ImportArguments(refs []int, from, to *ast.Document) []int
- func (i *Importer) ImportDescription(description ast.Description, from, to *ast.Document) ast.Description
- func (i *Importer) ImportDirective(ref int, from, to *ast.Document) int
- func (i *Importer) ImportDirectiveWithRename(ref int, renameTo string, from, to *ast.Document) int
- func (i *Importer) ImportField(ref int, from, to *ast.Document) int
- func (i *Importer) ImportListValues(ref int, from, to *ast.Document) (refs []int)
- func (i *Importer) ImportObjectFields(ref int, from, to *ast.Document) (refs []int)
- func (i *Importer) ImportSelectionSet(ref int, from, to *ast.Document) (int, error)
- func (i *Importer) ImportSelectionSetWithVariableRename(ref int, from, to *ast.Document, rename map[string]string) (int, error)
- func (i *Importer) ImportType(ref int, from, to *ast.Document) int
- func (i *Importer) ImportTypeWithRename(ref int, from, to *ast.Document, renameTo string) int
- func (i *Importer) ImportValue(fromValue ast.Value, from, to *ast.Document) (value ast.Value)
- func (i *Importer) ImportVariableDefinition(ref int, from, to *ast.Document) int
- func (i *Importer) ImportVariableDefinitionWithRename(ref int, from, to *ast.Document, renameTo string) int
- func (i *Importer) ImportVariableDefinitionWithVariableNameRename(ref int, from, to *ast.Document, newName string) int
- func (i *Importer) ImportVariableDefinitions(refs []int, from, to *ast.Document) []int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Importer ¶
type Importer struct {
}
Importer imports Nodes into an existing AST. Always use NewImporter() to create a new Importer.
func (*Importer) ImportArgument ¶
func (*Importer) ImportArguments ¶
func (*Importer) ImportDescription ¶ added in v2.2.0
func (i *Importer) ImportDescription(description ast.Description, from, to *ast.Document) ast.Description
ImportDescription copies a description from one document into another while preserving the original byte content, the block-string flag, and whether the description was defined. It does not go through Document.ImportDescription because that helper takes a plain string and guesses the block-string flag from the text, which would silently change a single-line block string like """foo""" into a regular "foo" on its way across.
func (*Importer) ImportDirective ¶
func (*Importer) ImportDirectiveWithRename ¶
func (*Importer) ImportListValues ¶
func (*Importer) ImportObjectFields ¶
func (*Importer) ImportSelectionSet ¶ added in v2.16.0
ImportSelectionSet deep-copies a selection set across documents. It is a thin wrapper over ImportSelectionSetWithVariableRename with a nil rename map.
func (*Importer) ImportSelectionSetWithVariableRename ¶ added in v2.16.0
func (i *Importer) ImportSelectionSetWithVariableRename(ref int, from, to *ast.Document, rename map[string]string) (int, error)
ImportSelectionSetWithVariableRename deep-copies a selection set across documents, applying rename to every variable occurrence in argument and directive values (a nil map keeps names verbatim). Fields carry name, alias, arguments, directives and nested sets; inline fragments carry the type condition, directives and nested sets. Fragment spreads are unsupported and return an error.
func (*Importer) ImportTypeWithRename ¶
func (*Importer) ImportValue ¶
func (*Importer) ImportVariableDefinition ¶
func (*Importer) ImportVariableDefinitionWithRename ¶
func (*Importer) ImportVariableDefinitionWithVariableNameRename ¶ added in v2.16.0
func (i *Importer) ImportVariableDefinitionWithVariableNameRename(ref int, from, to *ast.Document, newName string) int
ImportVariableDefinitionWithVariableNameRename imports a variable definition while writing newName as the variable value name. The type is imported unchanged (unlike ImportVariableDefinitionWithRename, which renames the type).