Package net.sf.rej.java

Examples of net.sf.rej.java.ClassFile


            if (!this.project.isModified(targetFile)) {
              // is the file in question is not modified yet, group the new action
              // with an action that changes the status of the file.
                GroupAction ga = new GroupAction();
                ga.add(action);
              ClassFile cf = getClassFile(targetFile);
                ga.add(new MarkClassFileModifiedAction(this.project, targetFile, cf));
                um.add(ga);
                ga.execute();
            } else {
              um.add(action);
View Full Code Here


    public void goTo(Link link) {
        if (link.getFile() != null) {
          if (!link.getFile().equals(this.openFile)) {
        Event event = new Event(EventType.CLASS_OPEN);
        try {
          ClassFile cf = this.project.getClassFile(link.getFile());
          event.setClassFile(cf);
          event.setFile(link.getFile());
          this.dispatcher.notifyObservers(event);
        } catch(Exception ex) {
          SystemFacade.getInstance().handleException(ex);
View Full Code Here

            // of classes that are not in the open project(but are in the
            // classpath)
            try {
                byte[] data = classLocator.getFileSet().getData(
                        classLocator.getFile());
                ClassFile cf = Disassembler.readClass(data);
                return cf;
            } catch (Exception e) {
                throw new ClassParsingException("Error opening file "
                        + classLocator.dumpDetails(), e);
            }
View Full Code Here

    }
    }

    public void createNewClass(String fullClassName, String selectedFile) {
        // TODO: Creating a new class should be an undoable action?
        ClassFile cf = this.classFactory.createClass(fullClassName);
        this.project.addFile(selectedFile, cf);
       
        /* TODO: the file hasn't been saved into the set yet at this point
         * sor the following throws a NullPointerException
        try {
View Full Code Here

      ic.setFilename(filename);
      agent.processFile(filename);
      if (!filename.endsWith(".class"))
        continue;
      try {
        ClassFile cf = this.project.getClassFile(filename);
        ic.setCf(cf);
        agent.processClass(ic, cf);
       
        ConstantPool cp = cf.getPool();
        for (int i=0; i < cp.size(); i++) {
          ConstantPoolInfo cpi = cp.get(i);
          if (cpi != null) {
            agent.processConstantPoolInfo(ic, cpi);           
          }
        }

        List<Interface> interfaces = cf.getInterfaces();
        for (Interface interface0 : interfaces) {
          agent.processInterface(ic, interface0.getName());
        }

        List<Field> fields = cf.getFields();
        for (Field field : fields) {
          ic.setField(field);
          agent.processField(ic, field);
        }

        List<Method> methods = cf.getMethods();
        for (Method method : methods) {
          ic.setMethod(method);
          agent.processMethod(ic, method);

          CodeAttribute ca = method.getAttributes().getCode();
          ic.setCodeAttribute(ca);
          if (ca != null) {
            processAttributes(ic, ca.getAttributes(), agent);
          }
          // method variables
          LocalVariableTableAttribute lvt = null;
          if (ca != null) {
            lvt = ca.getAttributes().getLocalVariableTable();
          }
          if (lvt != null) {
            List<LocalVariable> lvs = lvt.getLocalVariables();

            for (LocalVariable lv : lvs) {
              agent.processLocalVariable(ic, lv);
            }
          }

          // method code
          Code code = null;
          if (ca != null)
            code = ca.getCode();
          if (code != null) {
            DecompilationContext dc = code
                .createDecompilationContext();
            ic.setDc(dc);
            dc.setPosition(0);
            List<Instruction> instructions = code.getInstructions();
            for (Instruction instruction : instructions) {
              agent.processInstruction(ic, instruction);
              dc.incrementPosition(instruction);
            }
          }

          processAttributes(ic, method.getAttributes(), agent);

        }

        processAttributes(ic, cf.getAttributes(), agent);

        agent.postProcessFile(ic);
      } catch (Exception ex) {
        ex.printStackTrace();
        agent.processException(ex);
View Full Code Here

        } 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();
                  if (signature != null) {
                    classSig = Signatures.getClassSignature(signature.getSignatureString());
                  }
                }
               
                String access = cf.getAccessString();
                if (access.length() > 0) {
                    sd.drawKeyword(access + " ");
                }

                if (AccessFlags.isEnum(cf.getAccessFlags())) {
                  sd.drawKeyword("enum ");
                } else if (AccessFlags.isAnnotation(cf.getAccessFlags())) {
                  sd.drawKeyword("@interface ");
                } else if (AccessFlags.isInterface(cf.getAccessFlags())) {
                      sd.drawKeyword("interface ");
                } else {
                  sd.drawKeyword("class ");
                }

                sd.drawDefault(cf.getShortClassName());
                String superClass = cf.getSuperClassName();
               
                 if (classSig != null) {
                     renderFormalTypeParameters(sd, ia, classSig.getFormalTypeParameters());
                }
                
                 sd.drawDefault(" ");
               
                if (superClass != null) {
                  boolean displayExtendsObject = SystemFacade.getInstance().getPreferences().isSettingTrue(Settings.DISPLAY_EXTENDS_OBJECT);
                  if (!superClass.equals("java.lang.Object") ||
                    displayExtendsObject) {
                    sd.drawKeyword("extends ");
                    if (classSig == null) {
                      sd.drawDefault(ia.getShortName(superClass));
                    } else {
                      renderGenericJavaType(sd, ia, classSig.getSuperClassSignature());
                    }
                    sd.drawDefault(" ");
                  }
                }

                List interfaces = cf.getInterfaces();
                if (interfaces.size() > 0) {
                    if (AccessFlags.isInterface(cf.getAccessFlags())) {
                      sd.drawKeyword("extends ");
                    } else {
                      sd.drawKeyword("implements ");
                    }
                    if (classSig == null) {
View Full Code Here

    void updateFieldList() {
        this.fieldModel.removeAllElements();
        Object obj = this.cls.getSelectedItem();
        try {
            ClassFile cf = null;
            if (obj instanceof String) {
                // TODO: let user type his own class name?
            } else if (obj instanceof ClassLocator) {
                ClassLocator cl = (ClassLocator) obj;
                cf = SystemFacade.getInstance().getClassFile(cl);
            }

            // cf will be null if referenced class is not in project classpath
            if (cf != null) {
                List fields = cf.getFields();
                for (int i = 0; i < fields.size(); i++) {
                    Field field = (Field)fields.get(i);
                    Wrapper<Field> wrapper = new Wrapper<Field>();
                    wrapper.setContent(field);
                    wrapper.setDisplay(field.getSignatureLine());
View Full Code Here

    void updateMethodList() {
        this.methodModel.removeAllElements();
        Object obj = this.cls.getSelectedItem();
        try {
            ClassFile cf = null;
            if (obj instanceof String) {
                // TODO: let user type his own class name?
            } else if (obj instanceof ClassLocator) {
                ClassLocator cl = (ClassLocator) obj;
                cf = SystemFacade.getInstance().getClassFile(cl);
            }

            // cf will be null if referenced class is not in project classpath
            if (cf != null) {
                List methods = cf.getMethods();
                for (int i = 0; i < methods.size(); i++) {
                    Method method = (Method) methods.get(i);
                    Wrapper<Method> wrapper = new Wrapper<Method>();
                    wrapper.setContent(method);
                    wrapper.setDisplay(method.getSignatureLine());
View Full Code Here

      Descriptor desc) {
    try {
      ClassIndex ci = SystemFacade.getInstance().getClassIndex();
      ClassLocator cl = ci.getLocator(className);
      if (cl != null && cl.getFileSet().equals(this.openProject.getFileSet())) {
        ClassFile cf = SystemFacade.getInstance().getClassFile(cl);
        List methods = cf.getMethods();
        Method method = null;
        for (int i = 0; i < methods.size(); i++) {
          Method m = (Method) methods.get(i);
          if (m.getName().equals(methodName)
              && m.getDescriptor().equals(desc)) {
View Full Code Here

      Descriptor desc) {
    try {
      ClassIndex ci = SystemFacade.getInstance().getClassIndex();
      ClassLocator cl = ci.getLocator(className);
      if (cl != null && cl.getFileSet().equals(this.openProject.getFileSet())) {
        ClassFile cf = SystemFacade.getInstance().getClassFile(cl);
        List fields = cf.getFields();
        Field field = null;
        for (int i = 0; i < fields.size(); i++) {
          Field f = (Field) fields.get(i);
          if (f.getName().equals(fieldName)
              && f.getDescriptor().equals(desc)) {
View Full Code Here

TOP

Related Classes of net.sf.rej.java.ClassFile

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.