[mlir-vscode] Fix processing of files not within the workspace
In a previous commit we added proper support for separate configurations per workspace folder, but that effectively broke support for processing out-of-workspace files. Given how useful this is (e.g. when iterating on a test case in /tmp), this commit refactors server creation to support this again. We support this case using a "fallback" server that specifically handles files not within the workspace. This uses the configuration settings for the current workspace itself (not the specific folder). Differential Revision: https://reviews.llvm.org/D123183
This commit is contained in:
parent
195a8b977e
commit
3c7e467406
|
@ -39,10 +39,9 @@ export class MLIRContext implements vscode.Disposable {
|
||||||
this.workspaceFolders.push(await this.activateWorkspaceFolder(
|
this.workspaceFolders.push(await this.activateWorkspaceFolder(
|
||||||
workspaceFolder, outputChannel, warnOnEmptyServerPath));
|
workspaceFolder, outputChannel, warnOnEmptyServerPath));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.workspaceFolders.push(await this.activateWorkspaceFolder(
|
|
||||||
null, outputChannel, warnOnEmptyServerPath));
|
|
||||||
}
|
}
|
||||||
|
this.workspaceFolders.push(await this.activateWorkspaceFolder(
|
||||||
|
null, outputChannel, warnOnEmptyServerPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,6 +129,24 @@ export class MLIRContext implements vscode.Disposable {
|
||||||
selectorPattern = `${workspaceFolder.uri.fsPath}/**/*`;
|
selectorPattern = `${workspaceFolder.uri.fsPath}/**/*`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Configure the middleware of the client. This is sort of abused to allow
|
||||||
|
// for defining a "fallback" language server that operates on non-workspace
|
||||||
|
// folders. Workspace folder language servers can properly filter out
|
||||||
|
// documents not within the folder, but we can't effectively filter for
|
||||||
|
// documents outside of the workspace. To support this, and avoid having two
|
||||||
|
// servers targeting the same set of files, we use middleware to inject the
|
||||||
|
// dynamic logic for checking if a document is in the workspace.
|
||||||
|
let middleware = {};
|
||||||
|
if (!workspaceFolder) {
|
||||||
|
middleware = {
|
||||||
|
didOpen : (document, next) => {
|
||||||
|
if (!vscode.workspace.getWorkspaceFolder(document.uri)) {
|
||||||
|
next(document);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Configure the client options.
|
// Configure the client options.
|
||||||
const clientOptions: vscodelc.LanguageClientOptions = {
|
const clientOptions: vscodelc.LanguageClientOptions = {
|
||||||
documentSelector : [
|
documentSelector : [
|
||||||
|
@ -141,7 +158,8 @@ export class MLIRContext implements vscode.Disposable {
|
||||||
fileEvents : vscode.workspace.createFileSystemWatcher(filePattern)
|
fileEvents : vscode.workspace.createFileSystemWatcher(filePattern)
|
||||||
},
|
},
|
||||||
outputChannel : outputChannel,
|
outputChannel : outputChannel,
|
||||||
workspaceFolder : workspaceFolder
|
workspaceFolder : workspaceFolder,
|
||||||
|
middleware : middleware
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create the language client and start the client.
|
// Create the language client and start the client.
|
||||||
|
|
Loading…
Reference in New Issue