/** https://bugs.eclipse.org/bugs/show_bug.cgi?id=400193 */
  @Test
  public void testSourceRelativeOutput() throws Exception {
    IProject project = testHelper.getProject();
    String srcFolder = "/foo/bar/bug";
    JavaProjectSetupUtil.addSourceFolder(JavaCore.create(project), srcFolder);

    String path = srcFolder + "/Foo.xtend";
    String fullFileName = project.getName() + path;
    IFile sourceFile = testHelper.createFileImpl(fullFileName, "class Foo {}");
    assertTrue(sourceFile.exists());
    waitForBuild();

    IFile generatedFile = project.getFile("foo/bar/xtend-gen/Foo.java");
    assertTrue(generatedFile.exists());
    IFile traceFile = testHelper.getProject().getFile("foo/bar/xtend-gen/.Foo.java._trace");
    assertTrue(traceFile.exists());
    IFile classFile = testHelper.getProject().getFile("/bin/Foo.class");
    assertTrue(classFile.exists());

    List<IPath> traceFiles = traceMarkers.findTraceFiles(sourceFile);
    assertTrue(traceFiles.contains(traceFile.getFullPath()));

    sourceFile.delete(false, new NullProgressMonitor());
    waitForBuild();
    assertFalse(generatedFile.exists());
    assertFalse(traceFile.exists());
  }
Esempio n. 2
0
  public static void setUp() throws Exception {
    if (javaProject != null) return;
    javaProject =
        createJavaProject(
            "projectWithoutSources",
            new String[] {JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature"});
    String path = "/org/eclipse/xtext/common/types/testSetups";
    String jarFileName = "/testData.jar";
    IFile jarFile =
        PluginUtil.copyFileToWorkspace(
            AbstractActivator.getInstance(),
            path + jarFileName,
            javaProject.getProject(),
            jarFileName);
    JavaProjectSetupUtil.addJarToClasspath(javaProject, jarFile);

    javaProjectWithSources =
        createJavaProject(
            "projectWithSources",
            new String[] {JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature"});
    IFolder sourceFolder = JavaProjectSetupUtil.addSourceFolder(javaProjectWithSources, "src");

    List<String> filesToCopy = readResource(path + "/files.list");
    IFolder srcFolder = sourceFolder.getFolder(new Path(path));
    createFolderRecursively(srcFolder);
    for (String fileToCopy : filesToCopy) {
      List<String> content = readResource(path + "/" + fileToCopy);
      String contentAsString = Strings.concat("\n", content);
      createFile(
          fileToCopy.substring(0, fileToCopy.length() - ".txt".length()),
          srcFolder,
          contentAsString);
    }
    createFile(
        "ClassWithDefaultPackage.java", sourceFolder, "public class ClassWithDefaultPackage {}");
    waitForAutoBuild();
  }