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

Commit3d9a6d9

Browse files
authored
Link up new prepareRename command (#1124)
* link up new prepareRename command* adjust* changelog
1 parent0f4acf9 commit3d9a6d9

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
####:house: Internal
2525

2626
- Find`@rescript/runtime` for Rewatch compiler-args call.https://github.com/rescript-lang/rescript-vscode/pull/1125
27+
- Use`prepareRename` command (when a new enough ReScript version is used) to speed up the`rename` command.https://github.com/rescript-lang/rescript-vscode/pull/1124
2728

2829
##1.64.0
2930

‎server/src/server.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as p from "vscode-languageserver-protocol";
33
import*asvfrom"vscode-languageserver";
44
import*asrpcfrom"vscode-jsonrpc/node";
55
import*aspathfrom"path";
6+
importsemverfrom"semver";
67
importfsfrom"fs";
78
import{
89
DidChangeWatchedFilesNotification,
@@ -687,6 +688,37 @@ async function prepareRename(
687688
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_prepareRename
688689
letparams=msg.paramsasp.PrepareRenameParams;
689690
letfilePath=fileURLToPath(params.textDocument.uri);
691+
692+
// `prepareRename` was introduced in 12.0.0-beta.10
693+
letprojectRootPath=utils.findProjectRootOfFile(filePath);
694+
letrescriptVersion=
695+
(projectRootPath&&projectsFiles.get(projectRootPath)?.rescriptVersion)||
696+
(awaitutils.findReScriptVersionForProjectRoot(projectRootPath??null));
697+
698+
letshouldUsePrepareRenameCommand=false;
699+
if(rescriptVersion!=null){
700+
shouldUsePrepareRenameCommand=
701+
semver.valid(rescriptVersion)!=null&&
702+
semver.satisfies(rescriptVersion,">=12.0.0-beta.10",{
703+
includePrerelease:true,
704+
});
705+
}
706+
707+
if(shouldUsePrepareRenameCommand){
708+
letanalysisResult=awaitutils.runAnalysisAfterSanityCheck(filePath,[
709+
"prepareRename",
710+
filePath,
711+
params.position.line,
712+
params.position.character,
713+
]);
714+
715+
return{
716+
jsonrpc:c.jsonrpcVersion,
717+
id:msg.id,
718+
result:analysisResultasp.PrepareRenameResult,
719+
};
720+
}
721+
690722
letlocations:null|p.Location[]=awaitutils.getReferencesForPosition(
691723
filePath,
692724
params.position,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp