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.

Bug 134429

Summary: Autocompletion in class-inside-method should include non-final matches in method scope
Product: java Reporter: _ tboudreau <tboudreau>
Component: EditorAssignee: Dusan Balek <dbalek>
Status: NEW ---    
Severity: blocker CC: markiewb
Priority: P3    
Version: 6.x   
Hardware: Macintosh   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description _ tboudreau 2008-05-02 19:56:16 UTC
If in inner class in method, completions should include non-final objects in scope and automatically final them if necessary.  Example:

 public void testLongDescription() {
        System.out.println("testLongDescription");
        Wizard w = WizardPage.createWizard(new Class[] { AP.class });
        EventQueue.invokeAndWait(new Runnable() {
            public void run() {
                WizardDisplayer.showWizard(w);
            }
        });
        String s = w.getLongDescription("one");
        assertEquals ("LONG DESCRIPTION", ((AP) jc).getLongDescription());
        assertEquals ("LONG DESCRIPTION", s);
    }

I am adding the EventQueue.invokeAndWait() call and creating the runnable.  I complete WizardDisplayer.showWizard(), which takes an argument of Wizard.  
The variable w is in scope, but it is not final.  So code completion supplies a bogus variable "wizard".

It would be better if it would offer "w" and if I accept it, it would add "final" before the line beginning "Wizard w".