This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | "Introduce method" puts new method in an arbitrary location | ||
---|---|---|---|
Product: | java | Reporter: | jnicol <jnicol> |
Component: | Hints | Assignee: | Svata Dedic <sdedic> |
Status: | REOPENED --- | ||
Severity: | blocker | ||
Priority: | P2 | ||
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | ENHANCEMENT | Exception Reporter: | |
Attachments: | Patch that fixes the sorting issue for introduced methods |
Description
jnicol
2008-11-07 16:03:26 UTC
I don't think this is a defect, but this behavior could certainly enhance user's experience, IMO -> P2 Enhancement. Created attachment 78859 [details]
Patch that fixes the sorting issue for introduced methods
The attached patch should fix the issue. The problem was caused because introduced methods were being sorted in the same way as introduced classes. (Although classes have a defined order per the Java Sun coding standards, methods are to be put in a functional order, so this fix makes sense.) I was not certain if the fix also needed to be applied to the class IntroduceExpressionBasedMethodFix, so I left that one the same. If it does need to be applied to that class, it should only require changing the same three lines as changed in IntroduceMethodFix. Can this be added to the 6.8 release? There is an attached patch for this. Thanks for your contribution. There is already an implementation in org.netbeans.api.java.source.GeneratorUtilities, which adds even more logic. ie. GeneratorUtilities.get(copy).insertClassMember((ClassTree)pathToClass.getLeaf(), method); I'll fix this soon. Integrated into 'main-golden', will be available in build *200909021401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/27d3056062a7 User: Max Sauer <msauer@netbeans.org> Log: #152701: "Introduce method" puts new method in an arbitrary location I verified that the original sample works. However, a similar one does not. public class Main { private void main() {} void blah() { int i=5; } } If you highlight "int i=5;", and introduce a method called "a", then the method "a" appears ABOVE main(). If you highlight "int i=5;", and introduce a method called "c", then the method "c" appears BELOW blah(). |