本文整理汇总了TypeScript中vscode-languageserver.IConnection.onDidCloseTextDocument方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IConnection.onDidCloseTextDocument方法的具体用法?TypeScript IConnection.onDidCloseTextDocument怎么用?TypeScript IConnection.onDidCloseTextDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode-languageserver.IConnection
的用法示例。
在下文中一共展示了IConnection.onDidCloseTextDocument方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(input: any, output: any, strict: boolean) {
this.connection = createConnection(input, output);
input.removeAllListeners('end');
input.removeAllListeners('close');
output.removeAllListeners('end');
output.removeAllListeners('close');
let workspaceRoot: string;
let documents: TextDocuments = new TextDocuments();
let closed = false;
function close() {
if (!closed) {
input.close();
output.close();
closed = true;
}
}
let service: TypeScriptService;
let self = this;
let initialized: Thenable<void> = null;
this.connection.onRequest(InitializeRequest.type, (params: InitializeParams): Promise<InitializeResult> => {
console.error('initialize', params.rootPath);
return new Promise<InitializeResult>(function (resolve) {
if (params.rootPath) {
workspaceRoot = util.uri2path(params.rootPath);
service = new TypeScriptService(workspaceRoot, strict, self.connection);
initialized = service.host.initialize(workspaceRoot);
resolve({
capabilities: {
// Tell the client that the server works in FULL text document sync mode
textDocumentSync: documents.syncKind,
hoverProvider: true,
definitionProvider: true,
referencesProvider: true
}
})
}
});
});
this.connection.onNotification(ExitRequest.type, function () {
close();
});
this.connection.onRequest(ShutdownRequest.type, function () {
return [];
});
this.connection.onDidOpenTextDocument((params: DidOpenTextDocumentParams) => {
let relpath = util.uri2relpath(params.textDocument.uri, workspaceRoot);
console.error('add file', workspaceRoot, '/', relpath);
service.addFile(relpath, params.textDocument.text);
});
this.connection.onDidCloseTextDocument((params: DidCloseTextDocumentParams) => {
let relpath = util.uri2relpath(params.textDocument.uri, workspaceRoot);
console.error('remove file', workspaceRoot, '/', relpath);
service.removeFile(relpath);
});
this.connection.onRequest(WorkspaceSymbolsRequest.type, (params: WorkspaceSymbolParamsWithLimit): Promise<SymbolInformation[]> => {
const enter = new Date().getTime();
return new Promise<SymbolInformation[]>(function (resolve, reject) {
initialized.then(function () {
let result = [];
const init = new Date().getTime();
try {
if (params.query == "exported") {
const exported = service.getExportedEnts();
if (exported) {
result = exported.map(ent => {
return SymbolInformation.create(ent.name, ent.kind, ent.location.range,
'file:///' + ent.location.file, util.formExternalUri(ent));
});
}
} else if (params.query == "externals") {
const externals = service.getExternalRefs();
if (externals) {
result = externals.map(external => {
return SymbolInformation.create(external.name, util.formEmptyKind(), util.formEmptyRange(), util.formExternalUri(external));
});
}
} else if (params.query == '') {
const topDecls = service.getTopLevelDeclarations(params.limit);
if (topDecls) {
result = topDecls.map(decl => {
return SymbolInformation.create(decl.name, decl.kind, decl.location.range,
'file:///' + decl.location.file, util.formExternalUri(decl));
});
}
} else {
//.........这里部分代码省略.........