Examples of PathUtil


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

  public void onNodeMoved(
      PathUtil oldPath, FileTreeNode node, PathUtil newPath, FileTreeNode newNode) {
    // if the moved node is currently open in the editor, or is a dir that is
    // somewhere in the path of whatever is open in the editor, then fix the
    // breadcrumbs
    PathUtil editorPath = editorBundle.getBreadcrumbs().getPath();
    if (editorPath == null) {
      return;
    }

    if (oldPath.containsPath(editorPath)) {
      // replace the start of the editor's path with the node's new path
      final PathUtil newEditorPath = PathUtil.concatenate(newPath,
          PathUtil.createExcludingFirstN(editorPath, oldPath.getPathComponentsCount()));

      editorBundle.getBreadcrumbs().setPath(newEditorPath);

      // Wait until DocumentManagerFileTreeModelListener updates the path in the document.
View Full Code Here

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

      }
    });
  }

  private boolean isRelevantPath(PathUtil changePath) {
    PathUtil editorPath = editorBundle.getPath();
    return editorPath != null && changePath.containsPath(editorPath);
  }
View Full Code Here

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

            callback.onNodeAvailable(closest);
            return;
          }

          // Get the directory that contains the path.
          final PathUtil dirPath = PathUtil.createExcludingLastN(path, 1);

          // Request the node and its parents, starting from the closest node.
          /*
           * TODO: We should revisit deep linking in the file tree and possible only show
           * the directory that is deep linked. Otherwise, we may have to load a lot of parent
           * directories when deep linking to a very deep directory.
           */
          GetDirectoryImpl getDirectoryAndPath = GetDirectoryImpl.make()
              .setPath(dirPath.getPathString())
              .setDepth(FrontendConstants.DEFAULT_FILE_TREE_DEPTH)
              .setRootId(fileTreeModel.getLastAppliedTreeMutationRevision());
              // Include the root path so we load parent directories leading up to the file.
              //.setRootPath(closest.getNodePath().getPathString());
          appContext.getFrontendApi().GET_DIRECTORY.send(
              getDirectoryAndPath, new ApiCallback<GetDirectoryResponse>() {

                @Override
                public void onMessageReceived(GetDirectoryResponse response) {
                  DirInfo baseDir = response.getBaseDirectory();
                  if (baseDir == null) {
                    /*
                     * The folder was most probably deleted before the server received our request.
                     * We should receive a tango notification to update the client.
                     */
                    return;
                  }
                  FileTreeNode incomingSubtree = FileTreeNode.transform(baseDir);
                  fileTreeModel.replaceNode(
                      new PathUtil(response.getPath()), incomingSubtree, response.getRootId());

                  // Check if the node now exists.
                  FileTreeNode child = fileTreeModel.getWorkspaceRoot().findChildNode(path);
                  if (child == null) {
                    callback.onNodeUnavailable();
                  } else {
                    callback.onNodeAvailable(child);
                  }
                }

                @Override
                public void onFail(FailureReason reason) {
                  Log.error(getClass(), "Failed to retrieve directory path "
                      + dirPath.getPathString());

                  // Update the callback.
                  callback.onError(reason);
                }
              });
View Full Code Here

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

     * @see FileTreeModel#requestDirectoryChildren
     */
    void requestDirectoryChildren(
        final FileTreeModel fileTreeModel, FileTreeNode node, final NodeRequestCallback callback) {
      Preconditions.checkArgument(node.isDirectory(), "Cannot request children of a file");
      final PathUtil path = node.getNodePath();
      GetDirectoryImpl getDirectory = GetDirectoryImpl.make()
          .setPath(path.getPathString())
          .setDepth(FrontendConstants.DEFAULT_FILE_TREE_DEPTH)
          .setRootId(fileTreeModel.getLastAppliedTreeMutationRevision());
      appContext.getFrontendApi().GET_DIRECTORY.send(getDirectory,
          new ApiCallback<GetDirectoryResponse>() {

            @Override
            public void onMessageReceived(GetDirectoryResponse response) {
              DirInfo baseDir = response.getBaseDirectory();
              if (baseDir == null) {
                /*
                 * The folder was most probably deleted before the server received our request. We
                 * should receive a tango notification to update the client.
                 */
                if (callback != null) {
                  callback.onNodeUnavailable();
                }
                return;
              }

              FileTreeNode incomingSubtree = FileTreeNode.transform(baseDir);
              fileTreeModel.replaceNode(
                  new PathUtil(response.getPath()), incomingSubtree, response.getRootId());

              if (callback != null) {
                callback.onNodeAvailable(incomingSubtree);
              }
            }

            @Override
            public void onFail(FailureReason reason) {
              Log.error(getClass(), "Failed to retrieve children for directory "
                  + path.getPathString());

              if (callback != null) {
                callback.onError(reason);
              } else {
                StatusMessage fatal = new StatusMessage(
View Full Code Here

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

        // we check the very first file since that's all we support right now
        String file = metadata.getLastOpenFiles().get(0);
        Preconditions.checkNotNull(file, "Somehow the file to navigate to was null");

        PlaceNavigationEvent<FileSelectedPlace> event =
            FileSelectedPlace.PLACE.createNavigationEvent(new PathUtil(file));
        navigationEvent.getPlace().fireChildPlaceNavigation(event);
      }
    });
  }
View Full Code Here

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

  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

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

  }

  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

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

  }

  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

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

  }

  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

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

        + "  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
TOP
Copyright © 2018 www.massapi.com. 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.