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 215257 - Refactoring "change method parameters" does not import/qualify type correctly, when choosing type from code completion
Summary: Refactoring "change method parameters" does not import/qualify type correctly...
Status: REOPENED
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: Ralph Ruijs
URL:
Keywords:
: 251344 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-07-08 20:07 UTC by everflux
Modified: 2016-07-10 17:34 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Shows the issue (17.17 KB, image/png)
2016-07-10 17:34 UTC, markiewb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description everflux 2012-07-08 20:07:38 UTC
[ BUILD # : 201206291011 ]
[ JDK VERSION : 1.7.5 ]

Input:

package refactoringdemo;

import java.io.File;
import java.util.Scanner;

public class RefactoringDemo
{
    public static void main(String[] args) throws Exception
    {
        File file = new File("example");
        analyzeFile(file);
    }
    
    private static void analyzeFile(final File file) throws
java.io.FileNotFoundException
    {
        Scanner scanner = new Scanner(file);
        
        while(scanner.hasNext())
        {
            String nextLine = scanner.nextLine();
            System.out.println(nextLine);
        }
    }

}

Select "analyzeFile" and "Refactor->Change Method Parameters"
Change Type to "InputStream" by (important!) clicking on "File" and then typing
"IStream<ctrl>+<space>,<return>"
Change Name to "is"
Code Generation: Create new Method and Delegate

Result:

package refactoringdemo;

import java.io.File;
import java.util.Scanner;

public class RefactoringDemo
{
    public static void main(String[] args) throws Exception
    {
        File file = new File("example");
        analyzeFile(file);
    }
    
    private static void analyzeFile(final File is) throws
java.io.FileNotFoundException
    {
        analyzeFile(is);
    }

    private static void analyzeFile(final InputStream file) throws
java.io.FileNotFoundException
    {
        Scanner scanner = new Scanner(is);
        
        while(scanner.hasNext())
        {
            String nextLine = scanner.nextLine();
            System.out.println(nextLine);
        }
    }

}

Note: The "InputStream" type is neither imported, nor is is specified as fully
qualified type, leading to an error. This does *not* happen when the type is
specified by clicking on the "..." and choosing the type in the dialog. It will
be fully qualified then,

Note: The "new Scanner(is)" refers to a not specified method parameter. (See
previous bug report 215256)
Comment 1 Ralph Ruijs 2015-03-23 13:17:02 UTC
*** Bug 251344 has been marked as a duplicate of this bug. ***
Comment 2 Martin Balin 2016-07-07 07:18:29 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss
Comment 3 markiewb 2016-07-10 17:34:11 UTC
Created attachment 160334 [details]
Shows the issue

Still valid in 8.2 dev 
Product Version: NetBeans IDE Dev (Build 201607100002)