Package com.google.collide.client.util

Examples of com.google.collide.client.util.PathUtil


      pos = relativePath.indexOf('#');
      if (pos != -1) {
        relativePath = relativePath.substring(0, pos);
      }

      return new PathUtil(relativePath);
    }
    return null;
  }
View Full Code Here


    for (int i = 0; i < keys.size(); i++) {
      String key = keys.get(i);
      CodeBlock fileCodeBlock = codeBlockMap.get(key);
      SyntaxType fileMode = SyntaxType.syntaxTypeByFileName(fileCodeBlock.getName());
      if (mode.equals(fileMode)) {
        FileIndex fileIndex = new FileIndex(fileCodeBlock, new PathUtil(fileCodeBlock.getName()));
        fileIdToData.put(fileCodeBlock.getId(), fileIndex);

        String filePath = fileIndex.path.getPathString();
        String idList = filePathToId.get(filePath);
        if (idList != null) {
          idList += "," + fileCodeBlock.getId();
        } else {
          idList = fileCodeBlock.getId();
        }
        filePathToId.put(filePath, idList);
      }
    }

    CodeBlock defaultPackage = codeGraph.getDefaultPackage();
    if (defaultPackage != null) {
      filePathToId.put("", defaultPackage.getId());
      fileIdToData.put(defaultPackage.getId(), new FileIndex(defaultPackage, new PathUtil("")));
    }
  }
View Full Code Here

      }
    }
  }

  private static String truncateExtension(String name) {
    PathUtil path = new PathUtil(name);
    String basename = path.getBaseName();
    int lastDot = basename.lastIndexOf('.');
    return (lastDot == -1) ? basename : basename.substring(0, lastDot);
  }
View Full Code Here

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

    helper.setup(new PathUtil("foo.py"), text, 0, column, true);
    AutocompleteProposals proposals = helper.autocompleter.pyAutocompleter.findAutocompletions(
        helper.editor.getSelection(), CTRL_SPACE);
    assertEquals(message, expectHasProposals, proposals.size() > 0);
  }
View Full Code Here

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

    String text = "a .bc.de .f";
    helper.setup(new PathUtil("foo.py"), text, 0, text.length(), true);
    PyProposalBuilder proposalBuilder = new PyProposalBuilder();
    CompletionContext<PyState> completionContext = proposalBuilder
        .buildContext(helper.editor.getSelection(), helper.parser);
    assertEquals("previous context", "a.bc.de.", completionContext.getPreviousContext());
    assertEquals("triggering string", "f", completionContext.getTriggeringString());
View Full Code Here

  }

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

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

  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.none");
  }
View Full Code Here

    assertEquals("expected: 1 proposal found", 1, helper.popup.proposals.size());
  }

  public void testEditorContentsReplaced() {
    Autocompleter autocompleter = helper.setup(path, "", 0, 0, false);
    changeAutocompleterPath(autocompleter, new PathUtil("/test.html"));
    assertEquals(SyntaxType.HTML, autocompleter.getMode());

    changeAutocompleterPath(autocompleter, new PathUtil("/test.js"));
    assertEquals(SyntaxType.JS, autocompleter.getMode());

    changeAutocompleterPath(autocompleter, new PathUtil("/test.py"));
    assertEquals(SyntaxType.PY, autocompleter.getMode());

    changeAutocompleterPath(autocompleter, new PathUtil("/test.css"));
    assertEquals(SyntaxType.CSS, autocompleter.getMode());

    changeAutocompleterPath(autocompleter, new PathUtil("/test.foo"));
    assertEquals(SyntaxType.NONE, autocompleter.getMode());

    changeAutocompleterPath(autocompleter, new PathUtil(""));
    assertEquals(SyntaxType.NONE, autocompleter.getMode());
  }
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) {
      @Override
View Full Code Here

TOP

Related Classes of com.google.collide.client.util.PathUtil

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.