Validation: Proper way to check for errors in related resources [message #1810037] |
Mon, 29 July 2019 14:20  |
Eclipse User |
|
|
|
Hi,
I got two related files A and B, where B depends on A having no errors. There exists a reference within A to B. Of course, I already validate A and report those errors.
I would now like to create an error in file B, if any errors where reported in A in order to prevent the compilation of unit / file B. What is the proper way to do this?
Right now I implemented it like this:
@Check
def check(Entity ent) {
val res = ent.eResource
val validator = res?.resourceServiceProvider?.resourceValidator
if (validator !== null) {
val issues = validator.validate(res, CheckMode.ALL, CancelIndicator.NullImpl);
if (issues.exists[it.severity == Severity.ERROR]) {
// create error here, e.g. "An error in related file A exists."
}
}
}
This works, but I am fearful that now resource A is checked multiple times. Is there a better way to implement this?
Thanks,
Konrad
|
|
|
|
Re: Validation: Proper way to check for errors in related resources [message #1810064 is a reply to message #1810038] |
Tue, 30 July 2019 04:29   |
Eclipse User |
|
|
|
Hi Christian,
great, thanks for the hint. The IShouldGenerate Interface worked perfectly. I created my own IShouldGenerate delegator that delegates to EclipseBasedShouldGenerate and adds the necessary dependency check.
Thank you also for the Link to the CachingResourceValidatorImpl - I will look deeper into my validations in order to see, if I can save some performance there.
Regarding your quote:
Quote:i dont think that requirement is a good idea.
I don't fully understand your reservations here, maybe you can shed some light on this?
In my case, I would like to generate a SQL connection table, which must contain the primary keys of both tables connected to them. There are, thus, dependencies to both connected tables.
Anyway, thanks for your help and effort!
|
|
|
|
Re: Validation: Proper way to check for errors in related resources [message #1810091 is a reply to message #1810065] |
Tue, 30 July 2019 11:51  |
Eclipse User |
|
|
|
Hi christian,
Sorry for the confusion. Let me try to clear that up.
Standalone setup: We dont generate anything if there is any error in any file. So no problems here.
Eclipse setup (autobuild): It would be nice to generate as many files as possible, even if there are errors, so that the user can check all "unspoiled" files.
In out case we are talking about Entities (E) and Relations (R), from which we want to create DB tables. Relations contain foreign keys for each connected Entity.
So when do we want to generate what?
- E has an error, R has no error: Generate nothing
- E has no error, R has an error: Generate E
- E has no error, R has no error: Generate both
Also consider, that there might be multiple Es per R (E1, E2, ...).
Also, there does not have to be an R, so there are Es that possess no R.
Maybe it would be possible to validate the Relations (and all connected Es) and then only those Entities, that possess no Rs. This could work, but it feels unelegant to me.
|
|
|
Powered by
FUDForum. Page generated in 0.03784 seconds