Package net.sf.rej.gui.editor.row

Examples of net.sf.rej.gui.editor.row.ClassDefRow


    // Class
    if (cfA.getShortClassName().equals(cfB.getShortClassName())
     && cfA.getAccessFlags() == cfB.getAccessFlags()
     && cfA.getSuperClassName().equals(cfB.getSuperClassName())
     && interfacesAreEqual) {
      this.rowsAll.add(new ClassDefRow(cfA, true));
    } else {
      ClassDefRow cdrA = new ClassDefRow(cfA, true);
      ClassDefRow cdrB = new ClassDefRow(cfB, true);
      this.rowsA.add(cdrA);
      this.rowsB.add(cdrB);
      this.rowsAll.add(cdrA);
      this.rowsAll.add(cdrB);
    }
   
    this.rowsAll.add(new BlankRow());

    // Fields
    // TODO: Constant value compare
    Map<String, Field> fieldsA = new HashMap<String, Field>();
    for (Field field : cfA.getFields()) {
      fieldsA.put(field.getSignatureLine(), field);
    }
    Map<String, Field> fieldsB = new HashMap<String, Field>();
    for (Field field : cfB.getFields()) {
      fieldsB.put(field.getSignatureLine(), field);
    }
    Set<String> allFields = new TreeSet<String>();
    allFields.addAll(fieldsA.keySet());
    allFields.addAll(fieldsB.keySet());
    for (String fieldSignature : allFields) {
      // Field annotations
      /* TODO
      RuntimeInvisibleAnnotationsAttribute fieldAnnInvisible = field
          .getAttributes().getRuntimeInvisibleAnnotationsAttribute();
      RuntimeVisibleAnnotationsAttribute fieldAnnVisible = field
          .getAttributes().getRuntimeVisibleAnnotationsAttribute();
      List<Annotation> fieldAnnotations = new ArrayList<Annotation>();
      if (fieldAnnInvisible != null) {
        fieldAnnotations.addAll(fieldAnnInvisible.getAnnotations());
      }
      if (fieldAnnVisible != null) {
        fieldAnnotations.addAll(fieldAnnVisible.getAnnotations());
      }
      for (Annotation annotation : fieldAnnotations) {
        FieldAnnotationDefRow fadr = new FieldAnnotationDefRow(
            annotation);
        this.rows.add(fadr);
      }
       */

      FieldDefRow fdr = null;
      Field field = fieldsA.get(fieldSignature);
      if (field == null) {
        field = fieldsB.get(fieldSignature);
        fdr = new FieldDefRow(cfB, field);
        this.rowsB.add(fdr);
      } else {
        fdr = new FieldDefRow(cfA, field);
        if (!fieldsB.keySet().contains(fieldSignature)) {
          this.rowsA.add(fdr);
        }
      }
     
      this.rowsAll.add(fdr);
    }

    if (allFields.size() > 0) {
      this.rowsAll.add(new BlankRow());
    }

    // Methods
    Map<String, Method> methodsA = new HashMap<String, Method>();
    for (Method method : cfA.getMethods()) {
      Descriptor desc = method.getDescriptor();
      methodsA.put(desc.getReturn() + method.getName() + " " + desc.getParams(), method);
    }
    Map<String, Method> methodsB = new HashMap<String, Method>();
    for (Method method : cfB.getMethods()) {
      Descriptor desc = method.getDescriptor();
      methodsB.put(desc.getReturn() + method.getName() + " " + desc.getParams(), method);
    }

    Set<String> allMethods = new TreeSet<String>();
    allMethods.addAll(methodsA.keySet());
    allMethods.addAll(methodsB.keySet());
    for (String methodTypeNameParams : allMethods) {
      Method methodA = methodsA.get(methodTypeNameParams);
      Method methodB = methodsB.get(methodTypeNameParams);
      if (methodA == null) {
        List<EditorRow> methodRows = getMethodRows(cfB, methodB);
        this.rowsB.addAll(methodRows);
        this.rowsAll.addAll(methodRows);
        // method only exists in B
      } else if (methodB == null) {
        List<EditorRow> methodRows = getMethodRows(cfA, methodA);
        this.rowsA.addAll(methodRows);
        this.rowsAll.addAll(methodRows);
        // method only exists in A
      } else {
        // method exists in both
        addMethodRows(cfA, cfB, methodA, methodB);
      }

      this.rowsAll.add(new BlankRow());
    }

    this.rowsAll.add(new ClassDefRow(cfA, false));
   
    this.renderer.setRedSet(this.rowsA);
    this.renderer.setYellowSet(this.rowsB);

    this.model.clear();
View Full Code Here


    List<EditorRow> list = new ArrayList<EditorRow>();
    for (EditorRow er : this.rowsAll) {
      if (er instanceof PackageDefRow) {
        list.add(er);
      } else if (er instanceof ClassDefRow) {
        ClassDefRow cdr = (ClassDefRow) er;
        if (!cdr.isClosing()) {
          list.add(er);
        }
      } else if (er instanceof FieldDefRow) {
        list.add(er);
      } else if (er instanceof MethodDefRow) {
View Full Code Here

      ClassAnnotationDefRow adr = new ClassAnnotationDefRow(annotation);
      this.rows.add(adr);
    }

    // Class
    this.classDef = new ClassDefRow(cf, true);
    this.rows.add(this.classDef);
    this.rows.add(new BlankRow());

    // Fields
    java.util.List fields = cf.getFields();
    for (int i = 0; i < fields.size(); i++) {
      Field field = (Field) fields.get(i);

      // Field annotations
      RuntimeInvisibleAnnotationsAttribute fieldAnnInvisible = field
          .getAttributes().getRuntimeInvisibleAnnotationsAttribute();
      RuntimeVisibleAnnotationsAttribute fieldAnnVisible = field
          .getAttributes().getRuntimeVisibleAnnotationsAttribute();
      List<Annotation> fieldAnnotations = new ArrayList<Annotation>();
      if (fieldAnnInvisible != null) {
        fieldAnnotations.addAll(fieldAnnInvisible.getAnnotations());
      }
      if (fieldAnnVisible != null) {
        fieldAnnotations.addAll(fieldAnnVisible.getAnnotations());
      }
      for (Annotation annotation : fieldAnnotations) {
        FieldAnnotationDefRow fadr = new FieldAnnotationDefRow(
            annotation);
        this.rows.add(fadr);
      }

      FieldDefRow fdr = new FieldDefRow(cf, field);
      this.rows.add(fdr);
      this.classDef.addField(fdr);
    }

    if (fields.size() > 0) {
      this.rows.add(new BlankRow());
    }

    // Methods
    java.util.List methods = cf.getMethods();
    for (int i = 0; i < methods.size(); i++) {
      Method method = (Method) methods.get(i);

      // Method annotations
      boolean deprecatedAnnotationAdded = false;
      RuntimeInvisibleAnnotationsAttribute methodAnnInvisible = method
          .getAttributes().getRuntimeInvisibleAnnotationsAttribute();
      RuntimeVisibleAnnotationsAttribute methodAnnVisible = method
          .getAttributes().getRuntimeVisibleAnnotationsAttribute();
      List<Annotation> methodAnnotations = new ArrayList<Annotation>();
      if (methodAnnInvisible != null) {
        methodAnnotations.addAll(methodAnnInvisible.getAnnotations());
      }
      if (methodAnnVisible != null) {
        methodAnnotations.addAll(methodAnnVisible.getAnnotations());
      }
      for (Annotation annotation : methodAnnotations) {
        MethodAnnotationDefRow madr = new MethodAnnotationDefRow(
            annotation);
        this.rows.add(madr);
        if ("java.lang.Deprecated".equals(annotation.getName())) {
          deprecatedAnnotationAdded = true;
          // store this information so that
          // the Deprecated attribute isn't used to
          // create another deprecation EditorRow
        }
      }

      Attributes attr = method.getAttributes();
      CodeAttribute codeAttr = attr.getCode();
      MethodDefRow mdr = new MethodDefRow(cf, method, true,
          codeAttr != null);
      if (!deprecatedAnnotationAdded && method.isDeprecated()) {
        DeprecatedAnnotationDefRow ddr = new DeprecatedAnnotationDefRow();
        this.rows.add(ddr);
      }
      this.rows.add(mdr);
      this.classDef.addMethod(mdr);
      LineNumberTableAttribute lnAttr = null;
      LocalVariableTableAttribute lvs = null;
      if (codeAttr != null) {
        if (codeAttr.getAttributes() != null) {
          lnAttr = codeAttr.getAttributes().getLineNumberTable();
          lvs = codeAttr.getAttributes().getLocalVariableTable();
        }
        Code code = codeAttr.getCode();
        DecompilationContext dc = code.createDecompilationContext();
        dc.setPosition(0);
        for (Instruction instruction : code.getInstructions()) {

          if (instruction instanceof Label) {
            LabelRow lr = new LabelRow((Label) instruction, mdr);
            lr.setParentCode(code);
            this.rows.add(lr);
            mdr.addCodeRow(lr);
          } else {
            int lineNumber = -1;

            if (lnAttr != null) {
              lineNumber = lnAttr.getLineNumber(dc.getPosition());
            }
            if (lvs != null) {
              List locals = lvs
                  .getLocalVariable(dc.getPosition());
              for (int k = 0; k < locals.size(); k++) {
                LocalVariable lv = (LocalVariable) locals
                    .get(k);
                LocalVariableDefRow lvdr = new LocalVariableDefRow(
                    lv, mdr);
                this.rows.add(lvdr);
                mdr.addLocalVariable(lvdr);
              }
            }

            CodeRow cd = new CodeRow(cf, mdr, instruction);
            cd.setPosition(dc.getPosition());
            cd.setDecompilationContext(dc);
            cd.setParentCode(code);
            cd.setBreakpoint(EditorFacade.getInstance()
                .getBreakpoint(cf.getFullClassName(),
                    method.getName(),
                    method.getDescriptor(),
                    dc.getPosition()));

            if (lineNumber != -1) {
              cd.setLineNumber(lineNumber);
            }

            this.rows.add(cd);
            mdr.addCodeRow(cd);

            dc.incrementPosition(instruction);
          }

        }

        this.rows.add(new MethodDefRow(cf, method, false, true));
      }
      this.rows.add(new BlankRow());
    }

    this.rows.add(new ClassDefRow(cf, false));

    this.label.setText("Bytecode Editor: " + cf.getFullClassName());
    this.model.clear();
    for (EditorRow er : rows) {
      this.model.addElement(er);
View Full Code Here

        EditorFacade.getInstance().modifyField(
            fdr.getClassFile().getPool(), fdr.getField(), name,
            desc, af);
      }
    } else if (o instanceof ClassDefRow) {
      ClassDefRow cdr = (ClassDefRow) o;
      ClassFile cf = cdr.getClassFile();
      this.classEditor.invoke(cf.getFullClassName(), cf
          .getSuperClassName(), cf.getAccessFlags(), cf
          .getInterfaces());

      if (!this.classEditor.wasCancelled()) {
View Full Code Here

      wrapper.setContent(er);
      if (er instanceof PackageDefRow) {
        PackageDefRow pdr = (PackageDefRow)er;
        wrapper.setDisplay(pdr.getPackage());
      } else if (er instanceof ClassDefRow) {
        ClassDefRow cdr = (ClassDefRow)er;
        wrapper.setDisplay(cdr.getClassFile().getShortClassName());
      } else if (er instanceof FieldDefRow) {
        FieldDefRow fdr = (FieldDefRow)er;
        wrapper.setDisplay(fdr.getField().getName());
      } else if (er instanceof MethodDefRow) {
        MethodDefRow mdr = (MethodDefRow)er;
View Full Code Here

        } else if (er instanceof ClassCommentRow) {
          ClassCommentRow ccr = (ClassCommentRow) er;
          sd.drawComment("// ");
          sd.drawComment(ccr.getComment());
        } else if (er instanceof ClassDefRow) {
            ClassDefRow cdr = (ClassDefRow)er;
            if (cdr.isClosing()) {
                sd.drawDefault("}");
            } else {
                ClassFile cf = cdr.getClassFile();
                ClassSignature classSig = null;
               
            boolean displayGenerics = SystemFacade.getInstance().getPreferences().isSettingTrue(Settings.DISPLAY_GENERICS);
                if (displayGenerics) {
                  SignatureAttribute signature = cf.getAttributes().getSignatureAttribute();
View Full Code Here

TOP

Related Classes of net.sf.rej.gui.editor.row.ClassDefRow

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.