Updated multi root example to API changes

This commit is contained in:
Dirk Baeumer
2017-10-11 08:30:40 +02:00
parent d9072433a5
commit 744b55981f
2 changed files with 11 additions and 6 deletions

View File

@ -13,7 +13,7 @@ let clients: Map<string, LanguageClient> = new Map();
function getOuterMostWorkspaceFolder(folder: WorkspaceFolder): WorkspaceFolder {
let result = folder;
let candidate: WorkspaceFolder;
while((candidate = Workspace.getWorkspaceFolder(folder.uri)) !== void 0) {
while((candidate = Workspace.getWorkspaceFolder(folder.uri)) !== folder) {
result = candidate;
}
return result;
@ -51,7 +51,7 @@ export function activate(context: ExtensionContext) {
return;
}
let folder = Workspace.getWorkspaceFolder(uri);
// Files outside a folder can't be handled. This might depend on the language
// Files outside a folder can't be handled. This might depend on the language.
// Single file languages like JSON might handle files outside the workspace folders.
if (!folder) {
return;

View File

@ -7,18 +7,23 @@ import {
createConnection, TextDocuments, ProposedFeatures, TextDocumentSyncKind
} from 'vscode-languageserver';
// Creates the LSP connection
let connection = createConnection(ProposedFeatures.all);
// Create a manager for open text documents
let documents = new TextDocuments();
let rootUri: string;
// The workspace folder this server is operating on
let workspaceFolder: string;
documents.onDidOpen((event) => {
connection.console.log(`[Server ${rootUri}] Document opened: ${event.document.uri}`);
connection.console.log(`[Server ${workspaceFolder}] Document opened: ${event.document.uri}`);
})
documents.listen(connection);
connection.onInitialize((params) => {
rootUri = params.rootUri;
connection.console.log(`Server started for folder: ${rootUri}`);
workspaceFolder = params.rootUri;
connection.console.log(`Server started for folder: ${workspaceFolder}`);
return {
capabilities: {
textDocumentSync: {