Documentation
¶
Index ¶
- func ComputeLineOfPosition(lineStarts []core.TextPos, pos int) int
- func ComputePositionOfLineAndByteOffset(lineStarts []core.TextPos, line int, byteOffset int) int
- func ComputePositionOfLineAndUTF16Character(lineStarts []core.TextPos, line int, character core.UTF16Offset, text string, ...) int
- func DeclarationNameToString(name *ast.Node) string
- func GetECMAEndLinePosition(sourceFile *ast.SourceFile, line int) int
- func GetECMALineAndByteOffsetOfPosition(sourceFile ast.SourceFileLike, pos int) (line int, byteOffset int)
- func GetECMALineAndUTF16CharacterOfPosition(sourceFile ast.SourceFileLike, pos int) (line int, character core.UTF16Offset)
- func GetECMALineOfPosition(sourceFile ast.SourceFileLike, pos int) int
- func GetECMALineStarts(sourceFile ast.SourceFileLike) []core.TextPos
- func GetECMAPositionOfLineAndByteOffset(sourceFile ast.SourceFileLike, line int, byteOffset int) int
- func GetECMAPositionOfLineAndUTF16Character(sourceFile ast.SourceFileLike, line int, character core.UTF16Offset) int
- func GetErrorRangeForNode(sourceFile *ast.SourceFile, node *ast.Node) core.TextRange
- func GetIdentifierToken(str string) ast.Kind
- func GetLeadingCommentRanges(f *ast.NodeFactory, text string, pos int) iter.Seq[ast.CommentRange]
- func GetRangeOfTokenAtPosition(sourceFile *ast.SourceFile, pos int) core.TextRange
- func GetShebang(text string) string
- func GetSourceTextOfNodeFromSourceFile(sourceFile *ast.SourceFile, node *ast.Node, includeTrivia bool) string
- func GetTextOfNode(node *ast.Node) string
- func GetTextOfNodeFromSourceText(sourceText string, node *ast.Node, includeTrivia bool) string
- func GetTokenPosOfNode(node *ast.Node, sourceFile *ast.SourceFile, includeJSDoc bool) int
- func GetTrailingCommentRanges(f *ast.NodeFactory, text string, pos int) iter.Seq[ast.CommentRange]
- func GetViableKeywordSuggestions() []string
- func IdentifierToKeywordKind(node *ast.Identifier) ast.Kind
- func IsIdentifierPart(ch rune) bool
- func IsIdentifierPartEx(ch rune, languageVariant core.LanguageVariant) bool
- func IsIdentifierStart(ch rune) bool
- func IsIdentifierText(name string, languageVariant core.LanguageVariant) bool
- func IsIntrinsicJsxName(name string) bool
- func IsValidIdentifier(s string) bool
- func ScanTokenAtPosition(sourceFile *ast.SourceFile, pos int) ast.Kind
- func SkipTrivia(text string, pos int) int
- func SkipTriviaEx(text string, pos int, options *SkipTriviaOptions) int
- func StringToToken(s string) ast.Kind
- func TokenToString(token ast.Kind) string
- type ErrorCallback
- type EscapeSequenceScanningFlags
- type Scanner
- func (s *Scanner) CommentDirectives() []ast.CommentDirective
- func (s *Scanner) HasExtendedUnicodeEscape() bool
- func (s *Scanner) HasPrecedingJSDocComment() bool
- func (s *Scanner) HasPrecedingJSDocLeadingAsterisks() bool
- func (s *Scanner) HasPrecedingJSDocWithDeprecatedTag() bool
- func (s *Scanner) HasPrecedingJSDocWithSeeOrLink() bool
- func (s *Scanner) HasPrecedingLineBreak() bool
- func (s *Scanner) HasUnicodeEscape() bool
- func (s *Scanner) Mark() ScannerState
- func (s *Scanner) ReScanAsteriskEqualsToken() ast.Kind
- func (s *Scanner) ReScanGreaterThanToken() ast.Kind
- func (s *Scanner) ReScanHashToken() ast.Kind
- func (s *Scanner) ReScanJsxAttributeValue() ast.Kind
- func (s *Scanner) ReScanJsxToken(allowMultilineJsxText bool) ast.Kind
- func (s *Scanner) ReScanLessThanToken() ast.Kind
- func (s *Scanner) ReScanQuestionToken() ast.Kind
- func (s *Scanner) ReScanSlashToken() ast.Kind
- func (s *Scanner) ReScanTemplateToken(isTaggedTemplate bool) ast.Kind
- func (s *Scanner) Reset()
- func (s *Scanner) ResetPos(pos int)
- func (s *Scanner) ResetTokenState(pos int)
- func (s *Scanner) Rewind(state ScannerState)
- func (s *Scanner) Scan() ast.Kind
- func (s *Scanner) ScanJSDocCommentTextToken(inBackticks bool) ast.Kind
- func (s *Scanner) ScanJSDocToken() ast.Kind
- func (s *Scanner) ScanJsxAttributeValue() ast.Kind
- func (s *Scanner) ScanJsxIdentifier() ast.Kind
- func (s *Scanner) ScanJsxToken() ast.Kind
- func (s *Scanner) ScanJsxTokenEx(allowMultilineJsxText bool) ast.Kind
- func (s *Scanner) SetLanguageVariant(languageVariant core.LanguageVariant)
- func (s *Scanner) SetOnError(errorCallback ErrorCallback)
- func (s *Scanner) SetScriptKind(scriptKind core.ScriptKind)
- func (scanner *Scanner) SetSkipJSDocLeadingAsterisks(skip bool)
- func (scanner *Scanner) SetSkipTrivia(skip bool)
- func (s *Scanner) SetText(text string)
- func (s *Scanner) Text() string
- func (s *Scanner) Token() ast.Kind
- func (s *Scanner) TokenEnd() int
- func (s *Scanner) TokenFlags() ast.TokenFlags
- func (s *Scanner) TokenFullStart() int
- func (s *Scanner) TokenRange() core.TextRange
- func (s *Scanner) TokenStart() int
- func (s *Scanner) TokenText() string
- func (s *Scanner) TokenValue() string
- type ScannerState
- type SkipTriviaOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputePositionOfLineAndByteOffset ¶
ComputePositionOfLineAndByteOffset computes a byte position from a line and raw byte offset from the line start. This is a simple addition with validation.
func ComputePositionOfLineAndUTF16Character ¶
func ComputePositionOfLineAndUTF16Character(lineStarts []core.TextPos, line int, character core.UTF16Offset, text string, allowEdits bool) int
ComputePositionOfLineAndUTF16Character converts a line and UTF-16 character offset back to a byte position. The character parameter is measured in UTF-16 code units. It scans from the line start to correctly handle multi-byte characters. When allowEdits is true, out-of-range values are clamped instead of panicking.
func DeclarationNameToString ¶
func GetECMAEndLinePosition ¶
func GetECMAEndLinePosition(sourceFile *ast.SourceFile, line int) int
func GetECMALineAndByteOffsetOfPosition ¶
func GetECMALineAndByteOffsetOfPosition(sourceFile ast.SourceFileLike, pos int) (line int, byteOffset int)
GetECMALineAndByteOffsetOfPosition returns the 0-based line number and the raw UTF-8 byte offset from the start of that line for the given byte position. Uses ECMAScript line separators (LF, CR, CRLF, LS, PS). Unlike GetECMALineAndUTF16CharacterOfPosition, the offset is in bytes, not UTF-16 code units.
func GetECMALineAndUTF16CharacterOfPosition ¶
func GetECMALineAndUTF16CharacterOfPosition(sourceFile ast.SourceFileLike, pos int) (line int, character core.UTF16Offset)
GetECMALineAndUTF16CharacterOfPosition returns the 0-based line number and the UTF-16 code unit offset from the start of that line for the given byte position. Uses ECMAScript line separators (LF, CR, CRLF, LS, PS).
func GetECMALineOfPosition ¶
func GetECMALineOfPosition(sourceFile ast.SourceFileLike, pos int) int
func GetECMALineStarts ¶
func GetECMALineStarts(sourceFile ast.SourceFileLike) []core.TextPos
func GetECMAPositionOfLineAndByteOffset ¶
func GetECMAPositionOfLineAndByteOffset(sourceFile ast.SourceFileLike, line int, byteOffset int) int
GetECMAPositionOfLineAndByteOffset converts a 0-based line number and byte offset from line start back to an absolute byte position in the source text. Uses ECMAScript line separators.
func GetECMAPositionOfLineAndUTF16Character ¶
func GetECMAPositionOfLineAndUTF16Character(sourceFile ast.SourceFileLike, line int, character core.UTF16Offset) int
GetECMAPositionOfLineAndUTF16Character converts a 0-based line number and UTF-16 code unit character offset back to an absolute byte position in the source text. Uses ECMAScript line separators.
func GetErrorRangeForNode ¶
func GetIdentifierToken ¶
func GetLeadingCommentRanges ¶
func GetLeadingCommentRanges(f *ast.NodeFactory, text string, pos int) iter.Seq[ast.CommentRange]
func GetRangeOfTokenAtPosition ¶
func GetRangeOfTokenAtPosition(sourceFile *ast.SourceFile, pos int) core.TextRange
func GetShebang ¶
func GetTextOfNode ¶
func GetTokenPosOfNode ¶
func GetTrailingCommentRanges ¶
func GetTrailingCommentRanges(f *ast.NodeFactory, text string, pos int) iter.Seq[ast.CommentRange]
func GetViableKeywordSuggestions ¶
func GetViableKeywordSuggestions() []string
func IdentifierToKeywordKind ¶
func IdentifierToKeywordKind(node *ast.Identifier) ast.Kind
func IsIdentifierPart ¶
func IsIdentifierPartEx ¶
func IsIdentifierPartEx(ch rune, languageVariant core.LanguageVariant) bool
func IsIdentifierStart ¶
func IsIdentifierText ¶
func IsIdentifierText(name string, languageVariant core.LanguageVariant) bool
func IsIntrinsicJsxName ¶
func IsValidIdentifier ¶
func ScanTokenAtPosition ¶
func ScanTokenAtPosition(sourceFile *ast.SourceFile, pos int) ast.Kind
func SkipTrivia ¶
func SkipTriviaEx ¶
func SkipTriviaEx(text string, pos int, options *SkipTriviaOptions) int
func StringToToken ¶
func TokenToString ¶
Types ¶
type ErrorCallback ¶
type ErrorCallback func(diagnostic *diagnostics.Message, start, length int, args ...any)
type EscapeSequenceScanningFlags ¶
type EscapeSequenceScanningFlags int32
const ( EscapeSequenceScanningFlagsString EscapeSequenceScanningFlags = 1 << 0 EscapeSequenceScanningFlagsReportErrors EscapeSequenceScanningFlags = 1 << 1 EscapeSequenceScanningFlagsRegularExpression EscapeSequenceScanningFlags = 1 << 2 EscapeSequenceScanningFlagsAnnexB EscapeSequenceScanningFlags = 1 << 3 EscapeSequenceScanningFlagsAnyUnicodeMode EscapeSequenceScanningFlags = 1 << 4 EscapeSequenceScanningFlagsAtomEscape EscapeSequenceScanningFlags = 1 << 5 EscapeSequenceScanningFlagsReportInvalidEscapeErrors EscapeSequenceScanningFlags = EscapeSequenceScanningFlagsRegularExpression | EscapeSequenceScanningFlagsReportErrors EscapeSequenceScanningFlagsAllowExtendedUnicodeEscape EscapeSequenceScanningFlags = EscapeSequenceScanningFlagsString | EscapeSequenceScanningFlagsAnyUnicodeMode )
type Scanner ¶
type Scanner struct {
ScannerState
// contains filtered or unexported fields
}
func GetScannerForSourceFile ¶
func GetScannerForSourceFile(sourceFile *ast.SourceFile, pos int) *Scanner
func NewScanner ¶
func NewScanner() *Scanner
func (*Scanner) CommentDirectives ¶
func (s *Scanner) CommentDirectives() []ast.CommentDirective
func (*Scanner) HasExtendedUnicodeEscape ¶
func (*Scanner) HasPrecedingJSDocComment ¶
func (*Scanner) HasPrecedingJSDocLeadingAsterisks ¶
func (*Scanner) HasPrecedingJSDocWithDeprecatedTag ¶
func (*Scanner) HasPrecedingJSDocWithSeeOrLink ¶
func (*Scanner) HasPrecedingLineBreak ¶
func (*Scanner) HasUnicodeEscape ¶
func (*Scanner) Mark ¶
func (s *Scanner) Mark() ScannerState
func (*Scanner) ReScanAsteriskEqualsToken ¶
func (*Scanner) ReScanGreaterThanToken ¶
func (*Scanner) ReScanHashToken ¶
func (*Scanner) ReScanJsxAttributeValue ¶
func (*Scanner) ReScanJsxToken ¶
func (*Scanner) ReScanLessThanToken ¶
func (*Scanner) ReScanQuestionToken ¶
func (*Scanner) ReScanSlashToken ¶
func (*Scanner) ReScanTemplateToken ¶
func (*Scanner) ResetTokenState ¶
func (*Scanner) Rewind ¶
func (s *Scanner) Rewind(state ScannerState)
func (*Scanner) ScanJSDocCommentTextToken ¶
* In addition to the usual JSDoc ast.Kinds, can also return ast.KindJSDocCommentTextToken
func (*Scanner) ScanJSDocToken ¶
func (*Scanner) ScanJsxAttributeValue ¶
func (*Scanner) ScanJsxIdentifier ¶
Scans a JSX identifier; these differ from normal identifiers in that they allow dashes
func (*Scanner) ScanJsxToken ¶
func (*Scanner) ScanJsxTokenEx ¶
func (*Scanner) SetLanguageVariant ¶
func (s *Scanner) SetLanguageVariant(languageVariant core.LanguageVariant)
func (*Scanner) SetOnError ¶
func (s *Scanner) SetOnError(errorCallback ErrorCallback)
func (*Scanner) SetScriptKind ¶
func (s *Scanner) SetScriptKind(scriptKind core.ScriptKind)
func (*Scanner) SetSkipJSDocLeadingAsterisks ¶
func (*Scanner) SetSkipTrivia ¶
func (*Scanner) TokenFlags ¶
func (s *Scanner) TokenFlags() ast.TokenFlags
func (*Scanner) TokenFullStart ¶
func (*Scanner) TokenRange ¶
func (*Scanner) TokenStart ¶
func (*Scanner) TokenValue ¶
type ScannerState ¶
type ScannerState struct {
// contains filtered or unexported fields
}