Search in sources :

Example 1 with AbstractDeclarativeQuickfixProvider

use of org.eclipse.xtext.ui.editor.quickfix.AbstractDeclarativeQuickfixProvider in project xtext-eclipse by eclipse.

the class DeclarativeQuickfixProviderTest method testHasResolutions.

@Test
public void testHasResolutions() throws Exception {
    abstract class __DeclarativeQuickfixProviderTest_1 extends AbstractDeclarativeQuickfixProvider {

        public abstract void signature(final Issue i, final IssueResolutionAcceptor acceptor);
    }
    AbstractDeclarativeQuickfixProvider provider = new __DeclarativeQuickfixProviderTest_1() {

        @Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE)
        public void signature(final Issue i, final IssueResolutionAcceptor acceptor) {
        }
    };
    Assert.assertFalse(provider.hasResolutionFor((DeclarativeQuickfixProviderTest.DUMMY_CODE + Integer.valueOf(1))));
    Assert.assertTrue(provider.hasResolutionFor(DeclarativeQuickfixProviderTest.DUMMY_CODE));
}
Also used : AbstractDeclarativeQuickfixProvider(org.eclipse.xtext.ui.editor.quickfix.AbstractDeclarativeQuickfixProvider) Issue(org.eclipse.xtext.validation.Issue) IssueResolutionAcceptor(org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor) Test(org.junit.Test)

Example 2 with AbstractDeclarativeQuickfixProvider

use of org.eclipse.xtext.ui.editor.quickfix.AbstractDeclarativeQuickfixProvider in project xtext-eclipse by eclipse.

the class DeclarativeQuickfixProviderTest method testHasResolutions2.

@Test
public void testHasResolutions2() throws Exception {
    abstract class __DeclarativeQuickfixProviderTest_2 extends AbstractDeclarativeQuickfixProvider {

        public abstract void signature(final Issue i, final IssueResolutionAcceptor acceptor);
    }
    AbstractDeclarativeQuickfixProvider provider = new __DeclarativeQuickfixProviderTest_2() {

        @Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE)
        @Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE2)
        public void signature(final Issue i, final IssueResolutionAcceptor acceptor) {
        }
    };
    Assert.assertFalse(provider.hasResolutionFor((DeclarativeQuickfixProviderTest.DUMMY_CODE + Integer.valueOf(1))));
    Assert.assertTrue(provider.hasResolutionFor(DeclarativeQuickfixProviderTest.DUMMY_CODE));
    Assert.assertTrue(provider.hasResolutionFor(DeclarativeQuickfixProviderTest.DUMMY_CODE2));
}
Also used : AbstractDeclarativeQuickfixProvider(org.eclipse.xtext.ui.editor.quickfix.AbstractDeclarativeQuickfixProvider) Issue(org.eclipse.xtext.validation.Issue) IssueResolutionAcceptor(org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor) Test(org.junit.Test)

Example 3 with AbstractDeclarativeQuickfixProvider

use of org.eclipse.xtext.ui.editor.quickfix.AbstractDeclarativeQuickfixProvider in project xtext-eclipse by eclipse.

the class DeclarativeQuickfixProviderTest method testHasResolutions3.

@Test
public void testHasResolutions3() throws Exception {
    abstract class __DeclarativeQuickfixProviderTest_3 extends AbstractDeclarativeQuickfixProvider {

        public abstract void signature(final Issue i, final IssueResolutionAcceptor acceptor);
    }
    AbstractDeclarativeQuickfixProvider provider = new __DeclarativeQuickfixProviderTest_3() {

        @Fixes({ @Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE), @Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE2) })
        public void signature(final Issue i, final IssueResolutionAcceptor acceptor) {
        }
    };
    Assert.assertFalse(provider.hasResolutionFor((DeclarativeQuickfixProviderTest.DUMMY_CODE + Integer.valueOf(1))));
    Assert.assertTrue(provider.hasResolutionFor(DeclarativeQuickfixProviderTest.DUMMY_CODE));
    Assert.assertTrue(provider.hasResolutionFor(DeclarativeQuickfixProviderTest.DUMMY_CODE2));
}
Also used : AbstractDeclarativeQuickfixProvider(org.eclipse.xtext.ui.editor.quickfix.AbstractDeclarativeQuickfixProvider) Issue(org.eclipse.xtext.validation.Issue) IssueResolutionAcceptor(org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor) Test(org.junit.Test)

Example 4 with AbstractDeclarativeQuickfixProvider

use of org.eclipse.xtext.ui.editor.quickfix.AbstractDeclarativeQuickfixProvider in project xtext-eclipse by eclipse.

the class DeclarativeQuickfixProviderTest method testGetResolutions.

@Test
public void testGetResolutions() throws Exception {
    abstract class __DeclarativeQuickfixProviderTest_4 extends AbstractDeclarativeQuickfixProvider {

        public abstract void fixError1(final Issue i, final IssueResolutionAcceptor acceptor);

        public abstract void fixError2(final Issue i, final IssueResolutionAcceptor acceptor);
    }
    AbstractDeclarativeQuickfixProvider provider = new __DeclarativeQuickfixProviderTest_4() {

        @Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE)
        public void fixError1(final Issue i, final IssueResolutionAcceptor acceptor) {
            acceptor.accept(i, "fixError1", "", "", IModification.NULL);
        }

        @Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE)
        public void fixError2(final Issue i, final IssueResolutionAcceptor acceptor) {
            acceptor.accept(i, "fixError2", "", "", IModification.NULL);
        }
    };
    final Provider<IssueResolutionAcceptor> _function = () -> {
        final IssueModificationContext.Factory _function_1 = (Issue it) -> {
            return null;
        };
        return new IssueResolutionAcceptor(_function_1);
    };
    provider.setIssueResolutionAcceptorProvider(_function);
    List<IssueResolution> resolutionsIterable = provider.getResolutions(this.createIssue((DeclarativeQuickfixProviderTest.DUMMY_CODE + Integer.valueOf(1))));
    Assert.assertNull(IterableExtensions.<IssueResolution>head(resolutionsIterable));
    List<IssueResolution> resolutions = provider.getResolutions(this.createIssue(DeclarativeQuickfixProviderTest.DUMMY_CODE));
    Assert.assertEquals(2, resolutions.size());
    final Function1<IssueResolution, Boolean> _function_1 = (IssueResolution it) -> {
        String _label = it.getLabel();
        return Boolean.valueOf(Objects.equal(_label, "fixError1"));
    };
    Assert.assertTrue(IterableExtensions.<IssueResolution>exists(resolutions, _function_1));
    final Function1<IssueResolution, Boolean> _function_2 = (IssueResolution it) -> {
        String _label = it.getLabel();
        return Boolean.valueOf(Objects.equal(_label, "fixError2"));
    };
    Assert.assertTrue(IterableExtensions.<IssueResolution>exists(resolutions, _function_2));
}
Also used : AbstractDeclarativeQuickfixProvider(org.eclipse.xtext.ui.editor.quickfix.AbstractDeclarativeQuickfixProvider) Issue(org.eclipse.xtext.validation.Issue) IssueResolution(org.eclipse.xtext.ui.editor.quickfix.IssueResolution) IssueResolutionAcceptor(org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor) Test(org.junit.Test)

Example 5 with AbstractDeclarativeQuickfixProvider

use of org.eclipse.xtext.ui.editor.quickfix.AbstractDeclarativeQuickfixProvider in project xtext-eclipse by eclipse.

the class DeclarativeQuickfixProviderTest method testGetResolutions2.

@Test
public void testGetResolutions2() throws Exception {
    abstract class __DeclarativeQuickfixProviderTest_5 extends AbstractDeclarativeQuickfixProvider {

        public abstract void fixError1(final Issue i, final IssueResolutionAcceptor acceptor);

        public abstract void fixError2(final Issue i, final IssueResolutionAcceptor acceptor);

        public abstract void fixError3(final Issue i, final IssueResolutionAcceptor acceptor);
    }
    AbstractDeclarativeQuickfixProvider provider = new __DeclarativeQuickfixProviderTest_5() {

        @Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE)
        @Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE2)
        public void fixError1(final Issue i, final IssueResolutionAcceptor acceptor) {
            acceptor.accept(i, "fixError1", "", "", IModification.NULL);
        }

        @Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE)
        public void fixError2(final Issue i, final IssueResolutionAcceptor acceptor) {
            acceptor.accept(i, "fixError2", "", "", IModification.NULL);
        }

        @Fixes({ @Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE), @Fix(DeclarativeQuickfixProviderTest.DUMMY_CODE2) })
        public void fixError3(final Issue i, final IssueResolutionAcceptor acceptor) {
            acceptor.accept(i, "fixError3", "", "", IModification.NULL);
        }
    };
    final Provider<IssueResolutionAcceptor> _function = () -> {
        final IssueModificationContext.Factory _function_1 = (Issue it) -> {
            return null;
        };
        return new IssueResolutionAcceptor(_function_1);
    };
    provider.setIssueResolutionAcceptorProvider(_function);
    List<IssueResolution> resolutionsIterable = provider.getResolutions(this.createIssue((DeclarativeQuickfixProviderTest.DUMMY_CODE + Integer.valueOf(1))));
    Assert.assertNull(IterableExtensions.<IssueResolution>head(resolutionsIterable));
    List<IssueResolution> resolutions = provider.getResolutions(this.createIssue(DeclarativeQuickfixProviderTest.DUMMY_CODE));
    Assert.assertEquals(3, resolutions.size());
    final Function1<IssueResolution, Boolean> _function_1 = (IssueResolution it) -> {
        String _label = it.getLabel();
        return Boolean.valueOf(Objects.equal(_label, "fixError1"));
    };
    Assert.assertTrue(IterableExtensions.<IssueResolution>exists(resolutions, _function_1));
    final Function1<IssueResolution, Boolean> _function_2 = (IssueResolution it) -> {
        String _label = it.getLabel();
        return Boolean.valueOf(Objects.equal(_label, "fixError2"));
    };
    Assert.assertTrue(IterableExtensions.<IssueResolution>exists(resolutions, _function_2));
    final Function1<IssueResolution, Boolean> _function_3 = (IssueResolution it) -> {
        String _label = it.getLabel();
        return Boolean.valueOf(Objects.equal(_label, "fixError3"));
    };
    Assert.assertTrue(IterableExtensions.<IssueResolution>exists(resolutions, _function_3));
    List<IssueResolution> resolutions2 = provider.getResolutions(this.createIssue(DeclarativeQuickfixProviderTest.DUMMY_CODE2));
    Assert.assertEquals(2, resolutions2.size());
    final Function1<IssueResolution, Boolean> _function_4 = (IssueResolution it) -> {
        String _label = it.getLabel();
        return Boolean.valueOf(Objects.equal(_label, "fixError2"));
    };
    Assert.assertTrue(IterableExtensions.<IssueResolution>exists(resolutions, _function_4));
    final Function1<IssueResolution, Boolean> _function_5 = (IssueResolution it) -> {
        String _label = it.getLabel();
        return Boolean.valueOf(Objects.equal(_label, "fixError3"));
    };
    Assert.assertTrue(IterableExtensions.<IssueResolution>exists(resolutions, _function_5));
}
Also used : AbstractDeclarativeQuickfixProvider(org.eclipse.xtext.ui.editor.quickfix.AbstractDeclarativeQuickfixProvider) Issue(org.eclipse.xtext.validation.Issue) IssueResolution(org.eclipse.xtext.ui.editor.quickfix.IssueResolution) IssueResolutionAcceptor(org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor) Test(org.junit.Test)

Aggregations

AbstractDeclarativeQuickfixProvider (org.eclipse.xtext.ui.editor.quickfix.AbstractDeclarativeQuickfixProvider)5 IssueResolutionAcceptor (org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor)5 Issue (org.eclipse.xtext.validation.Issue)5 Test (org.junit.Test)5 IssueResolution (org.eclipse.xtext.ui.editor.quickfix.IssueResolution)2