11import * as vscode from "vscode" ;
22import * as os from "os" ;
3+ import * as path from "path" ;
34import fetch from "node-fetch" ;
45import {
56 Executable ,
89 LanguageClientOptions ,
910} from "vscode-languageclient/node" ;
1011
11- import { Utils as UriUtils } from "vscode-uri" ;
12-
1312import spawn from "./spawn" ;
1413
1514let client : LanguageClient ;
@@ -41,6 +40,14 @@ const exists = (uri: vscode.Uri): Thenable<boolean> => {
4140 ) ;
4241} ;
4342
43+ const basenameUri = ( uri : vscode . Uri ) : string => {
44+ return path . basename ( uri . fsPath ) ;
45+ } ;
46+
47+ const resolveUri = ( uri : vscode . Uri , ...paths : string [ ] ) : vscode . Uri => {
48+ return vscode . Uri . file ( path . resolve ( uri . fsPath , ...paths ) ) ;
49+ } ;
50+
4451const downloadApiDefinitions = async ( context : vscode . ExtensionContext ) => {
4552 try {
4653 return vscode . window . withProgress (
@@ -127,7 +134,7 @@ const updateSourceMap = async (workspaceFolder: vscode.WorkspaceFolder) => {
127134 // Check if the project file exists
128135 let projectFile =
129136 config . get < string > ( "rojoProjectFile" ) ?? "default.project.json" ;
130- const projectFileUri = UriUtils . resolvePath ( workspaceFolder . uri , projectFile ) ;
137+ const projectFileUri = resolveUri ( workspaceFolder . uri , projectFile ) ;
131138
132139 if ( ! ( await exists ( projectFileUri ) ) ) {
133140 // Search if there is a *.project.json file present in this workspace.
@@ -141,7 +148,7 @@ const updateSourceMap = async (workspaceFolder: vscode.WorkspaceFolder) => {
141148 ) ;
142149 return ;
143150 } else if ( foundProjectFiles . length === 1 ) {
144- const fileName = UriUtils . basename ( foundProjectFiles [ 0 ] ) ;
151+ const fileName = basenameUri ( foundProjectFiles [ 0 ] ) ;
145152 const option = await vscode . window . showWarningMessage (
146153 `Unable to find project file ${ projectFile } . We found ${ fileName } available` ,
147154 `Set project file to ${ fileName } ` ,
@@ -161,7 +168,7 @@ const updateSourceMap = async (workspaceFolder: vscode.WorkspaceFolder) => {
161168 "Cancel"
162169 ) ;
163170 if ( option === "Select project file" ) {
164- const files = foundProjectFiles . map ( ( file ) => UriUtils . basename ( file ) ) ;
171+ const files = foundProjectFiles . map ( ( file ) => basenameUri ( file ) ) ;
165172 const selectedFile = await vscode . window . showQuickPick ( files ) ;
166173 if ( selectedFile ) {
167174 config . update ( "rojoProjectFile" , selectedFile ) ;
@@ -223,7 +230,7 @@ export async function activate(context: vscode.ExtensionContext) {
223230 for ( const definitionPath of definitionFiles ) {
224231 let uri ;
225232 if ( vscode . workspace . workspaceFolders ) {
226- uri = UriUtils . resolvePath (
233+ uri = resolveUri (
227234 vscode . workspace . workspaceFolders [ 0 ] . uri ,
228235 definitionPath
229236 ) ;
0 commit comments