本文整理匯總了TypeScript中vs/base/common/uri.isUri函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isUri函數的具體用法?TypeScript isUri怎麽用?TypeScript isUri使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了isUri函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getMultiSelectedResources
export function getMultiSelectedResources(resource: URI | object, listService: IListService, editorService: IEditorService): URI[] {
const list = listService.lastFocusedList;
if (list && list.isDOMFocused()) {
// Explorer
if (list instanceof Tree) {
const selection = list.getSelection().map((fs: ExplorerItem) => fs.resource);
const focus = list.getFocus();
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 = list.getSelectedElements().filter(s => s instanceof OpenEditor).map((oe: OpenEditor) => oe.getResource());
const focusedElements = list.getFocusedElements();
const focus = focusedElements.length ? focusedElements[0] : undefined;
const mainUriStr = URI.isUri(resource) ? resource.toString() : (focus instanceof OpenEditor) ? focus.getResource().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] : [];
}
示例2: toPromise
p = toPromise(emitter.event).then(e => {
assert.equal(e.length, 2);
assert.ok(URI.isUri(e[0]));
assert.ok(URI.isUri(e[1]));
assert.equal(e[0].toString(), 'aa:bb');
assert.equal(e[1].toString(), 'aa:cc');
});
示例3: getMultiSelectedResources
export function getMultiSelectedResources(resource: URI | {}, listService: IListService, editorService: IWorkbenchEditorService): URI[] {
const list = listService.lastFocusedList;
if (list && list.isDOMFocused()) {
// Explorer
if (list instanceof Tree) {
const focus: IFileStat = list.getFocus();
// If the resource is passed it has to be a part of the returned context.
if (focus && (!URI.isUri(resource) || focus.resource.toString() === resource.toString())) {
const selection = list.getSelection();
// We only respect the selection if it contains the focused element.
if (selection && selection.indexOf(focus) >= 0) {
return selection.map(fs => fs.resource);
}
}
}
// Open editors view
if (list instanceof List) {
const focus = list.getFocusedElements();
// If the resource is passed it has to be a part of the returned context.
if (focus.length && (!URI.isUri(resource) || (focus[0] instanceof OpenEditor && focus[0].getResource().toString() === resource.toString()))) {
const selection = list.getSelectedElements();
// We only respect the selection if it contains the focused element.
if (selection && selection.indexOf(focus[0]) >= 0) {
return selection.filter(s => s instanceof OpenEditor).map((oe: OpenEditor) => oe.getResource());
}
}
}
}
const result = getResourceForCommand(resource, listService, editorService);
return !!result ? [result] : [];
}
示例4: 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.isDOMFocused()) {
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 });
}
示例5: getResourceForCommand
export function getResourceForCommand(resource: URI | {}, listService: IListService, editorService: IWorkbenchEditorService): URI {
if (URI.isUri(resource)) {
return resource;
}
const list = listService.lastFocusedList;
if (list && list.isDOMFocused()) {
const focus = list.getFocus();
if (focus instanceof FileStat) {
return focus.resource;
} else if (focus instanceof OpenEditor) {
return focus.getResource();
}
}
return toResource(editorService.getActiveEditorInput(), { supportSideBySide: true });
}
示例6: getResourceForCommand
id: OPEN_TO_SIDE_COMMAND_ID, handler: (accessor, resource: URI) => {
const editorService = accessor.get(IWorkbenchEditorService);
const listService = accessor.get(IListService);
const tree = listService.lastFocusedList;
resource = getResourceForCommand(resource, listService, editorService);
// Remove highlight
if (tree instanceof Tree) {
tree.clearHighlight();
}
// Set side input
if (URI.isUri(resource)) {
return editorService.openEditor({ resource, options: { preserveFocus: false } }, true);
}
return TPromise.as(true);
}
示例7: isTextChange
function isTextChange(thing: [URI, types.TextEdit[]] | [URI, URI]): thing is [URI, types.TextEdit[]] {
const [f, s] = thing;
return URI.isUri(f) && Array.isArray(s);
}
示例8: isFileChange
function isFileChange(thing: [URI, types.TextEdit[]] | [URI, URI]): thing is [URI, URI] {
const [f, s] = thing;
return URI.isUri(f) && URI.isUri(s);
}
示例9: 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);
}