AST for current selected code in eclipse editor?

前端 未结 4 600
隐瞒了意图╮
隐瞒了意图╮ 2021-01-19 03:59

I need to get the AST for the current selection in the java editor fo eclipse. Basically I want to convert the selected java code in to some other form(maybe some other lang

4条回答
  •  走了就别回头了
    2021-01-19 04:43

    IIRC, each node in the Eclipse AST contains an offset. All you need to do is to compute the offsets for the part of the code you are interested in then walk the AST to select the nodes within those offsets.

提交回复
热议问题