modulespecifiers

package
v0.0.0-...-54f5941 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountPathComponents

func CountPathComponents(path string) int

func GetModuleSpecifiers

func GetModuleSpecifiers(
	moduleSymbol *ast.Symbol,
	checker CheckerShape,
	compilerOptions *core.CompilerOptions,
	importingSourceFile SourceFileForSpecifierGeneration,
	host ModuleSpecifierGenerationHost,
	userPreferences UserPreferences,
	options ModuleSpecifierOptions,
) []string

Types

type CheckerShape

type CheckerShape interface {
	GetSymbolAtLocation(node *ast.Node) *ast.Symbol
	GetAliasedSymbol(symbol *ast.Symbol) *ast.Symbol
}

type ImportModuleSpecifierEndingPreference

type ImportModuleSpecifierEndingPreference string
const (
	ImportModuleSpecifierEndingPreferenceNone    ImportModuleSpecifierEndingPreference = ""
	ImportModuleSpecifierEndingPreferenceAuto    ImportModuleSpecifierEndingPreference = "auto"
	ImportModuleSpecifierEndingPreferenceMinimal ImportModuleSpecifierEndingPreference = "minimal"
	ImportModuleSpecifierEndingPreferenceIndex   ImportModuleSpecifierEndingPreference = "index"
	ImportModuleSpecifierEndingPreferenceJs      ImportModuleSpecifierEndingPreference = "js"
)

type ImportModuleSpecifierPreference

type ImportModuleSpecifierPreference string
const (
	ImportModuleSpecifierPreferenceNone            ImportModuleSpecifierPreference = ""
	ImportModuleSpecifierPreferenceShortest        ImportModuleSpecifierPreference = "shortest"
	ImportModuleSpecifierPreferenceProjectRelative ImportModuleSpecifierPreference = "project-relative"
	ImportModuleSpecifierPreferenceRelative        ImportModuleSpecifierPreference = "relative"
	ImportModuleSpecifierPreferenceNonRelative     ImportModuleSpecifierPreference = "non-relative"
)

type Info

type Info struct {
	UseCaseSensitiveFileNames bool
	ImportingSourceFileName   string
	SourceDirectory           string
}

type MatchingMode

type MatchingMode uint8
const (
	MatchingModeExact MatchingMode = iota
	MatchingModeDirectory
	MatchingModePattern
)

type ModulePath

type ModulePath struct {
	FileName        string
	IsInNodeModules bool
	IsRedirect      bool
}

type ModuleSpecifierEnding

type ModuleSpecifierEnding uint8
const (
	ModuleSpecifierEndingMinimal ModuleSpecifierEnding = iota
	ModuleSpecifierEndingIndex
	ModuleSpecifierEndingJsExtension
	ModuleSpecifierEndingTsExtension
)

type ModuleSpecifierGenerationHost

type ModuleSpecifierGenerationHost interface {
	// GetModuleResolutionCache() any // !!! TODO: adapt new resolution cache model
	// GetSymlinkCache() any // !!! TODO: adapt new resolution cache model
	// GetFileIncludeReasons() any // !!! TODO: adapt new resolution cache model
	CommonSourceDirectory() string
	GetGlobalTypingsCacheLocation() string
	UseCaseSensitiveFileNames() bool
	GetCurrentDirectory() string

	GetOutputAndProjectReference(path tspath.Path) *tsoptions.OutputDtsAndProjectReference
	GetRedirectTargets(path tspath.Path) []string

	FileExists(path string) bool

	GetNearestAncestorDirectoryWithPackageJson(dirname string) string
	GetPackageJsonInfo(pkgJsonPath string) PackageJsonInfo
	GetDefaultResolutionModeForFile(file ast.HasFileName) core.ResolutionMode
	GetResolvedModuleFromModuleSpecifier(file ast.HasFileName, moduleSpecifier *ast.StringLiteralLike) *module.ResolvedModule
	GetModeForUsageLocation(file ast.HasFileName, moduleSpecifier *ast.StringLiteralLike) core.ResolutionMode
}

type ModuleSpecifierOptions

type ModuleSpecifierOptions struct {
	OverrideImportMode core.ResolutionMode
}

type ModuleSpecifierPreferences

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

type NodeModulePathParts

type NodeModulePathParts struct {
	TopLevelNodeModulesIndex int
	TopLevelPackageNameIndex int
	PackageRootIndex         int
	FileNameIndex            int
}

type PackageJsonInfo

type PackageJsonInfo interface {
	GetDirectory() string
	GetContents() *packagejson.PackageJson
}

type RelativePreferenceKind

type RelativePreferenceKind uint8
const (
	RelativePreferenceRelative RelativePreferenceKind = iota
	RelativePreferenceNonRelative
	RelativePreferenceShortest
	RelativePreferenceExternalNonRelative
)

type ResultKind

type ResultKind uint8
const (
	ResultKindNone ResultKind = iota
	ResultKindNodeModules
	ResultKindPaths
	ResultKindRedirect
	ResultKindRelative
	ResultKindAmbient
)

type SourceFileForSpecifierGeneration

type SourceFileForSpecifierGeneration interface {
	Path() tspath.Path
	FileName() string
	OriginalFileName() string
	Imports() []*ast.StringLiteralLike
	IsJS() bool
}

type UserPreferences

type UserPreferences struct {
	ImportModuleSpecifierPreference       ImportModuleSpecifierPreference
	ImportModuleSpecifierEndingPreference ImportModuleSpecifierEndingPreference
	AutoImportSpecifierExcludeRegexes     []string
}

Jump to

Keyboard shortcuts

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