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

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


    String text = helper.editor.getDocument().getFirstLine().getText();
    assertEquals("resulting text", "continue\n", text);
  }

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

    String text = "if a is not None:";
    helper.setup(new PathUtil("foo.py"), text, 0, text.length(), true);
    JsonArray<Token> tokens = helper.parser
        .parseLineSync(helper.editor.getDocument().getFirstLine());
    assertEquals("4-th token == 'is'", "is", tokens.get(4).getValue());
    assertEquals("4-th token is keyword", TokenType.KEYWORD, tokens.get(4).getType());
    assertEquals("6-th token == 'not'", "not", tokens.get(6).getValue());
View Full Code Here


  }

  @Override
  public void gwtSetUp() throws Exception {
    super.gwtSetUp();
    helper = new MockAutocompleterEnvironment();
    path = new PathUtil("/test.html");
    lineTokens = JsonCollections.createArray();
    parsedLines = JsonCollections.createMap();

    helper.specificParser = new TestUtils.MockParser(SyntaxType.HTML) {
View Full Code Here

  public String getModuleName() {
    return "com.google.collide.client.TestCode";
  }

  public void testExplicit() {
    MockAutocompleterEnvironment helper = new MockAutocompleterEnvironment();
    setupHelper(helper, "<html><body><");
    AutocompleteResult commonResult = helper.autocompleter.htmlAutocompleter
        .getExplicitAction(helper.editor.getSelection(), new SignalEventEssence('/'), false)
        .getExplicitAutocompletion();
    assertTrue("result type", commonResult instanceof DefaultAutocompleteResult);
View Full Code Here

    DefaultAutocompleteResult result = (DefaultAutocompleteResult) commonResult;
    assertEquals("/body>", result.getAutocompletionText());
  }

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

    setupHelper(helper, "<html><head><style>p {color:bl");
    Line line = helper.editor.getDocument().getLastLine();
    JsonArray<Token> tokens = helper.parser.parseLineSync(line);
    assertEquals("html", tokens.get(0).getMode());
View Full Code Here

    assertEquals(2, proposals.size());
    assertEquals("blue", proposals.get(1).getName());
  }

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

    String line0 = "<html><head><style>p {color:";
    String line1 = "";
    String line2 = "bl";
    String text = line0 + "\n" + line1 + "\n" + line2;
    helper.setup(new PathUtil("foo.html"), text, 2, line2.length(), true);
    helper.parser.begin();
    Line line = helper.editor.getDocument().getFirstLine();
    JsonArray<Token> tokens = helper.parser.parseLineSync(line);
    assertEquals("html", tokens.get(0).getMode());
    assertEquals("css", tokens.get(tokens.size() - 2).getMode());
View Full Code Here

    assertEquals(2, proposals.size());
    assertEquals("blue", proposals.get(1).getName());
  }

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

    setupHelper(helper, "<html><head><style>p ");
    Line line = helper.editor.getDocument().getLastLine();
    JsonArray<Token> tokens = helper.parser.parseLineSync(line);
    assertEquals("html", tokens.get(0).getMode());
View Full Code Here

    DefaultAutocompleteResult defaultResult = (DefaultAutocompleteResult) result;
    assertEquals("{\n  \n}", defaultResult.getAutocompletionText());
  }

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

    setupHelper(helper, "<html><head><style>p {color:blue;}</style><a");

    AutocompleteProposals proposals =
        helper.autocompleter.htmlAutocompleter.findAutocompletions(
View Full Code Here

    assertEquals(7, proposals.size());
    assertEquals("abbr", proposals.get(1).getName());
  }

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

    setupHelper(helper,
        "<html><body><script type=\"text/javascript\">function a() { var abba, apple, arrow; a");
    Line line = helper.editor.getDocument().getLastLine();
    JsonArray<Token> tokens = helper.parser.parseLineSync(line);
View Full Code Here

    assertEquals(4, proposals.size());
    assertEquals("arguments", proposals.get(2).getName());
  }

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

    helper.setup(new PathUtil("foo.html"),
        "<html><head><script>\n\n</script></head></html>", 1, 0, true);

    helper.parser.getListenerRegistrar().add(new DocumentParserListenerAdapter(
        helper.autocompleter, helper.editor));
    helper.parser.begin();
View Full Code Here

        .findAutocompletions(helper.editor.getSelection(), CTRL_SPACE);
    assertTrue(TestUtils.findProposalByName(proposals.getItems(), "break") != null);
  }

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

    String prologue = "<html>\n<script type=\"text/javascript\">\n";
    String epilogue = "</script>\n</html>\n";
    String text = prologue + "d\n" + epilogue;
    helper.setup(new PathUtil("foo.html"), text, 2, 1, true);
    helper.parser.begin();
    helper.parseScheduler.requests.get(0).run(10);

    AutocompleteProposals proposals = helper.autocompleter.htmlAutocompleter.findAutocompletions(
        helper.editor.getSelection(), CTRL_SPACE);
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.