- StatementDefinition def = stmtContext.getPublicDefinition();
- return !noCopyDefSet.contains(def);
- }
-
- public static boolean isReusedByAugment(StmtContext<?, ?, ?> stmtContext) {
-
- Set<StatementDefinition> reusedDefSet = new HashSet<>();
- reusedDefSet.add(Rfc6020Mapping.TYPEDEF);
-
- StatementDefinition def = stmtContext.getPublicDefinition();
-
- return reusedDefSet.contains(def);
- }
-
- public static StatementContextBase<?, ?, ?> getAugmentTargetCtx(
- final Mutable<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> augmentNode) {
-
- final SchemaNodeIdentifier augmentTargetNode = augmentNode
- .getStatementArgument();
- if (augmentTargetNode == null) {
- throw new IllegalArgumentException(
- "Augment argument null, something bad happened in some of previous parsing phases");
- }
-
- List<StatementContextBase<?, ?, ?>> rootStatementCtxList = new LinkedList<>();
-
- if (augmentTargetNode.isAbsolute()) {
-
- QNameModule module = augmentTargetNode.getPathFromRoot().iterator()
- .next().getModule();
-
- StatementContextBase<?, ?, ?> rootStatementCtx = (StatementContextBase<?, ?, ?>) augmentNode
- .getFromNamespace(NamespaceToModule.class, module);
- rootStatementCtxList.add(rootStatementCtx);
-
- final Map<?, ?> subModules = rootStatementCtx
- .getAllFromNamespace(IncludedModuleContext.class);
- if (subModules != null) {
- rootStatementCtxList
- .addAll((Collection<? extends StatementContextBase<?, ?, ?>>) subModules
- .values());
- }
-
- } else {
- StatementContextBase<?, ?, ?> parent = (StatementContextBase<?, ?, ?>) augmentNode
- .getParentContext();
- if (StmtContextUtils.producesDeclared(parent, UsesStatement.class)) {
- rootStatementCtxList.add(parent.getParentContext());
- } else {
- // error
+ for (final StatementContextBase<?, ?, ?> sourceSubStatement : sourceSubStatements) {
+ InferenceException.throwIf(MandatoryStatement.class.equals(
+ sourceSubStatement.getPublicDefinition().getDeclaredRepresentationClass()),
+ sourceCtx.getStatementSourceReference(),
+ "An augment cannot add node '%s' because it is mandatory and in module different from target",
+ sourceCtx.rawStatementArgument());