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 45481 - [40cat] Cannot rename empty package in Project tab
Summary: [40cat] Cannot rename empty package in Project tab
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 4.x
Hardware: PC Windows XP
: P2 blocker (vote)
Assignee: Tomas Zezula
URL:
Keywords: UI
Depends on:
Blocks: 41535
  Show dependency tree
 
Reported: 2004-06-23 15:48 UTC by Lukas Hasik
Modified: 2006-09-14 10:32 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Hasik 2004-06-23 15:48:28 UTC
[200406230100]

-there is no way to rename empty package in IDE

refactoring doesnt provide its action
'Refactor->Rename' on empty packages (issue 44895)
and the 'normal' Rename is disabled(grey) on empty
package.

I dont see any reason why it shouldn't work. If
it's empty then can be simply renamed to anything
e.g. package 'a.b.c' can be easily renamed to
'd.e'=> just delete last package part 'c' and
create new (if doesn't exist) 'd.e'

The greyed=disabled 'Rename' on empty package
looks strange.
Comment 1 Petr Hrebejk 2004-07-21 14:05:38 UTC
Huh, that's a mess. 
Comment 2 jrojcek 2004-07-21 14:30:43 UTC
Sounds reasonable to me from UI perspective. It should be possible to rename an empty 
package.
Comment 3 Jesse Glick 2004-08-10 03:54:47 UTC
Appears to be controlled by the refactoring module, not java/project.
Main menu item Refactor -> Rename... also explicitly refuses to
operate on the default package.
Comment 4 Martin Matula 2004-08-10 08:39:37 UTC
This is not controlled by refactoring module, since in case of empty
packages the refactoring module delegates to the default rename action
since there is nothing to refactor. AFAIK it is java/project module
that disables the rename action (we don't do that).
Comment 5 Jesse Glick 2004-08-10 17:37:35 UTC
Actually there are two potential bugs.

1. An empty package cannot be renamed. This is I think the fault of
PackageViewChildren.

2. The default package (even if not empty) cannot be renamed as a
refactoring operation. This is I think the fault of the refactoring
module.

Right?
Comment 6 Jan Chalupa 2004-08-27 06:40:23 UTC
Quoting from related (already closed) issue #44895:

"For javac compiler it is not a package ;)"

I don't buy this argument. Are we building an IDE for the javac
compiler or for human users?

Recently pointed out by NetCAT participants. Raising priority and
adding '[40cat]' prefix.



Comment 7 Jan Chalupa 2004-08-27 06:42:28 UTC
Quoting from related (already closed) issue #44895:

"For javac compiler it is not a package ;)"

I don't buy this argument. Are we building an IDE for the javac
compiler or for human users?

Recently pointed out by NetCAT participants. Raising priority and
adding '[40cat]' prefix.



Comment 8 Jan Becicka 2004-08-27 07:16:17 UTC
> "For javac compiler it is not a package ;)"

> I don't buy this argument. Are we building an IDE for the javac
compiler or for human users?

It was argument, that we cannot do refactoring if this package does
not exists. We surely do IDE for human users. Maybe you missed my
previous comment: "I don't say that this is not a bug". I should
probably stop adding comments which are irrelevant for end users. 

BTW If you disable refactoring module, you will be unable to rename
any package.

Comment 9 Jan Chalupa 2004-08-27 08:59:32 UTC
Re: "we cannot do refactoring if this package does not exists"

The package does exist. IDE just let me create it. The fact that the
refacroring infrastructure doesn't know about it is an implementation
detail (perhaps a flaw).

In theory, I might create an empty package and start adding 'import
myeptypackage.*' statements to my sources and then go to
refactor/rename it and expect that everything would work.
Comment 10 Jan Becicka 2004-08-27 09:20:43 UTC
This kind of discussion does not lead anywhere.
There are two meanings of "package":
One package is provided by java/project. This package represents
folder structure. And other "package" comes from JLS. This package is
declared by package statement. (BTW if you do your scenario and add
'import
myeptypackage.*' statements. This statements will be marked with error
annotation saying, that myeptypackage does not exists - although
you've created it in the IDE).

Refactoring module unfortunately must work with both terms
consistently, which is sometimes almost impossible.
Comment 11 Martin Matula 2004-08-27 09:44:37 UTC
I don't see how the last 5 comments relate to this bug.
Rename of empty package is disabled by the projects, it is a known
problem (as apparent from previous comments) and should be fixed.

Regarding refactoring of empty packages, it is not possible and is as
designed. There is nothing to refactor in this case. Although one
might argue that somebody can have import mypackage.* in their code
and want's it to be renamed, it is an erroneous code and there will be
the same number (i.e. zero) of classes imported before and after the
rename of mypackage and the compiler/editor will still report the same
error about the import statement, so, I don't see the problem.
Comment 12 Martin Matula 2004-08-27 09:50:07 UTC
Just to be picky...

> The package does exist. IDE just let me create it. The fact that the
> refacroring infrastructure doesn't know about it is an implementation
> detail (perhaps a flaw).

If you call this a flaw in refactoring implementation, perhaps you
should also file an issue against the build system. I've just created
an empty package in the IDE (as you say) and imported it by Main
class. Compiled that Main class in the IDE and the IDE replied with:

Compiling 1 source file to
/home.local/martin/JavaApplication16/build/classes
/home.local/martin/JavaApplication16/src/javaapplication16/Main.java:9:
package empty does not exist
import empty.*;
1 error
Comment 13 Lukas Hasik 2004-08-27 10:53:46 UTC
Martin, let me introduce a scenario :)

We have two developers working on same project. Call them Pat and Mat.
Pat is responsible for package pat.hnusak and Mat for mat.dulezite
Pat is lazy and Mat have already included his package 'pat.hnisak; to
be imported (import pat.hnusak.*;) in some classes because he will
need to use Pat's classes when Pat will create them. 
Pat is not only lazy he is a little bit foolish and before he started
coding his part of project, he renamed the package 'pat.hnisak' to
'pat.lenivec'. AND to save Mat's time he wants to refactor his code too.

Does it really look so strange ? 
"People are strange" as Jim - the Lizard's king said.
Comment 14 Martin Matula 2004-08-27 13:15:58 UTC
If somebody feels strongly that we should support the scenario
presented by Lukas, please file a new enhancement request against
refactoring. I will not comment on whether I think it is strange -
last couple of days I feel like I am from a different planet. I guess
it must be my wedding fever. :)
Comment 15 Jan Chalupa 2004-08-27 13:33:52 UTC
Lukas' example is a variant of what has been discussed previously. I
understand that references to empty packages via 'import xxx.*' cause
compile errors and for the same reason empty packages cannot be
renamed via refactoring. Let's close this dicussion and focus on the
main problem: There's currently no way to rename an empty package in
the Projects view.
Comment 16 Jesse Glick 2004-08-31 00:05:44 UTC
So as I say, PackageViewChildren is presumably responsible for not
permitting an empty package to be renamed.

I filed a separate issue #48200 regarding the impossibility of moving
the default package, for easier tracking.
Comment 17 Jan Becicka 2004-08-31 12:58:35 UTC
I enabled rename refactoring for default package and also for folders,
which are not packages, but contain files.

Hrebejku, please enable rename action for empty folders:

Checking in src/org/netbeans/modules/refactoring/CheckUtils.java;
/cvs/refactoring/src/org/netbeans/modules/refactoring/CheckUtils.java,v
 <--  CheckUtils.java
new revision: 1.6; previous revision: 1.5
done
Processing log script arguments...
More commits to come...
Checking in
src/org/netbeans/modules/refactoring/api/MoveClassRefactoring.java;
/cvs/refactoring/src/org/netbeans/modules/refactoring/api/MoveClassRefactoring.java,v
 <--  MoveClassRefactoring.java
new revision: 1.24; previous revision: 1.23
done
Processing log script arguments...
More commits to come...
Checking in src/org/netbeans/modules/refactoring/ui/RSMJavaDOAction.java;
/cvs/refactoring/src/org/netbeans/modules/refactoring/ui/RSMJavaDOAction.java,v
 <--  RSMJavaDOAction.java
new revision: 1.6; previous revision: 1.5
done
Checking in src/org/netbeans/modules/refactoring/ui/RefactoringPanel.java;
/cvs/refactoring/src/org/netbeans/modules/refactoring/ui/RefactoringPanel.java,v
 <--  RefactoringPanel.java
new revision: 1.15; previous revision: 1.14
done
Checking in src/org/netbeans/modules/refactoring/ui/RenameAction.java;
/cvs/refactoring/src/org/netbeans/modules/refactoring/ui/RenameAction.java,v
 <--  RenameAction.java
new revision: 1.15; previous revision: 1.14
done
Checking in
src/org/netbeans/modules/refactoring/ui/RenameRefactoringUI.java;
/cvs/refactoring/src/org/netbeans/modules/refactoring/ui/RenameRefactoringUI.java,v
 <--  RenameRefactoringUI.java
new revision: 1.10; previous revision: 1.9
done
Comment 18 Jesse Glick 2004-08-31 13:36:08 UTC
What is a rename refactoring for "folders which are not packages but
which contain files"?? Isn't that simply renaming the folder?
Comment 19 Jan Becicka 2004-08-31 13:55:08 UTC
Let's have folder:
"org/netbeans" and a class in it Test.java:

package incorrect;
public class Test {
.
.
.
}

User wants to rename org.netbeans to com.netpeas. There is no package
org.netbeans defined in source files. But regardless of this fact
class Test is moved into new package com.netpeas.

But, in most cases it is simply the same as renaming folders.

Comment 20 Tomas Zezula 2004-09-06 15:25:55 UTC
Checking in
project/src/org/netbeans/spi/java/project/support/ui/PackageViewChildren.java;
/cvs/java/project/src/org/netbeans/spi/java/project/support/ui/PackageViewChildren.java,v
 <--  PackageViewChildren.java
new revision: 1.36; previous revision: 1.35
done
Processing log script arguments...
More commits to come...
Checking in
project/test/unit/src/org/netbeans/spi/java/project/support/ui/PackageViewTest.java;
/cvs/java/project/test/unit/src/org/netbeans/spi/java/project/support/ui/PackageViewTest.java,v
 <--  PackageViewTest.java
new revision: 1.15; previous revision: 1.14
done
Comment 21 Tomas Zezula 2004-09-07 10:10:37 UTC
Fixed rename of a.b.c to a.b
Added checking of package name validity
Checking in
project/src/org/netbeans/spi/java/project/support/ui/PackageViewChildren.java;
/cvs/java/project/src/org/netbeans/spi/java/project/support/ui/PackageViewChildren.java,v
 <--  PackageViewChildren.java
new revision: 1.39; previous revision: 1.38
done
Processing log script arguments...
More commits to come...
Checking in
project/test/unit/src/org/netbeans/spi/java/project/support/ui/PackageViewTest.java;
/cvs/java/project/test/unit/src/org/netbeans/spi/java/project/support/ui/PackageViewTest.java,v
 <--  PackageViewTest.java
new revision: 1.16; previous revision: 1.15
done
Comment 22 Lukas Hasik 2006-09-14 10:32:30 UTC
v