WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 957da63

Browse files
Arielwyy王雅仪
andauthored
fixbug: fix python loc column (#19)
* fixbug: 修正匿名函数定义节点id为null,以和其他语言保持一致 * fixbug: 修正参数节点loc列号信息 * fixbug: 修正参数节点loc列号信息 * fixbug: python CompileUnit node loc * fixbug: fix java _meta definition * fixbug: fix python loc column --------- Co-authored-by: 王雅仪 <[email protected]>
1 parent d188b21 commit 957da63

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

parser-Python/uast/visitor.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,9 @@ def collect_child_locations(node):
12901290
start_col = node.col_offset
12911291
end_lineno = node.end_lineno
12921292
end_col = node.end_col_offset
1293+
# 构建自定义的 SourceLocation 对象
1294+
start_pos = UNode.Position(start_lineno, start_col + 1)
1295+
end_pos = UNode.Position(end_lineno, end_col + 1)
12931296
else:
12941297
# 递归收集所有子节点的位置
12951298
child_locations = collect_child_locations(node)
@@ -1303,7 +1306,7 @@ def collect_child_locations(node):
13031306
end_lineno = max(loc.end.line for loc in child_locations)
13041307
end_col = max(loc.end.column for loc in child_locations)
13051308

1306-
# 构建自定义的 SourceLocation 对象
1307-
start_pos = UNode.Position(start_lineno, start_col + 1)
1308-
end_pos = UNode.Position(end_lineno, end_col + 1)
1309+
# 构建自定义的 SourceLocation 对象
1310+
start_pos = UNode.Position(start_lineno, start_col)
1311+
end_pos = UNode.Position(end_lineno, end_col)
13091312
return UNode.SourceLocation(start_pos, end_pos, self.sourcefile)

specification/scripts/generators/ast-types-java.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ abstract public class ASTNode {
1414
public ASTNode parent;
1515
public String type;
1616
public Loc loc;
17-
public Meta _meta;
17+
public Map<String, Object> _meta;
1818
abstract public <T> T accept(UastVisitor visitor);
1919
};`
2020
}
@@ -41,16 +41,6 @@ public class LineColumn {
4141
}
4242
}
4343

44-
const Meta = function(){
45-
return function(){
46-
return `${DISCLAIMER}${packageDecl}
47-
import java.util.Map;
48-
49-
public class Meta {
50-
public Map<String, Object> _meta;
51-
};`
52-
}
53-
}
5444

5545

5646
// java的每个 AST 节点的描述会作为一个类,单独写到一个文件中

0 commit comments

Comments
 (0)