use of com.avaloq.tools.ddk.check.runtime.quickfix.ICoreQuickfixProvider in project dsl-devkit by dsldevkit.
the class DefaultCheckQuickfixProvider method collectMethods.
/**
* Gets <em>all</em> provider methods by examining the Check quickfix extension point's registered clients. Includes eventual
* "fix methods" of current class.
* <p>
* {@inheritDoc}
*/
@Override
protected Iterable<Method> collectMethods(final Class<? extends AbstractDeclarativeQuickfixProvider> clazz, final String issueCode) {
if (!issueCodeToQuickfixMethods.containsKey(issueCode)) {
// Adds this class' methods: this class potentially is a quickfix provider
Iterable<Method> result = Lists.newArrayList(clazz.getMethods());
for (final ICoreQuickfixProvider provider : getProviders()) {
result = Iterables.concat(result, methodsForProvider(provider, issueCode));
}
issueCodeToQuickfixMethods.put(issueCode, Iterables.filter(result, getFixMethodPredicate(issueCode)));
}
return issueCodeToQuickfixMethods.get(issueCode);
}
use of com.avaloq.tools.ddk.check.runtime.quickfix.ICoreQuickfixProvider in project dsl-devkit by dsldevkit.
the class DefaultCheckQuickfixProvider method getResolutions.
/**
* Invokes quickfix methods and creates IssueResolution objects. Both "native" quickfix providers and Check
* quickfix providers are considered.
* <p>
* {@inheritDoc}
*/
@Override
protected List<IssueResolution> getResolutions(final Issue issue, final List<Method> fixMethods) {
final ICoreIssueResolutionAcceptor coreIssueResolutionAcceptor = coreIssueResolutionAcceptorProvider.get();
final IssueResolutionAcceptor defaultIssueResolutionAcceptor = issueResolutionAcceptorProvider.get();
for (Method fixMethod : fixMethods) {
try {
fixMethod.setAccessible(true);
if (Lists.newArrayList(getClass().getMethods()).contains(fixMethod)) {
if (fixMethod.getAnnotation(CoreFix.class) != null) {
fixMethod.invoke(this, issue, coreIssueResolutionAcceptor);
} else {
// Legacy code: executes native quickfixes
fixMethod.invoke(this, issue, defaultIssueResolutionAcceptor);
}
} else {
// the fix method
for (final ICoreQuickfixProvider p : getProviders()) {
if (Iterables.contains(methodsForProvider(p, issue.getCode()), fixMethod)) {
fixMethod.invoke(p, issue, coreIssueResolutionAcceptor);
}
}
}
// CHECKSTYLE:OFF
} catch (Exception e) {
// CHECKSTYLE:ON
// $NON-NLS-1$
LOGGER.error("Error executing fix method", e);
}
}
final Iterable<IssueResolution> allResolutions = Iterables.concat(Lists.transform(coreIssueResolutionAcceptor.getIssueResolutions(), new Function<CoreIssueResolution, IssueResolution>() {
@Override
public IssueResolution apply(final CoreIssueResolution from) {
return new IssueResolutionWrapper(from);
}
}), defaultIssueResolutionAcceptor.getIssueResolutions());
return Lists.newArrayList(allResolutions);
}
Aggregations