package rename
This commit is contained in:
parent
2a07ce848a
commit
ee0bbb059a
@ -1,3 +1,3 @@
|
||||
module efprojects.com/kitten-ipc/example/simple
|
||||
module github.com/egor3f/kitten-ipc/example/simple
|
||||
|
||||
go 1.25.1
|
||||
|
||||
@ -9,7 +9,7 @@ import (
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
kittenipc "efprojects.com/kitten-ipc"
|
||||
kittenipc "github.com/egor3f/kitten-ipc"
|
||||
)
|
||||
|
||||
// kittenipc:api
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
kittenipc "efprojects.com/kitten-ipc"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
kittenipc "github.com/egor3f/kitten-ipc"
|
||||
)
|
||||
|
||||
var _ = base64.StdEncoding
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
|
||||
SHELL := /bin/bash
|
||||
tsgo_dir = ./internal/tsgo
|
||||
my_package = efprojects.com/kitten-ipc/kitcom/internal/tsgo
|
||||
my_package = github.com/egor3f/kitten-ipc/kitcom/internal/tsgo
|
||||
|
||||
|
||||
default:
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
module efprojects.com/kitten-ipc/kitcom
|
||||
module github.com/egor3f/kitten-ipc/kitcom
|
||||
|
||||
go 1.25.1
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ package common
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/api"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/api"
|
||||
)
|
||||
|
||||
type Parser struct {
|
||||
|
||||
@ -9,8 +9,8 @@ import (
|
||||
|
||||
_ "embed"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/api"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/common"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/api"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/common"
|
||||
)
|
||||
|
||||
//go:embed gogen.tmpl
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{{- /*gotype: efprojects.com/kitten-ipc/kitcom/internal/golang.goGenData*/ -}}
|
||||
{{- /*gotype: github.com/egor3f/kitten-ipc/kitcom/internal/golang.goGenData*/ -}}
|
||||
|
||||
// Code generated by kitcom. DO NOT EDIT.
|
||||
|
||||
@ -6,7 +6,7 @@ package {{ .PkgName }}
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
kittenipc "efprojects.com/kitten-ipc"
|
||||
kittenipc "github.com/egor3f/kitten-ipc"
|
||||
"encoding/base64"
|
||||
)
|
||||
|
||||
|
||||
@ -7,8 +7,8 @@ import (
|
||||
"go/token"
|
||||
"regexp"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/api"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/common"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/api"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/common"
|
||||
)
|
||||
|
||||
var decorComment = regexp.MustCompile(`^//\s?kittenipc:api$`)
|
||||
|
||||
@ -3,8 +3,8 @@ package golang
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/api"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/common"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/api"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/common"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@ -9,8 +9,8 @@ import (
|
||||
|
||||
_ "embed"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/api"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/common"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/api"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/common"
|
||||
)
|
||||
|
||||
//go:embed tsgen.tmpl
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{{- /*gotype: efprojects.com/kitten-ipc/kitcom/internal/ts.tsGenData*/ -}}
|
||||
{{- /*gotype: github.com/egor3f/kitten-ipc/kitcom/internal/ts.tsGenData*/ -}}
|
||||
|
||||
// Code generated by kitcom. DO NOT EDIT.
|
||||
|
||||
|
||||
@ -6,12 +6,12 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/api"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/common"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/parser"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/api"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/common"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/parser"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
)
|
||||
|
||||
type TypescriptApiParser struct {
|
||||
|
||||
@ -4,8 +4,8 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/api"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/common"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/api"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/common"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
package ast
|
||||
|
||||
import "efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
import "github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
|
||||
// Ideally, this would get cached on the node factory so there's only ever one set of closures made per factory
|
||||
func getDeepCloneVisitor(f *NodeFactory, syntheticLocation bool) *NodeVisitor {
|
||||
|
||||
@ -5,8 +5,8 @@ import (
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/diagnostics"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/diagnostics"
|
||||
)
|
||||
|
||||
// Diagnostic
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
)
|
||||
|
||||
type JSDocParsingMode int
|
||||
@ -22,7 +22,10 @@ type SourceFileParseOptions struct {
|
||||
JSDocParsingMode JSDocParsingMode
|
||||
}
|
||||
|
||||
func GetSourceFileAffectingCompilerOptions(fileName string, options *core.CompilerOptions) core.SourceFileAffectingCompilerOptions {
|
||||
func GetSourceFileAffectingCompilerOptions(
|
||||
fileName string,
|
||||
options *core.CompilerOptions,
|
||||
) core.SourceFileAffectingCompilerOptions {
|
||||
// Declaration files are not parsed/bound differently depending on compiler options.
|
||||
if tspath.IsDeclarationFileName(fileName) {
|
||||
return core.SourceFileAffectingCompilerOptions{}
|
||||
@ -35,7 +38,11 @@ type ExternalModuleIndicatorOptions struct {
|
||||
force bool
|
||||
}
|
||||
|
||||
func GetExternalModuleIndicatorOptions(fileName string, options *core.CompilerOptions, metadata SourceFileMetaData) ExternalModuleIndicatorOptions {
|
||||
func GetExternalModuleIndicatorOptions(
|
||||
fileName string,
|
||||
options *core.CompilerOptions,
|
||||
metadata SourceFileMetaData,
|
||||
) ExternalModuleIndicatorOptions {
|
||||
if tspath.IsDeclarationFileName(fileName) {
|
||||
return ExternalModuleIndicatorOptions{}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
)
|
||||
|
||||
type SubtreeFacts int32
|
||||
|
||||
@ -3,7 +3,7 @@ package ast
|
||||
import (
|
||||
"sync/atomic"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/collections"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/collections"
|
||||
)
|
||||
|
||||
// Symbol
|
||||
|
||||
@ -7,9 +7,9 @@ import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/debug"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/debug"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
)
|
||||
|
||||
// Atomic ids
|
||||
@ -2302,7 +2302,11 @@ func getModuleInstanceState(node *Node, ancestors []*Node, visited map[NodeId]Mo
|
||||
}
|
||||
}
|
||||
|
||||
func getModuleInstanceStateCached(node *Node, ancestors []*Node, visited map[NodeId]ModuleInstanceState) ModuleInstanceState {
|
||||
func getModuleInstanceStateCached(
|
||||
node *Node,
|
||||
ancestors []*Node,
|
||||
visited map[NodeId]ModuleInstanceState,
|
||||
) ModuleInstanceState {
|
||||
if visited == nil {
|
||||
visited = make(map[NodeId]ModuleInstanceState)
|
||||
}
|
||||
@ -2319,7 +2323,11 @@ func getModuleInstanceStateCached(node *Node, ancestors []*Node, visited map[Nod
|
||||
return result
|
||||
}
|
||||
|
||||
func getModuleInstanceStateWorker(node *Node, ancestors []*Node, visited map[NodeId]ModuleInstanceState) ModuleInstanceState {
|
||||
func getModuleInstanceStateWorker(
|
||||
node *Node,
|
||||
ancestors []*Node,
|
||||
visited map[NodeId]ModuleInstanceState,
|
||||
) ModuleInstanceState {
|
||||
// A module is uninstantiated if it contains only
|
||||
switch node.Kind {
|
||||
case KindInterfaceDeclaration, KindTypeAliasDeclaration, KindJSTypeAliasDeclaration:
|
||||
@ -2373,7 +2381,11 @@ func getModuleInstanceStateWorker(node *Node, ancestors []*Node, visited map[Nod
|
||||
return ModuleInstanceStateInstantiated
|
||||
}
|
||||
|
||||
func getModuleInstanceStateForAliasTarget(node *Node, ancestors []*Node, visited map[NodeId]ModuleInstanceState) ModuleInstanceState {
|
||||
func getModuleInstanceStateForAliasTarget(
|
||||
node *Node,
|
||||
ancestors []*Node,
|
||||
visited map[NodeId]ModuleInstanceState,
|
||||
) ModuleInstanceState {
|
||||
spec := node.AsExportSpecifier()
|
||||
name := spec.PropertyName
|
||||
if name == nil {
|
||||
@ -2543,7 +2555,11 @@ func GetImpliedNodeFormatForFile(path string, packageJsonType string) core.Modul
|
||||
return impliedNodeFormat
|
||||
}
|
||||
|
||||
func GetEmitModuleFormatOfFileWorker(fileName string, options *core.CompilerOptions, sourceFileMetaData SourceFileMetaData) core.ModuleKind {
|
||||
func GetEmitModuleFormatOfFileWorker(
|
||||
fileName string,
|
||||
options *core.CompilerOptions,
|
||||
sourceFileMetaData SourceFileMetaData,
|
||||
) core.ModuleKind {
|
||||
result := GetImpliedNodeFormatForEmitWorker(fileName, options.GetEmitModuleKind(), sourceFileMetaData)
|
||||
if result != core.ModuleKindNone {
|
||||
return result
|
||||
@ -2551,7 +2567,11 @@ func GetEmitModuleFormatOfFileWorker(fileName string, options *core.CompilerOpti
|
||||
return options.GetEmitModuleKind()
|
||||
}
|
||||
|
||||
func GetImpliedNodeFormatForEmitWorker(fileName string, emitModuleKind core.ModuleKind, sourceFileMetaData SourceFileMetaData) core.ResolutionMode {
|
||||
func GetImpliedNodeFormatForEmitWorker(
|
||||
fileName string,
|
||||
emitModuleKind core.ModuleKind,
|
||||
sourceFileMetaData SourceFileMetaData,
|
||||
) core.ResolutionMode {
|
||||
if core.ModuleKindNode16 <= emitModuleKind && emitModuleKind <= core.ModuleKindNodeNext {
|
||||
return sourceFileMetaData.ImpliedNodeFormat
|
||||
}
|
||||
@ -3539,7 +3559,11 @@ func IsRightSideOfQualifiedNameOrPropertyAccess(node *Node) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func ShouldTransformImportCall(fileName string, options *core.CompilerOptions, impliedNodeFormatForEmit core.ModuleKind) bool {
|
||||
func ShouldTransformImportCall(
|
||||
fileName string,
|
||||
options *core.CompilerOptions,
|
||||
impliedNodeFormatForEmit core.ModuleKind,
|
||||
) bool {
|
||||
moduleKind := options.GetEmitModuleKind()
|
||||
if core.ModuleKindNode16 <= moduleKind && moduleKind <= core.ModuleKindNodeNext || moduleKind == core.ModuleKindPreserve {
|
||||
return false
|
||||
|
||||
@ -5,7 +5,7 @@ import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/collections"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/collections"
|
||||
)
|
||||
|
||||
type BreadthFirstSearchResult[N any] struct {
|
||||
|
||||
@ -5,8 +5,8 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/collections"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/collections"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
)
|
||||
|
||||
//go:generate go tool golang.org/x/tools/cmd/stringer -type=ModuleKind -trimprefix=ModuleKind -output=modulekind_stringer_generated.go
|
||||
|
||||
@ -11,10 +11,10 @@ import (
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/debug"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/jsonutil"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/stringutil"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/debug"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/jsonutil"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/stringutil"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
)
|
||||
|
||||
func Filter[T any](slice []T, f func(T) bool) []T {
|
||||
@ -620,11 +620,24 @@ func comparableValuesEqual[T comparable](a, b T) bool {
|
||||
return a == b
|
||||
}
|
||||
|
||||
func DiffMaps[K comparable, V comparable](m1 map[K]V, m2 map[K]V, onAdded func(K, V), onRemoved func(K, V), onChanged func(K, V, V)) {
|
||||
func DiffMaps[K comparable, V comparable](
|
||||
m1 map[K]V,
|
||||
m2 map[K]V,
|
||||
onAdded func(K, V),
|
||||
onRemoved func(K, V),
|
||||
onChanged func(K, V, V),
|
||||
) {
|
||||
DiffMapsFunc(m1, m2, comparableValuesEqual, onAdded, onRemoved, onChanged)
|
||||
}
|
||||
|
||||
func DiffMapsFunc[K comparable, V any](m1 map[K]V, m2 map[K]V, equalValues func(V, V) bool, onAdded func(K, V), onRemoved func(K, V), onChanged func(K, V, V)) {
|
||||
func DiffMapsFunc[K comparable, V any](
|
||||
m1 map[K]V,
|
||||
m2 map[K]V,
|
||||
equalValues func(V, V) bool,
|
||||
onAdded func(K, V),
|
||||
onRemoved func(K, V),
|
||||
onChanged func(K, V, V),
|
||||
) {
|
||||
for k, v2 := range m2 {
|
||||
if _, ok := m1[k]; !ok {
|
||||
onAdded(k, v2)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package core
|
||||
|
||||
import "efprojects.com/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
import "github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
|
||||
type ProjectReference struct {
|
||||
Path string
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// Package diagnostics contains generated localizable diagnostic messages.
|
||||
package diagnostics
|
||||
|
||||
import "efprojects.com/kitten-ipc/kitcom/internal/tsgo/stringutil"
|
||||
import "github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/stringutil"
|
||||
|
||||
//go:generate go run generate.go -output ./diagnostics_generated.go
|
||||
//go:generate go tool golang.org/x/tools/cmd/stringer -type=Category -output=stringer_generated.go
|
||||
|
||||
@ -20,8 +20,8 @@ import (
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/repo"
|
||||
"github.com/go-json-experiment/json"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/repo"
|
||||
)
|
||||
|
||||
type diagnosticMessage struct {
|
||||
|
||||
@ -9,7 +9,7 @@ import (
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/stringutil"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/stringutil"
|
||||
"github.com/go-json-experiment/json"
|
||||
)
|
||||
|
||||
|
||||
@ -4,10 +4,10 @@ import (
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/diagnostics"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/stringutil"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/diagnostics"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/stringutil"
|
||||
)
|
||||
|
||||
type jsdocState int32
|
||||
@ -717,7 +717,12 @@ func isObjectOrObjectArrayTypeReference(node *ast.TypeNode) bool {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Parser) parseParameterOrPropertyTag(start int, tagName *ast.IdentifierNode, target propertyLikeParse, indent int) *ast.Node {
|
||||
func (p *Parser) parseParameterOrPropertyTag(
|
||||
start int,
|
||||
tagName *ast.IdentifierNode,
|
||||
target propertyLikeParse,
|
||||
indent int,
|
||||
) *ast.Node {
|
||||
typeExpression := p.tryParseTypeExpression()
|
||||
isNameFirst := typeExpression == nil
|
||||
p.skipWhitespaceOrAsterisk()
|
||||
@ -745,7 +750,12 @@ func (p *Parser) parseParameterOrPropertyTag(start int, tagName *ast.IdentifierN
|
||||
return p.finishNode(result, start)
|
||||
}
|
||||
|
||||
func (p *Parser) parseNestedTypeLiteral(typeExpression *ast.Node, name *ast.EntityName, target propertyLikeParse, indent int) *ast.Node {
|
||||
func (p *Parser) parseNestedTypeLiteral(
|
||||
typeExpression *ast.Node,
|
||||
name *ast.EntityName,
|
||||
target propertyLikeParse,
|
||||
indent int,
|
||||
) *ast.Node {
|
||||
if typeExpression != nil && isObjectOrObjectArrayTypeReference(typeExpression.Type()) {
|
||||
pos := p.nodePos()
|
||||
var children []*ast.Node
|
||||
@ -770,7 +780,13 @@ func (p *Parser) parseNestedTypeLiteral(typeExpression *ast.Node, name *ast.Enti
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Parser) parseReturnTag(previousTags []*ast.Node, start int, tagName *ast.IdentifierNode, indent int, indentText string) *ast.Node {
|
||||
func (p *Parser) parseReturnTag(
|
||||
previousTags []*ast.Node,
|
||||
start int,
|
||||
tagName *ast.IdentifierNode,
|
||||
indent int,
|
||||
indentText string,
|
||||
) *ast.Node {
|
||||
if core.Some(previousTags, ast.IsJSDocReturnTag) {
|
||||
p.parseErrorAt(tagName.Pos(), p.scanner.TokenStart(), diagnostics.X_0_tag_already_specified, tagName.Text())
|
||||
}
|
||||
@ -780,7 +796,13 @@ func (p *Parser) parseReturnTag(previousTags []*ast.Node, start int, tagName *as
|
||||
}
|
||||
|
||||
// pass indent=-1 to skip parsing trailing comments (as when a type tag is nested in a typedef)
|
||||
func (p *Parser) parseTypeTag(previousTags []*ast.Node, start int, tagName *ast.IdentifierNode, indent int, indentText string) *ast.Node {
|
||||
func (p *Parser) parseTypeTag(
|
||||
previousTags []*ast.Node,
|
||||
start int,
|
||||
tagName *ast.IdentifierNode,
|
||||
indent int,
|
||||
indentText string,
|
||||
) *ast.Node {
|
||||
if core.Some(previousTags, ast.IsJSDocTypeTag) {
|
||||
p.parseErrorAt(tagName.Pos(), p.scanner.TokenStart(), diagnostics.X_0_tag_already_specified, tagName.Text())
|
||||
}
|
||||
@ -862,7 +884,13 @@ func (p *Parser) parsePropertyAccessEntityNameExpression() *ast.Node {
|
||||
return node
|
||||
}
|
||||
|
||||
func (p *Parser) parseSimpleTag(start int, createTag func(tagName *ast.IdentifierNode, comment *ast.NodeList) *ast.Node, tagName *ast.IdentifierNode, margin int, indentText string) *ast.Node {
|
||||
func (p *Parser) parseSimpleTag(
|
||||
start int,
|
||||
createTag func(tagName *ast.IdentifierNode, comment *ast.NodeList) *ast.Node,
|
||||
tagName *ast.IdentifierNode,
|
||||
margin int,
|
||||
indentText string,
|
||||
) *ast.Node {
|
||||
return p.finishNode(createTag(tagName, p.parseTrailingTagComments(start, p.nodePos(), margin, indentText)), start)
|
||||
}
|
||||
|
||||
@ -1034,7 +1062,11 @@ func (p *Parser) parseChildPropertyTag(indent int) *ast.Node {
|
||||
return p.parseChildParameterOrPropertyTag(propertyLikeParseProperty, indent, nil)
|
||||
}
|
||||
|
||||
func (p *Parser) parseChildParameterOrPropertyTag(target propertyLikeParse, indent int, name *ast.EntityName) *ast.Node {
|
||||
func (p *Parser) parseChildParameterOrPropertyTag(
|
||||
target propertyLikeParse,
|
||||
indent int,
|
||||
name *ast.EntityName,
|
||||
) *ast.Node {
|
||||
canParseTag := true
|
||||
seenAsterisk := false
|
||||
for {
|
||||
|
||||
@ -4,13 +4,13 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/collections"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/debug"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/diagnostics"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/scanner"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/collections"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/debug"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/diagnostics"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/scanner"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
)
|
||||
|
||||
type ParsingContext int
|
||||
@ -583,7 +583,12 @@ func (p *Parser) parseDelimitedList(kind ParsingContext, parseElement func(p *Pa
|
||||
|
||||
// Return a non-nil (but possibly empty) NodeList if parsing was successful, or nil if opening token wasn't found
|
||||
// or parseElement returned nil.
|
||||
func (p *Parser) parseBracketedList(kind ParsingContext, parseElement func(p *Parser) *ast.Node, opening ast.Kind, closing ast.Kind) *ast.NodeList {
|
||||
func (p *Parser) parseBracketedList(
|
||||
kind ParsingContext,
|
||||
parseElement func(p *Parser) *ast.Node,
|
||||
opening ast.Kind,
|
||||
closing ast.Kind,
|
||||
) *ast.NodeList {
|
||||
if p.parseExpected(opening) {
|
||||
result := p.parseDelimitedList(kind, parseElement)
|
||||
p.parseExpected(closing)
|
||||
@ -840,7 +845,12 @@ func (p *Parser) parseExpectedJSDoc(kind ast.Kind) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *Parser) parseExpectedMatchingBrackets(openKind ast.Kind, closeKind ast.Kind, openParsed bool, openPosition int) {
|
||||
func (p *Parser) parseExpectedMatchingBrackets(
|
||||
openKind ast.Kind,
|
||||
closeKind ast.Kind,
|
||||
openParsed bool,
|
||||
openPosition int,
|
||||
) {
|
||||
if p.token == closeKind {
|
||||
p.nextToken()
|
||||
return
|
||||
@ -1605,7 +1615,12 @@ func (p *Parser) parseClassExpression() *ast.Node {
|
||||
return p.parseClassDeclarationOrExpression(p.nodePos(), p.hasPrecedingJSDocComment(), nil /*modifiers*/, ast.KindClassExpression)
|
||||
}
|
||||
|
||||
func (p *Parser) parseClassDeclarationOrExpression(pos int, hasJSDoc bool, modifiers *ast.ModifierList, kind ast.Kind) *ast.Node {
|
||||
func (p *Parser) parseClassDeclarationOrExpression(
|
||||
pos int,
|
||||
hasJSDoc bool,
|
||||
modifiers *ast.ModifierList,
|
||||
kind ast.Kind,
|
||||
) *ast.Node {
|
||||
saveContextFlags := p.contextFlags
|
||||
saveHasAwaitIdentifier := p.statementHasAwaitIdentifier
|
||||
p.parseExpected(ast.KindClassKeyword)
|
||||
@ -1811,7 +1826,15 @@ func (p *Parser) parsePropertyOrMethodDeclaration(pos int, hasJSDoc bool, modifi
|
||||
return p.parsePropertyDeclaration(pos, hasJSDoc, modifiers, name, questionToken)
|
||||
}
|
||||
|
||||
func (p *Parser) parseMethodDeclaration(pos int, hasJSDoc bool, modifiers *ast.ModifierList, asteriskToken *ast.Node, name *ast.Node, questionToken *ast.Node, diagnosticMessage *diagnostics.Message) *ast.Node {
|
||||
func (p *Parser) parseMethodDeclaration(
|
||||
pos int,
|
||||
hasJSDoc bool,
|
||||
modifiers *ast.ModifierList,
|
||||
asteriskToken *ast.Node,
|
||||
name *ast.Node,
|
||||
questionToken *ast.Node,
|
||||
diagnosticMessage *diagnostics.Message,
|
||||
) *ast.Node {
|
||||
signatureFlags := core.IfElse(asteriskToken != nil, ParseFlagsYield, ParseFlagsNone) | core.IfElse(modifierListHasAsync(modifiers), ParseFlagsAwait, ParseFlagsNone)
|
||||
typeParameters := p.parseTypeParameters()
|
||||
parameters := p.parseParameters(signatureFlags)
|
||||
@ -1827,7 +1850,13 @@ func modifierListHasAsync(modifiers *ast.ModifierList) bool {
|
||||
return modifiers != nil && core.Some(modifiers.Nodes, isAsyncModifier)
|
||||
}
|
||||
|
||||
func (p *Parser) parsePropertyDeclaration(pos int, hasJSDoc bool, modifiers *ast.ModifierList, name *ast.Node, questionToken *ast.Node) *ast.Node {
|
||||
func (p *Parser) parsePropertyDeclaration(
|
||||
pos int,
|
||||
hasJSDoc bool,
|
||||
modifiers *ast.ModifierList,
|
||||
name *ast.Node,
|
||||
questionToken *ast.Node,
|
||||
) *ast.Node {
|
||||
postfixToken := questionToken
|
||||
if postfixToken == nil && !p.hasPrecedingLineBreak() {
|
||||
postfixToken = p.parseOptionalToken(ast.KindExclamationToken)
|
||||
@ -1934,7 +1963,11 @@ func getSpaceSuggestion(expressionText string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (p *Parser) parseErrorForInvalidName(nameDiagnostic *diagnostics.Message, blankDiagnostic *diagnostics.Message, tokenIfBlankName ast.Kind) {
|
||||
func (p *Parser) parseErrorForInvalidName(
|
||||
nameDiagnostic *diagnostics.Message,
|
||||
blankDiagnostic *diagnostics.Message,
|
||||
tokenIfBlankName ast.Kind,
|
||||
) {
|
||||
if p.token == tokenIfBlankName {
|
||||
p.parseErrorAtCurrentToken(blankDiagnostic)
|
||||
} else {
|
||||
@ -2066,7 +2099,13 @@ func (p *Parser) parseModuleBlock() *ast.Node {
|
||||
return p.finishNode(p.factory.NewModuleBlock(statements), pos)
|
||||
}
|
||||
|
||||
func (p *Parser) parseModuleOrNamespaceDeclaration(pos int, hasJSDoc bool, modifiers *ast.ModifierList, nested bool, keyword ast.Kind) *ast.Node {
|
||||
func (p *Parser) parseModuleOrNamespaceDeclaration(
|
||||
pos int,
|
||||
hasJSDoc bool,
|
||||
modifiers *ast.ModifierList,
|
||||
nested bool,
|
||||
keyword ast.Kind,
|
||||
) *ast.Node {
|
||||
saveHasAwaitIdentifier := p.statementHasAwaitIdentifier
|
||||
var name *ast.Node
|
||||
if nested {
|
||||
@ -2091,7 +2130,11 @@ func (p *Parser) parseModuleOrNamespaceDeclaration(pos int, hasJSDoc bool, modif
|
||||
return result
|
||||
}
|
||||
|
||||
func (p *Parser) parseImportDeclarationOrImportEqualsDeclaration(pos int, hasJSDoc bool, modifiers *ast.ModifierList) *ast.Statement {
|
||||
func (p *Parser) parseImportDeclarationOrImportEqualsDeclaration(
|
||||
pos int,
|
||||
hasJSDoc bool,
|
||||
modifiers *ast.ModifierList,
|
||||
) *ast.Statement {
|
||||
p.parseExpected(ast.KindImportKeyword)
|
||||
afterImportPos := p.nodePos()
|
||||
// We don't parse the identifier here in await context, instead we will report a grammar error in the checker.
|
||||
@ -2155,7 +2198,13 @@ func (p *Parser) tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration
|
||||
return p.token == ast.KindCommaToken || p.token == ast.KindFromKeyword
|
||||
}
|
||||
|
||||
func (p *Parser) parseImportEqualsDeclaration(pos int, hasJSDoc bool, modifiers *ast.ModifierList, identifier *ast.Node, isTypeOnly bool) *ast.Node {
|
||||
func (p *Parser) parseImportEqualsDeclaration(
|
||||
pos int,
|
||||
hasJSDoc bool,
|
||||
modifiers *ast.ModifierList,
|
||||
identifier *ast.Node,
|
||||
isTypeOnly bool,
|
||||
) *ast.Node {
|
||||
p.parseExpected(ast.KindEqualsToken)
|
||||
moduleReference := p.parseModuleReference()
|
||||
p.parseSemicolon()
|
||||
@ -2194,7 +2243,12 @@ func (p *Parser) parseModuleSpecifier() *ast.Expression {
|
||||
return p.parseExpression()
|
||||
}
|
||||
|
||||
func (p *Parser) tryParseImportClause(identifier *ast.Node, pos int, phaseModifier ast.Kind, skipJSDocLeadingAsterisks bool) *ast.Node {
|
||||
func (p *Parser) tryParseImportClause(
|
||||
identifier *ast.Node,
|
||||
pos int,
|
||||
phaseModifier ast.Kind,
|
||||
skipJSDocLeadingAsterisks bool,
|
||||
) *ast.Node {
|
||||
// ImportDeclaration:
|
||||
// import ImportClause from ModuleSpecifier ;
|
||||
// import ModuleSpecifier;
|
||||
@ -2206,7 +2260,12 @@ func (p *Parser) tryParseImportClause(identifier *ast.Node, pos int, phaseModifi
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Parser) parseImportClause(identifier *ast.Node, pos int, phaseModifier ast.Kind, skipJSDocLeadingAsterisks bool) *ast.Node {
|
||||
func (p *Parser) parseImportClause(
|
||||
identifier *ast.Node,
|
||||
pos int,
|
||||
phaseModifier ast.Kind,
|
||||
skipJSDocLeadingAsterisks bool,
|
||||
) *ast.Node {
|
||||
// ImportClause:
|
||||
// ImportedDefaultBinding
|
||||
// NameSpaceImport
|
||||
@ -2495,7 +2554,10 @@ func (p *Parser) parseIntersectionTypeOrHigher() *ast.TypeNode {
|
||||
return p.parseUnionOrIntersectionType(ast.KindAmpersandToken, (*Parser).parseTypeOperatorOrHigher)
|
||||
}
|
||||
|
||||
func (p *Parser) parseUnionOrIntersectionType(operator ast.Kind, parseConstituentType func(p *Parser) *ast.TypeNode) *ast.TypeNode {
|
||||
func (p *Parser) parseUnionOrIntersectionType(
|
||||
operator ast.Kind,
|
||||
parseConstituentType func(p *Parser) *ast.TypeNode,
|
||||
) *ast.TypeNode {
|
||||
pos := p.nodePos()
|
||||
isUnionType := operator == ast.KindBarToken
|
||||
hasLeadingOperator := p.parseOptional(operator)
|
||||
@ -2776,7 +2838,11 @@ func (p *Parser) parseEntityName(allowReservedWords bool, diagnosticMessage *dia
|
||||
return entity
|
||||
}
|
||||
|
||||
func (p *Parser) parseRightSideOfDot(allowIdentifierNames bool, allowPrivateIdentifiers bool, allowUnicodeEscapeSequenceInIdentifierName bool) *ast.Node {
|
||||
func (p *Parser) parseRightSideOfDot(
|
||||
allowIdentifierNames bool,
|
||||
allowPrivateIdentifiers bool,
|
||||
allowUnicodeEscapeSequenceInIdentifierName bool,
|
||||
) *ast.Node {
|
||||
// Technically a keyword is valid here as all identifiers and keywords are identifier names.
|
||||
// However, often we'll encounter this in error situations when the identifier or keyword
|
||||
// is actually starting another valid construct.
|
||||
@ -3279,7 +3345,13 @@ func (p *Parser) parseTypeMemberSemicolon() {
|
||||
p.parseSemicolon()
|
||||
}
|
||||
|
||||
func (p *Parser) parseAccessorDeclaration(pos int, hasJSDoc bool, modifiers *ast.ModifierList, kind ast.Kind, flags ParseFlags) *ast.Node {
|
||||
func (p *Parser) parseAccessorDeclaration(
|
||||
pos int,
|
||||
hasJSDoc bool,
|
||||
modifiers *ast.ModifierList,
|
||||
kind ast.Kind,
|
||||
flags ParseFlags,
|
||||
) *ast.Node {
|
||||
name := p.parsePropertyName()
|
||||
typeParameters := p.parseTypeParameters()
|
||||
parameters := p.parseParameters(ParseFlagsNone)
|
||||
@ -3600,7 +3672,10 @@ func (p *Parser) parseTemplateMiddleOrTail() *ast.Node {
|
||||
return p.finishNode(result, pos)
|
||||
}
|
||||
|
||||
func (p *Parser) parseFunctionOrConstructorTypeToError(isInUnionType bool, parseConstituentType func(p *Parser) *ast.TypeNode) *ast.TypeNode {
|
||||
func (p *Parser) parseFunctionOrConstructorTypeToError(
|
||||
isInUnionType bool,
|
||||
parseConstituentType func(p *Parser) *ast.TypeNode,
|
||||
) *ast.TypeNode {
|
||||
// the function type and constructor type shorthand notation
|
||||
// are not allowed directly in unions and intersections, but we'll
|
||||
// try to parse them gracefully and issue a helpful message.
|
||||
@ -3712,7 +3787,11 @@ func (p *Parser) parseModifiers() *ast.ModifierList {
|
||||
return p.parseModifiersEx(false, false, false)
|
||||
}
|
||||
|
||||
func (p *Parser) parseModifiersEx(allowDecorators bool, permitConstAsModifier bool, stopOnStartOfClassStaticBlock bool) *ast.ModifierList {
|
||||
func (p *Parser) parseModifiersEx(
|
||||
allowDecorators bool,
|
||||
permitConstAsModifier bool,
|
||||
stopOnStartOfClassStaticBlock bool,
|
||||
) *ast.ModifierList {
|
||||
var hasLeadingModifier bool
|
||||
var hasTrailingDecorator bool
|
||||
var hasTrailingModifier bool
|
||||
@ -3772,7 +3851,11 @@ func (p *Parser) parseDecoratorExpression() *ast.Expression {
|
||||
return p.parseLeftHandSideExpressionOrHigher()
|
||||
}
|
||||
|
||||
func (p *Parser) tryParseModifier(hasSeenStaticModifier bool, permitConstAsModifier bool, stopOnStartOfClassStaticBlock bool) *ast.Node {
|
||||
func (p *Parser) tryParseModifier(
|
||||
hasSeenStaticModifier bool,
|
||||
permitConstAsModifier bool,
|
||||
stopOnStartOfClassStaticBlock bool,
|
||||
) *ast.Node {
|
||||
pos := p.nodePos()
|
||||
kind := p.token
|
||||
if p.token == ast.KindConstKeyword && permitConstAsModifier {
|
||||
@ -4194,7 +4277,10 @@ func (p *Parser) tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInA
|
||||
return result
|
||||
}
|
||||
|
||||
func (p *Parser) parseParenthesizedArrowFunctionExpression(allowAmbiguity bool, allowReturnTypeInArrowFunction bool) *ast.Node {
|
||||
func (p *Parser) parseParenthesizedArrowFunctionExpression(
|
||||
allowAmbiguity bool,
|
||||
allowReturnTypeInArrowFunction bool,
|
||||
) *ast.Node {
|
||||
pos := p.nodePos()
|
||||
hasJSDoc := p.hasPrecedingJSDocComment()
|
||||
modifiers := p.parseModifiersForArrowFunction()
|
||||
@ -4393,7 +4479,13 @@ func (p *Parser) nextIsUnParenthesizedAsyncArrowFunction() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *Parser) parseSimpleArrowFunctionExpression(pos int, identifier *ast.Node, allowReturnTypeInArrowFunction bool, hasJSDoc bool, asyncModifier *ast.ModifierList) *ast.Node {
|
||||
func (p *Parser) parseSimpleArrowFunctionExpression(
|
||||
pos int,
|
||||
identifier *ast.Node,
|
||||
allowReturnTypeInArrowFunction bool,
|
||||
hasJSDoc bool,
|
||||
asyncModifier *ast.ModifierList,
|
||||
) *ast.Node {
|
||||
debug.Assert(p.token == ast.KindEqualsGreaterThanToken, "parseSimpleArrowFunctionExpression should only have been called if we had a =>")
|
||||
parameter := p.finishNode(p.factory.NewParameterDeclaration(nil /*modifiers*/, nil /*dotDotDotToken*/, identifier, nil /*questionToken*/, nil /*typeNode*/, nil /*initializer*/), identifier.Pos())
|
||||
parameters := p.newNodeList(parameter.Loc, []*ast.Node{parameter})
|
||||
@ -4404,7 +4496,11 @@ func (p *Parser) parseSimpleArrowFunctionExpression(pos int, identifier *ast.Nod
|
||||
return result
|
||||
}
|
||||
|
||||
func (p *Parser) parseConditionalExpressionRest(leftOperand *ast.Expression, pos int, allowReturnTypeInArrowFunction bool) *ast.Expression {
|
||||
func (p *Parser) parseConditionalExpressionRest(
|
||||
leftOperand *ast.Expression,
|
||||
pos int,
|
||||
allowReturnTypeInArrowFunction bool,
|
||||
) *ast.Expression {
|
||||
// Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
|
||||
questionToken := p.parseOptionalToken(ast.KindQuestionToken)
|
||||
if questionToken == nil {
|
||||
@ -4433,7 +4529,11 @@ func (p *Parser) parseBinaryExpressionOrHigher(precedence ast.OperatorPrecedence
|
||||
return p.parseBinaryExpressionRest(precedence, leftOperand, pos)
|
||||
}
|
||||
|
||||
func (p *Parser) parseBinaryExpressionRest(precedence ast.OperatorPrecedence, leftOperand *ast.Expression, pos int) *ast.Expression {
|
||||
func (p *Parser) parseBinaryExpressionRest(
|
||||
precedence ast.OperatorPrecedence,
|
||||
leftOperand *ast.Expression,
|
||||
pos int,
|
||||
) *ast.Expression {
|
||||
for {
|
||||
// We either have a binary operator here, or we're finished. We call
|
||||
// reScanGreaterToken so that we merge token sequences like > and = into >=
|
||||
@ -4504,7 +4604,12 @@ func (p *Parser) makeAsExpression(left *ast.Expression, right *ast.TypeNode) *as
|
||||
return p.checkJSSyntax(p.finishNode(p.factory.NewAsExpression(left, right), left.Pos()))
|
||||
}
|
||||
|
||||
func (p *Parser) makeBinaryExpression(left *ast.Expression, operatorToken *ast.Node, right *ast.Expression, pos int) *ast.Node {
|
||||
func (p *Parser) makeBinaryExpression(
|
||||
left *ast.Expression,
|
||||
operatorToken *ast.Node,
|
||||
right *ast.Expression,
|
||||
pos int,
|
||||
) *ast.Node {
|
||||
return p.finishNode(p.factory.NewBinaryExpression(nil /*modifiers*/, left, nil /*typeNode*/, operatorToken, right), pos)
|
||||
}
|
||||
|
||||
@ -4576,7 +4681,12 @@ func (p *Parser) parseUpdateExpression() *ast.Expression {
|
||||
return expression
|
||||
}
|
||||
|
||||
func (p *Parser) parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext bool, topInvalidNodePosition int, openingTag *ast.Node, mustBeUnary bool) *ast.Expression {
|
||||
func (p *Parser) parseJsxElementOrSelfClosingElementOrFragment(
|
||||
inExpressionContext bool,
|
||||
topInvalidNodePosition int,
|
||||
openingTag *ast.Node,
|
||||
mustBeUnary bool,
|
||||
) *ast.Expression {
|
||||
pos := p.nodePos()
|
||||
opening := p.parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext)
|
||||
var result *ast.Expression
|
||||
@ -5176,7 +5286,11 @@ func (p *Parser) parseMemberExpressionOrHigher() *ast.Node {
|
||||
return p.parseMemberExpressionRest(pos, expression, true /*allowOptionalChain*/)
|
||||
}
|
||||
|
||||
func (p *Parser) parseMemberExpressionRest(pos int, expression *ast.Expression, allowOptionalChain bool) *ast.Expression {
|
||||
func (p *Parser) parseMemberExpressionRest(
|
||||
pos int,
|
||||
expression *ast.Expression,
|
||||
allowOptionalChain bool,
|
||||
) *ast.Expression {
|
||||
for {
|
||||
var questionDotToken *ast.Node
|
||||
isPropertyAccess := false
|
||||
@ -5231,7 +5345,11 @@ func (p *Parser) nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() bool {
|
||||
return tokenIsIdentifierOrKeyword(p.token) || p.token == ast.KindOpenBracketToken || p.isTemplateStartOfTaggedTemplate()
|
||||
}
|
||||
|
||||
func (p *Parser) parsePropertyAccessExpressionRest(pos int, expression *ast.Expression, questionDotToken *ast.Node) *ast.Node {
|
||||
func (p *Parser) parsePropertyAccessExpressionRest(
|
||||
pos int,
|
||||
expression *ast.Expression,
|
||||
questionDotToken *ast.Node,
|
||||
) *ast.Node {
|
||||
name := p.parseRightSideOfDot(true /*allowIdentifierNames*/, true /*allowPrivateIdentifiers*/, true /*allowUnicodeEscapeSequenceInIdentifierName*/)
|
||||
isOptionalChain := questionDotToken != nil || p.tryReparseOptionalChain(expression)
|
||||
propertyAccess := p.factory.NewPropertyAccessExpression(expression, questionDotToken, name, core.IfElse(isOptionalChain, ast.NodeFlagsOptionalChain, ast.NodeFlagsNone))
|
||||
@ -5270,7 +5388,11 @@ func (p *Parser) tryReparseOptionalChain(node *ast.Expression) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *Parser) parseElementAccessExpressionRest(pos int, expression *ast.Expression, questionDotToken *ast.Node) *ast.Node {
|
||||
func (p *Parser) parseElementAccessExpressionRest(
|
||||
pos int,
|
||||
expression *ast.Expression,
|
||||
questionDotToken *ast.Node,
|
||||
) *ast.Node {
|
||||
var argumentExpression *ast.Expression
|
||||
if p.token == ast.KindCloseBracketToken {
|
||||
p.parseErrorAt(p.nodePos(), p.nodePos(), diagnostics.An_element_access_expression_should_take_an_argument)
|
||||
@ -5356,7 +5478,12 @@ func (p *Parser) parseSpreadElement() *ast.Node {
|
||||
return p.finishNode(p.factory.NewSpreadElement(expression), pos)
|
||||
}
|
||||
|
||||
func (p *Parser) parseTaggedTemplateRest(pos int, tag *ast.Expression, questionDotToken *ast.Node, typeArguments *ast.NodeList) *ast.Node {
|
||||
func (p *Parser) parseTaggedTemplateRest(
|
||||
pos int,
|
||||
tag *ast.Expression,
|
||||
questionDotToken *ast.Node,
|
||||
typeArguments *ast.NodeList,
|
||||
) *ast.Node {
|
||||
var template *ast.Expression
|
||||
if p.token == ast.KindNoSubstitutionTemplateLiteral {
|
||||
p.reScanTemplateToken(true /*isTaggedTemplate*/)
|
||||
@ -5578,7 +5705,11 @@ func (p *Parser) parseDecoratedExpression() *ast.Expression {
|
||||
return p.finishNode(p.factory.NewMissingDeclaration(modifiers), pos)
|
||||
}
|
||||
|
||||
func (p *Parser) unparseExpressionWithTypeArguments(expression *ast.Node, typeArguments *ast.NodeList, result *ast.Node) {
|
||||
func (p *Parser) unparseExpressionWithTypeArguments(
|
||||
expression *ast.Node,
|
||||
typeArguments *ast.NodeList,
|
||||
result *ast.Node,
|
||||
) {
|
||||
// force overwrite the `.Parent` of the expression and type arguments to erase the fact that they may have originally been parsed as an ExpressionWithTypeArguments and be parented to such
|
||||
if expression != nil {
|
||||
expression.Parent = result
|
||||
@ -5685,7 +5816,10 @@ func (p *Parser) parseIdentifier() *ast.Node {
|
||||
return p.parseIdentifierWithDiagnostic(nil, nil)
|
||||
}
|
||||
|
||||
func (p *Parser) parseIdentifierWithDiagnostic(diagnosticMessage *diagnostics.Message, privateIdentifierDiagnosticMessage *diagnostics.Message) *ast.Node {
|
||||
func (p *Parser) parseIdentifierWithDiagnostic(
|
||||
diagnosticMessage *diagnostics.Message,
|
||||
privateIdentifierDiagnosticMessage *diagnostics.Message,
|
||||
) *ast.Node {
|
||||
return p.createIdentifierWithDiagnostic(p.isIdentifier(), diagnosticMessage, privateIdentifierDiagnosticMessage)
|
||||
}
|
||||
|
||||
@ -5693,7 +5827,11 @@ func (p *Parser) createIdentifier(isIdentifier bool) *ast.Node {
|
||||
return p.createIdentifierWithDiagnostic(isIdentifier, nil, nil)
|
||||
}
|
||||
|
||||
func (p *Parser) createIdentifierWithDiagnostic(isIdentifier bool, diagnosticMessage *diagnostics.Message, privateIdentifierDiagnosticMessage *diagnostics.Message) *ast.Node {
|
||||
func (p *Parser) createIdentifierWithDiagnostic(
|
||||
isIdentifier bool,
|
||||
diagnosticMessage *diagnostics.Message,
|
||||
privateIdentifierDiagnosticMessage *diagnostics.Message,
|
||||
) *ast.Node {
|
||||
if isIdentifier {
|
||||
var pos int
|
||||
if p.scanner.HasPrecedingJSDocLeadingAsterisks() {
|
||||
@ -6483,7 +6621,11 @@ func (p *Parser) processPragmasIntoFields(context *ast.SourceFile) {
|
||||
}
|
||||
}
|
||||
|
||||
func parseResolutionMode(mode string, pos int, end int /*reportDiagnostic: PragmaDiagnosticReporter*/) (resolutionKind core.ResolutionMode) {
|
||||
func parseResolutionMode(
|
||||
mode string,
|
||||
pos int,
|
||||
end int, /*reportDiagnostic: PragmaDiagnosticReporter*/
|
||||
) (resolutionKind core.ResolutionMode) {
|
||||
if mode == "import" {
|
||||
resolutionKind = core.ModuleKindESNext
|
||||
}
|
||||
|
||||
@ -3,9 +3,9 @@ package parser
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/tspath"
|
||||
)
|
||||
|
||||
func collectExternalModuleReferences(file *ast.SourceFile) {
|
||||
@ -14,7 +14,10 @@ func collectExternalModuleReferences(file *ast.SourceFile) {
|
||||
}
|
||||
|
||||
if file.Flags&ast.NodeFlagsPossiblyContainsDynamicImport != 0 || ast.IsInJSFile(file.AsNode()) {
|
||||
ast.ForEachDynamicImportOrRequireCall(file /*includeTypeSpaceImports*/, true /*requireStringLiteralLikeArgument*/, true, func(node *ast.Node, moduleSpecifier *ast.Expression) bool {
|
||||
ast.ForEachDynamicImportOrRequireCall(file /*includeTypeSpaceImports*/, true /*requireStringLiteralLikeArgument*/, true, func(
|
||||
node *ast.Node,
|
||||
moduleSpecifier *ast.Expression,
|
||||
) bool {
|
||||
ast.SetImportsOfSourceFile(file, append(file.Imports(), moduleSpecifier))
|
||||
return false
|
||||
})
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
)
|
||||
|
||||
func (p *Parser) finishReparsedNode(node *ast.Node, locationNode *ast.Node) {
|
||||
@ -132,7 +132,13 @@ func (p *Parser) reparseUnhosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Nod
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Parser) reparseJSDocSignature(jsSignature *ast.Node, fun *ast.Node, jsDoc *ast.Node, tag *ast.Node, modifiers *ast.ModifierList) *ast.Node {
|
||||
func (p *Parser) reparseJSDocSignature(
|
||||
jsSignature *ast.Node,
|
||||
fun *ast.Node,
|
||||
jsDoc *ast.Node,
|
||||
tag *ast.Node,
|
||||
modifiers *ast.ModifierList,
|
||||
) *ast.Node {
|
||||
var signature *ast.Node
|
||||
clonedModifiers := p.factory.DeepCloneReparseModifiers(modifiers)
|
||||
switch fun.Kind {
|
||||
@ -548,7 +554,11 @@ func (p *Parser) makeQuestionIfOptional(parameter *ast.JSDocParameterTag) *ast.N
|
||||
return questionToken
|
||||
}
|
||||
|
||||
func findMatchingParameter(fun *ast.Node, parameterTag *ast.JSDocParameterTag, jsDoc *ast.Node) (*ast.ParameterDeclaration, bool) {
|
||||
func findMatchingParameter(
|
||||
fun *ast.Node,
|
||||
parameterTag *ast.JSDocParameterTag,
|
||||
jsDoc *ast.Node,
|
||||
) (*ast.ParameterDeclaration, bool) {
|
||||
tagIndex := -1
|
||||
paramCount := -1
|
||||
for _, tag := range jsDoc.AsJSDoc().Tags.Nodes {
|
||||
|
||||
@ -3,9 +3,9 @@ package parser
|
||||
import (
|
||||
"slices"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/scanner"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/scanner"
|
||||
)
|
||||
|
||||
func getLanguageVariant(scriptKind core.ScriptKind) core.LanguageVariant {
|
||||
@ -25,7 +25,12 @@ func tokenIsIdentifierOrKeywordOrGreaterThan(token ast.Kind) bool {
|
||||
return token == ast.KindGreaterThanToken || tokenIsIdentifierOrKeyword(token)
|
||||
}
|
||||
|
||||
func GetJSDocCommentRanges(f *ast.NodeFactory, commentRanges []ast.CommentRange, node *ast.Node, text string) []ast.CommentRange {
|
||||
func GetJSDocCommentRanges(
|
||||
f *ast.NodeFactory,
|
||||
commentRanges []ast.CommentRange,
|
||||
node *ast.Node,
|
||||
text string,
|
||||
) []ast.CommentRange {
|
||||
switch node.Kind {
|
||||
case ast.KindParameter, ast.KindTypeParameter, ast.KindFunctionExpression, ast.KindArrowFunction, ast.KindParenthesizedExpression, ast.KindVariableDeclaration, ast.KindExportSpecifier:
|
||||
for commentRange := range scanner.GetTrailingCommentRanges(f, text, node.Pos()) {
|
||||
|
||||
@ -9,12 +9,12 @@ import (
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/debug"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/diagnostics"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/jsnum"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/stringutil"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/debug"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/diagnostics"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/jsnum"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/stringutil"
|
||||
)
|
||||
|
||||
type EscapeSequenceScanningFlags int32
|
||||
@ -2235,7 +2235,11 @@ func isConflictMarkerTrivia(text string, pos int) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func scanConflictMarkerTrivia(text string, pos int, reportError func(diag *diagnostics.Message, pos int, length int, args ...any)) int {
|
||||
func scanConflictMarkerTrivia(
|
||||
text string,
|
||||
pos int,
|
||||
reportError func(diag *diagnostics.Message, pos int, length int, args ...any),
|
||||
) int {
|
||||
if reportError != nil {
|
||||
reportError(diagnostics.Merge_conflict_marker_encountered, pos, mergeConflictMarkerLength)
|
||||
}
|
||||
@ -2459,7 +2463,13 @@ func ComputePositionOfLineAndCharacter(lineStarts []core.TextPos, line int, char
|
||||
return ComputePositionOfLineAndCharacterEx(lineStarts, line, character, nil, false)
|
||||
}
|
||||
|
||||
func ComputePositionOfLineAndCharacterEx(lineStarts []core.TextPos, line int, character int, text *string, allowEdits bool) int {
|
||||
func ComputePositionOfLineAndCharacterEx(
|
||||
lineStarts []core.TextPos,
|
||||
line int,
|
||||
character int,
|
||||
text *string,
|
||||
allowEdits bool,
|
||||
) int {
|
||||
if line < 0 || line >= len(lineStarts) {
|
||||
if allowEdits {
|
||||
// Clamp line to nearest allowable value
|
||||
|
||||
@ -4,8 +4,8 @@ import (
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/ast"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/core"
|
||||
)
|
||||
|
||||
func tokenIsIdentifierOrKeyword(token ast.Kind) bool {
|
||||
|
||||
@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/stringutil"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/tsgo/stringutil"
|
||||
)
|
||||
|
||||
type Path string
|
||||
@ -724,7 +724,12 @@ func ConvertToRelativePath(absoluteOrRelativePath string, options ComparePathsOp
|
||||
return GetRelativePathToDirectoryOrUrl(options.CurrentDirectory, absoluteOrRelativePath, false /*isAbsolutePathAnUrl*/, options)
|
||||
}
|
||||
|
||||
func GetRelativePathToDirectoryOrUrl(directoryPathOrUrl string, relativeOrAbsolutePath string, isAbsolutePathAnUrl bool, options ComparePathsOptions) string {
|
||||
func GetRelativePathToDirectoryOrUrl(
|
||||
directoryPathOrUrl string,
|
||||
relativeOrAbsolutePath string,
|
||||
isAbsolutePathAnUrl bool,
|
||||
options ComparePathsOptions,
|
||||
) string {
|
||||
pathComponents := GetPathComponentsRelativeTo(
|
||||
directoryPathOrUrl,
|
||||
relativeOrAbsolutePath,
|
||||
@ -812,7 +817,11 @@ func GetAnyExtensionFromPath(path string, extensions []string, ignoreCase bool)
|
||||
return ""
|
||||
}
|
||||
|
||||
func getAnyExtensionFromPathWorker(path string, extensions []string, stringEqualityComparer func(a, b string) bool) string {
|
||||
func getAnyExtensionFromPathWorker(
|
||||
path string,
|
||||
extensions []string,
|
||||
stringEqualityComparer func(a, b string) bool,
|
||||
) string {
|
||||
for _, extension := range extensions {
|
||||
result := tryGetExtensionFromPath(path, extension, stringEqualityComparer)
|
||||
if result != "" {
|
||||
@ -991,7 +1000,10 @@ func ForEachAncestorDirectoryStoppingAtGlobalCache[T any](
|
||||
return result
|
||||
}
|
||||
|
||||
func ForEachAncestorDirectory[T any](directory string, callback func(directory string) (result T, stop bool)) (result T, ok bool) {
|
||||
func ForEachAncestorDirectory[T any](
|
||||
directory string,
|
||||
callback func(directory string) (result T, stop bool),
|
||||
) (result T, ok bool) {
|
||||
for {
|
||||
result, stop := callback(directory)
|
||||
if stop {
|
||||
@ -1008,7 +1020,10 @@ func ForEachAncestorDirectory[T any](directory string, callback func(directory s
|
||||
}
|
||||
}
|
||||
|
||||
func ForEachAncestorDirectoryPath[T any](directory Path, callback func(directory Path) (result T, stop bool)) (result T, ok bool) {
|
||||
func ForEachAncestorDirectoryPath[T any](
|
||||
directory Path,
|
||||
callback func(directory Path) (result T, stop bool),
|
||||
) (result T, ok bool) {
|
||||
return ForEachAncestorDirectory(string(directory), func(directory string) (T, bool) {
|
||||
return callback(Path(directory))
|
||||
})
|
||||
|
||||
@ -10,10 +10,10 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/api"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/common"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/golang"
|
||||
"efprojects.com/kitten-ipc/kitcom/internal/ts"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/api"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/common"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/golang"
|
||||
"github.com/egor3f/kitten-ipc/kitcom/internal/ts"
|
||||
)
|
||||
|
||||
type ApiParser interface {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
module efprojects.com/kitten-ipc
|
||||
module github.com/egor3f/kitten-ipc
|
||||
|
||||
go 1.25.1
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user