【问题标题】:Getting the raw code in xtext dsl在 xtext dsl 中获取原始代码
【发布时间】:2014-04-22 16:10:18
【问题描述】:

我尝试基于现有的解释语言实现 xtext dsl 插件。该语言已经有一个解释器,我想使用它。问题是,我看不到任何可以访问原始代码并将其发送到解释的阶段。我只注意到带有 doGenerate 方法的代码生成器,但这不是我的情况。

感谢您的帮助

【问题讨论】:

    标签: java eclipse eclipse-plugin xtext


    【解决方案1】:

    尝试从解析的 AST 中获取 XtextResource。它可以提供原始文本。

    MyModel model = ..
    XtextResource res = (XtextResource)model.eResource();
    String text = res.getParseResult().getRootNode().getText();
    

    【讨论】:

      猜你喜欢
      • 2016-11-22
      • 2017-04-14
      • 1970-01-01
      • 2021-12-16
      • 2011-05-04
      • 1970-01-01
      • 2021-04-28
      • 1970-01-01
      • 2018-09-02
      相关资源
      最近更新 更多