Symbolk / Code2Graph

Towards converting multilingual source code into one language-agnostic graph representation.
42 stars 7 forks source link

bug: gen.java | QUALIFIED_NAME 类型的 ASTNode 节点缺少 reference 边连接类静态变量 #131

Open Guitenbay opened 2 years ago

Guitenbay commented 2 years ago

对于以下情况 gen.java 不能处理: src/Main.java

public static void main(String[] args) {
    ...
    Global.LOGS.add("TEST");
}

src/Global.java

public class Global {
    public static List<String> LOGS = new ArrayList<>(Arrays.asList("<GLOBAL LOGS>", "--------------"));
    ...
}

Main.javaGlobal.LOGS 链接不到 Global.java 的静态变量 LOGS

原因是 gen.java 里的 edu.pku.code2graph.gen.jdt.ExpressionVisitor.java 第 1095 行:

case ASTNode.QUALIFIED_NAME:
      {
        QualifiedName name = (QualifiedName) exp;
        root.setType(NodeType.QUALIFIED_NAME);
        root.setUri(createIdentifier(name.getFullyQualifiedName()));
        GraphUtil.addNode(root);
        break;
      }

缺少对 ((QualifiedName) exp).getName() 这个SimpleName节点的处理

解决方案:

image