解决方案是扩展DefaultDeclarativeQualifiedNameProvider
:
import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider;
import org.eclipse.xtext.naming.QualifiedName;
import model.Revision;
public class ModelQualifiedNameProvider extends DefaultDeclarativeQualifiedNameProvider {
public final static String REVISION_TABLE_EXTENSION = "_REV";
public final static String REVISION_TYPE_EXTENSION = "Rev";
public QualifiedName qualifiedName( Revision obj ) {
QualifiedName qn = getFullyQualifiedName( obj.eContainer() );
String typeName = qn.getLastSegment() + REVISION_TABLE_EXTENSION;
QualifiedName result = qn.skipLast( 1 );
result = result.append( typeName );
return result;
}
}
确保您获得正确的方法签名!Xtext 反射调用QualifiedName qualifiedName(MyType ele)
,如果您从 1.0 升级到 2.0,请不要忘记更新签名:将返回类型从更改String
为QualifiedName