Program: 72364
Project: 72364
Buggy source:
/** 
 * Builds the context menu. Single selection menu and multiple selection menu are created while selecting just single element or multiple elements
 * @param menu the menu
 */
public void buildContextMenu(IMenuManager menu){
  if (Policy.TRACING_MENU_SHOW) {
    System.out.println("String_Node_Str");
  }
  resetActionStatus();
  menu.removeAll();
  menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
  menu.add(new Separator());
  IStructuredSelection selection=(IStructuredSelection)page.getSelection();
  if (selection != null && selection.getFirstElement() != null) {
    Object selected=selection.getFirstElement();
    if (selected instanceof ReportResourceEntry) {
      selected=((ReportResourceEntry)selected).getReportElement();
    }
    if (selected instanceof ResourceEntryWrapper) {
      int type=((ResourceEntryWrapper)selected).getType();
      if (type == ResourceEntryWrapper.LIBRARY) {
        menu.add(useLibraryAction);
      }
 else       if (type == ResourceEntryWrapper.CSS_STYLE_SHEET) {
        menu.add(new UseCssInReportDesignAction(page));
        menu.add(new UseCssInThemeAction(page));
      }
      if (((ResourceEntryWrapper)selected).getParent() instanceof PathResourceEntry) {
        menu.add(new Separator());
        menu.add(newMenuGroup);
        menu.add(addResourceAction);
      }
      menu.add(new Separator());
      menu.add(copyLibraryandCssAction);
      if (((ResourceEntryWrapper)selected).getParent() instanceof PathResourceEntry) {
        menu.add(pasteLibraryandCssAction);
        menu.add(deleteLibraryandCssAction);
        menu.add(moveLibraryandCssAction);
        menu.add(renameLibraryandCssAction);
        menu.add(new Separator());
      }
    }
 else     if (selected instanceof LibraryHandle) {
      menu.add(useLibraryAction);
      menu.add(new Separator());
    }
 else     if (selected instanceof CssStyleSheetHandle) {
      menu.add(new UseCssInReportDesignAction(page));
      menu.add(new UseCssInThemeAction(page));
      menu.add(new Separator());
    }
 else     if (selected instanceof PathResourceEntry) {
      menu.add(newMenuGroup);
      menu.add(addResourceAction);
      menu.add(new Separator());
      menu.add(copyLibraryandCssAction);
      menu.add(pasteLibraryandCssAction);
      menu.add(deleteLibraryandCssAction);
      menu.add(moveLibraryandCssAction);
      menu.add(renameLibraryandCssAction);
      menu.add(new Separator());
    }
 else     if (selected instanceof FragmentResourceEntry) {
      if (copyLibraryandCssAction.isEnabled()) {
        menu.add(copyLibraryandCssAction);
        menu.add(new Separator());
      }
    }
    if (canAddtoReport(selected)) {
      if (selection.size() == 1) {
        AddElementtoReport addElementAction=new AddElementtoReport((StructuredViewer)getViewer());
        addElementAction.setSelectedElement(selected);
        menu.add(addElementAction);
        menu.add(new Separator());
      }
    }
    menu.add(new Separator());
    menu.add(refreshExplorerAction);
  }
 else {
    menu.add(addResourceAction);
    menu.add(new Separator());
    menu.add(refreshExplorerAction);
  }
}

Fixed version (ground truth):
/** 
 * Builds the context menu. Single selection menu and multiple selection menu are created while selecting just single element or multiple elements
 * @param menu the menu
 */
public void buildContextMenu(IMenuManager menu){
  if (Policy.TRACING_MENU_SHOW) {
    System.out.println("String_Node_Str");
  }
  resetActionStatus();
  menu.removeAll();
  menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
  menu.add(new Separator());
  IStructuredSelection selection=(IStructuredSelection)page.getSelection();
  if (selection != null && selection.getFirstElement() != null) {
    Object selected=selection.getFirstElement();
    if (selected instanceof ReportResourceEntry) {
      selected=((ReportResourceEntry)selected).getReportElement();
    }
    if (selected instanceof ResourceEntryWrapper) {
      int type=((ResourceEntryWrapper)selected).getType();
      if (type == ResourceEntryWrapper.LIBRARY) {
        menu.add(useLibraryAction);
      }
 else       if (type == ResourceEntryWrapper.CSS_STYLE_SHEET) {
        menu.add(new UseCssInReportDesignAction(page));
        menu.add(new UseCssInThemeAction(page));
      }
      if (((ResourceEntryWrapper)selected).getParent() instanceof PathResourceEntry) {
        menu.add(new Separator());
        menu.add(newMenuGroup);
        menu.add(addResourceAction);
      }
      menu.add(new Separator());
      menu.add(copyResourceAction);
      if (((ResourceEntryWrapper)selected).getParent() instanceof PathResourceEntry) {
        menu.add(pasteResourceAction);
        menu.add(deleteResourceAction);
        menu.add(moveResourceAction);
        menu.add(renameResourceAction);
        menu.add(new Separator());
      }
    }
 else     if (selected instanceof LibraryHandle) {
      menu.add(useLibraryAction);
      menu.add(new Separator());
    }
 else     if (selected instanceof CssStyleSheetHandle) {
      menu.add(new UseCssInReportDesignAction(page));
      menu.add(new UseCssInThemeAction(page));
      menu.add(new Separator());
    }
 else     if (selected instanceof PathResourceEntry) {
      menu.add(newMenuGroup);
      menu.add(addResourceAction);
      menu.add(new Separator());
      menu.add(copyResourceAction);
      menu.add(pasteResourceAction);
      menu.add(deleteResourceAction);
      menu.add(moveResourceAction);
      menu.add(renameResourceAction);
      menu.add(new Separator());
    }
 else     if (selected instanceof FragmentResourceEntry) {
      if (copyResourceAction.isEnabled()) {
        menu.add(copyResourceAction);
        menu.add(new Separator());
      }
    }
    if (canAddtoReport(selected)) {
      if (selection.size() == 1) {
        AddElementtoReport addElementAction=new AddElementtoReport((StructuredViewer)getViewer());
        addElementAction.setSelectedElement(selected);
        menu.add(addElementAction);
        menu.add(new Separator());
      }
    }
    menu.add(new Separator());
    menu.add(refreshExplorerAction);
  }
 else {
    menu.add(addResourceAction);
    menu.add(new Separator());
    menu.add(refreshExplorerAction);
  }
}