コード例 #1
0
  public void testIndexWithEmptyContent() throws Exception {
    File tmpDir = null;
    try {
      String src = "\n";

      // Generate some files to index!
      tmpDir =
          new File(
              FileUtil.getTempDirectory().toOSString(),
              "testIndexWithEmptyContent" + System.currentTimeMillis());
      tmpDir.mkdirs();

      File coffeeFile = new File(tmpDir, "index_me.coffee");
      IOUtil.write(new FileOutputStream(coffeeFile), src);

      IFileStore fileStore = EFS.getStore(coffeeFile.toURI());
      BuildContext context = new FileStoreBuildContext(fileStore);

      IProgressMonitor monitor = new NullProgressMonitor();
      indexer.index(context, null, monitor);
    } finally {
      // Clean up the generated files!
      FileUtil.deleteRecursively(tmpDir);
    }
  }
コード例 #2
0
  /**
   * testStringF
   *
   * @throws IOException
   */
  @Test
  public void testStringFPrefix() throws IOException {
    File bundleFile = FileUtil.createTempFile("editor_unit_tests", "rb");

    BundleElement bundleElement = new BundleElement(bundleFile.getAbsolutePath());
    bundleElement.setDisplayName("Editor Unit Tests");

    File f = FileUtil.createTempFile("snippet", "rb");
    SnippetElement se = createSnippet(f.getAbsolutePath(), "FunctionTemplate", "fun", "source.js");
    bundleElement.addChild(se);
    BundleManager.getInstance().addBundle(bundleElement);

    try {
      // note template is before true proposal, as we are ordering by trigger prefix
      this.checkProposals(
          "contentAssist/f-prefix.js",
          true,
          true,
          "false",
          "finally",
          "focus",
          "for",
          "forward",
          "frames",
          "function",
          "FunctionTemplate",
          "Function");
    } finally {
      BundleManager.getInstance().unloadScript(f);
    }
  }
コード例 #3
0
  /**
   * testStringFunction
   *
   * @throws IOException
   */
  @Test
  public void testStringThis() throws IOException {
    File bundleFile = FileUtil.createTempFile("editor_unit_tests", "rb");

    BundleElement bundleElement = new BundleElement(bundleFile.getAbsolutePath());
    bundleElement.setDisplayName("Editor Unit Tests");

    File f = FileUtil.createTempFile("snippet", "rb");
    SnippetElement se = createSnippet(f.getAbsolutePath(), "$(this)", "this", "source.js");
    bundleElement.addChild(se);
    BundleManager.getInstance().addBundle(bundleElement);

    this.checkProposals("contentAssist/this.js", true, true, "$(this)", "this", "throw");

    BundleManager.getInstance().unloadScript(f);
  }
  private void cloneFromGit(
      String gitURL, final IProject projectHandle, final IProjectDescription projectDescription) {
    IPath path = mainPage.getLocationPath();
    // when default is used, getLocationPath() only returns the workspace root, so needs to append
    // the project name
    // to the path
    if (mainPage.useDefaults()) {
      path = path.append(projectDescription.getName());
    }

    // Wipe the destination directory if it already exists, or git clone will fail.
    File directory = path.toFile();
    if (directory.exists()) {
      FileUtil.deleteRecursively(directory);
    }

    // FIXME Run an IRunnableWithProgress in wizard container, have it just do job.run(monitor)!
    Job job = new CloneJob(gitURL, path.toOSString(), true, true);
    job.addJobChangeListener(
        new JobChangeAdapter() {

          @Override
          public void done(IJobChangeEvent event) {
            if (!event.getResult().isOK()) {
              return;
            }

            try {
              projectHandle.setDescription(projectDescription, null);
              projectHandle.refreshLocal(IResource.DEPTH_INFINITE, null);
            } catch (CoreException e) {
              IdeLog.logError(SamplesUIPlugin.getDefault(), e);
            }

            doPostProjectCreation(newProject);
          }
        });
    job.schedule(500);
  }