Search in sources :

Example 6 with SignatureHelpConfiguration

use of org.eclipse.xtext.testing.SignatureHelpConfiguration in project xtext-core by eclipse.

the class SignatureHelpTest method afterOperationCall.

@Test
public void afterOperationCall() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("foo(1, 2)");
    final String testMe = _builder.toString();
    final Procedure1<SignatureHelpConfiguration> _function = (SignatureHelpConfiguration it) -> {
        it.setModel(this.getModel(testMe));
        it.setLine(SignatureHelpTest.LINE_NUMBER);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("foo(1, 2)");
        it.setColumn(_builder_1.length());
        it.setExpectedSignatureHelp("<empty>");
    };
    this.testSignatureHelp(_function);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) SignatureHelpConfiguration(org.eclipse.xtext.testing.SignatureHelpConfiguration) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 7 with SignatureHelpConfiguration

use of org.eclipse.xtext.testing.SignatureHelpConfiguration in project xtext-core by eclipse.

the class AbstractLanguageServerTest method testSignatureHelp.

protected void testSignatureHelp(final Procedure1<? super SignatureHelpConfiguration> configurator) {
    try {
        @Extension final SignatureHelpConfiguration configuration = new SignatureHelpConfiguration();
        configuration.setFilePath(("MyModel." + this.fileExtension));
        configurator.apply(configuration);
        final String fileUri = this.initializeContext(configuration).getUri();
        TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams();
        final Procedure1<TextDocumentPositionParams> _function = (TextDocumentPositionParams it) -> {
            TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileUri);
            it.setTextDocument(_textDocumentIdentifier);
            int _line = configuration.getLine();
            int _column = configuration.getColumn();
            Position _position = new Position(_line, _column);
            it.setPosition(_position);
        };
        TextDocumentPositionParams _doubleArrow = ObjectExtensions.<TextDocumentPositionParams>operator_doubleArrow(_textDocumentPositionParams, _function);
        final CompletableFuture<SignatureHelp> signatureHelpFuture = this.languageServer.signatureHelp(_doubleArrow);
        final SignatureHelp signatureHelp = signatureHelpFuture.get();
        Procedure1<? super SignatureHelp> _assertSignatureHelp = configuration.getAssertSignatureHelp();
        boolean _tripleNotEquals = (_assertSignatureHelp != null);
        if (_tripleNotEquals) {
            configuration.getAssertSignatureHelp().apply(signatureHelp);
        } else {
            final String actualSignatureHelp = this.toExpectation(signatureHelp);
            this.assertEquals(configuration.getExpectedSignatureHelp().trim(), actualSignatureHelp.trim());
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Extension(org.eclipse.xtext.xbase.lib.Extension) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) SignatureHelpConfiguration(org.eclipse.xtext.testing.SignatureHelpConfiguration) SignatureHelp(org.eclipse.lsp4j.SignatureHelp) TextDocumentPositionParams(org.eclipse.lsp4j.TextDocumentPositionParams)

Example 8 with SignatureHelpConfiguration

use of org.eclipse.xtext.testing.SignatureHelpConfiguration in project xtext-core by eclipse.

the class SignatureHelpTest method multipleArgsWithLeadingWhitespaceBeforeFirstArg_ExpectFirstArg.

@Test
public void multipleArgsWithLeadingWhitespaceBeforeFirstArg_ExpectFirstArg() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("foo(    1, 2)");
    final String testMe = _builder.toString();
    final Procedure1<SignatureHelpConfiguration> _function = (SignatureHelpConfiguration it) -> {
        it.setModel(this.getModel(testMe));
        it.setLine(SignatureHelpTest.LINE_NUMBER);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("foo(    1");
        it.setColumn(_builder_1.length());
        it.setExpectedSignatureHelp("B.foo(a: A, b: B): int | C.foo(a: A, b: B, c: C): void | a: A");
    };
    this.testSignatureHelp(_function);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) SignatureHelpConfiguration(org.eclipse.xtext.testing.SignatureHelpConfiguration) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 9 with SignatureHelpConfiguration

use of org.eclipse.xtext.testing.SignatureHelpConfiguration in project xtext-core by eclipse.

the class SignatureHelpTest method singleArgWithTrailingWhitespace.

@Test
public void singleArgWithTrailingWhitespace() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("foo(1    )");
    final String testMe = _builder.toString();
    final Procedure1<SignatureHelpConfiguration> _function = (SignatureHelpConfiguration it) -> {
        it.setModel(this.getModel(testMe));
        it.setLine(SignatureHelpTest.LINE_NUMBER);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("foo(1    ");
        it.setColumn(_builder_1.length());
        it.setExpectedSignatureHelp("A.foo(a: A): string | B.foo(a: A, b: B): int | C.foo(a: A, b: B, c: C): void | a: A");
    };
    this.testSignatureHelp(_function);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) SignatureHelpConfiguration(org.eclipse.xtext.testing.SignatureHelpConfiguration) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Example 10 with SignatureHelpConfiguration

use of org.eclipse.xtext.testing.SignatureHelpConfiguration in project xtext-core by eclipse.

the class SignatureHelpTest method multipleArgsAtCommaIncomplete.

@Test
public void multipleArgsAtCommaIncomplete() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("foo(1, 2,)");
    final String testMe = _builder.toString();
    final Procedure1<SignatureHelpConfiguration> _function = (SignatureHelpConfiguration it) -> {
        it.setModel(this.getModel(testMe));
        it.setLine(SignatureHelpTest.LINE_NUMBER);
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("foo(1, 2,");
        it.setColumn(_builder_1.length());
        it.setExpectedSignatureHelp("C.foo(a: A, b: B, c: C): void | c: C");
    };
    this.testSignatureHelp(_function);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) SignatureHelpConfiguration(org.eclipse.xtext.testing.SignatureHelpConfiguration) Test(org.junit.Test) AbstractTestLangLanguageServerTest(org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)

Aggregations

SignatureHelpConfiguration (org.eclipse.xtext.testing.SignatureHelpConfiguration)16 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)15 AbstractTestLangLanguageServerTest (org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest)15 Test (org.junit.Test)15 Position (org.eclipse.lsp4j.Position)1 SignatureHelp (org.eclipse.lsp4j.SignatureHelp)1 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)1 TextDocumentPositionParams (org.eclipse.lsp4j.TextDocumentPositionParams)1 Extension (org.eclipse.xtext.xbase.lib.Extension)1