Skip to content

Commit d7ae476

Browse files
dependabot[bot]github-actions[bot]buke
authored
deps(deps): bump microsoft/typescript-go from fb0c169 to f16a4b7 (#42)
* deps(deps): bump microsoft/typescript-go from `fb0c169` to `f16a4b7` Bumps [microsoft/typescript-go](https://github.com/microsoft/typescript-go) from `fb0c169` to `f16a4b7`. - [Commits](microsoft/typescript-go@fb0c169...f16a4b7) --- updated-dependencies: - dependency-name: microsoft/typescript-go dependency-version: f16a4b74c0663b390f96f9a9e7d3f7a3cc76f650 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * chore(sync): mirror internal packages into pkg/ (auto) (#43) 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 c1b48ea commit d7ae476

File tree

12 files changed

+247
-97
lines changed

12 files changed

+247
-97
lines changed

pkg/compiler/fileloader.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ type fileLoader struct {
3434
comparePathsOptions tspath.ComparePathsOptions
3535
supportedExtensions []string
3636

37-
filesParser *filesParser
38-
rootTasks []*parseTask
39-
includeProcessor *includeProcessor
37+
filesParser *filesParser
38+
rootTasks []*parseTask
4039

4140
totalFileCount atomic.Int32
4241
libFileCount atomic.Int32
@@ -101,7 +100,6 @@ func processAllProgramFiles(
101100
},
102101
rootTasks: make([]*parseTask, 0, len(rootFiles)+len(compilerOptions.Lib)),
103102
supportedExtensions: core.Flatten(tsoptions.GetSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions)),
104-
includeProcessor: &includeProcessor{},
105103
}
106104
loader.addProjectReferenceTasks(singleThreaded)
107105
loader.resolver = module.NewResolver(loader.projectReferenceFileMapper.host, compilerOptions, opts.TypingsLocation, opts.ProjectName)
@@ -363,7 +361,7 @@ func (p *fileLoader) resolveTypeReferenceDirectives(t *parseTask) {
363361
includeReason: includeReason,
364362
}, nil)
365363
} else {
366-
p.includeProcessor.addProcessingDiagnostic(&processingDiagnostic{
364+
t.processingDiagnostics = append(t.processingDiagnostics, &processingDiagnostic{
367365
kind: processingDiagnosticKindUnknownReference,
368366
data: includeReason,
369367
})

pkg/compiler/filesparser.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (t *parseTask) load(loader *fileLoader) {
129129
includeReason: includeReason,
130130
}, libFile)
131131
} else {
132-
loader.includeProcessor.addProcessingDiagnostic(&processingDiagnostic{
132+
t.processingDiagnostics = append(t.processingDiagnostics, &processingDiagnostic{
133133
kind: processingDiagnosticKindUnknownReference,
134134
data: includeReason,
135135
})
@@ -268,7 +268,9 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles {
268268
tasksSeenByNameIgnoreCase = make(map[string]*parseTask, totalFileCount)
269269
}
270270

271-
loader.includeProcessor.fileIncludeReasons = make(map[tspath.Path][]*FileIncludeReason, totalFileCount)
271+
includeProcessor := &includeProcessor{
272+
fileIncludeReasons: make(map[tspath.Path][]*FileIncludeReason, totalFileCount),
273+
}
272274
var outputFileToProjectReferenceSource map[tspath.Path]string
273275
if !loader.opts.canUseProjectReferenceSource() {
274276
outputFileToProjectReferenceSource = make(map[tspath.Path]string, totalFileCount)
@@ -292,7 +294,7 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles {
292294
if task.loadedTask != nil {
293295
task = task.loadedTask
294296
}
295-
w.addIncludeReason(loader, task, includeReason)
297+
w.addIncludeReason(includeProcessor, task, includeReason)
296298
}
297299
data, _ := w.taskDataByPath.Load(task.path)
298300
if !task.loaded {
@@ -306,7 +308,7 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles {
306308
checkedAbsolutePath := tspath.GetNormalizedAbsolutePathWithoutRoot(checkedName, loader.comparePathsOptions.CurrentDirectory)
307309
inputAbsolutePath := tspath.GetNormalizedAbsolutePathWithoutRoot(task.normalizedFilePath, loader.comparePathsOptions.CurrentDirectory)
308310
if checkedAbsolutePath != inputAbsolutePath {
309-
loader.includeProcessor.addProcessingDiagnosticsForFileCasing(task.path, checkedName, task.normalizedFilePath, includeReason)
311+
includeProcessor.addProcessingDiagnosticsForFileCasing(task.path, checkedName, task.normalizedFilePath, includeReason)
310312
}
311313
}
312314
continue
@@ -317,7 +319,7 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles {
317319
if tasksSeenByNameIgnoreCase != nil {
318320
pathLowerCase := tspath.ToFileNameLowerCase(string(task.path))
319321
if taskByIgnoreCase, ok := tasksSeenByNameIgnoreCase[pathLowerCase]; ok {
320-
loader.includeProcessor.addProcessingDiagnosticsForFileCasing(taskByIgnoreCase.path, taskByIgnoreCase.normalizedFilePath, task.normalizedFilePath, includeReason)
322+
includeProcessor.addProcessingDiagnosticsForFileCasing(taskByIgnoreCase.path, taskByIgnoreCase.normalizedFilePath, task.normalizedFilePath, includeReason)
321323
} else {
322324
tasksSeenByNameIgnoreCase[pathLowerCase] = task
323325
}
@@ -351,7 +353,7 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles {
351353
path := task.path
352354

353355
if len(task.processingDiagnostics) > 0 {
354-
loader.includeProcessor.processingDiagnostics = append(loader.includeProcessor.processingDiagnostics, task.processingDiagnostics...)
356+
includeProcessor.processingDiagnostics = append(includeProcessor.processingDiagnostics, task.processingDiagnostics...)
355357
}
356358

357359
if file == nil {
@@ -420,19 +422,19 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles {
420422
sourceFilesFoundSearchingNodeModules: sourceFilesFoundSearchingNodeModules,
421423
libFiles: libFilesMap,
422424
missingFiles: missingFiles,
423-
includeProcessor: loader.includeProcessor,
425+
includeProcessor: includeProcessor,
424426
outputFileToProjectReferenceSource: outputFileToProjectReferenceSource,
425427
}
426428
}
427429

428-
func (w *filesParser) addIncludeReason(loader *fileLoader, task *parseTask, reason *FileIncludeReason) {
430+
func (w *filesParser) addIncludeReason(includeProcessor *includeProcessor, task *parseTask, reason *FileIncludeReason) {
429431
if task.redirectedParseTask != nil {
430-
w.addIncludeReason(loader, task.redirectedParseTask, reason)
432+
w.addIncludeReason(includeProcessor, task.redirectedParseTask, reason)
431433
} else if task.loaded {
432-
if existing, ok := loader.includeProcessor.fileIncludeReasons[task.path]; ok {
433-
loader.includeProcessor.fileIncludeReasons[task.path] = append(existing, reason)
434+
if existing, ok := includeProcessor.fileIncludeReasons[task.path]; ok {
435+
includeProcessor.fileIncludeReasons[task.path] = append(existing, reason)
434436
} else {
435-
loader.includeProcessor.fileIncludeReasons[task.path] = []*FileIncludeReason{reason}
437+
includeProcessor.fileIncludeReasons[task.path] = []*FileIncludeReason{reason}
436438
}
437439
}
438440
}

pkg/lsp/logger.go

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
package lsp
2+
3+
import (
4+
"fmt"
5+
"sync"
6+
7+
"github.com/buke/typescript-go-internal/pkg/lsp/lsproto"
8+
"github.com/buke/typescript-go-internal/pkg/project/logging"
9+
)
10+
11+
var _ logging.Logger = (*logger)(nil)
12+
13+
type logger struct {
14+
server *Server
15+
mu sync.Mutex
16+
verbose bool
17+
}
18+
19+
func newLogger(server *Server) *logger {
20+
return &logger{
21+
server: server,
22+
}
23+
}
24+
25+
func (l *logger) sendLogMessage(msgType lsproto.MessageType, message string) {
26+
if l == nil {
27+
return
28+
}
29+
30+
if !l.server.initStarted.Load() {
31+
fmt.Fprintln(l.server.stderr, message)
32+
return
33+
}
34+
35+
notification := lsproto.WindowLogMessageInfo.NewNotificationMessage(&lsproto.LogMessageParams{
36+
Type: msgType,
37+
Message: message,
38+
})
39+
l.server.outgoingQueue <- notification.Message()
40+
}
41+
42+
func (l *logger) Log(msg ...any) {
43+
if l == nil {
44+
return
45+
}
46+
l.sendLogMessage(lsproto.MessageTypeLog, fmt.Sprint(msg...))
47+
}
48+
49+
func (l *logger) Logf(format string, args ...any) {
50+
if l == nil {
51+
return
52+
}
53+
l.sendLogMessage(lsproto.MessageTypeLog, fmt.Sprintf(format, args...))
54+
}
55+
56+
func (l *logger) Verbose() logging.Logger {
57+
if l == nil {
58+
return nil
59+
}
60+
l.mu.Lock()
61+
defer l.mu.Unlock()
62+
if !l.verbose {
63+
return nil
64+
}
65+
return l
66+
}
67+
68+
func (l *logger) IsVerbose() bool {
69+
if l == nil {
70+
return false
71+
}
72+
l.mu.Lock()
73+
defer l.mu.Unlock()
74+
return l.verbose
75+
}
76+
77+
func (l *logger) SetVerbose(verbose bool) {
78+
if l == nil {
79+
return
80+
}
81+
l.mu.Lock()
82+
defer l.mu.Unlock()
83+
l.verbose = verbose
84+
}
85+
86+
func (l *logger) Error(msg ...any) {
87+
if l == nil {
88+
return
89+
}
90+
l.sendLogMessage(lsproto.MessageTypeError, fmt.Sprint(msg...))
91+
}
92+
93+
func (l *logger) Errorf(format string, args ...any) {
94+
if l == nil {
95+
return
96+
}
97+
l.sendLogMessage(lsproto.MessageTypeError, fmt.Sprintf(format, args...))
98+
}
99+
100+
func (l *logger) Warn(msg ...any) {
101+
if l == nil {
102+
return
103+
}
104+
l.sendLogMessage(lsproto.MessageTypeWarning, fmt.Sprint(msg...))
105+
}
106+
107+
func (l *logger) Warnf(format string, args ...any) {
108+
if l == nil {
109+
return
110+
}
111+
l.sendLogMessage(lsproto.MessageTypeWarning, fmt.Sprintf(format, args...))
112+
}
113+
114+
func (l *logger) Info(msg ...any) {
115+
if l == nil {
116+
return
117+
}
118+
l.sendLogMessage(lsproto.MessageTypeInfo, fmt.Sprint(msg...))
119+
}
120+
121+
func (l *logger) Infof(format string, args ...any) {
122+
if l == nil {
123+
return
124+
}
125+
l.sendLogMessage(lsproto.MessageTypeInfo, fmt.Sprintf(format, args...))
126+
}

pkg/lsp/lsproto/_generate/fetchModel.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const __dirname = path.dirname(__filename);
88
const metaModelPath = path.join(__dirname, "metaModel.json");
99
const metaModelSchemaPath = path.join(__dirname, "metaModelSchema.mts");
1010

11-
const hash = "dadd73f7fc283b4d0adb602adadcf4be16ef3a7b";
11+
const hash = "2abd2d977aa36e8c6b242ff048bdbf5df71e3088";
1212

1313
const metaModelURL = `https://raw.githubusercontent.com/microsoft/vscode-languageserver-node/${hash}/protocol/metaModel.json`;
1414
const metaModelSchemaURL = `https://raw.githubusercontent.com/microsoft/vscode-languageserver-node/${hash}/tools/src/metaModel.ts`;

pkg/lsp/lsproto/_generate/metaModelSchema.mts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,16 @@ export type Request = {
202202
* the property contains the deprecation message.
203203
*/
204204
deprecated?: string;
205+
206+
/**
207+
* The client capability property path if any.
208+
*/
209+
clientCapability?: string;
210+
211+
/**
212+
* The server capability property path if any.
213+
*/
214+
serverCapability?: string;
205215
};
206216

207217
/**
@@ -269,6 +279,16 @@ export type Notification = {
269279
* the property contains the deprecation message.
270280
*/
271281
deprecated?: string;
282+
283+
/**
284+
* The client capability property path if any.
285+
*/
286+
clientCapability?: string;
287+
288+
/**
289+
* The server capability property path if any.
290+
*/
291+
serverCapability?: string;
272292
};
273293

274294
/**

0 commit comments

Comments
 (0)