本文整理汇总了TypeScript中atom.Range类的典型用法代码示例。如果您正苦于以下问题:TypeScript Range类的具体用法?TypeScript Range怎么用?TypeScript Range使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Range类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getSymbolInRange
export function getSymbolInRange(editor: TextEditor, crange: Range) {
const buffer = editor.getBuffer()
if (crange.isEmpty()) {
return getSymbolAtPoint(editor, crange.start)
} else {
return {
symbol: buffer.getTextInRange(crange),
range: crange,
}
}
}
示例2: 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,
},
});
}
示例3: 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 },
)
}