public DiscoveredScannerInfo getDiscoveredScannerInfo(IProject project, boolean cacheInfo)
      throws CoreException {
    DiscoveredScannerInfo scannerInfo = null;
    // See if there's already one associated with the resource for this
    // session
    scannerInfo = (DiscoveredScannerInfo) project.getSessionProperty(scannerInfoProperty);

    if (scannerInfo == null) {
      scannerInfo = new DiscoveredScannerInfo(project);
      // this will convert user info
      org.eclipse.cdt.make.core.MakeScannerInfo makeScannerInfo =
          org.eclipse.cdt.make.core.MakeScannerProvider.getDefault()
              .getMakeScannerInfo(project, cacheInfo);
      scannerInfo.setUserScannerInfo(makeScannerInfo);

      // migrate to new C Path Entries
      IContainerEntry container = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID);
      ICProject cProject = CoreModel.getDefault().create(project);
      if (cProject != null) {
        IPathEntry[] entries = cProject.getRawPathEntries();
        List<IPathEntry> newEntries = new ArrayList<IPathEntry>(Arrays.asList(entries));
        if (!newEntries.contains(container)) {
          newEntries.add(container);
          cProject.setRawPathEntries(newEntries.toArray(new IPathEntry[newEntries.size()]), null);
        }
      }
      ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
      descriptor.remove(
          CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID); // remove scanner provider which will fallback to
      // default
      // cpath provider.
      // place holder to that we don't convert again.
      project.setSessionProperty(scannerInfoProperty, scannerInfo);
    }
    return scannerInfo;
  }
  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);
  }