@@ -16,18 +16,18 @@ namespace KS.RustAnalyzer.Infrastructure;
1616
1717public interface IRlsInstallerService
1818{
19- Task < PathEx > GetRustAnalyzerExePathAsync ( ) ;
19+ Task < PathEx > GetExePathAsync ( ) ;
2020
21- Task InstallLatestRAAsync ( ) ;
21+ Task InstallLatestAsync ( ) ;
2222}
2323
2424[ Export ( typeof ( IRlsInstallerService ) ) ]
2525[ PartCreationPolicy ( CreationPolicy . Shared ) ]
2626public class RlsInstallerService : IRlsInstallerService
2727{
28- public const string LatestInPackageRAVersion = "2024-01-08" ;
29- public const string RAVersionFormat = "yyyy-MM-dd" ;
30- private const string InstalledRAVersionKey = "InstalledRAVersion " ;
28+ public const string LatestInPackageVersion = "2024-01-08" ;
29+ public const string VersionFormat = "yyyy-MM-dd" ;
30+ private const string InstalledRlsVersionKey = "InstalledRlsVersion " ;
3131 private readonly IRegistrySettingsService _regSettings ;
3232 private readonly TL _tl ;
3333
@@ -42,17 +42,17 @@ public RlsInstallerService(IRegistrySettingsService regSettings, [Import] ITelem
4242 } ;
4343 }
4444
45- public async Task InstallLatestRAAsync ( )
45+ public async Task InstallLatestAsync ( )
4646 {
47- _tl . L . WriteLine ( "Initiating download of RA ..." ) ;
47+ _tl . L . WriteLine ( "Initiating download of RLS ..." ) ;
4848 try
4949 {
50- var latestRel = await GetLatestRAReleaseRedirectUriAsync ( ) ;
50+ var latestRel = await GetLatestRlsReleaseRedirectUriAsync ( ) ;
5151 string installedVer = await GetInstalledVersionAsync ( ) ;
5252 if ( latestRel != null && installedVer . CompareTo ( latestRel ? . Version ) >= 0 )
5353 {
54- _tl . L . WriteLine ( $ "Not going to download RA . Installed = { installedVer } , Latest = { latestRel ? . Uri } .") ;
55- _tl . T . TrackEvent ( "RADS.RAUpToDate " , ( "Installed" , installedVer ) , ( "Latest" , latestRel ? . Uri . ToString ( ) ) ) ;
54+ _tl . L . WriteLine ( $ "Not going to download RLS . Installed = { installedVer } , Latest = { latestRel ? . Uri } .") ;
55+ _tl . T . TrackEvent ( "RLSDS.RlsUpToDate " , ( "Installed" , installedVer ) , ( "Latest" , latestRel ? . Uri . ToString ( ) ) ) ;
5656 return ;
5757 }
5858
@@ -62,7 +62,7 @@ public async Task InstallLatestRAAsync()
6262 Install ( zipStream , latestRel ? . Version ) ;
6363
6464 await CommitAsync ( latestRel ) ;
65- _tl . T . TrackEvent ( "RADS.RAInstalled " , ( "Installed" , installedVer ) ) ;
65+ _tl . T . TrackEvent ( "RLSDS.RlsInstalled " , ( "Installed" , installedVer ) ) ;
6666 }
6767 catch ( Exception ex )
6868 {
@@ -72,43 +72,43 @@ public async Task InstallLatestRAAsync()
7272 }
7373 }
7474
75- public async Task < PathEx > GetRustAnalyzerExePathAsync ( )
75+ public async Task < PathEx > GetExePathAsync ( )
7676 {
77- return GetVersionedRAExePath ( await GetInstalledVersionAsync ( ) ) ;
77+ return GetVersionedExePath ( await GetInstalledVersionAsync ( ) ) ;
7878 }
7979
80- public static async Task < ( Uri Uri , string Version ) ? > GetLatestRAReleaseRedirectUriAsync ( )
80+ public static async Task < ( Uri Uri , string Version ) ? > GetLatestRlsReleaseRedirectUriAsync ( )
8181 {
8282 try
8383 {
8484 var latestRelUri = await GetRedirectedUrlAsync ( "https://github.com/rust-lang/rust-analyzer/releases/latest" . ToUri ( ) ) ;
8585
8686 var latestRelVersion = latestRelUri . Segments [ latestRelUri . Segments . Length - 1 ] ;
87- var latestRelDate = DateTime . ParseExact ( latestRelVersion , RAVersionFormat , CultureInfo . InvariantCulture ) ;
87+ var latestRelDate = DateTime . ParseExact ( latestRelVersion , VersionFormat , CultureInfo . InvariantCulture ) ;
8888
8989 return ( Uri : new Uri ( $ "https://github.com/rust-lang/rust-analyzer/releases/download/{ latestRelVersion } /rust-analyzer-x86_64-pc-windows-msvc.zip") ,
90- Version : latestRelDate . ToString ( RAVersionFormat , CultureInfo . InvariantCulture ) ) ;
90+ Version : latestRelDate . ToString ( VersionFormat , CultureInfo . InvariantCulture ) ) ;
9191 }
9292 catch
9393 {
9494 return null ;
9595 }
9696 }
9797
98- private PathEx GetVersionedRAExePath ( string version )
98+ private PathEx GetVersionedExePath ( string version )
9999 {
100- return GetRAFolder ( version ) + ( PathEx ) $ "rust-analyzer.exe";
100+ return GetInstallFolder ( version ) + ( PathEx ) $ "rust-analyzer.exe";
101101 }
102102
103103 private async Task < HttpResponseMessage > DownloadAsync ( ( Uri Uri , string Version ) ? latestRel )
104104 {
105- _tl . L . WriteLine ( $ "Downloading RA v { latestRel ? . Uri } .") ;
105+ _tl . L . WriteLine ( $ "Downloading RLS from { latestRel ? . Uri } .") ;
106106 var response = await new HttpClient ( ) . GetAsync ( latestRel ? . Uri ) ;
107107 if ( ! response . IsSuccessStatusCode )
108108 {
109109 _tl . L . WriteError ( $ "Download failed. StatusCode { response . StatusCode } .") ;
110- _tl . T . TrackEvent ( "RADS.RADownloadFailed " , ( "StatusCode" , response . StatusCode . ToString ( ) ) ) ;
111- throw new Exception ( $ "RADS.RADownloadFailed . { response . StatusCode } .") ;
110+ _tl . T . TrackEvent ( "RLSDS.RlsDownloadFailed " , ( "StatusCode" , response . StatusCode . ToString ( ) ) ) ;
111+ throw new Exception ( $ "RLSDS.RlsDownloadFailed . { response . StatusCode } .") ;
112112 }
113113
114114 return response ;
@@ -123,15 +123,15 @@ private async Task CommitAsync((Uri Uri, string Version)? latestRel)
123123 throw new Exception ( $ "GetPackageRegistryRoot failed.") ;
124124 }
125125
126- Registry . SetValue ( regRoot , InstalledRAVersionKey , latestRel ? . Version ) ;
126+ Registry . SetValue ( regRoot , InstalledRlsVersionKey , latestRel ? . Version ) ;
127127 RlsUpdatedNotification . Enabled = true ;
128- _tl . L . WriteLine ( $ "Committed RA installation.") ;
128+ _tl . L . WriteLine ( $ "Committed RLS installation.") ;
129129 }
130130
131131 private void Install ( Stream zipStream , string downloadedVersion )
132132 {
133- _tl . L . WriteLine ( $ "Installing RA v { downloadedVersion } ...") ;
134- var raFolder = GetRAFolder ( downloadedVersion ) ;
133+ _tl . L . WriteLine ( $ "Installing RLS v { downloadedVersion } ...") ;
134+ var raFolder = GetInstallFolder ( downloadedVersion ) ;
135135 Directory . CreateDirectory ( raFolder ) ;
136136 using var zip = new ZipArchive ( zipStream ) ;
137137 foreach ( var entry in zip . Entries )
@@ -146,22 +146,22 @@ private async Task<string> GetInstalledVersionAsync()
146146 {
147147 await ThreadHelper . JoinableTaskFactory . SwitchToMainThreadAsync ( ) ;
148148
149- var installedRAVersion = LatestInPackageRAVersion ;
149+ var installedRlsVersion = LatestInPackageVersion ;
150150 if ( _regSettings . GetPackageRegistryRoot ( out var regRoot ) )
151151 {
152- installedRAVersion = Registry . GetValue ( regRoot , InstalledRAVersionKey , null ) as string ;
152+ installedRlsVersion = Registry . GetValue ( regRoot , InstalledRlsVersionKey , null ) as string ;
153153 }
154154
155- installedRAVersion ??= LatestInPackageRAVersion ;
156- if ( GetVersionedRAExePath ( installedRAVersion ) . FileExists ( ) )
155+ installedRlsVersion ??= LatestInPackageVersion ;
156+ if ( GetVersionedExePath ( installedRlsVersion ) . FileExists ( ) )
157157 {
158- return installedRAVersion ;
158+ return installedRlsVersion ;
159159 }
160160
161- return LatestInPackageRAVersion ;
161+ return LatestInPackageVersion ;
162162 }
163163
164- private static PathEx GetRAFolder ( string version )
164+ private static PathEx GetInstallFolder ( string version )
165165 {
166166 return ( PathEx ) Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) + ( PathEx ) version ;
167167 }
0 commit comments