- if (stmtDef != null && Utils.isValidStatementDefinition(prefixes, stmtDef, identifier)
- && toBeSkipped.isEmpty()) {
- final String argument = argumentCtx != null ? Utils.stringFromStringContext(argumentCtx) : null;
- // FIXME: this looks like a fishy special case
- if (identifier.equals(Rfc6020Mapping.TYPE.getStatementName())) {
- Preconditions.checkArgument(argument != null);
- if (TypeUtils.isYangTypeBodyStmtString(argument)) {
- writer.startStatement(QName.create(YangConstants.RFC6020_YIN_MODULE, argument), ref);
- } else {
- writer.startStatement(QName.create(YangConstants.RFC6020_YIN_MODULE, Rfc6020Mapping
- .TYPE.getStatementName().getLocalName()), ref);
- }
- writer.argumentValue(argument, ref);
- } else {
- writer.startStatement(identifier, ref);
- if(argument != null) {
- writer.argumentValue(argument, ref);
- }
- }
- } else {
- Preconditions.checkArgument(writer.getPhase() != ModelProcessingPhase.FULL_DECLARATION,
- "%s is not a YANG statement or use of extension. Source: %s", identifier.getLocalName(), ref);
+ final QName validStatementDefinition = Utils.getValidStatementDefinition(prefixes, stmtDef, identifier);
+
+ if (stmtDef == null || validStatementDefinition == null || !toBeSkipped.isEmpty()) {
+ SourceException.throwIf(writer.getPhase() == ModelProcessingPhase.FULL_DECLARATION, ref,
+ "%s is not a YANG statement or use of extension.", keywordTxt);