History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEABKL-5339
Type: New Feature New Feature
Status: Open Open
Priority: Normal Normal
Assignee: Bas Leijdekkers
Reporter: Tom Adams
Votes: 0
Watchers: 1
Available Workflow Actions

Mark as Stalled
Operations

If you were logged in you would be able to see more operations.
IDEA: Backlog

Add intention to turn list literal creation using List.add() into Arrays.asList()

Created: 06 Nov 07 01:46   Updated: 06 Dec 07 15:46
Component/s: Editor. Intention Actions
Affects Version/s: None
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
Environment: Linux duke 2.6.22-14-generic #1 SMP Sun Oct 14 23:05:12 GMT 2007 i686 GNU/Linux

Build: 7,364


 Description  « Hide
It'd be nice to add an inspection/intention to turn list literal creation using List.add() into Arrays.asList() (and vice-versa).

So this:

final List<Integer> signs = new ArrayList<Integer>();
signs.add(3);
signs.add(9);

Becomes:

final List<Integer> signs = Arrays.asList(3, 9);

It should also handle list creation using anonymous inner classes (and possibly 1.7 closures) like:

final List<Integer> signs = new ArrayList<Integer>() {{
    add(3);
    add(9);
}};

Becomes:

final List<Integer> signs = Arrays.asList(3, 9);

Also, list creation in a loop (loop gets unrolled - loop unrolling itself would be a nice intention):

List<Integer> fiveDays = new ArrayList<Integer>();
for (int i = 1; i <= 5; ++i) {
    fiveDays.add(i);
}

becomes:

List<Integer> fiveDays = Arrays.asList(1, 2, 3, 4, 5);


 All   Comments   Work Log   Change History      Sort Order:
There are no comments yet on this issue.