示例#1
0
  /**
   * Check if model version is changed and rebuild PHP projects if necessary.
   *
   * @see PHPCoreConstants.STRUCTURE_VERSION
   */
  private void rebuildProjects() {
    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(ID);
    String modelVersion = preferences.get(PHPCoreConstants.STRUCTURE_VERSION_PREFERENCE, null);
    if (PHPCoreConstants.STRUCTURE_VERSION.equals(modelVersion)) {
      return;
    }

    preferences.put(
        PHPCoreConstants.STRUCTURE_VERSION_PREFERENCE, PHPCoreConstants.STRUCTURE_VERSION);
    try {
      preferences.flush();
    } catch (BackingStoreException e1) {
      Logger.logException(e1);
    }

    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IProject[] projects = workspace.getRoot().getProjects();
    if (workspace.isAutoBuilding()) {
      try {
        for (IProject project : projects) {
          if (PHPToolkitUtil.isPhpProject(project)) {
            project.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
          }
        }
      } catch (CoreException e) {
        Logger.logException(e);
      }
    }
  }
示例#2
0
    public void resourceChanged(IResourceChangeEvent event) {
      if (event.getBuildKind() == IncrementalProjectBuilder.CLEAN_BUILD) {
        Object source = event.getSource();
        try {
          if (source instanceof IProject) {
            IProject project = (IProject) source;
            ProjectIndexerManager.removeProject(project.getFullPath());
            ProjectIndexerManager.indexProject(project);

          } else if (source instanceof IWorkspace) {
            IWorkspace workspace = (IWorkspace) source;
            IProject[] projects = workspace.getRoot().getProjects();

            // remove from index:
            for (IProject project : projects) {
              if (!project.isAccessible()) {
                continue;
              }
              IScriptProject scriptProject = DLTKCore.create(project);
              if (scriptProject.isOpen()) {
                IProjectFragment[] projectFragments = scriptProject.getProjectFragments();
                for (IProjectFragment projectFragment : projectFragments) {
                  ProjectIndexerManager.removeProjectFragment(
                      scriptProject, projectFragment.getPath());
                }
                ProjectIndexerManager.removeProject(project.getFullPath());
              }
            }

            // add to index:
            for (IProject project : projects) {
              if (!project.isAccessible()) {
                continue;
              }
              ProjectIndexerManager.indexProject(project);
            }
          }
        } catch (CoreException e) {
          Logger.logException(e);
        }
      }
    }