Beispiel #1
0
  private static List<Operation> get_matching_operations(UmlClass klass, Operation op_gold) {
    List<Feature> operation_list = klass.getFeature();
    List<Operation> return_list = new ArrayList<Operation>();
    List<Parameter> param_list_gold = op_gold.getParameter();

    for (Feature _op_silv : operation_list) {
      boolean match = true;
      Operation op_silv = (Operation) _op_silv;
      if (op_silv.getName().equals(op_gold.getName())) {
        List<Parameter> param_list_silv = op_silv.getParameter();
        if (param_list_silv.size() == param_list_gold.size()) {
          // Return type is not used in matching method signatures.
          for (int i = 1; i < param_list_gold.size(); i++) {
            Parameter param_gold = param_list_gold.get(i);
            String type_gold = param_gold.getType().getName();

            Parameter param_silv = param_list_silv.get(i);
            String type_silv = param_silv.getType().getName();

            if (!type_gold.equals(type_silv)) {
              LOG.log(
                  Level.FINE,
                  "Failed because param types" + " differ: " + type_silv + ", " + type_gold);
              match = false;
              break;
            }
          }
        } else {
          LOG.log(
              Level.FINE,
              "Failed because param list sizes "
                  + "differ"
                  + param_list_silv.size()
                  + ", "
                  + param_list_gold.size());
          match = false;
        }
      } else {
        LOG.log(
            Level.FINE,
            "Failed because function names differ: "
                + op_silv.getName()
                + ", "
                + op_gold.getName());
        match = false;
      }

      if (match) {
        return_list.add(op_silv);
      }
    }

    return return_list;
  }
Beispiel #2
0
  private void setRenameNode() {
    String method_name = null, return_type = null;
    List<Parameter> param_list = target.getParameter();
    Parameter return_param = param_list.get(0);

    method_name = target.getName();
    return_type = return_param.getType() != null ? return_param.getType().getName() : "void";

    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());

    JLabel gui_return_type = new JLabel("Return type:");
    gui_method_return_type = new JTextField(return_type, 15);

    JLabel gui_name = new JLabel("Method name:");
    gui_method_name = new JTextField(method_name, 15);

    cp.add(gui_return_type);
    cp.add(gui_method_return_type);
    cp.add(gui_name);
    cp.add(gui_method_name);

    return_types = new JTextField[param_list.size() - 1];
    param_names = new JTextField[param_list.size() - 1];

    for (int i = 1; i < param_list.size(); i++) {
      Parameter param = param_list.get(i);
      String type = param.getType() != null ? param.getType().getName() : "void";
      return_types[i - 1] = new JTextField(type, 15);
      param_names[i - 1] = new JTextField(param.getName(), 15);

      cp.add(return_types[i - 1]);
      cp.add(param_names[i - 1]);
    }

    setSize(350, 400);

    JButton submitButton = new JButton("Change method signature");
    cp.add(submitButton);
    submitButton.addActionListener(this);
  }