Skip to content

Commit a51e947

Browse files
dependabot[bot]github-actions[bot]buke
authored
deps(deps): bump microsoft/typescript-go from 93841b5 to c15e764 (#61)
* deps(deps): bump microsoft/typescript-go from `93841b5` to `c15e764` Bumps [microsoft/typescript-go](https://github.com/microsoft/typescript-go) from `93841b5` to `c15e764`. - [Commits](microsoft/typescript-go@93841b5...c15e764) --- updated-dependencies: - dependency-name: microsoft/typescript-go dependency-version: c15e7649ca152ac52d424558abae7addd3f43801 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * chore(sync): mirror internal packages into pkg/ (auto) (#62) Co-authored-by: buke <1013738+buke@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: buke <1013738+buke@users.noreply.github.com>
1 parent ecd778b commit a51e947

File tree

137 files changed

+595
-1148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+595
-1148
lines changed

microsoft/typescript-go

Submodule typescript-go updated 137 files

pkg/binder/binder.go

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,32 +46,33 @@ type Binder struct {
4646
bindFunc func(*ast.Node) bool
4747
unreachableFlow *ast.FlowNode
4848

49-
container *ast.Node
50-
thisContainer *ast.Node
51-
blockScopeContainer *ast.Node
52-
lastContainer *ast.Node
53-
currentFlow *ast.FlowNode
54-
currentBreakTarget *ast.FlowLabel
55-
currentContinueTarget *ast.FlowLabel
56-
currentReturnTarget *ast.FlowLabel
57-
currentTrueTarget *ast.FlowLabel
58-
currentFalseTarget *ast.FlowLabel
59-
currentExceptionTarget *ast.FlowLabel
60-
preSwitchCaseFlow *ast.FlowNode
61-
activeLabelList *ActiveLabel
62-
emitFlags ast.NodeFlags
63-
seenThisKeyword bool
64-
hasExplicitReturn bool
65-
hasFlowEffects bool
66-
inStrictMode bool
67-
inAssignmentPattern bool
68-
seenParseError bool
69-
symbolCount int
70-
classifiableNames collections.Set[string]
71-
symbolPool core.Pool[ast.Symbol]
72-
flowNodePool core.Pool[ast.FlowNode]
73-
flowListPool core.Pool[ast.FlowList]
74-
singleDeclarationsPool core.Pool[*ast.Node]
49+
container *ast.Node
50+
thisContainer *ast.Node
51+
blockScopeContainer *ast.Node
52+
lastContainer *ast.Node
53+
currentFlow *ast.FlowNode
54+
currentBreakTarget *ast.FlowLabel
55+
currentContinueTarget *ast.FlowLabel
56+
currentReturnTarget *ast.FlowLabel
57+
currentTrueTarget *ast.FlowLabel
58+
currentFalseTarget *ast.FlowLabel
59+
currentExceptionTarget *ast.FlowLabel
60+
preSwitchCaseFlow *ast.FlowNode
61+
activeLabelList *ActiveLabel
62+
emitFlags ast.NodeFlags
63+
seenThisKeyword bool
64+
hasExplicitReturn bool
65+
hasFlowEffects bool
66+
inStrictMode bool
67+
inAssignmentPattern bool
68+
seenParseError bool
69+
symbolCount int
70+
classifiableNames collections.Set[string]
71+
notConstEnumOnlyModules collections.Set[*ast.Symbol]
72+
symbolPool core.Pool[ast.Symbol]
73+
flowNodePool core.Pool[ast.FlowNode]
74+
flowListPool core.Pool[ast.FlowList]
75+
singleDeclarationsPool core.Pool[*ast.Node]
7576
}
7677

7778
func (b *Binder) options() core.SourceFileAffectingCompilerOptions {
@@ -794,9 +795,17 @@ func (b *Binder) bindModuleDeclaration(node *ast.Node) {
794795
state := b.declareModuleSymbol(node)
795796
if state != ast.ModuleInstanceStateNonInstantiated {
796797
symbol := node.Symbol()
797-
if symbol.Flags&(ast.SymbolFlagsFunction|ast.SymbolFlagsClass|ast.SymbolFlagsRegularEnum) != 0 || state != ast.ModuleInstanceStateConstEnumOnly {
798-
// if module was already merged with some function, class or non-const enum, treat it as non-const-enum-only
798+
// if module was already merged with some function, class or non-const enum, treat it as non-const-enum-only
799+
constEnumOnlyModule := (symbol.Flags&(ast.SymbolFlagsFunction|ast.SymbolFlagsClass|ast.SymbolFlagsRegularEnum) == 0) &&
800+
// Current must be `const enum` only
801+
state == ast.ModuleInstanceStateConstEnumOnly &&
802+
// Can't have been set to 'false' in a previous merged symbol. ('undefined' OK)
803+
!b.notConstEnumOnlyModules.Has(symbol)
804+
if constEnumOnlyModule {
805+
symbol.Flags |= ast.SymbolFlagsConstEnumOnlyModule
806+
} else {
799807
symbol.Flags &^= ast.SymbolFlagsConstEnumOnlyModule
808+
b.notConstEnumOnlyModules.Add(symbol)
800809
}
801810
}
802811
}
@@ -2424,6 +2433,7 @@ func (b *Binder) addDeclarationToSymbol(symbol *ast.Symbol, node *ast.Node, symb
24242433
// On merge of const enum module with class or function, reset const enum only flag (namespaces will already recalculate)
24252434
if symbol.Flags&ast.SymbolFlagsConstEnumOnlyModule != 0 && symbol.Flags&(ast.SymbolFlagsFunction|ast.SymbolFlagsClass|ast.SymbolFlagsRegularEnum) != 0 {
24262435
symbol.Flags &^= ast.SymbolFlagsConstEnumOnlyModule
2436+
b.notConstEnumOnlyModules.Add(symbol)
24272437
}
24282438
if symbolFlags&ast.SymbolFlagsValue != 0 {
24292439
SetValueDeclaration(symbol, node)

pkg/bundled/noembed.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ package bundled
55
import (
66
"fmt"
77
"os"
8-
"path/filepath"
98
"sync"
109
"testing"
1110

1211
"github.com/buke/typescript-go-internal/pkg/tspath"
1312
"github.com/buke/typescript-go-internal/pkg/vfs"
13+
"github.com/buke/typescript-go-internal/pkg/vfs/osvfs"
1414
)
1515

1616
const embedded = false
@@ -24,11 +24,9 @@ var executableDir = sync.OnceValue(func() string {
2424
if err != nil {
2525
panic(fmt.Sprintf("bundled: failed to get executable path: %v", err))
2626
}
27-
exe, err = filepath.EvalSymlinks(exe)
28-
if err != nil {
29-
panic(fmt.Sprintf("bundled: failed to evaluate symlinks: %v", err))
30-
}
31-
return filepath.Dir(exe)
27+
exe = tspath.NormalizeSlashes(exe)
28+
exe = osvfs.FS().Realpath(exe)
29+
return tspath.GetDirectoryPath(exe)
3230
})
3331

3432
var libPath = sync.OnceValue(func() string {
@@ -37,10 +35,10 @@ var libPath = sync.OnceValue(func() string {
3735
}
3836
dir := executableDir()
3937

40-
libdts := filepath.Join(dir, "lib.d.ts")
41-
if _, err := os.Stat(libdts); err != nil {
38+
libdts := tspath.CombinePaths(dir, "lib.d.ts")
39+
if info := osvfs.FS().Stat(libdts); info == nil {
4240
panic(fmt.Sprintf("bundled: %v does not exist; this executable may be misplaced", libdts))
4341
}
4442

45-
return tspath.NormalizeSlashes(dir)
43+
return dir
4644
})

pkg/checker/emitresolver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ func (r *EmitResolver) IsTopLevelValueImportEqualsWithEntityName(node *ast.Node)
764764
return false
765765
}
766766
if ast.IsImportEqualsDeclaration(node) &&
767-
(ast.NodeIsMissing(node.AsImportEqualsDeclaration().ModuleReference) || node.AsImportEqualsDeclaration().ModuleReference.Kind != ast.KindExternalModuleReference) {
767+
(ast.NodeIsMissing(node.AsImportEqualsDeclaration().ModuleReference) || node.AsImportEqualsDeclaration().ModuleReference.Kind == ast.KindExternalModuleReference) {
768768
return false
769769
}
770770

pkg/fourslash/fourslash.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,20 @@ var (
492492
defaultDocumentSymbolCapabilities = &lsproto.DocumentSymbolClientCapabilities{
493493
HierarchicalDocumentSymbolSupport: ptrTrue,
494494
}
495+
defaultFoldingRangeCapabilities = &lsproto.FoldingRangeClientCapabilities{
496+
RangeLimit: ptrTo[uint32](5000),
497+
// LineFoldingOnly: ptrTrue,
498+
FoldingRangeKind: &lsproto.ClientFoldingRangeKindOptions{
499+
ValueSet: &[]lsproto.FoldingRangeKind{
500+
lsproto.FoldingRangeKindComment,
501+
lsproto.FoldingRangeKindImports,
502+
lsproto.FoldingRangeKindRegion,
503+
},
504+
},
505+
FoldingRange: &lsproto.ClientFoldingRangeOptions{
506+
CollapsedText: ptrTrue, // Unused by our testing, but set to exercise the code.
507+
},
508+
}
495509
)
496510

497511
func getCapabilitiesWithDefaults(capabilities *lsproto.ClientCapabilities) *lsproto.ClientCapabilities {
@@ -554,6 +568,9 @@ func getCapabilitiesWithDefaults(capabilities *lsproto.ClientCapabilities) *lspr
554568
if capabilitiesWithDefaults.TextDocument.DocumentSymbol == nil {
555569
capabilitiesWithDefaults.TextDocument.DocumentSymbol = defaultDocumentSymbolCapabilities
556570
}
571+
if capabilitiesWithDefaults.TextDocument.FoldingRange == nil {
572+
capabilitiesWithDefaults.TextDocument.FoldingRange = defaultFoldingRangeCapabilities
573+
}
557574
return &capabilitiesWithDefaults
558575
}
559576

0 commit comments

Comments
 (0)