- EffectiveStatement<SchemaNodeIdentifier, DeviationStatement>> stmt) {
- super.onFullDefinitionDeclared(stmt);
- SUBSTATEMENT_VALIDATOR.validate(stmt);
+ EffectiveStatement<SchemaNodeIdentifier, DeviationStatement>> ctx) {
+ final QNameModule currentModule = ctx.getFromNamespace(ModuleCtxToModuleQName.class,
+ ctx.getRoot());
+ final QNameModule targetModule = ctx.getStatementArgument().getLastComponent().getModule();
+
+ if (currentModule.equals(targetModule)) {
+ throw new InferenceException(ctx.getStatementSourceReference(),
+ "Deviation must not target the same module as the one it is defined in: %s", currentModule);
+ }
+ }
+
+ @Override
+ protected SubstatementValidator getSubstatementValidator() {
+ return SUBSTATEMENT_VALIDATOR;