简体   繁体   中英

Inspection of long condition bodies using Intellij Idea

I want to find and re-factor code snippets like this:

@Override
public void init() {
    if (!initialized) {
        super.init();
        setSizeFull();
        initLayout();
        initTable();
        initButtons();
        initialized = true;
    }
}

to

@Override
public void init() {
    if (initialized) {
        return;
    }
    super.init();
    setSizeFull();
    initLayout();
    initTable();
    initButtons();
    initialized = true;
}

I couldn't find any way to find all snippets like this in my code. I've tried regular expression but I could not write a valid regular expression to find them. If there is any solution I would like to hear it. Thanks...

您可以使用结构搜索和替换(编辑|查找|结构替换)来查找和重构此类代码片段。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM