GumTreeDiff / gumtree

An awesome code differencing tool
https://github.com/GumTreeDiff/gumtree/wiki
GNU Lesser General Public License v3.0
933 stars 174 forks source link

parse go throw ClassCastException #362

Closed yikengboy closed 1 month ago

yikengboy commented 3 months ago

when I use gen.treesitter-ng parse go file, throw ClassCastException. The complete exception stack is as follows: Exception in thread "main" java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.util.Map (java.util.ArrayList and java.util.Map are in module java.base of loader 'bootstrap') at com.github.gumtreediff.gen.treesitterng.AbstractTreeSitterNgGenerator.tsNode2GumTree(AbstractTreeSitterNgGenerator.java:171) at com.github.gumtreediff.gen.treesitterng.AbstractTreeSitterNgGenerator.generateFromTreeSitterTree(AbstractTreeSitterNgGenerator.java:199) at com.github.gumtreediff.gen.treesitterng.AbstractTreeSitterNgGenerator.generate(AbstractTreeSitterNgGenerator.java:59) at com.github.gumtreediff.gen.TreeGenerator.generateTree(TreeGenerator.java:41) at com.github.gumtreediff.gen.TreeGenerator$ReaderConfigurator.reader(TreeGenerator.java:119) at com.github.gumtreediff.gen.TreeGenerator$ReaderConfigurator.file(TreeGenerator.java:90) at com.github.gumtreediff.gen.TreeGenerator$ReaderConfigurator.file(TreeGenerator.java:100) at com.github.gumtreediff.gen.TreeGenerators.getTree(TreeGenerators.java:58) at com.qunhe.devops.ast.analysis.biz.demo.main(demo.java:30)

After debugging, I found that it was caused by forcibly converting an empty List into a Map. image image Is this a bug?

jrfaller commented 3 months ago

Hi, and thanks a lot for the report!

This is definitively a bug :-) Normally aliased configuration is given using a Yaml dictionary. However, when there is no configuration, I used an empty list that worked fine in Python but not in Java where there is a static type error.

Maybe the way to go is to not have the aliased configuration when it's empty?

Cheers.