Exemple #1
0
  public void testFindFilesByLocation() throws Exception {
    fProject.create(new NullProgressMonitor());
    fProject.open(new NullProgressMonitor());
    createFolder(fProject, "folder1");
    createFolder(fProject, "folder2");
    IFile file = createFile(fProject, "abc.h");
    createFile(fProject, "folder1/abc.h");
    createFile(fProject, "folder2/abC.h");

    URI uri = file.getLocationURI();
    IPath path = file.getLocation();
    IFile[] files = ResourceLookup.findFilesForLocationURI(uri);
    assertEquals(1, files.length);
    files = ResourceLookup.findFilesForLocation(path);
    assertEquals(1, files.length);

    if (new File("a").equals(new File("A"))) {
      URI upperCase =
          new URI(uri.getScheme(), uri.getSchemeSpecificPart().toUpperCase(), uri.getFragment());
      IPath upperCasePath = new Path(path.toString().toUpperCase());
      files = ResourceLookup.findFilesForLocationURI(upperCase);
      assertEquals(1, files.length);
      files = ResourceLookup.findFilesForLocation(upperCasePath);
      assertEquals(1, files.length);
    }
  }
Exemple #2
0
  public void testLinkedResourceFiles() throws Exception {
    IProject[] prjs = new IProject[] {fProject};

    fProject.create(new NullProgressMonitor());
    fProject.open(new NullProgressMonitor());
    createFolder(fProject, "folder1");
    File f = createTempFile("extern", ".h");
    IPath location = Path.fromOSString(f.getAbsolutePath());
    IFile file1 = fProject.getFile("linked1");
    IFile file2 = fProject.getFile("linked2.h");
    file1.createLink(location, 0, new NullProgressMonitor());
    file2.createLink(location, 0, new NullProgressMonitor());

    IFile[] files = ResourceLookup.findFilesForLocation(location);
    assertEquals(2, files.length);

    files = ResourceLookup.findFilesByName(new Path(location.lastSegment()), prjs, false);
    assertEquals(2, files.length);

    files = ResourceLookup.findFilesByName(new Path("linked2.h"), prjs, false);
    assertEquals(0, files.length);
  }