intellij小技巧

2019/08/02 ide

IntelliJ IDEA小技巧,可以mark,很方便

live template(模板,输入字符弹出相应代码)

Add live template->define java

这个例子输入abbreviation->main

public static void main(String[] args){
$END$
}

psvm

public static void main(String[] args)

psfi

public static final int

psfs

public static final String

pi

public int

ps

public String

postfix(变量.*)

Preferences->Editor->General->Postfix Completion

sout

before

public class Foo {
  void m(boolean b) {
    b.sout
  }
}

after

public class Foo {
  void m(boolean b) {
      System.out.println(b);
  }
}
for,fori,forr(倒序)

before

public class Foo {
    void m() {
        int[] values = {1, 2, 3};
        values.for
    }
}

after

public class Foo {
    void m() {
        int[] values = {1, 2, 3};
        for (int value : values) {

        }
    }
}
try

Before

public void m2() {
  m().try
}

public void m() throws CheckedException { }

after

public void m2() {
  try {
    m();
  } catch(CheckedException e) {
    e.printStackTrace();
  }
}

public void m() throws CheckedException { }
null,not,notnull,nn

Before

public class Foo {
    void m(Object o) {
        o.null
    }
}

after

public class Foo {
    void m(Object o) {
        if (o == null){

        }
    }
}
iter

Before

public class Foo {
    void m() {
        int[] values = {1, 2, 3};
        values.iter
    }
}

after

public class Foo {
    void m() {
        int[] values = {1, 2, 3};
        for (int value : values) {

        }
    }
}

查看类图

类名右键->Diagrams->show diagrams

call hierachy调用堆栈

查看当前方法的调用栈 option+control+H

Search

    Table of Contents