- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我们想要重新实现一个旧项目,该项目通过 xtext 和 xpand 使用代码生成。 Xpand 应替换为 Xtend(2),并且应删除旧的 fornax 插件工作流程执行,并替换为 xtext 和 xtend maven 插件。在旧项目中我们使用两个 Maven 项目。第一个是 xtext-project,它保存“ownLanguage”的语言定义,并且如果可能的话,只能作为编译依赖项重新使用。第二个包含一个文件,其中包含所描述语言的模型、xpand 的旧工作流程和 xpt 文件。旧的工作流程使用此 main.xpt 作为入口:
«IMPORT ownLanguage»
«DEFINE main FOR Model-»
«EXPAND AttributeInterfaces::attributeInterfaces FOR this»
«ENDDEFINE»
这里引用了 AttributesInterfaces.xpt
«IMPORT ownLanguage»
«DEFINE attributeInterfaces FOR Model»
«EXPAND attributeInterface FOREACH this.fieldDefs»
«ENDDEFINE»
«DEFINE attributeInterface FOR FieldDef»
«FILE "com/package/attributes/" + this.name.toFirstUpper() + "Attribute.java"»
package ....attributes;
public interface «this.name.toFirstUpper()»Attribute {
«this.type.mappedTypeNullable.fullName» get«this.name.toFirstUpper()»OrNull();
}
«ENDFILE»
«ENDDEFINE»
用于从“fieldDef”列表生成接口(interface)。此“fieldDef”列表取自 model.ownLaguage 文件,该文件使用依赖项中的语言。
有没有办法将这些 .xpt 文件重写为 .xtend 文件,以便在新项目中结合使用 xtext 和 xtend maven 插件来生成与旧项目中相同的文件?
最佳答案
您可以使用依赖注入(inject)将其他内容导入到您的类中
@Inject extension Xxx
或者
@Inject Xxx xxx
然后从丰富的字符串中调用它
'''«method»'''
没有默认的maven或工作流组件,但写一点gluecode应该没问题
关于java - 如何将代码生成从 xpand 迁移到 xtend(2)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42512288/
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我正在学习 xtend。在 xtend 中创建逗号分隔列表的好方法是什么? (类似于 xpand 中的 SEPARATOR) 我想在我的生成器中生成一个逗号分隔的参数列表: «FOR param: r
给定一些可迭代变量 v和一个类型 T我经常发现自己在编写代码,例如 v.filter[it instanceof T].map[it as T] 是否存在一些可以在单个步骤中完成相同功能的助手? 最佳
documentation说 Ctrl< 但似乎不起作用(我有带美式键盘的 Mmac)。我可以 CtrlSpace 插入一对引号。 最佳答案 在 Eclipse Oxygen.1a 版本 (4.7.1
我有以下代码: 即使我不想要它,它也会迭代 arrayList 直到结束。我不知道如何打破它,因为 xtend 没有 break 语句。如果我无法将其转换为 while 循环,那么 xtend 中是否
我需要使用 xtend 2.5 通过 DSL 生成 Java 枚举。我的语法看起来像这样: grammar de.mytest.xtext.enumdsl.EnumDsl with org.eclip
我的 Eclipse 版本 Photon Release (4.8.0) 与 Eclipse Xtend 2.15.0 插件始终以深色主题显示 .xtend 源文件模式下,我什至尝试更改 Window
假设您在 xTend 中有以下代码: class StackOverflowGenerator { def generate()''' «var counter = 0» «F
我正在尝试将以下 java 片段转换为 Xtend,但我做不到。我无法访问静态属性“类”。 public class SyncService{ private static final Strin
大家好,我找到了 XTend (http://xtend-lang.org),它听起来真的很棒!但是,我看不到这种语言的任何独立命令行编译器。好像只能在eclipse下运行。我做了一些研究,发现有人说
是否可以控制 xtend 中递归调用方法的缩进?我有以下案例: def generateField(Field field) ''' field «field.name» {
我试图 100% 理解以下 Xtend 语法的含义: myVar.addSelectionListener( [MultiSelectionEvent event
我正在使用 Eclipse IDE。第一个构造函数可调用,但第二个构造函数不可调用。我想知道 xtend 是否支持多个构造函数? @Data abstract class MatchingBase i
我在 Eclipse 中有一个 XText 项目,其中实现了我自己的语法文件。使用doGenerate函数我生成了几个.java文件。到目前为止,一切都很顺利。 我的问题是每次生成文件时我都需要执行以
我有一个整数的ArrayList。 a = {1, 2, 3, 4, 5} b = {6, 7, 8, 9, 10} 我想添加两个数组的元素。因此,新数组现在将是:c = {7, 9, 11, 13,
在 Xtend 中,是否可以中断循环或进行检查以中断循环? «FOR e:d.entitys» «FOR a:e.attributes» «IF a.eClass.name.c
我有一个关于 Xtend 的非常具体的问题。 在我读到的有关 xText/xTend 的每个示例中,我都会看到类似这样的内容: override void doGenerate(Resource re
我尝试使用 Xtend 重载现有外部类的运算符,但它不起作用。我无法在类源代码中编写,例如 BigIntegerExtension。我该怎么做? 回答 答案很简单。我们可以使用 operator ov
我正在尝试 Xtend .是否有可能制作构造函数?看起来很简单,但是当我尝试这样的事情时出现错误: class Scope extends Rect { public Scope(){
我正在将我的模板代码移植到 XTend。在某些时候,我在测试用例中有这种类型的条件处理: @Test def xtendIfTest() { val obj = new FD if (
我是一名优秀的程序员,十分优秀!