當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript vscode.Uri類代碼示例

本文整理匯總了TypeScript中vscode.Uri的典型用法代碼示例。如果您正苦於以下問題:TypeScript Uri類的具體用法?TypeScript Uri怎麽用?TypeScript Uri使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Uri類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

    test('addUniqueDiagnostic adds the diagnostic to the empty diagnostics', () => {
        const diagnostic: FileDiagnostic = {
            filePath: '/1',
            diagnostic: new Diagnostic(new Range(1, 2, 3, 4), 'Hello', undefined)
        };

        const diagnostics = languages.createDiagnosticCollection('rust');

        addUniqueDiagnostic(diagnostic, diagnostics);

        const fileDiagnostics = diagnostics.get(Uri.file('/1'));

        if (!fileDiagnostics) {
            assert.notEqual(fileDiagnostics, undefined);
        } else {
            assert.equal(fileDiagnostics.length, 1);
        }
    });
開發者ID:KalitaAlexey,項目名稱:RustyCode,代碼行數:18,代碼來源:diagnostic_utils.test.ts

示例2: openChange

	@command('git.openChange')
	async openChange(uri: Uri): Promise<void> {
		const scmResource = resolveGitResource(uri);

		if (scmResource) {
			return await this.open(scmResource);
		}

		if (uri.scheme === 'file') {
			const uriString = uri.toString();
			const resource = this.model.workingTreeGroup.resources.filter(r => r.uri.toString() === uriString)[0]
				|| this.model.indexGroup.resources.filter(r => r.uri.toString() === uriString)[0];

			if (resource) {
				return await this.open(resource);
			}
		}
	}
開發者ID:diarmaidm,項目名稱:vscode,代碼行數:18,代碼來源:commands.ts

示例3: it

        it("should call update method of previewManager with correct parameters", sinon.test(function () {
            let checkExtensionTypeStub = this.stub(utilities, "checkExtensionType", function () {
                ExtensionConstants.EXTENSION_TYPE = ExtensionConstants.VSC_EXTENSION;
                return true;
            })

            let previewManagerStub = sinon.createStubInstance(dummyPreviewManager);

            previewManagerController = new PreviewManagerController(utilities, previewManagerStub, previewManagerStub);
            previewManagerController.onEvent();

            sinon.assert.calledOnce(checkExtensionTypeStub);
            expect(previewManagerController.previewManager).to.equal(previewManagerStub);
            sinon.assert.calledOnce(previewManagerStub.generatePreview);
            sinon.assert.calledOnce(previewManagerStub.update);
            sinon.assert.calledWith(previewManagerStub.update,vscode.Uri.parse(ExtensionConstants.PREVIEW_URI))
            
        }))
開發者ID:Microsoft,項目名稱:extension-manifest-editor,代碼行數:18,代碼來源:PreviewManagerController.test.ts

示例4: createTempDocument

export function createTempDocument(content?: string) {

    const uri = Uri.parse(`untitled:${__dirname}.${Math.random()}.tmp`);

    return workspace.openTextDocument(uri)
        .then(document => {
            return window.showTextDocument(document);
        })
        .then(() => {
            if (content) {
                window.activeTextEditor.edit(editBuilder => {
                    editBuilder.insert(new Position(0, 0), content);
                });
            }

            return window.activeTextEditor;
        });
}
開發者ID:benjaminRomano,項目名稱:amVim-for-VSCode,代碼行數:18,代碼來源:Util.ts

示例5: setupWorkspace

export async function setupWorkspace(
  config: IConfiguration = new Configuration(),
  fileExtension: string = ''
): Promise<any> {
  const filePath = await createRandomFile('', fileExtension);
  const doc = await vscode.workspace.openTextDocument(vscode.Uri.file(filePath));

  await vscode.window.showTextDocument(doc);

  Globals.mockConfiguration = config;
  reloadConfiguration();

  let activeTextEditor = vscode.window.activeTextEditor;
  assert.ok(activeTextEditor);

  activeTextEditor!.options.tabSize = config.tabstop;
  activeTextEditor!.options.insertSpaces = config.expandtab;
}
開發者ID:rebornix,項目名稱:Vim,代碼行數:18,代碼來源:testUtils.ts

示例6: activate

export function activate(context: vscode.ExtensionContext) {
    let previewUri = vscode.Uri.parse('html-preview://html-preview');
    
    class MyTextDocumentContentProvider implements vscode.TextDocumentContentProvider {
        
        public provideTextDocumentContent(uri: vscode.Uri): string {
            return this.displayHtml();
        }
        
        private displayHtml() {
            var renderer = new marked.Renderer();
 
            renderer.heading = function (text, level) {
            
                return '<h' + level + '>' + text + '</h' + level + '>';
            };

             let editor = vscode.window.activeTextEditor;
            if (editor.document.languageId === 'markdown') {
                let text = editor.document.getText();
                let htmlText = encode(marked(text, {renderer:renderer}));
                
                return htmlText; 
            }
            else {
                return null;
            }
            
            
        }
    }
    
    let provider = new MyTextDocumentContentProvider();
    let registration = vscode.workspace.registerTextDocumentContentProvider('html-preview', provider);

    let disposable = vscode.commands.registerCommand('extension.previewHtml', () => {
        return vscode.commands.executeCommand('vscode.previewHtml', previewUri, vscode.ViewColumn.Two).then((success) => {
        }, (reason) => {
            vscode.window.showErrorMessage(reason);
        });
	});

	context.subscriptions.push(disposable);
}
開發者ID:buzzfrog,項目名稱:vscode-markedtohtml,代碼行數:44,代碼來源:extension.ts

示例7: manageIncludes

export async function manageIncludes(uri: Uri, opened: boolean) {
  const key = uri.toString()
  if (opened) {
    const include = includes.get(key)
    if (isString(include)) return
    const server = fromUri(uri)
    const obj = await server.findAbapObject(uri)
    if (obj.type !== "PROG/I") includes.set(key, "")
    else {
      let main = ""
      try {
        main = await await server.activator.selectMain(obj)
      } finally {
        includes.set(key, main || "")
        // if(main)
      }
    }
  } else includes.delete(key)
}
開發者ID:valdirmendesgt,項目名稱:vscode_abap_remote_fs,代碼行數:19,代碼來源:langClient.ts

示例8: it

	it("Flutter: New Project can be invoked and creates trigger file", async () => {
		const showInputBox = sb.stub(vs.window, "showInputBox");
		showInputBox.resolves("my_test_flutter_proj");

		const showOpenDialog = sb.stub(vs.window, "showOpenDialog");
		const tempFolder = getRandomTempFolder();
		showOpenDialog.resolves([vs.Uri.file(tempFolder)]);

		// Intercept executeCommand for openFolder so we don't spawn a new instance of Code!
		const executeCommand = sb.stub(vs.commands, "executeCommand").callThrough();
		const openFolder = executeCommand.withArgs("vscode.openFolder", sinon.match.any).resolves();

		await vs.commands.executeCommand("flutter.createProject");

		assert.ok(showInputBox.calledOnce);
		assert.ok(showOpenDialog.calledOnce);
		assert.ok(openFolder.calledOnce);
		assert.ok(fs.existsSync(path.join(tempFolder, "my_test_flutter_proj", FLUTTER_CREATE_PROJECT_TRIGGER_FILE)));
	});
開發者ID:DanTup,項目名稱:Dart-Code,代碼行數:19,代碼來源:extension.test.ts

示例9: openOrCreateConfigFile

export async function openOrCreateConfigFile(
	isTypeScriptProject: boolean,
	rootPath: string,
	config: TypeScriptServiceConfiguration
): Promise<vscode.TextEditor | null> {
	const configFile = vscode.Uri.file(path.join(rootPath, isTypeScriptProject ? 'tsconfig.json' : 'jsconfig.json'));
	const col = vscode.window.activeTextEditor ? vscode.window.activeTextEditor.viewColumn : undefined;
	try {
		const doc = await vscode.workspace.openTextDocument(configFile);
		return vscode.window.showTextDocument(doc, col);
	} catch {
		const doc = await vscode.workspace.openTextDocument(configFile.with({ scheme: 'untitled' }));
		const editor = await vscode.window.showTextDocument(doc, col);
		if (editor.document.getText().length === 0) {
			await editor.insertSnippet(inferredProjectConfigSnippet(config));
		}
		return editor;
	}
}
開發者ID:PKRoma,項目名稱:vscode,代碼行數:19,代碼來源:tsconfig.ts

示例10: test

	test('registerTextDocumentContentProvider, change event', function() {

		let callCount = 0;
		let listeners: Function[] = [];
		let registration = workspace.registerTextDocumentContentProvider('foo', {
			onDidChange(callback, thisArg, disposables) {
				let actual = thisArg ? callback.bind(thisArg) : callback;
				listeners.push(actual);
				let subscription = new Disposable(() => {
					const idx = listeners.indexOf(actual);
					listeners.splice(idx, 1);
				});
				if (Array.isArray(disposables)) {
					disposables.push(subscription);
				}
				return subscription;
			},
			provideTextDocumentContent(uri) {
				return 'call' + (callCount++);
			}
		});

		const uri = Uri.parse('foo://testing/path2');

		return workspace.openTextDocument(uri).then(doc => {

			assert.equal(callCount, 1);
			assert.equal(doc.getText(), 'call0');

			return new Promise((resolve, reject) => {

				workspace.onDidChangeTextDocument(event => {
					assert.ok(event.document === doc);
					assert.equal(event.document.getText(), 'call1');
					resolve();
				});

				listeners.forEach(l => l(doc.uri));

				registration.dispose();
			});
		});
	});
開發者ID:sangohan,項目名稱:KodeStudio,代碼行數:43,代碼來源:workspace.test.ts


注:本文中的vscode.Uri類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。