Package com.google.collide.client.code.autocomplete

Examples of com.google.collide.client.code.autocomplete.MockAutocompleterEnvironment


    checkHasProposals(text2, 21, true, "after multiline");
  }

  private void checkHasProposals(String text, int column,
      boolean expectHasProposals, String message) {
    MockAutocompleterEnvironment helper = new MockAutocompleterEnvironment();

    helper.setup(new PathUtil("foo.js"), text, 0, column, true);
    AutocompleteProposals proposals = helper.autocompleter.jsAutocompleter.findAutocompletions(
        helper.editor.getSelection(), CTRL_SPACE);
    assertEquals(message, expectHasProposals, !proposals.isEmpty());
  }
View Full Code Here


        helper.editor.getSelection(), CTRL_SPACE);
    assertEquals(message, expectHasProposals, !proposals.isEmpty());
  }

  public void testNoTemplateProposalsAfterThis() {
    MockAutocompleterEnvironment helper = new MockAutocompleterEnvironment();

    helper.setup(new PathUtil("foo.js"), "this.", 0, 5, true);
    AutocompleteProposals proposals = helper.autocompleter.jsAutocompleter.findAutocompletions(
        helper.editor.getSelection(), CTRL_SPACE);
    assertTrue("has no proposals", proposals.isEmpty());
  }
View Full Code Here

        helper.editor.getSelection(), CTRL_SPACE);
    assertTrue("has no proposals", proposals.isEmpty());
  }

  public void testTemplateProposalsInGlobal() {
    MockAutocompleterEnvironment helper = new MockAutocompleterEnvironment();

    helper.setup(new PathUtil("foo.js"), "", 0, 0, true);
    AutocompleteProposals autocompletions =
        helper.autocompleter.jsAutocompleter.findAutocompletions(
            helper.editor.getSelection(), CTRL_SPACE);
    assertFalse("has proposals", autocompletions.isEmpty());
    ProposalWithContext whileProposal = TestUtils.selectProposalByName(autocompletions, "while");
View Full Code Here

    helper.autocompleter.reallyFinishAutocompletion(whileProposal);
    assertEquals("while () {\n  \n}", helper.editor.getDocument().asText());
  }

  public void testAutocompletionAfterKeyword() {
    MockAutocompleterEnvironment helper = new MockAutocompleterEnvironment();

    helper.setup(new PathUtil("foo.js"), "for", 0, 3, true);
    AutocompleteProposals autocompletions =
        helper.autocompleter.jsAutocompleter.findAutocompletions(
            helper.editor.getSelection(), CTRL_SPACE);
    ProposalWithContext proposal = autocompletions.select(0);
    assertEquals("proposal name", "for", proposal.getItem().getName());
View Full Code Here

    for (int i = 0; i < 12; i++) {
      longLine = longLine + longLine;
    }
    // longLine length is 4096

    MockAutocompleterEnvironment helper = new MockAutocompleterEnvironment();
    String text = "function foo() {\n"
        + "  var bar1;\n"
        + "  var bar2 ='" + longLine + "';\n"
        + "  var bar3;\n"
        + "  " // Cursor here.
        + "}";
    helper.setup(new PathUtil("foo.js"), text, 4, 2, true);
    helper.parser.begin();
    helper.parseScheduler.requests.get(0).run(10);
    AutocompleteProposals autocompletions =
        helper.autocompleter.jsAutocompleter.findAutocompletions(
            helper.editor.getSelection(), CTRL_SPACE);
View Full Code Here

    assertTrue("contains var defined before long line", proposals.contains("bar1"));
    assertTrue("contains var defined after long line", proposals.contains("bar3"));
  }

  public void testDoNotDieOnRegExp() {
    MockAutocompleterEnvironment helper = new MockAutocompleterEnvironment();
    String text = "function foo() {\n"
        + "  var bar1 = /regexp/;\n"
        + "  var bar2;\n"
        + "  " // Cursor here.
        + "}";
    helper.setup(new PathUtil("foo.js"), text, 3, 2, true);
    helper.parser.begin();
    helper.parseScheduler.requests.get(0).run(10);
    AutocompleteProposals autocompletions =
        helper.autocompleter.jsAutocompleter.findAutocompletions(
            helper.editor.getSelection(), CTRL_SPACE);
View Full Code Here

    assertTrue("contains var defined in line with regexp", proposals.contains("bar1"));
    assertTrue("contains var defined after line with regexp", proposals.contains("bar2"));
  }

  public void testDeleteAtBeginningOfDocument() {
    MockAutocompleterEnvironment helper = new MockAutocompleterEnvironment();

    String text = "<cursorAtTheBeginingOfFirstLine>";
    helper.setup(new PathUtil("foo.js"), text, 0, 0, true);
    ExplicitAction action = helper.autocompleter.jsAutocompleter.getExplicitAction(
        helper.editor.getSelection(), DELETE_KEY, false);
    assertEquals(LanguageSpecificAutocompleter.ExplicitActionType.DEFAULT, action.getType());
  }
View Full Code Here

        helper.editor.getSelection(), DELETE_KEY, false);
    assertEquals(LanguageSpecificAutocompleter.ExplicitActionType.DEFAULT, action.getType());
  }

  public void testClosePopupOnSpace() {
    MockAutocompleterEnvironment helper = new MockAutocompleterEnvironment();

    // TODO: vars in the global scope are not registered by CM.
    String text = "function a() { var abba, apple, arrow; a";
    helper.setup(new PathUtil("foo.js"), text, 0, text.length(), true);
    final MockAutocompleter autocompleter = helper.autocompleter;

    assertFalse("initially popup is not shown", helper.popup.isShowing());

    final JsonArray<Scheduler.ScheduledCommand> scheduled = JsonCollections.createArray();
View Full Code Here

        new DefaultAutocompleteResult("\n    \n  ", "", 5));
  }

  private void checkExplicit(String message, String text, int tailOffset,
      SignalEventEssence trigger, @Nullable DefaultAutocompleteResult expected) {
    MockAutocompleterEnvironment helper = new MockAutocompleterEnvironment();

    Document document = Document.createFromString(text);
    int column = LineUtils.getLastCursorColumn(document.getFirstLine()) - tailOffset;
    helper.setup(new PathUtil("foo.js"), document, 0, column, true);

    ExplicitAction action = helper.autocompleter.jsAutocompleter.getExplicitAction(
        helper.editor.getSelection(), trigger, false);
    AutocompleteResult commonResult = action.getExplicitAutocompletion();
    if (expected == null) {
View Full Code Here

   * {@link com.google.collide.client.editor.input.DefaultScheme} to
   * perform specific textual changes.
   */
  public void testDoNotPreventCtrlBs() {
    String text = "#!@abc   ";
    MockAutocompleterEnvironment helper = new MockAutocompleterEnvironment();
    helper.setup(new PathUtil("test.js"), text, 0, text.length(), true);

    final Editor editor = helper.editor;

    final JsonArray<Scheduler.ScheduledCommand> scheduled = JsonCollections.createArray();

View Full Code Here

TOP

Related Classes of com.google.collide.client.code.autocomplete.MockAutocompleterEnvironment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.