Bug 112072 - [refactoring] [extract method] Extract method should recognize differing constants as parameter opportunities
Summary: [refactoring] [extract method] Extract method should recognize differing cons...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P4 enhancement with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: Dirk Baeumer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-09 21:07 EDT by David Saff CLA
Modified: 2014-04-15 15:44 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Saff CLA 2005-10-09 21:07:22 EDT
Consider this code:

ArrayList allKinds = new TestKindRegistry(point).getAllKinds();
assertEquals("id3", ((TestKind) allKinds.get(0)).getId());
assertEquals("id1", ((TestKind) allKinds.get(1)).getId());
assertEquals("id2", ((TestKind) allKinds.get(2)).getId());

It would be really useful if extracting a method from the first line would offer
a method that was parameterized on a String, an ArrayList, and an int, with two
duplications to replace, resulting in

ArrayList allKinds = new TestKindRegistry(point).getAllKinds();
assertHasId("id3", allKinds, 0);
assertHasId("id1", allKinds, 1);
assertHasId("id2", allKinds, 2);
Comment 1 Dirk Baeumer CLA 2006-04-03 10:49:06 EDT
Postponing > 3.2
Comment 2 Markus Keller CLA 2009-05-04 06:27:03 EDT
> It would be really useful if extracting a method from the first line [..]

Not from the first line, but from:

    assertEquals("id3", ((TestKind) allKinds.get(0)).getId());

, extract method:

    void assertHasId(String id, ArrayList allKinds, int i) {
        assertEquals(id, ((TestKind) allKinds.get(i)).getId());
    }
Comment 3 Jean-Noel Rouvignac CLA 2012-01-20 02:21:49 EST
This seems related to bug 183189.