本文整理匯總了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 },
)
}