private void setupDestination() {
   String dest;
   ICProject[] prjs = getCheckedElements();
   if (prjs.length > 0) {
     dest = IndexerPreferences.getIndexImportLocation(prjs[0].getProject());
   } else {
     dest = IndexerPreferences.getIndexImportLocation(null);
   }
   fDestinationField.setText(dest);
 }
    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;
    }
示例#3
0
  /**
   * Creates CDT project in a specific path in workspace adding specified configurations and opens
   * it.
   *
   * @param projectName - project name.
   * @param pathInWorkspace - path relative to workspace root.
   * @param configurationIds - array of configuration IDs.
   * @return - new {@link IProject}.
   * @throws CoreException - if the project can't be created.
   * @throws OperationCanceledException...
   */
  public static IProject createCDTProject(
      String projectName, String pathInWorkspace, String[] configurationIds)
      throws OperationCanceledException, CoreException {
    CCorePlugin cdtCorePlugin = CCorePlugin.getDefault();
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();

    IProject project = root.getProject(projectName);
    IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER);
    resourcesCreated.add(project);

    IProjectDescription prjDescription = workspace.newProjectDescription(projectName);
    if (pathInWorkspace != null) {
      IPath absoluteLocation = root.getLocation().append(pathInWorkspace);
      prjDescription.setLocation(absoluteLocation);
    }

    if (configurationIds != null && configurationIds.length > 0) {
      ICProjectDescriptionManager prjDescManager = cdtCorePlugin.getProjectDescriptionManager();

      project.create(NULL_MONITOR);
      project.open(NULL_MONITOR);

      ICProjectDescription icPrjDescription =
          prjDescManager.createProjectDescription(project, false);
      ICConfigurationDescription baseConfiguration =
          cdtCorePlugin.getPreferenceConfiguration(TestCfgDataProvider.PROVIDER_ID);

      for (String cfgId : configurationIds) {
        icPrjDescription.createConfiguration(cfgId, cfgId + " Name", baseConfiguration);
      }
      prjDescManager.setProjectDescription(project, icPrjDescription);
    }
    project = cdtCorePlugin.createCDTProject(prjDescription, project, NULL_MONITOR);
    waitForProjectRefreshToFinish();
    Assert.assertNotNull(project);

    project.open(null);
    Assert.assertTrue(project.isOpen());

    return project;
  }
示例#4
0
  /**
   * Creates CDT project in a specific location and opens it.
   *
   * @param projectName - project name.
   * @param locationURI - location.
   * @return - new {@link IProject}.
   * @throws CoreException - if the project can't be created.
   * @throws OperationCanceledException...
   */
  public static IProject createCDTProject(String projectName, URI locationURI)
      throws OperationCanceledException, CoreException {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();

    IProject project = root.getProject(projectName);
    IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER);
    resourcesCreated.add(project);

    IProjectDescription description = workspace.newProjectDescription(projectName);
    description.setLocationURI(locationURI);
    project = CCorePlugin.getDefault().createCDTProject(description, project, NULL_MONITOR);
    waitForProjectRefreshToFinish();
    Assert.assertNotNull(project);

    project.open(null);
    Assert.assertTrue(project.isOpen());

    return project;
  }
    @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);
    }