本文整理汇总了TypeScript中vs/base/common/uri.URI.isUri方法的典型用法代码示例。如果您正苦于以下问题:TypeScript URI.isUri方法的具体用法?TypeScript URI.isUri怎么用?TypeScript URI.isUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/base/common/uri.URI
的用法示例。
在下文中一共展示了URI.isUri方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getResourceForCommand
export function getResourceForCommand(resource: URI | object | undefined, listService: IListService, editorService: IEditorService): URI | undefined {
if (URI.isUri(resource)) {
return resource;
}
let list = listService.lastFocusedList;
if (list && list.getHTMLElement() === document.activeElement) {
let focus: unknown;
if (list instanceof List) {
const focused = list.getFocusedElements();
if (focused.length) {
focus = focused[0];
}
} else if (list instanceof WorkbenchAsyncDataTree) {
const focused = list.getFocus();
if (focused.length) {
focus = focused[0];
}
}
if (focus instanceof ExplorerItem) {
return focus.resource;
} else if (focus instanceof OpenEditor) {
return focus.getResource();
}
}
return editorService.activeEditor ? toResource(editorService.activeEditor, { supportSideBySide: SideBySideEditor.MASTER }) : undefined;
}
示例2: getResourceForCommand
export function getResourceForCommand(resource: URI | object, listService: IListService, editorService: IEditorService): URI {
if (URI.isUri(resource)) {
return resource;
}
let list = listService.lastFocusedList;
if (list && list.getHTMLElement() === document.activeElement) {
let focus: any;
if (list instanceof List) {
const focused = list.getFocusedElements();
if (focused.length) {
focus = focused[0];
}
} else {
focus = list.getFocus();
}
if (focus instanceof ExplorerItem) {
return focus.resource;
} else if (focus instanceof OpenEditor) {
return focus.getResource();
}
}
return toResource(editorService.activeEditor, { supportSideBySide: true });
}
示例3: getMultiSelectedResources
export function getMultiSelectedResources(resource: URI | object | undefined, listService: IListService, editorService: IEditorService): Array<URI> {
const list = listService.lastFocusedList;
if (list && list.getHTMLElement() === document.activeElement) {
// Explorer
if (list instanceof WorkbenchAsyncDataTree) {
const selection = list.getSelection().map((fs: ExplorerItem) => fs.resource);
const focusedElements = list.getFocus();
const focus = focusedElements.length ? focusedElements[0] : undefined;
const mainUriStr = URI.isUri(resource) ? resource.toString() : focus instanceof ExplorerItem ? focus.resource.toString() : undefined;
// If the resource is passed it has to be a part of the returned context.
// We only respect the selection if it contains the focused element.
if (selection.some(s => URI.isUri(s) && s.toString() === mainUriStr)) {
return selection;
}
}
// Open editors view
if (list instanceof List) {
const selection = coalesce(list.getSelectedElements().filter(s => s instanceof OpenEditor).map((oe: OpenEditor) => oe.getResource()));
const focusedElements = list.getFocusedElements();
const focus = focusedElements.length ? focusedElements[0] : undefined;
let mainUriStr: string | undefined = undefined;
if (URI.isUri(resource)) {
mainUriStr = resource.toString();
} else if (focus instanceof OpenEditor) {
const focusedResource = focus.getResource();
mainUriStr = focusedResource ? focusedResource.toString() : undefined;
}
// We only respect the selection if it contains the main element.
if (selection.some(s => s.toString() === mainUriStr)) {
return selection;
}
}
}
const result = getResourceForCommand(resource, listService, editorService);
return !!result ? [result] : [];
}
示例4: isTextChange
function isTextChange(thing: [URI, types.TextEdit[]] | [URI?, URI?, { overwrite?: boolean }?]): thing is [URI, types.TextEdit[]] {
const [f, s] = thing;
return URI.isUri(f) && Array.isArray(s);
}
示例5:
let p = Event.toPromise(emitter.event).then(a => {
assert.equal(a.length, 1);
assert.equal(a[0].toString(), 'aa:bb');
assert.ok(URI.isUri(a[0]));
});
示例6:
if (selection.some(s => URI.isUri(s) && s.toString() === mainUriStr)) {
示例7: isFileChange
function isFileChange(thing: [URI, types.TextEdit[]] | [URI, URI, { overwrite?: boolean }]): thing is [URI, URI, { overwrite?: boolean }] {
const [f, s] = thing;
return URI.isUri(f) && URI.isUri(s);
}