Evil Washing Machine
Evil Washing Machine

Reputation: 1341

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

Upvotes: 1

Views: 50

Answers (2)

Peter Gromov
Peter Gromov

Reputation: 18911

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.

Upvotes: 1

vikingsteve
vikingsteve

Reputation: 40378

Sure, you can use a structural find and replace that is a little bit smart.

First, let's presume that this code has the form return XYZ; where XYZ is a constant identifier (CAPS or _)

Then you can go into search and replace in files (ctrl+shift+R), tick Case Sensitive and Regular Expression and enter:

Text to find: return ([A-Z_]*);

Replace with: return properties.getProperty($1);

Upvotes: 1

Related Questions