private ICProject createReferencedContent() throws Exception {
      ICProject referenced =
          cpp
              ? CProjectHelper.createCCProject(
                  "ReferencedContent" + System.currentTimeMillis(),
                  "bin",
                  IPDOMManager.ID_NO_INDEXER)
              : CProjectHelper.createCProject(
                  "ReferencedContent" + System.currentTimeMillis(),
                  "bin",
                  IPDOMManager.ID_NO_INDEXER);
      String content = testData[0].toString();
      IFile file =
          TestSourceReader.createFile(referenced.getProject(), new Path("header.h"), content);

      IndexerPreferences.set(
          referenced.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
      CCorePlugin.getIndexManager().reindex(referenced);

      waitForIndexer(referenced);

      if (DEBUG) {
        System.out.println("Referenced: " + getName());
        ((PDOM) CCoreInternals.getPDOMManager().getPDOM(referenced))
            .accept(new PDOMPrettyPrinter());
      }

      return referenced;
    }
    @Override
    public void setUp() throws Exception {
      cproject =
          cpp
              ? CProjectHelper.createCCProject(
                  getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER)
              : CProjectHelper.createCProject(
                  getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
      Bundle b = CTestPlugin.getDefault().getBundle();
      testData =
          TestSourceReader.getContentsForTest(
              b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2);

      if (testData.length < 2) return;
      IFile file =
          TestSourceReader.createFile(
              cproject.getProject(), new Path("header.h"), testData[0].toString());
      CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
      waitForIndexer(cproject);

      if (DEBUG) {
        System.out.println("Project PDOM: " + getName());
        ((PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
      }

      index = CCorePlugin.getIndexManager().getIndex(cproject);

      index.acquireReadLock();
      IFile cppfile =
          TestSourceReader.createFile(
              cproject.getProject(),
              new Path("references.c" + (cpp ? "pp" : "")),
              testData[1].toString());
      ast = TestSourceReader.createIndexBasedAST(index, cproject, cppfile);
    }
  @Override
  protected void setUp() throws Exception {
    cproject =
        cpp
            ? CProjectHelper.createCCProject(
                getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER)
            : CProjectHelper.createCProject(
                getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
    testData = testSourceReader.getContentsForTest(getName());

    if (testData.length > 0) {
      for (int i = 0; i < testData.length - 1; i++) {
        String filename = String.format("header%d.h", i + 1);
        IFile file =
            TestSourceReader.createFile(
                cproject.getProject(), new Path(filename), testData[i].toString());
        CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
      }
    }

    IFile cppfile =
        TestSourceReader.createFile(
            cproject.getProject(), new Path("source.c" + (cpp ? "pp" : "")), getAstSource());
    waitForIndexer(cproject);

    if (DEBUG) {
      System.out.println("Project PDOM: " + getName());
      ((PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
    }

    index = CCorePlugin.getIndexManager().getIndex(cproject);

    index.acquireReadLock();
    ast = TestSourceReader.createIndexBasedAST(index, cproject, cppfile);
  }
 @Override
 public ICProject createProject() throws CoreException {
   ICProject cproject =
       CProjectHelper.createCProject(
           "test" + System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
   projectsToDeleteOnTearDown.add(cproject);
   CProjectHelper.importSourcesFromPlugin(
       cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ3);
   return cproject;
 }
    @Override
    public void setUp() throws Exception {
      cproject =
          cpp
              ? CProjectHelper.createCCProject(
                  getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER)
              : CProjectHelper.createCProject(
                  getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
      Bundle b = CTestPlugin.getDefault().getBundle();
      testData =
          TestSourceReader.getContentsForTest(
              b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 0);

      List<IFile> astFiles = new ArrayList<IFile>();
      for (int i = 0; i < testData.length; i++) {
        StringBuilder contents = testData[i];
        int endOfLine = contents.indexOf("\n");
        if (endOfLine >= 0) endOfLine++;
        else endOfLine = contents.length();
        String filename = contents.substring(0, endOfLine).trim();
        contents.delete(0, endOfLine); // Remove first line from the file contents
        boolean astRequested = filename.endsWith("*");
        if (astRequested) {
          filename = filename.substring(0, filename.length() - 1).trim();
        }
        IFile file =
            TestSourceReader.createFile(
                cproject.getProject(), new Path(filename), contents.toString());
        if (astRequested || (i == testData.length - 1 && astFiles.isEmpty())) {
          astSources.add(contents);
          astFiles.add(file);
        }
      }
      CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
      waitForIndexer(cproject);

      if (DEBUG) {
        System.out.println("Project PDOM: " + getName());
        ((PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
      }

      index = CCorePlugin.getIndexManager().getIndex(cproject);

      index.acquireReadLock();
      for (IFile file : astFiles) {
        asts.add(TestSourceReader.createIndexBasedAST(index, cproject, file));
      }
    }
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    if (fIsCpp) {
      fCProject = CProjectHelper.createCCProject(getName(), "unused", IPDOMManager.ID_FAST_INDEXER);
    } else {
      fCProject = CProjectHelper.createCProject(getName(), "unused", IPDOMManager.ID_FAST_INDEXER);
    }
    fCFile = setUpProjectContent(fCProject.getProject());
    assertNotNull(fCFile);
    waitForIndexer(fCProject);
    fEditor = (ITextEditor) EditorTestHelper.openInEditor(fCFile, true);
    assertNotNull(fEditor);
    CPPASTNameBase.sAllowNameComputation = true;

    //		EditorTestHelper.joinBackgroundActivities((AbstractTextEditor)fEditor);
  }
 @Override
 protected void tearDown() throws Exception {
   EditorTestHelper.closeEditor(fEditor);
   fEditor = null;
   CProjectHelper.delete(fCProject);
   fCProject = null;
   fCFile = null;
   super.tearDown();
 }
  public void testCPathEntriesForOldStyle() throws Exception {
    p2 = CProjectHelper.createCCProject(PROJ_NAME_PREFIX + "b", null, IPDOMManager.ID_NO_INDEXER);
    ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
    IProject project = p2.getProject();
    ICProjectDescription des = mngr.getProjectDescription(project, false);
    assertNotNull(des);
    assertEquals(1, des.getConfigurations().length);
    assertFalse(mngr.isNewStyleProject(des));
    assertFalse(mngr.isNewStyleProject(project));

    IPathEntry[] entries = CoreModel.getRawPathEntries(p2);
    entries =
        concatEntries(
            entries,
            new IPathEntry[] {
              CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
              CoreModel.newOutputEntry(project.getFullPath().append("test_out")),
            });

    CoreModel.setRawPathEntries(p2, entries, null);

    ICSourceEntry[] expectedSourceEntries =
        new ICSourceEntry[] {
          new CSourceEntry(
              project.getFullPath(), new IPath[] {new Path("test_src")}, ICSettingEntry.RESOLVED),
          new CSourceEntry(project.getFullPath().append("test_src"), null, ICSettingEntry.RESOLVED),
        };

    ICOutputEntry[] expectedOutputEntries =
        new ICOutputEntry[] {
          new COutputEntry(
              project.getFullPath(),
              null,
              ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH),
          new COutputEntry(
              project.getFullPath().append("test_out"),
              null,
              ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH),
        };

    des = mngr.getProjectDescription(project, false);
    ICConfigurationDescription cfg = des.getDefaultSettingConfiguration();
    ICSourceEntry[] sEntries = cfg.getSourceEntries();
    ICOutputEntry[] oEntries = cfg.getBuildSetting().getOutputDirectories();

    checkCEntriesMatch(expectedSourceEntries, sEntries);
    checkCEntriesMatch(expectedOutputEntries, oEntries);

    des = mngr.getProjectDescription(project, true);
    cfg = des.getDefaultSettingConfiguration();
    sEntries = cfg.getSourceEntries();
    oEntries = cfg.getBuildSetting().getOutputDirectories();

    checkCEntriesMatch(expectedSourceEntries, sEntries);
    checkCEntriesMatch(expectedOutputEntries, oEntries);
  }
  public void testICDescriptorGetProjectData() throws Exception {
    p3 = CProjectHelper.createCCProject(PROJ_NAME_PREFIX + "c", null, IPDOMManager.ID_NO_INDEXER);
    IProject proj = p3.getProject();

    doTestRm(proj);
    doTestRm(proj);
    doTestRm(proj);
    doTestRm(proj);
    doTestRm(proj);
  }
    @Override
    public void setUp() throws Exception {
      cproject =
          cpp
              ? CProjectHelper.createCCProject(
                  "OnlineContent" + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER)
              : CProjectHelper.createCProject(
                  "OnlineContent" + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
      Bundle b = CTestPlugin.getDefault().getBundle();
      testData =
          TestSourceReader.getContentsForTest(
              b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2);
      referenced = createReferencedContent();

      TestScannerProvider.sIncludes =
          new String[] {referenced.getProject().getLocation().toOSString()};
      IFile references =
          TestSourceReader.createFile(
              cproject.getProject(),
              new Path("refs.c" + (cpp ? "pp" : "")),
              testData[1].toString());

      IProject[] refs = new IProject[] {referenced.getProject()};
      IProjectDescription pd = cproject.getProject().getDescription();
      pd.setReferencedProjects(refs);
      cproject.getProject().setDescription(pd, new NullProgressMonitor());

      IndexerPreferences.set(
          cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
      CCorePlugin.getIndexManager().reindex(cproject);
      waitForIndexer(cproject);

      if (DEBUG) {
        System.out.println("Online: " + getName());
        ((PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
      }

      index = CCorePlugin.getIndexManager().getIndex(cproject, IIndexManager.ADD_DEPENDENCIES);
      index.acquireReadLock();
      ast = TestSourceReader.createIndexBasedAST(index, cproject, references);
    }
  public void testPathEntriesForNewStyle() throws Exception {
    p1 =
        CProjectHelper.createNewStileCProject(
            PROJ_NAME_PREFIX + "a",
            TestUserAndDiscoveredEntriesCfgDataProvider.PROVIDER_ID,
            IPDOMManager.ID_NO_INDEXER);
    IProject project = p1.getProject();

    IPathEntry[] entries = CoreModel.getRawPathEntries(p1);
    IPathEntry[] resolvedentries = CoreModel.getResolvedPathEntries(p1);
    IPathEntry[] expectedRawEntries =
        new IPathEntry[] {
          CoreModel.newContainerEntry(new Path("org.eclipse.cdt.core.CFG_BASED_CONTAINER")),
          CoreModel.newSourceEntry(project.getFullPath()),
          CoreModel.newOutputEntry(project.getFullPath()),
        };
    checkEntriesMatch(expectedRawEntries, entries);

    IPathEntry[] expectedResolvedEntries =
        new IPathEntry[] {
          CoreModel.newSourceEntry(project.getFullPath()),
          CoreModel.newOutputEntry(project.getFullPath()),
          CoreModel.newMacroEntry(project.getFullPath(), "a", "b"),
          CoreModel.newMacroEntry(project.getFullPath(), "c", ""),
          CoreModel.newIncludeEntry(
              project.getFullPath(), null, project.getLocation().append("a/b/c")),
          CoreModel.newIncludeEntry(project.getFullPath(), null, new Path("/d/e/f")),
          CoreModel.newIncludeEntry(
              project.getFullPath(), project.getFullPath().makeRelative(), new Path("g/h/i")),
          CoreModel.newIncludeEntry(project.getFullPath(), new Path("j"), new Path("k/l")),
        };
    checkEntriesMatch(expectedResolvedEntries, resolvedentries);

    IPathEntry[] newEntries = new IPathEntry[entries.length + 1];
    System.arraycopy(entries, 0, newEntries, 0, entries.length);
    newEntries[entries.length] =
        CoreModel.newIncludeEntry(
            new Path("d"),
            null,
            new Path("/C/d/e"),
            true,
            new Path[] {new Path("a"), new Path("b")},
            false);

    IPathEntry[] newExpectedRawEntries = new IPathEntry[entries.length + 1];
    System.arraycopy(entries, 0, newExpectedRawEntries, 0, entries.length);
    newExpectedRawEntries[entries.length] =
        CoreModel.newIncludeEntry(
            project.getFullPath().append("d"),
            null,
            new Path("/C/d/e"),
            true,
            new Path[] {new Path("a"), new Path("b")},
            false);

    CoreModel.setRawPathEntries(p1, newEntries, null);

    entries = CoreModel.getRawPathEntries(p1);
    checkEntriesMatch(entries, newExpectedRawEntries);

    IPathEntry[] newExpectedResolved = new IPathEntry[resolvedentries.length + 1];
    System.arraycopy(resolvedentries, 0, newExpectedResolved, 0, resolvedentries.length);
    newExpectedResolved[resolvedentries.length] =
        CoreModel.newIncludeEntry(
            project.getFullPath().append("d"),
            null,
            new Path("/C/d/e"),
            true,
            new Path[] {new Path("a"), new Path("b")},
            false);
    resolvedentries = CoreModel.getResolvedPathEntries(p1);
    checkEntriesMatch(resolvedentries, newExpectedResolved);

    entries =
        concatEntries(
            entries,
            new IPathEntry[] {
              CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
              CoreModel.newOutputEntry(project.getFullPath().append("test_out")),
            });

    newExpectedRawEntries =
        concatEntries(
            newExpectedRawEntries,
            new IPathEntry[] {
              CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
              CoreModel.newOutputEntry(project.getFullPath().append("test_out")),
            });

    for (int i = 0; i < newExpectedRawEntries.length; i++) {
      IPathEntry entry = newExpectedRawEntries[i];
      if (entry.getEntryKind() == IPathEntry.CDT_SOURCE
          && entry.getPath().equals(project.getFullPath())) {
        newExpectedRawEntries[i] =
            CoreModel.newSourceEntry(project.getFullPath(), new Path[] {new Path("test_src")});
      }
      //			if(entry.getEntryKind() == IPathEntry.CDT_OUTPUT &&
      // entry.getPath().equals(project.getFullPath())){
      //				newExpectedRawEntries[i] = CoreModel.newOutputEntry(project.getFullPath(), new
      // Path[]{new Path("test_out")});
      //			}
    }

    newExpectedResolved =
        concatEntries(
            newExpectedResolved,
            new IPathEntry[] {
              CoreModel.newSourceEntry(project.getFullPath().append("test_src")),
              CoreModel.newOutputEntry(project.getFullPath().append("test_out")),
            });

    for (int i = 0; i < newExpectedResolved.length; i++) {
      IPathEntry entry = newExpectedResolved[i];
      if (entry.getEntryKind() == IPathEntry.CDT_SOURCE
          && entry.getPath().equals(project.getFullPath())) {
        newExpectedResolved[i] =
            CoreModel.newSourceEntry(project.getFullPath(), new Path[] {new Path("test_src")});
      }
      //			if(entry.getEntryKind() == IPathEntry.CDT_OUTPUT &&
      // entry.getPath().equals(project.getFullPath())){
      //				newExpectedResolved[i] = CoreModel.newOutputEntry(project.getFullPath(), new Path[]{new
      // Path("test_out")});
      //			}
    }

    CoreModel.setRawPathEntries(p1, entries, null);

    entries = CoreModel.getRawPathEntries(p1);
    resolvedentries = CoreModel.getResolvedPathEntries(p1);

    checkEntriesMatch(newExpectedRawEntries, entries);
    checkEntriesMatch(newExpectedResolved, resolvedentries);

    CoreModel.setRawPathEntries(p1, expectedRawEntries, null);
    entries = CoreModel.getRawPathEntries(p1);
    resolvedentries = CoreModel.getResolvedPathEntries(p1);

    checkEntriesMatch(expectedRawEntries, entries);
    checkEntriesMatch(expectedResolvedEntries, resolvedentries);

    // check to see that setting the same entries do not give errors
    CoreModel.setRawPathEntries(p1, expectedRawEntries, null);
    entries = CoreModel.getRawPathEntries(p1);
    resolvedentries = CoreModel.getResolvedPathEntries(p1);

    checkEntriesMatch(expectedRawEntries, entries);
    checkEntriesMatch(expectedResolvedEntries, resolvedentries);
  }