private EffectiveModelContext transform() { checkState(finishedPhase == ModelProcessingPhase.EFFECTIVE_MODEL); final List<DeclaredStatement<?>> rootStatements = new ArrayList<>(sources.size()); for (final SourceSpecificContext source : sources) { rootStatements.add(source.getRoot().buildDeclared()); } return new EffectiveModelContext(rootStatements); }
private PrefixToModule prefixes() { final Map<String, StmtContext<?, ?, ?>> allImports = getRoot().getAllFromNamespace( ImportPrefixToModuleCtx.class); if (allImports != null) { allImports.forEach((key, value) -> prefixToModuleMap.put(key, getRoot().getFromNamespace(ModuleCtxToModuleQName.class, value))); } final Map<String, StmtContext<?, ?, ?>> allBelongsTo = getRoot().getAllFromNamespace( BelongsToPrefixToModuleCtx.class); if (allBelongsTo != null) { allBelongsTo.forEach((key, value) -> prefixToModuleMap.put(key, getRoot().getFromNamespace(ModuleCtxToModuleQName.class, value))); } return prefixToModuleMap; }
private SomeModifiersUnresolvedException propagateException(final SourceSpecificContext source, final RuntimeException cause) throws SomeModifiersUnresolvedException { final SourceIdentifier sourceId = StmtContextUtils.createSourceIdentifier(source.getRoot()); if (!(cause instanceof SourceException)) { /* * This should not be happening as all our processing should provide SourceExceptions. * We will wrap the exception to provide enough information to identify the problematic model, * but also emit a warning so the offending codepath will get fixed. */ LOG.warn("Unexpected error processing source {}. Please file an issue with this model attached.", sourceId, cause); } throw new SomeModifiersUnresolvedException(currentPhase, sourceId, cause); }
@Override public <K, V, N extends IdentifierNamespace<K, V>> V putToLocalStorage(final Class<N> type, final K key, final V value) { // RootStatementContext takes care of IncludedModuleContext and the rest... final V ret = getRoot().putToLocalStorage(type, key, value); // FIXME: what about duplicates? updateImportedNamespaces(type, value); return ret; }
@Override public <K, V, N extends IdentifierNamespace<K, V>> V putToLocalStorageIfAbsent(final Class<N> type, final K key, final V value) { // RootStatementContext takes care of IncludedModuleContext and the rest... final V ret = getRoot().putToLocalStorageIfAbsent(type, key, value); if (ret == null) { updateImportedNamespaces(type, value); } return ret; }
@Override public <K, V, N extends IdentifierNamespace<K, V>> V getFromLocalStorage(final Class<N> type, final K key) { final V potentialLocal = getRoot().getFromLocalStorage(type, key); if (potentialLocal != null) { return potentialLocal; } for (final NamespaceStorageNode importedSource : importedNamespaces) { final V potential = importedSource.getFromLocalStorage(type, key); if (potential != null) { return potential; } } return null; }
@Override public <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromLocalStorage(final Class<N> type) { final Map<K, V> potentialLocal = getRoot().getAllFromLocalStorage(type); if (potentialLocal != null) { return potentialLocal; } for (final NamespaceStorageNode importedSource : importedNamespaces) { final Map<K, V> potential = importedSource.getAllFromLocalStorage(type); if (potential != null) { return potential; } } return null; }
@SuppressWarnings("checkstyle:illegalCatch") private EffectiveSchemaContext transformEffective() throws ReactorException { checkState(finishedPhase == ModelProcessingPhase.EFFECTIVE_MODEL); final List<DeclaredStatement<?>> rootStatements = new ArrayList<>(sources.size()); final List<EffectiveStatement<?, ?>> rootEffectiveStatements = new ArrayList<>(sources.size()); try { for (final SourceSpecificContext source : sources) { final RootStatementContext<?, ?, ?> root = source.getRoot(); try { rootStatements.add(root.buildDeclared()); rootEffectiveStatements.add(root.buildEffective()); } catch (final RuntimeException ex) { throw propagateException(source, ex); } } } finally { RecursiveObjectLeaker.cleanup(); } sealMutableStatements(); return EffectiveSchemaContext.create(rootStatements, rootEffectiveStatements); }
final SourceIdentifier sourceId = StmtContextUtils.createSourceIdentifier(failedSource.getRoot()); buildFailure = new SomeModifiersUnresolvedException(currentPhase, sourceId, sourceEx); } else {