compiler

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package compiler implements the TypeScript compiler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortAndDeduplicateDiagnostics

func SortAndDeduplicateDiagnostics(diagnostics []*ast.Diagnostic) []*ast.Diagnostic

Types

type CompilerHost

type CompilerHost interface {
	FS() vfs.FS
	DefaultLibraryPath() string
	GetCurrentDirectory() string
	NewLine() string
	Trace(msg string)
	GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget) *ast.SourceFile
}

func NewCompilerHost

func NewCompilerHost(options *core.CompilerOptions, currentDirectory string, fs vfs.FS, defaultLibraryPath string) CompilerHost

type EmitHost

type EmitHost interface {
	Options() *core.CompilerOptions
	SourceFiles() []*ast.SourceFile
	UseCaseSensitiveFileNames() bool
	GetCurrentDirectory() string
	CommonSourceDirectory() string
	IsEmitBlocked(file string) bool
	WriteFile(fileName string, text string, writeByteOrderMark bool, relatedSourceFiles []*ast.SourceFile, data *WriteFileData) error
	GetEmitResolver(file *ast.SourceFile, skipDiagnostics bool) printer.EmitResolver
}

NOTE: EmitHost operations must be thread-safe

type EmitOptions

type EmitOptions struct {
	TargetSourceFile *ast.SourceFile // Single file to emit. If `nil`, emits all files
	// contains filtered or unexported fields
}

type EmitResult

type EmitResult struct {
	EmitSkipped  bool
	Diagnostics  []*ast.Diagnostic // Contains declaration emit diagnostics
	EmittedFiles []string          // Array of files the compiler wrote to disk
	// contains filtered or unexported fields
}

type FileIncludeKind

type FileIncludeKind int
const (
	FileIncludeKindRootFile FileIncludeKind = iota
	FileIncludeKindSourceFromProjectReference
	FileIncludeKindOutputFromProjectReference
	FileIncludeKindImport
	FileIncludeKindReferenceFile
	FileIncludeKindTypeReferenceDirective
	FileIncludeKindLibFile
	FileIncludeKindLibReferenceDirective
	FileIncludeKindAutomaticTypeDirectiveFile
)

type FileIncludeReason

type FileIncludeReason struct {
	Kind  FileIncludeKind
	Index int
}

type FileInfo

type FileInfo struct {
	Name string
	Size int64
}

type Program

type Program struct {
	// contains filtered or unexported fields
}

func NewProgram

func NewProgram(options ProgramOptions) *Program

func NewProgramFromParsedCommandLine

func NewProgramFromParsedCommandLine(config *tsoptions.ParsedCommandLine, host CompilerHost) *Program

func (*Program) BindSourceFiles

func (p *Program) BindSourceFiles()

func (*Program) CheckSourceFiles

func (p *Program) CheckSourceFiles()

func (*Program) CommonSourceDirectory

func (p *Program) CommonSourceDirectory() string

func (*Program) Emit

func (p *Program) Emit(options *EmitOptions) *EmitResult

func (*Program) GetBindDiagnostics

func (p *Program) GetBindDiagnostics(sourceFile *ast.SourceFile) []*ast.Diagnostic

func (*Program) GetCompilerOptions

func (p *Program) GetCompilerOptions() *core.CompilerOptions

func (*Program) GetConfigFileParsingDiagnostics

func (p *Program) GetConfigFileParsingDiagnostics() []*ast.Diagnostic

func (*Program) GetEmitModuleFormatOfFile

func (p *Program) GetEmitModuleFormatOfFile(sourceFile *ast.SourceFile) core.ModuleKind

func (*Program) GetEmitModuleFormatOfFileWorker

func (p *Program) GetEmitModuleFormatOfFileWorker(sourceFile *ast.SourceFile, options *core.CompilerOptions) core.ModuleKind

func (*Program) GetGlobalDiagnostics

func (p *Program) GetGlobalDiagnostics() []*ast.Diagnostic

func (*Program) GetImpliedNodeFormatForEmit

func (p *Program) GetImpliedNodeFormatForEmit(sourceFile *ast.SourceFile) core.ResolutionMode

func (*Program) GetOptionsDiagnostics

func (p *Program) GetOptionsDiagnostics() []*ast.Diagnostic

func (*Program) GetResolvedModule

func (p *Program) GetResolvedModule(file *ast.SourceFile, moduleReference string) *ast.SourceFile

func (*Program) GetSemanticDiagnostics

func (p *Program) GetSemanticDiagnostics(sourceFile *ast.SourceFile) []*ast.Diagnostic

func (*Program) GetSourceFile

func (p *Program) GetSourceFile(filename string) *ast.SourceFile

func (*Program) GetSourceFileByPath

func (p *Program) GetSourceFileByPath(path tspath.Path) *ast.SourceFile

func (*Program) GetSourceFiles

func (p *Program) GetSourceFiles() []*ast.SourceFile

func (*Program) GetSyntacticDiagnostics

func (p *Program) GetSyntacticDiagnostics(sourceFile *ast.SourceFile) []*ast.Diagnostic

func (*Program) GetTypeChecker

func (p *Program) GetTypeChecker() *checker.Checker

Return the type checker associated with the program.

func (*Program) GetTypeCheckerForFile

func (p *Program) GetTypeCheckerForFile(file *ast.SourceFile) *checker.Checker

Return a checker for the given file. We may have multiple checkers in concurrent scenarios and this method returns the checker that was tasked with checking the file. Note that it isn't possible to mix types obtained from different checkers, so only non-type data (such as diagnostics or string representations of types) should be obtained from checkers returned by this method.

func (*Program) Host

func (p *Program) Host() CompilerHost

func (*Program) Options

func (p *Program) Options() *core.CompilerOptions

func (*Program) PrintSourceFileWithTypes

func (p *Program) PrintSourceFileWithTypes()

func (*Program) SourceFiles

func (p *Program) SourceFiles() []*ast.SourceFile

func (*Program) TypeCount

func (p *Program) TypeCount() int

type ProgramOptions

type ProgramOptions struct {
	ConfigFileName               string
	RootFiles                    []string
	Host                         CompilerHost
	Options                      *core.CompilerOptions
	SingleThreaded               bool
	ProjectReference             []core.ProjectReference
	ConfigFileParsingDiagnostics []*ast.Diagnostic
}

type WriteFileData

type WriteFileData struct {
	SourceMapUrlPos int
	// BuildInfo BuildInfo
	Diagnostics      []*ast.Diagnostic
	DiffersOnlyInMap bool
	SkippedDtsWrite  bool
}

Directories

Path Synopsis
Package diagnostics contains generated localizable diagnostic messages.
Package diagnostics contains generated localizable diagnostic messages.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL