本文整理汇总了TypeScript中atom.Range.fromObject方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Range.fromObject方法的具体用法?TypeScript Range.fromObject怎么用?TypeScript Range.fromObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atom.Range
的用法示例。
在下文中一共展示了Range.fromObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: syntaxTreeToRange
function syntaxTreeToRange(node: ReVIEW.NodeLocation): TextBuffer.IRange {
return Range.fromObject({
start: {
row: node.location.start.line - 1,
column: node.location.start.column - 1,
},
end: {
row: node.location.start.line - 1,
column: node.location.end ? node.location.end.column - 1 : node.location.start.column - 1,
},
});
}
示例2: showTooltip
public async showTooltip(
editor: TextEditor,
type: TEventRangeType,
spec?: ITooltipSpec,
) {
const controller = this.pluginManager.controller(editor)
if (!controller) {
return
}
let pluginName: string
let tooltipData: TTooltipFunctionExt | ITooltipDataExt
if (spec && typeof spec.tooltip !== 'function') {
tooltipData = spec.tooltip
pluginName = spec.pluginName
} else {
const eventRange = controller.getEventRange(type)
if (!eventRange) {
return
}
if (spec && typeof spec.tooltip === 'function') {
pluginName = spec.pluginName
try {
tooltipData = await Promise.resolve(spec.tooltip(eventRange.crange))
} catch (e) {
this.pluginManager.backendStatus(spec.pluginName, {
status: 'warning',
detail: e.toString(),
})
return
}
} else {
const tooltip = await this.defaultTooltipFunction(
editor,
type,
eventRange.crange,
)
if (!tooltip) {
// if nobody wants to show anything, might as well hide...
// TODO: this doesn't seem like a particularly bright idea?
controller.tooltips.hide(type, undefined, { persistent: false })
return
}
;({ pluginName, tooltipData } = tooltip)
}
const newEventRange = controller.getEventRange(type)
if (!newEventRange || !eventRange.crange.isEqual(newEventRange.crange)) {
return
}
}
const { persistent = false } = tooltipData
let msg
if (Array.isArray(tooltipData.text)) {
msg = tooltipData.text.map(MessageObject.fromObject)
} else {
msg = MessageObject.fromObject(tooltipData.text)
}
controller.tooltips.show(
Range.fromObject(tooltipData.range),
msg,
type,
pluginName,
{ persistent },
)
}