当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript IConnection.onShutdown方法代码示例

本文整理汇总了TypeScript中vscode-languageserver.IConnection.onShutdown方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IConnection.onShutdown方法的具体用法?TypeScript IConnection.onShutdown怎么用?TypeScript IConnection.onShutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vscode-languageserver.IConnection的用法示例。

在下文中一共展示了IConnection.onShutdown方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: getLanguageModes

connection.onInitialize((params: InitializeParams): InitializeResult => {
	let initializationOptions = params.initializationOptions;

	workspacePath = params.rootPath;

	languageModes = getLanguageModes(initializationOptions ? initializationOptions.embeddedLanguages : { css: true, javascript: true });
	documents.onDidClose(e => {
		languageModes.getAllModes().forEach(m => m.onDocumentRemoved(e.document));
	});
	connection.onShutdown(() => {
		languageModes.getAllModes().forEach(m => m.dispose());
	});

	return {
		capabilities: {
			// Tell the client that the server works in FULL text document sync mode
			textDocumentSync: documents.syncKind,
			completionProvider: { resolveProvider: true, triggerCharacters: ['.', ':', '<', '"', '=', '/'] },
			hoverProvider: true,
			documentHighlightProvider: true,
			documentRangeFormattingProvider: initializationOptions && initializationOptions['format.enable'],
			documentLinkProvider: true,
			definitionProvider: true,
			signatureHelpProvider: { triggerCharacters: ['('] },
			referencesProvider: true
		}
	};
});
开发者ID:,项目名称:,代码行数:28,代码来源:


示例2: getLanguageModes

connection.onInitialize((params: InitializeParams): InitializeResult => {
	let initializationOptions = params.initializationOptions;

	workspacePath = params.rootPath;

	languageModes = getLanguageModes(initializationOptions ? initializationOptions.embeddedLanguages : { css: true, javascript: true });
	documents.onDidClose(e => {
		languageModes.onDocumentRemoved(e.document);
	});
	connection.onShutdown(() => {
		languageModes.dispose();
	});

	function hasClientCapability(...keys: string[]) {
		let c = params.capabilities;
		for (let i = 0; c && i < keys.length; i++) {
			c = c[keys[i]];
		}
		return !!c;
	}

	clientSnippetSupport = hasClientCapability('textDocument', 'completion', 'completionItem', 'snippetSupport');
	clientDynamicRegisterSupport = hasClientCapability('workspace', 'symbol', 'dynamicRegistration');
	scopedSettingsSupport = hasClientCapability('workspace', 'configuration');
	let capabilities: ServerCapabilities & CPServerCapabilities = {
		// Tell the client that the server works in FULL text document sync mode
		textDocumentSync: documents.syncKind,
		completionProvider: clientSnippetSupport ? { resolveProvider: true, triggerCharacters: ['.', ':', '<', '"', '=', '/', '>'] } : null,
		hoverProvider: true,
		documentHighlightProvider: true,
		documentRangeFormattingProvider: false,
		documentLinkProvider: { resolveProvider: false },
		documentSymbolProvider: true,
		definitionProvider: true,
		signatureHelpProvider: { triggerCharacters: ['('] },
		referencesProvider: true,
		colorProvider: true
	};

	return { capabilities };
});
开发者ID:armanio123,项目名称:vscode,代码行数:41,代码来源:htmlServerMain.ts


示例3: run


//.........这里部分代码省略.........
            }
            lastDurationSelector = new Rx.Subject<number>();
            Rx.Observable.timer(activeSettings.spellCheckDelayMs || defaultDebounce).subscribe(lastDurationSelector);
            return lastDurationSelector;
        })
        .do(doc => log(`Validate: ${doc.uri}`))
        .do(() => lastDurationSelector = undefined)
        .subscribe(validateTextDocument);

    // Clear the diagnostics for documents we do not want to validate
    const disposableSkipValidationStream = validationRequestStream
        .filter(doc => !shouldValidateDocument(doc))
        .do(doc => log(`Skip Validate: ${doc.uri}`))
        .subscribe(doc => {
            connection.sendDiagnostics({ uri: doc.uri, diagnostics: [] });
        });

    const disposableTriggerUpdateConfigStream = triggerUpdateConfig
        .do(() => log('Trigger Update Config'))
        .do(() => activeSettingsNeedUpdating = true)
        .debounceTime(100)
        .subscribe(() => {
            updateActiveSettings();
        });

    const disposableTriggerValidateAll = triggerValidateAll
        .debounceTime(250)
        .subscribe(() => {
            log('Validate all documents');
            documents.all().forEach(doc => validationRequestStream.next(doc));
        });

    validationFinishedStream.next({ uri: 'start', version: 0 });

    function shouldValidateDocument(textDocument: TextDocument): boolean {
        const { uri, languageId } = textDocument;
        return !!getActiveSettings().enabled && isLanguageEnabled(languageId)
            && !isUriExcluded(uri);
    }

    function isLanguageEnabled(languageId: string) {
        const { enabledLanguageIds = []} = getActiveSettings();
        return enabledLanguageIds.indexOf(languageId) >= 0;
    }

    function isUriExcluded(uri: string) {
        return fnFileExclusionTest(uri);
    }

    function getBaseSettings() {
        return {...CSpell.mergeSettings(defaultSettings, getActiveSettings()), enabledLanguageIds: getActiveSettings().enabledLanguageIds};
    }

    function getSettingsToUseForDocument(doc: TextDocument) {
        return tds.constructSettingsForText(getBaseSettings(), doc.getText(), doc.languageId);
    }

    function validateTextDocument(textDocument: TextDocument): void {
        try {
            const settingsToUse = getSettingsToUseForDocument(textDocument);
            if (settingsToUse.enabled) {
                Validator.validateTextDocument(textDocument, settingsToUse).then(diagnostics => {
                    // Send the computed diagnostics to VSCode.
                    validationFinishedStream.next(textDocument);
                    connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
                });
            }
        } catch (e) {
            console.log(e);
        }
    }

    // Make the text document manager listen on the connection
    // for open, change and close text document events
    documents.listen(connection);

    // The content of a text document has changed. This event is emitted
    // when the text document first opened or when its content has changed.
    documents.onDidChangeContent((change) => {
        validationRequestStream.next(change.document);
    });

    documents.onDidClose((event) => {
        // A text document was closed we clear the diagnostics
        connection.sendDiagnostics({ uri: event.document.uri, diagnostics: [] });
    });

    connection.onCodeAction(onCodeActionHandler(documents, getBaseSettings));

    // Listen on the connection
    connection.listen();

    // Free up the validation streams on shutdown.
    connection.onShutdown(() => {
        disposableSkipValidationStream.unsubscribe();
        disposeValidationStream.unsubscribe();
        disposableTriggerUpdateConfigStream.unsubscribe();
        disposableTriggerValidateAll.unsubscribe();
    });
}
开发者ID:AlekSi,项目名称:vscode-spell-checker,代码行数:101,代码来源:server.ts


示例4: catch

                    });
            } else {
                return {
                    images: []
                };
            }
        } catch (e) {
            console.error(e);
            return {
                images: []
            };
        }
    }
);
connection.onShutdown(() => {
    ImageCache.cleanup();
});
connection.listen();

async function collectEntries(
    document: TextDocument,
    request: ImageInfoRequest,
    cancellationToken: CancellationToken
): Promise<ImageInfo[]> {
    let items = [];

    absoluteUrlMappers.forEach(absoluteUrlMapper =>
        absoluteUrlMapper.refreshConfig(request.workspaceFolder, request.additionalSourcefolder, request.paths)
    );

    const lines = document.getText().split(/\r\n|\r|\n/);
开发者ID:kisstkondoros,项目名称:gutter-preview,代码行数:31,代码来源:server.ts



注:本文中的vscode-languageserver.IConnection.onShutdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。