我目前正在我们的一个项目中搜索问题,该项目使用Xtext生成java源代码。 我们使用模型推导者和Xannotation来使用javax。*注释来生成我们的实体。
import javax.persistence.FetchType
import javax.persistence.Id
import javax.persistence.Column
import javax.persistence.ManyToOne
package test.some.namespace {
domain DomainA {
entity for table "DOMAINA" {
@Id
@Column(name = "DAIA", unique = true)
Long id;
}
}
domain DomainB {
entity for table "DOMAINB" {
@Id
@Column(name = "DAIB", unique = true)
Long id;
@ManyToOne(fetch = FetchType::LAZY)
DomainA domainA;
}
}
domain DomainC {
entity for table "DOMAINC" {
@Id
@Column(name = "DAIC", unique = true)
Long id;
@ManyToOne(fetch = FetchType::LAZY)
DomainA domainA;
}
}
}
我们通过迭代XAnnotationElementValuePair pair : annotation.getElementValuePairs()
来搜索注释并返回值pair.getValue()
,到目前为止它都有效。
现在我们尝试使用(exp as XMemberFeatureCall).feature
访问FetchType,其中exp
是pair.getValue()
的结果。
对于DomainB.domainA
,它将返回org.eclipse.xtext.common.types.impl.JvmEnumerationLiteralImplCustom
。
对于DomainC.domainA
,它将返回org.eclipse.xtext.common.types.impl.JvmVoidImplCustom
。
仅在保存文档时才会出现此问题。这是eclipse的当前线程堆栈。
Thread [Worker-5] (Suspended (breakpoint at line 60 in CustomDSLJvmModelInferrer$2))
owns: ClusteringBuilderState (id=19135)
CustomDSLJvmModelInferrer.xtend line: 60
JvmDispatchableModelAssociator.installDerivedState(DerivedStateAwareResource, boolean) line: 66
BatchLinkableResource(DerivedStateAwareResource).installDerivedState(boolean) line: 159
DerivedStateAwareResourceDescriptionManager.internalGetResourceDescription(Resource, IDefaultResourceDescriptionStrategy) line: 53
DefaultResourceDescriptionManager$1.get() line: 60
DefaultResourceDescriptionManager$1.get() line: 1
OnChangeEvictingCache.get(Object, Resource, Provider<T>) line: 75
DerivedStateAwareResourceDescriptionManager(DefaultResourceDescriptionManager).getResourceDescription(Resource) line: 58
ClusteringBuilderState.writeNewResourceDescriptions(BuildData, IResourceDescriptions, CurrentDescriptions, IProgressMonitor) line: 366
ClusteringBuilderState.doUpdate(BuildData, ResourceDescriptionsData, IProgressMonitor) line: 121
ClusteringBuilderState(AbstractBuilderState).update(BuildData, IProgressMonitor) line: 112
XtextBuilder.doBuild(ToBeBuilt, IProgressMonitor, IXtextBuilderParticipant$BuildType) line: 194
XtextBuilder.incrementalBuild(IResourceDelta, IProgressMonitor) line: 171
XtextBuilder.build(int, Map, IProgressMonitor) line: 99
BuildManager$2.run() line: 734
SafeRunner.run(ISafeRunnable) line: 42
BuildManager.basicBuild(int, IncrementalProjectBuilder, Map<String,String>, MultiStatus, IProgressMonitor) line: 206
BuildManager.basicBuild(IBuildConfiguration, int, IBuildContext, ICommand[], MultiStatus, IProgressMonitor) line: 246
BuildManager$1.run() line: 299
SafeRunner.run(ISafeRunnable) line: 42
BuildManager.basicBuild(IBuildConfiguration, int, IBuildContext, MultiStatus, IProgressMonitor) line: 302
BuildManager.basicBuildLoop(IBuildConfiguration[], IBuildConfiguration[], int, MultiStatus, IProgressMonitor) line: 358
BuildManager.build(IBuildConfiguration[], IBuildConfiguration[], int, IProgressMonitor) line: 381
AutoBuildJob.doBuild(IProgressMonitor) line: 143
AutoBuildJob.run(IProgressMonitor) line: 241
Worker.run() line: 54
但是如果我只修改文档而不保存它就可以了。来自日食的堆栈:
Thread [Worker-3] (Suspended (breakpoint at line 60 in CustomDSLJvmModelInferrer$2))
owns: DirtyStateManager (id=19093)
owns: Object (id=19094)
CustomDSLJvmModelInferrer.xtend line: 60
JvmDispatchableModelAssociator.installDerivedState(DerivedStateAwareResource, boolean) line: 66
BatchLinkableResource(DerivedStateAwareResource).installDerivedState(boolean) line: 159
DirtyStateResourceDescription$Manager.getResourceDescription(Resource) line: 65
DirtyStateEditorSupport.announceDirtyState(XtextResource) line: 467
XtextDocumentReconcileStrategy.postParse(XtextResource, IProgressMonitor) line: 160
XtextDocumentReconcileStrategy.doReconcile(IRegion) line: 146
XtextDocumentReconcileStrategy.reconcile(IRegion) line: 65
XtextReconciler.doRun(XtextResource, IProgressMonitor) line: 401
XtextReconciler.access$3(XtextReconciler, XtextResource, IProgressMonitor) line: 386
XtextReconciler$1.process(XtextResource) line: 327
XtextReconciler$1.process(Object) line: 1
XtextReconciler$1(IUnitOfWork$Void).exec(T) line: 36
XtextDocument$XtextDocumentLocker.modify(IUnitOfWork<T,XtextResource>) line: 418
XtextDocument.internalModify(IUnitOfWork<T,XtextResource>) line: 131
XtextReconciler.run(IProgressMonitor) line: 324
Worker.run() line: 54
到目前为止,我完全没有想法。这是一个错误吗?我错过了什么吗? 我希望你们能帮助我。
祝你好运