本文整理汇总了TypeScript中@utils/error.error_formatSource函数的典型用法代码示例。如果您正苦于以下问题:TypeScript error_formatSource函数的具体用法?TypeScript error_formatSource怎么用?TypeScript error_formatSource使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了error_formatSource函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: util_getNodeStack
export function util_getNodeStack(astNode) {
var domNode = null,
x = astNode;
while (domNode == null && x != null) {
domNode = x.node;
x = x.parent;
}
if (domNode == null) {
var str, i;
x = astNode;
while (x != null) {
if (i == null) {
i = x.sourceIndex;
}
if (str == null) {
str = x.source;
}
x = x.parent;
}
if (str != null) {
return '\n' + error_formatSource(str, i || 0);
}
return '';
}
return reporter_getNodeStack(domNode);
}
示例2: function
return function(str, source, index?, token?, state?, file?) {
var error = new Ctor(str);
var tokenMsg = formatToken(token);
if (tokenMsg) {
error.message += tokenMsg;
}
var stateMsg = formatState(state);
if (stateMsg) {
error.message += stateMsg;
}
var cursorMsg = error_formatSource(source, index, file);
if (cursorMsg) {
error.message += '\n' + cursorMsg;
}
report(error, 'error');
};
示例3: reporter_getNodeStack
export function reporter_getNodeStack(node) {
var stack = [node];
var parent = node.parent;
while (parent != null) {
stack.unshift(parent);
parent = parent.parent;
}
var str = '';
var root = stack[0];
if (root !== node && is_String(root.source) && node.sourceIndex > -1) {
str += error_formatSource(root.source, node.sourceIndex, root.filename) + '\n';
}
str += ' at ' + stack.map(function(x) { return x.tagName || x.compoName;}).join(' > ');
return str;
}