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