@@ -29,7 +29,7 @@ import * as ic from "./incrementalCompilation";
2929import config , { extensionConfiguration , initialConfiguration } from "./config" ;
3030import { projectsFiles } from "./projectFiles" ;
3131import { NormalizedPath } from "./utils" ;
32- import { initializeLogger , getLogger , setLogLevel , LogLevel } from "./logger" ;
32+ import { initializeLogger , getLogger , setLogLevel } from "./logger" ;
3333
3434function applyUserConfiguration ( configuration : extensionConfiguration ) {
3535 // We always want to spread the initial configuration to ensure all defaults are respected.
@@ -1285,27 +1285,30 @@ function openCompiledFile(msg: p.RequestMessage): p.Message {
12851285 return response ;
12861286}
12871287
1288+ async function getServerVersion ( ) : Promise < string | undefined > {
1289+ // Read the server version from package.json
1290+ let serverVersion : string | undefined ;
1291+ try {
1292+ const packageJsonPath = path . join ( __dirname , ".." , "package.json" ) ;
1293+ const packageJsonContent = await fsAsync . readFile ( packageJsonPath , {
1294+ encoding : "utf-8" ,
1295+ } ) ;
1296+ const packageJson : { version ?: unknown } = JSON . parse ( packageJsonContent ) ;
1297+ serverVersion =
1298+ typeof packageJson . version === "string" ? packageJson . version : undefined ;
1299+ } catch ( e ) {
1300+ // If we can't read the version, that's okay - we'll just omit it
1301+ serverVersion = undefined ;
1302+ }
1303+ return serverVersion ;
1304+ }
1305+
12881306async function dumpServerState (
12891307 msg : p . RequestMessage ,
12901308) : Promise < p . ResponseMessage > {
12911309 // Custom debug endpoint: dump current server state (config + projectsFiles)
12921310 try {
1293- // Read the server version from package.json
1294- let serverVersion : string | undefined ;
1295- try {
1296- const packageJsonPath = path . join ( __dirname , ".." , "package.json" ) ;
1297- const packageJsonContent = await fsAsync . readFile ( packageJsonPath , {
1298- encoding : "utf-8" ,
1299- } ) ;
1300- const packageJson : { version ?: unknown } = JSON . parse ( packageJsonContent ) ;
1301- serverVersion =
1302- typeof packageJson . version === "string"
1303- ? packageJson . version
1304- : undefined ;
1305- } catch ( e ) {
1306- // If we can't read the version, that's okay - we'll just omit it
1307- serverVersion = undefined ;
1308- }
1311+ const serverVersion = await getServerVersion ( ) ;
13091312
13101313 const projects = Array . from ( projectsFiles . entries ( ) ) . map (
13111314 ( [ projectRootPath , pf ] ) => ( {
@@ -1477,7 +1480,10 @@ async function onMessage(msg: p.Message) {
14771480 } ;
14781481 send ( response ) ;
14791482 } else if ( msg . method === "initialize" ) {
1480- getLogger ( ) . info ( "Received initialize request from client." ) ;
1483+ const serverVersion = await getServerVersion ( ) ;
1484+ getLogger ( ) . info (
1485+ `Received initialize request from client. Server version: ${ serverVersion } ` ,
1486+ ) ;
14811487 // Save initial configuration, if present
14821488 let initParams = msg . params as InitializeParams ;
14831489 for ( const workspaceFolder of initParams . workspaceFolders || [ ] ) {
0 commit comments