use of org.revapi.AnalysisContext in project revapi by revapi.
the class JavaApiAnalyzer method initialize.
@Override
public void initialize(@Nonnull AnalysisContext analysisContext) {
this.analysisContext = analysisContext;
this.configuration = AnalysisConfiguration.fromModel(analysisContext.getConfiguration());
for (Check c : checks) {
if (c.getExtensionId() != null) {
ModelNode checkConfig = analysisContext.getConfiguration().get("checks", c.getExtensionId());
AnalysisContext checkCtx = analysisContext.copyWithConfiguration(checkConfig);
c.initialize(checkCtx);
}
}
}
use of org.revapi.AnalysisContext in project revapi by revapi.
the class RevapiTask method initAnalysisContext.
private AnalysisContext initAnalysisContext(Revapi revapi) {
API oldApi = API.of(FileArchive.from(oldArchives)).addSupportArchives(FileArchive.from(oldSupplementaryArchives)).build();
API newApi = API.of(FileArchive.from(newArchives)).addSupportArchives(FileArchive.from(newSupplementaryArchives)).build();
AnalysisContext.Builder builder = AnalysisContext.builder(revapi).withOldAPI(oldApi).withNewAPI(newApi).withLocale(Locale.getDefault());
if (configuration != null) {
builder.withConfigurationFromJSON(configuration);
}
builder.withData(AntReporter.ANT_REPORTER_LOGGER_KEY, this);
builder.withData(AntReporter.MIN_SEVERITY_KEY, FailSeverity.valueOf(breakingSeverity).asDifferenceSeverity());
return builder.build();
}
use of org.revapi.AnalysisContext in project revapi by revapi.
the class SemverIgnoreTransformTest method getTestTransform.
private DifferenceTransform<Element> getTestTransform(String oldVersion, String newVersion, String configuration) {
API oldApi = oldVersion != null ? API.of(new Ar(oldVersion)).build() : API.of().build();
API newApi = newVersion != null ? API.of(new Ar(newVersion)).build() : API.of().build();
AnalysisContext ctx = Util.setAnalysisContextFullConfig(AnalysisContext.builder().withOldAPI(oldApi).withNewAPI(newApi), SemverIgnoreTransform.class, configuration);
SemverIgnoreTransform tr = new SemverIgnoreTransform();
tr.initialize(ctx);
return tr;
}
use of org.revapi.AnalysisContext in project revapi by revapi.
the class IgnoreDifferenceTransformTest method testAttachmentMatch.
@Test
public void testAttachmentMatch() throws Exception {
DummyElement oldE = new DummyElement("a");
DummyElement newE = new DummyElement("b");
Difference difference = Difference.builder().withCode("c").addAttachment("kachna", "nedobra").build();
Difference anotherDiff = Difference.builder().withCode("d").build();
Difference matchingDiff = Difference.builder().withCode("c").addAttachment("kachna", "dobra").build();
try (IgnoreDifferenceTransform t = new IgnoreDifferenceTransform()) {
AnalysisContext config = getAnalysisContextFromFullConfig(IgnoreDifferenceTransform.class, "[{\"extension\": \"revapi.ignore\", \"configuration\": [{\"code\":\"c\", \"kachna\": \"dobra\", \"justification\" : \"because\"}]}]");
t.initialize(config);
difference = t.transform(oldE, newE, difference);
Assert.assertNotNull(difference);
anotherDiff = t.transform(oldE, newE, anotherDiff);
Assert.assertNotNull(anotherDiff);
matchingDiff = t.transform(oldE, newE, matchingDiff);
Assert.assertNull(matchingDiff);
}
}
use of org.revapi.AnalysisContext in project revapi by revapi.
the class IgnoreDifferenceTransformTest method testSimpleTextMatch.
@Test
public void testSimpleTextMatch() throws Exception {
DummyElement oldE = new DummyElement("a");
DummyElement newE = new DummyElement("b");
Difference difference = Difference.builder().withCode("c").build();
try (IgnoreDifferenceTransform t = new IgnoreDifferenceTransform()) {
AnalysisContext config = getAnalysisContextFromFullConfig(IgnoreDifferenceTransform.class, "[{\"extension\": \"revapi.ignore\", \"configuration\": [{\"code\":\"c\", \"justification\" : \"because\"}]}]");
t.initialize(config);
difference = t.transform(oldE, newE, difference);
Assert.assertNull(difference);
}
}
Aggregations