export function activate()

in client/src/extension.ts [20:87]


export function activate(context: ExtensionContext) {

	commands.registerCommand('lsif.openDatabase', () => {
		window.showOpenDialog(
			{
				openLabel: 'Select LSIF Database to open',
				canSelectFiles: true,
				canSelectFolders: false,
				canSelectMany: true,
				filters: { 'LSIF': ['db', 'lsif'] }
			}
		).then((values: Uri[] | undefined) => {
			if (values === undefined || values.length === 0) {
				return;
			}
			let toAdd = values.map((uri) => { return { uri: uri.with({ scheme: 'lsif'}) }; });
			workspace.updateWorkspaceFolders(
				workspace.workspaceFolders ? workspace.workspaceFolders.length : 0,
				0,
				...toAdd
			);
		});
	});

	// The server is implemented in node
	let serverModule = context.asAbsolutePath(
		path.join('server', 'out', 'lsifServer.js')
	);
	// The debug options for the server
	// --inspect=6019: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
	let debugOptions = { execArgv: ['--nolazy', '--inspect=6029'] };

	// If the extension is launched in debug mode then the debug server options are used
	// Otherwise the run options are used
	let serverOptions: ServerOptions = {
		run: { module: serverModule, transport: TransportKind.ipc },
		debug: {
			module: serverModule,
			transport: TransportKind.ipc,
			options: debugOptions
		}
	};

	// Options to control the language client
	let clientOptions: LanguageClientOptions = {
	};

	// Create the language client and start the client.
	client = new LanguageClient(
		'lsif',
		'Language Server Index Format',
		serverOptions,
		clientOptions
	);

	// Start the client. This will also launch the server
	client.start();

	let clientPromise = new Promise<LanguageClient>((resolve, reject) => {
		client.onReady().then(() => {
			resolve(client);
		}, (error) => {
			reject(error);
		});
	});

	workspace.registerFileSystemProvider('lsif', new LsifFS(clientPromise), { isCaseSensitive: true, isReadonly: true});
}