Skip to content

Commit cde5b83

Browse files
author
mergerepo
committed
Merge remote branch 'origin/master' into edge
(no-precommit-check no-tn-check)
2 parents 72782d1 + 65aa931 commit cde5b83

File tree

1 file changed

+47
-44
lines changed

1 file changed

+47
-44
lines changed

integration/vscode/ada/src/extension.ts

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -128,57 +128,60 @@ export function activate(context: vscode.ExtensionContext): void {
128128

129129
// Check if we need to add some source directories to the workspace (e.g: when imported projects'
130130
// source directories are not placed under the root project's directory).
131-
client.onReady().then(() => {
132-
client.sendRequest("workspace/alsSourceDirs").then(
133-
data => {
134-
const source_dirs = JSON.parse(JSON.stringify(data));
135-
const workspace_folders = vscode.workspace.workspaceFolders ?? []
136-
let workspace_dirs_to_add: { uri: vscode.Uri, name?: string | undefined}[] = []
137-
138-
for (var source_dir of source_dirs) {
139-
const source_dir_uri = vscode.Uri.parse(source_dir.uri)
140-
let source_dir_path = source_dir_uri.path
141-
let workspace_folder_path = workspace_folders[0].uri.path
142-
143-
function is_subdirectory(dir: string, parent: string) {
144-
// Use lower-case on Windows since drives can be specified in VS Code either
145-
// with lower or upper case characters.
146-
if (process.platform == "win32") {
147-
dir = dir.toLowerCase();
148-
parent = parent.toLowerCase();
149-
}
131+
// Do nothing is the user did not setup any workspace file.
132+
if (vscode.workspace.workspaceFile !== undefined) {
133+
client.onReady().then(() => {
134+
client.sendRequest("workspace/alsSourceDirs").then(
135+
data => {
136+
const source_dirs = JSON.parse(JSON.stringify(data));
137+
const workspace_folders = vscode.workspace.workspaceFolders ?? []
138+
let workspace_dirs_to_add: { uri: vscode.Uri, name?: string | undefined }[] = []
139+
140+
for (var source_dir of source_dirs) {
141+
const source_dir_uri = vscode.Uri.parse(source_dir.uri)
142+
let source_dir_path = source_dir_uri.path
143+
let workspace_folder_path = workspace_folders[0].uri.path
144+
145+
function is_subdirectory(dir: string, parent: string) {
146+
// Use lower-case on Windows since drives can be specified in VS Code either
147+
// with lower or upper case characters.
148+
if (process.platform == "win32") {
149+
dir = dir.toLowerCase();
150+
parent = parent.toLowerCase();
151+
}
150152

151-
return dir.startsWith(parent + '/');
153+
return dir.startsWith(parent + '/');
152154

153-
}
155+
}
154156

155-
// If the source directory is not under one of the workspace folders, push this
156-
// source directory to the workspace folders to add later.
157-
if (!workspace_folders.some(workspace_folder =>
158-
is_subdirectory(source_dir_path, workspace_folder.uri.path))) {
159-
workspace_dirs_to_add.push({name: source_dir.name, uri: source_dir_uri});
157+
// If the source directory is not under one of the workspace folders, push this
158+
// source directory to the workspace folders to add later.
159+
if (!workspace_folders.some(workspace_folder =>
160+
is_subdirectory(source_dir_path, workspace_folder.uri.path))) {
161+
workspace_dirs_to_add.push({ name: source_dir.name, uri: source_dir_uri });
162+
}
160163
}
161-
}
162164

163-
// If there are some source directories missing in the workspace, ask the user
164-
// to add them in his workspace.
165-
if (workspace_dirs_to_add.length > 0) {
166-
vscode.window
167-
.showInformationMessage("Some project source directories are not "
168-
+ "listed in your workspace: do you want to add them?", "Yes", "No")
169-
.then(answer => {
170-
if (answer === "Yes") {
171-
for (var workspace_dir of workspace_dirs_to_add) {
172-
vscode.workspace.updateWorkspaceFolders(
173-
vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders.length : 0, null,
174-
workspace_dir);
165+
// If there are some source directories missing in the workspace, ask the user
166+
// to add them in his workspace.
167+
if (workspace_dirs_to_add.length > 0) {
168+
vscode.window
169+
.showInformationMessage("Some project source directories are not "
170+
+ "listed in your workspace: do you want to add them?", "Yes", "No")
171+
.then(answer => {
172+
if (answer === "Yes") {
173+
for (var workspace_dir of workspace_dirs_to_add) {
174+
vscode.workspace.updateWorkspaceFolders(
175+
vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders.length : 0, null,
176+
workspace_dir);
175177
}
176-
}
177-
})
178+
}
179+
})
180+
}
178181
}
179-
}
180-
)
181-
})
182+
)
183+
})
184+
}
182185
}
183186

184187
export function deactivate(): void {

0 commit comments

Comments
 (0)