我知道我们可以使用$json = '{
"a":0.0000051,
"b":0.00000051,
"c":0.000000051,
"d":0.0000000000051
}';
$data = json_decode($json, true);
$data = float_to_string($data);
print_r($data);
来获取节点的位置,但有没有办法获取节点的行号?像Array
(
[a] => 0.0000051
[b] => 0.00000051
[c] => 0.000000051
[d] => 0.0000000000051
)
?
答案 0 :(得分:3)
let { line, character } =
sourceFile.getLineAndCharacterOfPosition(node.getStart());
console.log(`${sourceFile.fileName} (${line + 1},${character + 1}):
${message}`);
从这里开始:
https://github.com/Microsoft/TypeScript-wiki/blob/master/Using-the-Compiler-API.md