Search in sources :

Example 1 with CoreIssueResolution

use of com.avaloq.tools.ddk.check.runtime.quickfix.CoreIssueResolution 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);
}
Also used : Function(com.google.common.base.Function) CoreIssueResolution(com.avaloq.tools.ddk.check.runtime.quickfix.CoreIssueResolution) ICoreIssueResolutionAcceptor(com.avaloq.tools.ddk.check.runtime.quickfix.ICoreIssueResolutionAcceptor) CoreFix(com.avaloq.tools.ddk.check.runtime.quickfix.CoreFix) ICoreQuickfixProvider(com.avaloq.tools.ddk.check.runtime.quickfix.ICoreQuickfixProvider) CoreIssueResolution(com.avaloq.tools.ddk.check.runtime.quickfix.CoreIssueResolution) IssueResolution(org.eclipse.xtext.ui.editor.quickfix.IssueResolution) Method(java.lang.reflect.Method) IssueResolutionAcceptor(org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor) ICoreIssueResolutionAcceptor(com.avaloq.tools.ddk.check.runtime.quickfix.ICoreIssueResolutionAcceptor)

Example 2 with CoreIssueResolution

use of com.avaloq.tools.ddk.check.runtime.quickfix.CoreIssueResolution in project dsl-devkit by dsldevkit.

the class CoreIssueResolutionAcceptor method accept.

public void accept(final Issue issue, final String label, final String description, final String image, final ICoreSemanticModification semanticModification) {
    CoreSemanticModificationWrapper modificationWrapper = new CoreSemanticModificationWrapper(issue.getUriToProblem(), semanticModification);
    issueResolutions.add(new CoreIssueResolution(label, description, image, modificationContextFactory.createModificationContext(issue), modificationWrapper));
}
Also used : CoreIssueResolution(com.avaloq.tools.ddk.check.runtime.quickfix.CoreIssueResolution) CoreSemanticModificationWrapper(com.avaloq.tools.ddk.check.runtime.quickfix.CoreSemanticModificationWrapper)

Aggregations

CoreIssueResolution (com.avaloq.tools.ddk.check.runtime.quickfix.CoreIssueResolution)2 CoreFix (com.avaloq.tools.ddk.check.runtime.quickfix.CoreFix)1 CoreSemanticModificationWrapper (com.avaloq.tools.ddk.check.runtime.quickfix.CoreSemanticModificationWrapper)1 ICoreIssueResolutionAcceptor (com.avaloq.tools.ddk.check.runtime.quickfix.ICoreIssueResolutionAcceptor)1 ICoreQuickfixProvider (com.avaloq.tools.ddk.check.runtime.quickfix.ICoreQuickfixProvider)1 Function (com.google.common.base.Function)1 Method (java.lang.reflect.Method)1 IssueResolution (org.eclipse.xtext.ui.editor.quickfix.IssueResolution)1 IssueResolutionAcceptor (org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor)1