use of com.avaloq.tools.ddk.check.runtime.quickfix.CoreFix in project dsl-devkit by dsldevkit.
the class DefaultCheckQuickfixProvider method getFixMethodPredicate.
/**
* Returns a method predicate indicating whether a given method is an executable quickfix method. Both Check
* quickfix methods and native quickfix methods are considered.
*
* @param issueCode
* the issue code
* @return the fix method predicate
* @see com.avaloq.tools.ddk.check.runtime.quickfix.CoreFix CoreFix annotation
* @see org.eclipse.xtext.ui.editor.quickfix.Fix Fix annotation
*/
@Override
protected Predicate<Method> getFixMethodPredicate(final String issueCode) {
return new Predicate<Method>() {
@Override
public boolean apply(final Method input) {
CoreFix coreFixAnnotation = input.getAnnotation(CoreFix.class);
Fix fixAnnotation = input.getAnnotation(Fix.class);
if (coreFixAnnotation == null && fixAnnotation == null) {
// Definitely no candidate
return false;
}
final boolean typesMatch = Void.TYPE == input.getReturnType() && input.getParameterTypes().length == 2 && input.getParameterTypes()[0].isAssignableFrom(Issue.class);
boolean result;
if (coreFixAnnotation != null) {
result = coreFixAnnotation != null && issueCode.equals(coreFixAnnotation.value()) && typesMatch && input.getParameterTypes()[1].isAssignableFrom(CoreIssueResolutionAcceptor.class);
} else {
result = fixAnnotation != null && issueCode.equals(fixAnnotation.value()) && typesMatch && input.getParameterTypes()[1].isAssignableFrom(IssueResolutionAcceptor.class);
}
return result;
}
};
}