|
|
|
|
|
|
|
|
|
Re: cross-project references not resolved in standalone mode [message #1779840 is a reply to message #1746478] |
Sun, 14 January 2018 12:52 |
Martin Trummer Messages: 17 Registered: December 2017 |
Junior Member |
|
|
I also have a problem with simple cross-references between 2 java modules in a gradle build.
Here is my DSL-project :
Relevant parts of
X2Dsl.xtext
grammar com.tmtron.ex.xtext2.dsl.X2Dsl with org.eclipse.xtext.xbase.annotations.XbaseWithAnnotations
generate x2Dsl "http://www.example.com/ex/xtext2/dsl/X2Dsl"
x2Model:
importSection=XImportSection?
elements+=AbstractElement*
;
AbstractElement:
PackageDeclaration | DomainObject | UseCase;
PackageDeclaration:
'package' name=QualifiedName '{'
elements+=AbstractElement*
'}';
DomainObject:
'do' name=ValidID;
UseCase:
'uc' name=ValidID 'do=' doRef=[DomainObject|ValidID];
The Inferrer-code:
X2DslJvmModelInferrer.xtend
def dispatch void infer(DomainObject domainObject, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {
acceptor.accept(domainObject.toClass(domainObject.fullyQualifiedName)) [
documentation = "generated from the domain model"
]
}
def dispatch void infer(UseCase useCase, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {
acceptor.accept(useCase.toClass(useCase.fullyQualifiedName)) [
documentation = "use-case generated from the domain model"
val doClassRef = typeRef(useCase.doRef.fullyQualifiedName.toString)
members += useCase.doRef.toField(useCase.doRef.name.toFirstLower, doClassRef) => [
visibility = JvmVisibility.PUBLIC
]
]
}
The DSL is used in this project: dsl-usage
which uses gradle and has 2 java-modules.
Domain project
domain has a simple model, which defines a User DomainObject: model.x2dsl
package com.tmtron.test.domain {
do User
}
the gradle build file build.gradle
makes sure that the model.x2dsl file is included in the jar:
sourceSets.main.resources.srcDirs += ["src/main/java"]
Interactors project
The interactors module
has a dependency on the domain module. Gradle build file: interactors/build.gradle
dependencies {
implementation project(':domain')
}
and in the Interactors model interactorModel.x2dsl
, I want to reference the User domain object like this:
import com.tmtron.test.domain.User
package com.tmtron.text {
uc GetUserName do=User
uc SetUserName do=User
}
but the build fails (see log output)
with this error:
Error calling inferrer
ERROR:User cannot be resolved. (file:/builds/xtext2/dsl-usage/interactors/src/main/java/com/tmtron/ex/xtext2/usage/interactorModel.x2dsl line : 5 column : 20)
ERROR:User cannot be resolved. (file:/builds/xtext2/dsl-usage/interactors/src/main/java/com/tmtron/ex/xtext2/usage/interactorModel.x2dsl line : 6 column : 20)
Maybe the problem is in my inferrer?
I am not sure if this reference type is correct:
val doClassRef = typeRef(useCase.doRef.fullyQualifiedName.toString)
[Updated on: Sun, 04 September 2022 06:54] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05754 seconds