Search in sources :

Example 51 with AutocompleteResult

use of com.twosigma.beakerx.autocomplete.AutocompleteResult in project beakerx by twosigma.

the class CompleteHandler method handleMsg.

private void handleMsg(Message message) {
    String code = ((String) message.getContent().get(CODE));
    int cursorPos = ((int) message.getContent().get(CURSOR_POS));
    AutocompleteResult autocomplete = kernel.autocomplete(code, cursorPos);
    Message reply = createMsg(message, cursorPos, autocomplete);
    send(reply);
}
Also used : Message(com.twosigma.beakerx.message.Message) AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult)

Example 52 with AutocompleteResult

use of com.twosigma.beakerx.autocomplete.AutocompleteResult in project beakerx by twosigma.

the class SQLAutocompleteTest method shouldAutocompleteToPercentPercentbeakerD.

@Test
public void shouldAutocompleteToPercentPercentbeakerD() throws Exception {
    // given
    givenColorTable();
    // when
    String code = "%%beakerD";
    AutocompleteResult autocomplete = sqlEvaluator.autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(0);
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 53 with AutocompleteResult

use of com.twosigma.beakerx.autocomplete.AutocompleteResult in project beakerx by twosigma.

the class SQLAutocompleteTest method shouldAutocompleteAfterSpace.

@Test
public void shouldAutocompleteAfterSpace() throws Exception {
    // given
    givenColorTable();
    // when
    String code = "%%beakerDB ";
    AutocompleteResult autocomplete = sqlEvaluator.autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(code.length());
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 54 with AutocompleteResult

use of com.twosigma.beakerx.autocomplete.AutocompleteResult in project beakerx by twosigma.

the class JavaEvaluatorAutocompleteTest method autocompleteForJavaAwtPackage.

@Test
public void autocompleteForJavaAwtPackage() throws Exception {
    String code = "java.aw";
    // when
    AutocompleteResult autocomplete = evaluator().autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(code.length() - 2);
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Test(org.junit.Test)

Example 55 with AutocompleteResult

use of com.twosigma.beakerx.autocomplete.AutocompleteResult in project beakerx by twosigma.

the class JavaEvaluatorAutocompleteTest method autocompleteStringMethod.

@Ignore
@Test
public void autocompleteStringMethod() throws Exception {
    String code = "String a = \"ABC\";\n" + "a.";
    // when
    AutocompleteResult autocomplete = evaluator().autocomplete(code, code.length());
    // then
    assertThat(autocomplete.getMatches()).isNotEmpty();
    assertThat(autocomplete.getStartIndex()).isEqualTo(code.length());
}
Also used : AutocompleteResult(com.twosigma.beakerx.autocomplete.AutocompleteResult) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

AutocompleteResult (com.twosigma.beakerx.autocomplete.AutocompleteResult)107 Test (org.junit.Test)102 Ignore (org.junit.Ignore)20 BaseEvaluator (com.twosigma.beakerx.evaluator.BaseEvaluator)10 Collectors (java.util.stream.Collectors)10 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)10 AfterClass (org.junit.AfterClass)10 BeforeClass (org.junit.BeforeClass)10 EvaluatorTest (com.twosigma.beakerx.evaluator.EvaluatorTest)6 KERNEL_PARAMETERS (com.twosigma.beakerx.evaluator.EvaluatorTest.KERNEL_PARAMETERS)6 EvaluatorTest.getTestTempFolderFactory (com.twosigma.beakerx.evaluator.EvaluatorTest.getTestTempFolderFactory)6 TestBeakerCellExecutor.cellExecutor (com.twosigma.beakerx.evaluator.TestBeakerCellExecutor.cellExecutor)6 JavaEvaluator (com.twosigma.beakerx.javash.evaluator.JavaEvaluator)6 KernelTest (com.twosigma.beakerx.KernelTest)4 AutocompleteCandidate (com.twosigma.beakerx.autocomplete.AutocompleteCandidate)4 TestGroovyEvaluator (com.twosigma.beakerx.groovy.TestGroovyEvaluator)4 ArrayList (java.util.ArrayList)4 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)2 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)2 Lexer (org.antlr.v4.runtime.Lexer)2