-
-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: inconsistent parents for elements in model (#5870)
Co-authored-by: I-Al-Istannen <[email protected]>
- Loading branch information
1 parent
692c4d4
commit d1c9d72
Showing
7 changed files
with
159 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/test/java/spoon/reflect/visitor/ModelConsistencyCheckerTestHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package spoon.reflect.visitor; | ||
|
||
import spoon.reflect.factory.Factory; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
public class ModelConsistencyCheckerTestHelper { | ||
|
||
public static void assertModelIsConsistent(Factory factory) { | ||
// contract: each elements direct descendants should have the element as parent | ||
factory.getModel().getAllModules().forEach(ctModule -> { | ||
var invalidElements = ModelConsistencyChecker.listInconsistencies(ctModule); | ||
|
||
if (!invalidElements.isEmpty()) { | ||
throw new AssertionError("Model is inconsistent, %d elements have invalid parents:%n%s".formatted( | ||
invalidElements.size(), | ||
invalidElements.stream() | ||
.map(ModelConsistencyChecker.InconsistentElements::toString) | ||
.limit(5) | ||
.collect(Collectors.joining(System.lineSeparator())) | ||
)); | ||
} | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters