예제 #1
0
  public void testSearchAfterDeletion()
      throws JavaModelException, PartInitException, IOException, CoreException {
    view = (ActiveSearchView) JavaPlugin.getActivePage().showView(ActiveSearchView.ID);
    if (view != null) {
      assertEquals(0, view.getViewer().getTree().getItemCount());

      IWorkbenchPart part =
          PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
      IMethod m1 = type1.createMethod("void m1() {\n m2() \n}", null, true, null);
      IMethod m2 = type1.createMethod("void m2() { }", null, true, null);
      StructuredSelection sm2 = new StructuredSelection(m2);
      monitor.selectionChanged(part, sm2);
      IInteractionElement node =
          manager.processInteractionEvent(
              mockInterestContribution(m2.getHandleIdentifier(), scaling.getLandmark()));
      assertEquals(1, ContextCore.getContextManager().getActiveLandmarks().size());

      assertEquals(1, search(2, node).size());

      m1.delete(true, null);
      assertFalse(m1.exists());

      assertEquals(0, search(2, node).size());
    }
  }
예제 #2
0
  @Override
  public void generate(Shell parentShell, IType objectClass, CommandIdentifier commandIdentifier) {
    LinkedHashSet<MethodSkeleton<U>> methodSkeletons =
        methodSkeletonManager.getMethodSkeletons(commandIdentifier);
    LinkedHashSet<StrategyIdentifier> strategyIdentifiers =
        methodContentManager.getStrategiesIntersection(methodSkeletons);

    try {
      Set<IMethod> excludedMethods = getExcludedMethods(objectClass, methodSkeletons);
      FieldDialog<U> dialog =
          dialogFactory.createDialog(
              parentShell, objectClass, excludedMethods, strategyIdentifiers);
      int returnCode = dialog.getDialog().open();
      if (returnCode == Window.OK) {

        for (IMethod excludedMethod : excludedMethods) {
          excludedMethod.delete(true, null);
        }

        U data = dialog.getData();
        StrategyIdentifier selectedContentStrategy = data.getSelectedStrategyIdentifier();
        LinkedHashSet<Method<T, U>> methods =
            methodContentManager.getAllMethods(methodSkeletons, selectedContentStrategy);
        generateCode(parentShell, objectClass, data, methods);
      }

    } catch (Exception exception) {
      MessageDialog.openError(parentShell, "Method Generation Failed", exception.getMessage());
    }
  }