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);
  }
  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);
  }
예제 #5
0
 @Override
 public ICProject createProject() throws CoreException {
   ICProject cproject =
       CProjectHelper.createCCProject(
           "test" + System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
   projectsToDeleteOnTearDown.add(cproject);
   CProjectHelper.importSourcesFromPlugin(
       cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1);
   return cproject;
 }
  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(
                  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));
      }
    }
예제 #8
0
  @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
    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);
    }