⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 movemethod.java

📁 emacs的一个非常有用的插件,叫xrefactory,可以实现source insight里的那种函数跳转.和cscope(跳回来不方便)配合使用,非常的不错.
💻 JAVA
字号:
package com.xrefactory.refactorings;/*  Move method  'participate' from class  Person into class  Project by  composing following three refactorings:  1.)   Put cursor  on  'participate'  method and  make  it static  by  pressing  F11   and  selecting  'Turn  Dynamic   Method  to  Static'  refactoring.  When  prompted  for  the  new  parameter  name,  press  <return> to accept default value.  2.)   Move it into  class Project  using F11,  'Set Target  for Next  Moving Refactoring' and F11, 'Move Static Method'.  3.)   Turn it  back to  virtual method  using F11  and  'Turn Static  Method to Dynamic'.  Determine  target object via 2-nd parameter and  empty field name.*/class Project {    Person[] participants;    // set target position here}class Person {    int id;    // cursor has to be on method name    public boolean participate(Project proj) {        for(int i=0; i<proj.participants.length; i++) {            if (proj.participants[i].id == id) return(true);        }        return(false);    }       Person(int id) {this.id=id;}}class MoveMethod {    public static void main(String[] args) {        Person[] pparticipants = {new Person(5), new Person(7)};        Project pp = new Project();        pp.participants = pparticipants;        System.out.println("part 3 "+ (new Person(3)).participate(pp));        System.out.println("part 5 "+ (new Person(5)).participate(pp));    }}/*  (multiple) F5 will bring you back to Index*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -