本文整理汇总了TypeScript中vscode.workspace.textDocuments类的典型用法代码示例。如果您正苦于以下问题:TypeScript workspace.textDocuments类的具体用法?TypeScript workspace.textDocuments怎么用?TypeScript workspace.textDocuments使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了workspace.textDocuments类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
return Promise.all([workspace.openTextDocument(uri), workspace.openTextDocument(uri)]).then(docs => {
let [first, second] = docs;
assert.ok(first === second);
assert.ok(workspace.textDocuments.some(doc => doc.uri.toString() === uri.toString()));
assert.equal(callCount, 1);
registration.dispose();
});
示例2: if
workspace.onDidChangeConfiguration(() => {
workspace.textDocuments.forEach(document => {
if (document.uri.scheme === ConstVariable.markdownScheme) {
dfmPreviewProcessor.updateContent(document.uri);
} else if (document.uri.scheme === ConstVariable.tokenTreeScheme) {
tokenTreeProcessor.updateContent(document.uri);
}
});
});
示例3: updatePriorityFiles
updatePriorityFiles() {
let visibleDocuments = window.visibleTextEditors.map(e => e.document);
let otherOpenDocuments = workspace.textDocuments.filter(doc => visibleDocuments.indexOf(doc) == -1);
let priorityDocuments = visibleDocuments.concat(otherOpenDocuments).filter(d => util.isAnalyzable(d));
let priorityFiles = priorityDocuments.map(doc => doc.fileName);
this.analyzer.analysisSetPriorityFiles({
files: priorityFiles
}).then(() => {}, e => console.warn(e.message));
}
示例4: restart
/** Stops the running language client if any and starts a new one. */
private async restart(): Promise<void> {
const isAnyDocumentDirty = !workspace.textDocuments.every(t => !t.isDirty);
if (isAnyDocumentDirty) {
window.showErrorMessage('You have unsaved changes. Save or discard them and try to restart again');
return;
}
await this.stop();
this.languageClient = this.languageClientCreator.create();
this.subscribeOnStateChanging();
this.start();
}
示例5: test
test('Convert from yaml to tmLanguage', async function() {
const textDocument = await workspace.openTextDocument(jsonTestFile);
const textEditor = await window.showTextDocument(textDocument);
const fileConverter: FileConverter = new FileConverter();
var success : boolean = await fileConverter.convertFileToTml();
assert.equal(true, success);
let resultDoc = workspace.textDocuments.find((doc : TextDocument) => { return doc.fileName == jsonResultFile;});
var text = resultDoc.getText();
assert.notEqual(text, "");
});
示例6: encode_preview
language_client.onNotification(protocol.preview_response_type, params =>
{
const preview_uri = encode_preview(Uri.parse(params.uri))
if (preview_uri) {
content_provider.set_content(preview_uri, params.content)
content_provider.update(preview_uri)
const existing_document =
workspace.textDocuments.find(document =>
document.uri.scheme === preview_uri.scheme &&
document.uri.query === preview_uri.query)
if (!existing_document && params.column != 0) {
commands.executeCommand("vscode.previewHtml", preview_uri, params.column, params.label)
}
}
})
示例7: selectDocument
function selectDocument() {
if (isViableEditor(window.activeTextEditor)) {
return window.activeTextEditor!.document;
}
const docs = workspace.textDocuments
.filter(isSupportedDoc);
if (lastUri) {
const candidate = docs
.filter(document => document.uri.toString() === lastUri)
.shift();
if (candidate) return candidate;
}
return docs.shift();
}
示例8: encode_state
language_client.onNotification(protocol.state_output_type, params =>
{
const uri = encode_state(params.id)
if (uri) {
content_provider.set_content(uri, params.content)
content_provider.update(uri)
const existing_document =
workspace.textDocuments.find(document =>
document.uri.scheme === uri.scheme &&
document.uri.fragment === uri.fragment)
if (!existing_document) {
const column = library.adjacent_editor_column(window.activeTextEditor, true)
commands.executeCommand("vscode.previewHtml", uri, column, "State")
}
}
})
示例9: checkVariablesInAllTextDocuments
public checkVariablesInAllTextDocuments() {
workspace.textDocuments.forEach(this.checkVariables, this);
}
示例10: activate
export function activate(context: ExtensionContext) {
let module = context.asAbsolutePath(path.join('server', 'out', 'server.js'));
let outputChannel: OutputChannel = Window.createOutputChannel('lsp-multi-server-example');
function didOpenTextDocument(document: TextDocument): void {
// We are only interested in language mode text
if (document.languageId !== 'plaintext' || (document.uri.scheme !== 'file' && document.uri.scheme !== 'untitled')) {
return;
}
let uri = document.uri;
// Untitled files go to a default client.
if (uri.scheme === 'untitled' && !defaultClient) {
let debugOptions = { execArgv: ["--nolazy", "--inspect=6010"] };
let serverOptions = {
run: { module, transport: TransportKind.ipc },
debug: { module, transport: TransportKind.ipc, options: debugOptions}
};
let clientOptions: LanguageClientOptions = {
documentSelector: [
{ scheme: 'untitled', language: 'plaintext' }
],
diagnosticCollectionName: 'lsp-multi-server-example',
outputChannel: outputChannel
}
defaultClient = new LanguageClient('lsp-multi-server-example', 'LSP Multi Server Example', serverOptions, clientOptions);
defaultClient.start();
return;
}
let folder = Workspace.getWorkspaceFolder(uri);
// 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;
}
// If we have nested workspace folders we only start a server on the outer most workspace folder.
folder = getOuterMostWorkspaceFolder(folder);
if (!clients.has(folder.uri.toString())) {
let debugOptions = { execArgv: ["--nolazy", `--inspect=${6011 + clients.size}`] };
let serverOptions = {
run: { module, transport: TransportKind.ipc },
debug: { module, transport: TransportKind.ipc, options: debugOptions}
};
let clientOptions: LanguageClientOptions = {
documentSelector: [
{ scheme: 'file', language: 'plaintext', pattern: `${folder.uri.fsPath}/**/*` }
],
diagnosticCollectionName: 'lsp-multi-server-example',
workspaceFolder: folder,
outputChannel: outputChannel
}
let client = new LanguageClient('lsp-multi-server-example', 'LSP Multi Server Example', serverOptions, clientOptions);
client.start();
clients.set(folder.uri.toString(), client);
}
}
Workspace.onDidOpenTextDocument(didOpenTextDocument);
Workspace.textDocuments.forEach(didOpenTextDocument);
Workspace.onDidChangeWorkspaceFolders((event) => {
for (let folder of event.removed) {
let client = clients.get(folder.uri.toString());
if (client) {
clients.delete(folder.uri.toString());
client.stop();
}
}
});
}