use of org.revapi.configuration.Configurable in project revapi by revapi.
the class ConvertToXmlConfigMojo method getKnownExtensionSchemas.
private static Map<String, ModelNode> getKnownExtensionSchemas(AnalysisResult.Extensions extensions) throws IOException {
List<Configurable> exts = extensions.stream().map(e -> (Configurable) e.getKey()).collect(Collectors.toList());
Map<String, ModelNode> extensionSchemas = new HashMap<>();
for (Configurable ext : exts) {
String extensionId = ext.getExtensionId();
if (extensionId == null || extensionSchemas.containsKey(extensionId)) {
continue;
}
try (Reader schemaRdr = ext.getJSONSchema()) {
if (schemaRdr == null) {
continue;
}
ModelNode schema = ModelNode.fromJSONString(readFull(schemaRdr));
extensionSchemas.put(extensionId, schema);
}
}
return extensionSchemas;
}
use of org.revapi.configuration.Configurable in project revapi by revapi.
the class Revapi method validate.
private ValidationResult validate(@Nonnull AnalysisContext analysisContext, ValidationResult validationResult, Iterator<? extends Configurable> configurables) {
while (configurables.hasNext()) {
Configurable c = configurables.next();
ValidationResult partial = configurationValidator.validate(analysisContext.getConfiguration(), c);
validationResult = validationResult.merge(partial);
}
return validationResult;
}
use of org.revapi.configuration.Configurable in project revapi by revapi.
the class Revapi method analyze.
/**
* Performs the analysis configured by the given analysis context.
* <p>
* Make sure to call the {@link AnalysisResult#close()} method (or perform the analysis in try-with-resources
* block).
*
* @param analysisContext describes the analysis to be performed
* @return a result object that has to be closed for the analysis to conclude
*/
@SuppressWarnings("unchecked")
public AnalysisResult analyze(@Nonnull AnalysisContext analysisContext) {
TIMING_LOG.debug("Analysis starts");
AnalysisResult.Extensions extensions = prepareAnalysis(analysisContext);
StreamSupport.stream(extensions.spliterator(), false).map(e -> (Map.Entry<Configurable, AnalysisContext>) e).forEach(e -> e.getKey().initialize(e.getValue()));
TIMING_LOG.debug("Initialization complete.");
matchingTransformsCache.clear();
Exception error = null;
try {
for (ApiAnalyzer a : extensions.getAnalyzers().keySet()) {
analyzeWith(a, analysisContext.getOldApi(), analysisContext.getNewApi(), extensions);
}
} catch (Exception t) {
error = t;
}
return new AnalysisResult(error, extensions);
}
Aggregations