Program: 138368
Project: 138368
Buggy source:
private void impactExistingAnalyses(DataProvider oldDataProvider) throws PartInitException {
  EList<Dependency> clientDependencies=oldDataProvider.getSupplierDependency();
  List<Analysis> unsynedAnalyses=new ArrayList<Analysis>();
  for (  Dependency dep : clientDependencies) {
    StringBuffer impactedAnaStr=new StringBuffer();
    for (    ModelElement mod : dep.getClient()) {
      if (!(mod instanceof Analysis)) {
        continue;
      }
      Analysis ana=(Analysis)mod;
      unsynedAnalyses.add(ana);
      impactedAnaStr.append(ana.getName());
    }
    for (    Analysis analysis : unsynedAnalyses) {
      Resource eResource=analysis.eResource();
      if (eResource == null) {
        continue;
      }
      EMFSharedResources.getInstance().unloadResource(eResource.getURI().toString());
      IWorkspaceRoot root=ResourcesPlugin.getWorkspace().getRoot();
      Path path=new Path(analysis.getFileName() == null ? eResource.getURI().toPlatformString(false) : analysis.getFileName());
      IFile file=root.getFile(path);
      analysis=AnaResourceFileHelper.getInstance().readFromFile(file);
      eResource=analysis.eResource();
      Map<EObject,Collection<Setting>> referenceMaps=EcoreUtil.UnresolvedProxyCrossReferencer.find(eResource);
      Iterator<EObject> it=referenceMaps.keySet().iterator();
      ModelElement eobj=null;
      while (it.hasNext()) {
        eobj=(ModelElement)it.next();
        Collection<Setting> settings=referenceMaps.get(eobj);
        for (        Setting setting : settings) {
          if (setting.getEObject() instanceof AnalysisContext) {
            analysis.getContext().getAnalysedElements().remove(eobj);
          }
 else           if (setting.getEObject() instanceof Indicator) {
            analysis.getResults().getIndicators().remove(setting.getEObject());
          }
        }
      }
      AnaResourceFileHelper.getInstance().save(analysis);
    }
  }
  IWorkbenchPage activePage=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
  IEditorReference[] editors=activePage.getEditorReferences();
  if (editors != null) {
    for (    IEditorReference editorRef : editors) {
      if (editorRef.getId().equals(ANALYSIS_EDITOR_ID)) {
        boolean isConfirm=MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
        if (!isConfirm) {
          return;
        }
      }
    }
    for (    IEditorReference editorRef : editors) {
      IEditorInput editorInput=editorRef.getEditorInput();
      if (editorRef.getId().equals(ANALYSIS_EDITOR_ID)) {
        activePage.closeEditor(editorRef.getEditor(false),false);
        activePage.openEditor(editorInput,ANALYSIS_EDITOR_ID);
      }
    }
  }
}

Fixed version (ground truth):
private void impactExistingAnalyses(DataProvider oldDataProvider) throws PartInitException {
  EList<Dependency> clientDependencies=oldDataProvider.getSupplierDependency();
  List<Analysis> unsynedAnalyses=new ArrayList<Analysis>();
  for (  Dependency dep : clientDependencies) {
    StringBuffer impactedAnaStr=new StringBuffer();
    for (    ModelElement mod : dep.getClient()) {
      if (!(mod instanceof Analysis)) {
        continue;
      }
      Analysis ana=(Analysis)mod;
      unsynedAnalyses.add(ana);
      impactedAnaStr.append(ana.getName());
    }
    for (    Analysis analysis : unsynedAnalyses) {
      Resource eResource=analysis.eResource();
      if (eResource == null) {
        continue;
      }
      EMFSharedResources.getInstance().unloadResource(eResource.getURI().toString());
      IWorkspaceRoot root=ResourcesPlugin.getWorkspace().getRoot();
      Path path=new Path(analysis.getFileName() == null ? eResource.getURI().toPlatformString(false) : analysis.getFileName());
      IFile file=root.getFile(path);
      analysis=(Analysis)AnaResourceFileHelper.getInstance().getModelElement(file);
      if (analysis != null) {
        eResource=analysis.eResource();
        Map<EObject,Collection<Setting>> referenceMaps=EcoreUtil.UnresolvedProxyCrossReferencer.find(eResource);
        Iterator<EObject> it=referenceMaps.keySet().iterator();
        ModelElement eobj=null;
        while (it.hasNext()) {
          eobj=(ModelElement)it.next();
          Collection<Setting> settings=referenceMaps.get(eobj);
          for (          Setting setting : settings) {
            if (setting.getEObject() instanceof AnalysisContext) {
              analysis.getContext().getAnalysedElements().remove(eobj);
            }
 else             if (setting.getEObject() instanceof Indicator) {
              analysis.getResults().getIndicators().remove(setting.getEObject());
            }
          }
        }
        AnaResourceFileHelper.getInstance().save(analysis);
      }
    }
  }
  IWorkbenchPage activePage=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
  IEditorReference[] editors=activePage.getEditorReferences();
  if (editors != null) {
    for (    IEditorReference editorRef : editors) {
      if (editorRef.getId().equals(ANALYSIS_EDITOR_ID)) {
        boolean isConfirm=MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
        if (!isConfirm) {
          return;
        }
      }
    }
    for (    IEditorReference editorRef : editors) {
      IEditorInput editorInput=editorRef.getEditorInput();
      if (editorRef.getId().equals(ANALYSIS_EDITOR_ID)) {
        activePage.closeEditor(editorRef.getEditor(false),false);
        activePage.openEditor(editorInput,ANALYSIS_EDITOR_ID);
      }
    }
  }
}