Search in sources :

Example 6 with ContentAssistProcessorTestBuilder

use of org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder in project xtext-xtend by eclipse.

the class Bug461923Test method test_04.

@Test
public void test_04() throws Exception {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.append("import com.google.common.collect.ImmutableList");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def static m(List<? extends String> list, String value) {");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("ImmutableList.builder.addAll(list.<|>filter[it != value]).build");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _newBuilder.append(_builder.toString()).assertProposalAtCursor("filter[]");
}
Also used : ContentAssistProcessorTestBuilder(org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractXtendContentAssistBugTest(org.eclipse.xtend.ide.tests.contentassist.AbstractXtendContentAssistBugTest) Test(org.junit.Test)

Example 7 with ContentAssistProcessorTestBuilder

use of org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder in project xtext-xtend by eclipse.

the class Bug461923Test method test_07.

@Test
public void test_07() throws Exception {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.append("import com.google.common.collect.ImmutableList");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def static <T> m(T[] arr, T value) {");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("ImmutableList.builder.addAll(arr.<|>filter[it != value]).build");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _newBuilder.append(_builder.toString()).assertProposalAtCursor("filter[]");
}
Also used : ContentAssistProcessorTestBuilder(org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractXtendContentAssistBugTest(org.eclipse.xtend.ide.tests.contentassist.AbstractXtendContentAssistBugTest) Test(org.junit.Test)

Example 8 with ContentAssistProcessorTestBuilder

use of org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder in project xtext-xtend by eclipse.

the class Bug461923Test method test_03.

@Test
public void test_03() throws Exception {
    ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.append("import com.google.common.collect.ImmutableList");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("def static <T> m(List<? super T> list, T value) {");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("ImmutableList.builder.addAll(list.<|>filter[it != value]).build");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _newBuilder.append(_builder.toString()).assertProposalAtCursor("filter[]");
}
Also used : ContentAssistProcessorTestBuilder(org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractXtendContentAssistBugTest(org.eclipse.xtend.ide.tests.contentassist.AbstractXtendContentAssistBugTest) Test(org.junit.Test)

Example 9 with ContentAssistProcessorTestBuilder

use of org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder in project xtext-xtend by eclipse.

the class Bug462915Test method testAdditionalProposalInfoWorks.

/**
 * make sure additional proposal infos can be calculated
 */
@Test
public void testAdditionalProposalInfoWorks() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class A {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("test");
        _builder.newLine();
        _builder.append("}");
        final String model = _builder.toString();
        ContentAssistProcessorTestBuilder _append = this.newBuilder().append(model);
        int _indexOf = model.indexOf("test");
        int _plus = (_indexOf + 4);
        final ICompletionProposal[] proposals = _append.computeCompletionProposals(_plus);
        Assert.assertEquals("More than one proposal found", 1, ((List<ICompletionProposal>) Conversions.doWrapArray(proposals)).size());
        final ICompletionProposal proposal = IterableExtensions.<ICompletionProposal>head(((Iterable<ICompletionProposal>) Conversions.doWrapArray(proposals)));
        Assert.assertEquals("test - JUnit test method", proposal.getDisplayString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("@Test");
        _builder_1.newLine();
        _builder_1.append("def void testName() {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.newLine();
        _builder_1.append("}");
        Assert.assertEquals(_builder_1.toString(), proposal.getAdditionalProposalInfo());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : ContentAssistProcessorTestBuilder(org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractXtendContentAssistBugTest(org.eclipse.xtend.ide.tests.contentassist.AbstractXtendContentAssistBugTest) Test(org.junit.Test)

Example 10 with ContentAssistProcessorTestBuilder

use of org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder in project xtext-xtend by eclipse.

the class JavaDocContentAssistTest method testTypeInJavaDoc.

@Test
public void testTypeInJavaDoc() {
    try {
        ContentAssistProcessorTestBuilder _newBuilder = this.newBuilder();
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package foo");
        _builder.newLine();
        _builder.append("/**");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("* @see java.util.Dat");
        _builder.newLine();
        _builder.append(" ");
        _builder.append("*/");
        _builder.newLine();
        _builder.append("class Foo {}");
        _builder.newLine();
        ContentAssistProcessorTestBuilder _applyProposal = _newBuilder.append(_builder.toString()).assertTextAtCursorPosition(37, "java.util.Date").applyProposal(37);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("package foo");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("import java.util.Date");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("/**");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("* @see Date");
        _builder_1.newLine();
        _builder_1.append(" ");
        _builder_1.append("*/");
        _builder_1.newLine();
        _builder_1.append("class Foo {}");
        _builder_1.newLine();
        _applyProposal.expectContent(_builder_1.toString());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : ContentAssistProcessorTestBuilder(org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractXtendContentAssistBugTest(org.eclipse.xtend.ide.tests.contentassist.AbstractXtendContentAssistBugTest) Test(org.junit.Test)

Aggregations

ContentAssistProcessorTestBuilder (org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder)185 Test (org.junit.Test)184 AbstractXtendContentAssistBugTest (org.eclipse.xtend.ide.tests.contentassist.AbstractXtendContentAssistBugTest)183 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)182 Flaky (org.eclipse.xtext.testing.Flaky)13 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)4 List (java.util.List)1