Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3d1700f

Browse files
committed
Send message to lsp client when runtime was not found.
1 parent39b7ed2 commit3d1700f

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

‎server/src/bsc-args/rewatch.ts‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import*aspathfrom"path";
22
import*asutilsfrom"../utils";
33
import*ascpfrom"node:child_process";
4+
import*aspfrom"vscode-languageserver-protocol";
45
importsemverfrom"semver";
56
import{
67
debug,
@@ -9,6 +10,7 @@ import {
910
importtype{projectFiles}from"../projectFiles";
1011
importconfigfrom"../config";
1112
import{findRescriptRuntimesInProject}from"../find-runtime";
13+
import{jsonrpcVersion}from"../constants";
1214

1315
exporttypeRewatchCompilerArgs={
1416
compiler_args:Array<string>;
@@ -54,6 +56,7 @@ async function getRuntimePath(
5456
}
5557

5658
exportasyncfunctiongetRewatchBscArgs(
59+
send:(msg:p.Message)=>void,
5760
projectsFiles:Map<string,projectFiles>,
5861
entry:IncrementallyCompiledFileInfo,
5962
):Promise<RewatchCompilerArgs|null>{
@@ -129,17 +132,33 @@ export async function getRewatchBscArgs(
129132
(envasany)["RESCRIPT_BSC_EXE"]=bscExe;
130133
}
131134

132-
letrescriptRuntime:string|null=awaitgetRuntimePath(entry);
133-
135+
// For ReScript >= 12.0.0-beta.11 we need to set RESCRIPT_RUNTIME
134136
if(
135-
rescriptRuntime!==null&&
136137
semver.satisfies(project.rescriptVersion,">=12.0.0-beta.11",{
137138
includePrerelease:true,
138139
})
139140
){
140-
(envasany)["RESCRIPT_RUNTIME"]=rescriptRuntime;
141-
}else{
142-
// TODO: if no runtime was found, we should let the user know
141+
letrescriptRuntime:string|null=awaitgetRuntimePath(entry);
142+
143+
if(rescriptRuntime!==null){
144+
(envasany)["RESCRIPT_RUNTIME"]=rescriptRuntime;
145+
}else{
146+
// If no runtime was found, we should let the user know.
147+
letparams:p.ShowMessageParams={
148+
type:p.MessageType.Error,
149+
message:
150+
`[Incremental type checking] The @rescript/runtime package was not found in your project. `+
151+
`It is normally included with ReScript, but either it's missing or could not be detected. `+
152+
`Check that it exists in your dependencies, or configure 'rescript.settings.runtimePath' to point to it. `+
153+
`Without this package, incremental type checking may not work as expected.`,
154+
};
155+
letmessage:p.NotificationMessage={
156+
jsonrpc:jsonrpcVersion,
157+
method:"window/showMessage",
158+
params:params,
159+
};
160+
send(message);
161+
}
143162
}
144163

145164
constcompilerArgs=JSON.parse(

‎server/src/incrementalCompilation.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,12 @@ export function cleanUpIncrementalFiles(
180180
}
181181

182182
exportasyncfunctiongetBscArgs(
183+
send:(msg:p.Message)=>void,
183184
entry:IncrementallyCompiledFileInfo,
184185
):Promise<BsbCompilerArgs|RewatchCompilerArgs|null>{
185186
returnentry.buildSystem==="bsb"
186187
?awaitgetBsbBscArgs(entry)
187-
:awaitgetRewatchBscArgs(projectsFiles,entry);
188+
:awaitgetRewatchBscArgs(send,projectsFiles,entry);
188189
}
189190

190191
functionargCouples(argList:string[]):string[][]{
@@ -331,6 +332,7 @@ function triggerIncrementalCompilationOfFile(
331332
};
332333

333334
incrementalFileCacheEntry.project.callArgs=figureOutBscArgs(
335+
send,
334336
incrementalFileCacheEntry,
335337
);
336338
originalTypeFileToFilePath.set(
@@ -371,7 +373,10 @@ function verifyTriggerToken(filePath: string, triggerToken: number): boolean {
371373

372374
constisWindows=os.platform()==="win32";
373375

374-
asyncfunctionfigureOutBscArgs(entry:IncrementallyCompiledFileInfo){
376+
asyncfunctionfigureOutBscArgs(
377+
send:(msg:p.Message)=>void,
378+
entry:IncrementallyCompiledFileInfo,
379+
){
375380
constproject=projectsFiles.get(entry.project.rootPath);
376381
if(project?.rescriptVersion==null){
377382
if(debug()){
@@ -382,7 +387,7 @@ async function figureOutBscArgs(entry: IncrementallyCompiledFileInfo) {
382387
}
383388
returnnull;
384389
}
385-
constres=awaitgetBscArgs(entry);
390+
constres=awaitgetBscArgs(send,entry);
386391
if(res==null)returnnull;
387392
letastArgs:Array<Array<string>>=[];
388393
letbuildArgs:Array<Array<string>>=[];
@@ -483,7 +488,7 @@ async function compileContents(
483488
consttriggerToken=entry.compilation?.triggerToken;
484489
letcallArgs=awaitentry.project.callArgs;
485490
if(callArgs==null){
486-
constcallArgsRetried=awaitfigureOutBscArgs(entry);
491+
constcallArgsRetried=awaitfigureOutBscArgs(send,entry);
487492
if(callArgsRetried!=null){
488493
callArgs=callArgsRetried;
489494
entry.project.callArgs=Promise.resolve(callArgsRetried);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp