本文整理汇总了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;未经允许,请勿转载。 |
请发表评论