Search code examples
javaintellij-ideaintellij-13

Can I automatically pass an existing text into the method parameter?


For example I have the following block of code:

public String getDbSchema() {
    return DB_SCHEMA;
}

Is there a shortcut to quickly turn this code into

public String getDbSchema() {
    return properties.getProperty(DB_SCHEMA);
}

Currently I have to do properties.getproperty then take out right bracket and re-insert it into the end of the statement


Solution

  • When you select getProperty from the code completion, instead of pressing Enter, press the shortcut of Edit | Complete Current Statement (e.g. Ctrl+Shift+Enter), and DB_SCHEMA will be wrapped into call parentheses.