issue_id
int64 2.03k
426k
| title
stringlengths 9
251
| body
stringlengths 1
32.8k
⌀ | status
stringclasses 6
values | after_fix_sha
stringlengths 7
7
| project_name
stringclasses 6
values | repo_url
stringclasses 6
values | repo_name
stringclasses 6
values | language
stringclasses 1
value | issue_url
null | before_fix_sha
null | pull_url
null | commit_datetime
timestamp[us, tz=UTC] | report_datetime
timestamp[us, tz=UTC] | updated_file
stringlengths 2
187
| file_content
stringlengths 0
368k
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringSearchEngine.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/InlineConstantRefactoring.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceFactoryRefactoring.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceParameterRefactoring.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/TargetProvider.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameFieldProcessor.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameMethodProcessor.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameNonVirtualMethodProcessor.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenamePackageProcessor.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeProcessor.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/CreateCopyOfCompilationUnitChange.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/MoveCuUpdateCreator.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgPolicyFactory.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/sef/SelfEncapsulateFieldRefactoring.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeSignatureRefactoring.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeTypeRefactoring.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ConstructorReferenceFinder.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceUtil.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInnerToTopRefactoring.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveStaticMembersProcessor.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoring.java
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
org.eclipse.jdt.ui/core
| |
63,908
|
Bug 63908 Refactorings should inform user about unprecise matches
|
M9 Currently refactoring considers unprecise matches during searching and refactors them as well which can lead to unexpected results. Refactorings should inform the user about this.
|
verified fixed
|
134a20d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-25T19:46:04Z
| 2004-05-25T15:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PushDownRefactoring.java
| |
63,794
|
Bug 63794 NLS Search reports bogus match ranges [search]
|
M9 1) Do an NLS search with org.eclipse.search.internal.ui.SearchMessages and the SearchMessages.properties file in the same package 2) Observe: you get 116 unused keys reported, but there are two problems: a) you get an internal error dialog b) when I fixed the internal error (its' an error trying to log a BadLocationException), I noticed that we get loads of bogus match positions for unused keys in SearchMessages.properties. It seems that the method that looks for the position of an unused property key doesn't handle the case where the key is not found.
|
verified fixed
|
44d8f11
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T09:28:07Z
| 2004-05-25T07:26:40Z
|
org.eclipse.jdt.ui/core
| |
63,794
|
Bug 63794 NLS Search reports bogus match ranges [search]
|
M9 1) Do an NLS search with org.eclipse.search.internal.ui.SearchMessages and the SearchMessages.properties file in the same package 2) Observe: you get 116 unused keys reported, but there are two problems: a) you get an internal error dialog b) when I fixed the internal error (its' an error trying to log a BadLocationException), I noticed that we get loads of bogus match positions for unused keys in SearchMessages.properties. It seems that the method that looks for the position of an unused property key doesn't handle the case where the key is not found.
|
verified fixed
|
44d8f11
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T09:28:07Z
| 2004-05-25T07:26:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/PropertyFileDocumentModel.java
| |
63,794
|
Bug 63794 NLS Search reports bogus match ranges [search]
|
M9 1) Do an NLS search with org.eclipse.search.internal.ui.SearchMessages and the SearchMessages.properties file in the same package 2) Observe: you get 116 unused keys reported, but there are two problems: a) you get an internal error dialog b) when I fixed the internal error (its' an error trying to log a BadLocationException), I noticed that we get loads of bogus match positions for unused keys in SearchMessages.properties. It seems that the method that looks for the position of an unused property key doesn't handle the case where the key is not found.
|
verified fixed
|
44d8f11
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T09:28:07Z
| 2004-05-25T07:26:40Z
|
org.eclipse.jdt.ui/ui
| |
63,794
|
Bug 63794 NLS Search reports bogus match ranges [search]
|
M9 1) Do an NLS search with org.eclipse.search.internal.ui.SearchMessages and the SearchMessages.properties file in the same package 2) Observe: you get 116 unused keys reported, but there are two problems: a) you get an internal error dialog b) when I fixed the internal error (its' an error trying to log a BadLocationException), I noticed that we get loads of bogus match positions for unused keys in SearchMessages.properties. It seems that the method that looks for the position of an unused property key doesn't handle the case where the key is not found.
|
verified fixed
|
44d8f11
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T09:28:07Z
| 2004-05-25T07:26:40Z
|
refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/search/NLSSearchResultRequestor.java
| |
63,845
|
Bug 63845 quick assist: NPE in getInvertEqualsProposal [quick assist]
|
3.0 m9 code: class CellWrapper2{ private Cell _cell; public CellWrapper2(Object elem){ _cell = new Cell(elem); } public Cell getCell(){ if (this.equals(_cell)) { return _cell; } return _cell; } public Object getElem(){ return _cell.getData(); } } class Cell{ private Object _data; public Cell(Object data){ _data = data; } public Object getData(){ return _data; } } i selected the equals in CellWrapper2.getCell and pressed ctrl+1 java.lang.NullPointerException at org.eclipse.jdt.internal.ui.text.correction.QuickAssistProcessor.getInvertEqualsProposal(QuickAssistProcessor.java:795) at org.eclipse.jdt.internal.ui.text.correction.QuickAssistProcessor.getAssists(QuickAssistProcessor.java:136) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.collectAssists(JavaCorrectionProcessor.java:281) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.processAnnotations(JavaCorrectionProcessor.java:231) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.computeCompletionProposals(JavaCorrectionProcessor.java:198) at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1457) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:244) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$7(CompletionProposalPopup.java:240) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$1.run(CompletionProposalPopup.java:199) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:194) at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1308) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionAssistant.showPossibleCompletions(JavaCorrectionAssistant.java:158) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:183) at org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java:122) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) at org.eclipse.ui.texteditor.TextOperationAction.run(TextOperationAction.java:120) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:141) at org.eclipse.ui.internal.commands.Command.execute(Command.java:132) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:469) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:887) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:928) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:546) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$2(WorkbenchKeyboard.java:494) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$1.handleEvent(WorkbenchKeyboard.java:259) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:712) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:795) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:820) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:805) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1724) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1720) at org.eclipse.swt.widgets.Control.WM_KEYDOWN(Control.java:3499) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2978) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3282) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1475) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2380) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:253) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:97) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:307) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:256) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622)
|
verified fixed
|
1a260f3
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T13:49:26Z
| 2004-05-25T13:00:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java
|
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Sebastian Davids <sdavids@gmx.de> - Bug 37432 getInvertEqualsProposal
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.correction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.graphics.Image;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
import org.eclipse.jdt.core.dom.ArrayCreation;
import org.eclipse.jdt.core.dom.ArrayInitializer;
import org.eclipse.jdt.core.dom.ArrayType;
import org.eclipse.jdt.core.dom.Assignment;
import org.eclipse.jdt.core.dom.Block;
import org.eclipse.jdt.core.dom.BodyDeclaration;
import org.eclipse.jdt.core.dom.CastExpression;
import org.eclipse.jdt.core.dom.CatchClause;
import org.eclipse.jdt.core.dom.ChildListPropertyDescriptor;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.ConditionalExpression;
import org.eclipse.jdt.core.dom.DoStatement;
import org.eclipse.jdt.core.dom.Expression;
import org.eclipse.jdt.core.dom.ExpressionStatement;
import org.eclipse.jdt.core.dom.ForStatement;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
import org.eclipse.jdt.core.dom.IfStatement;
import org.eclipse.jdt.core.dom.InfixExpression;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SimpleType;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.Statement;
import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor;
import org.eclipse.jdt.core.dom.ThisExpression;
import org.eclipse.jdt.core.dom.TryStatement;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationExpression;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
import org.eclipse.jdt.core.dom.WhileStatement;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
import org.eclipse.jdt.ui.text.java.IInvocationContext;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.IProblemLocation;
import org.eclipse.jdt.ui.text.java.IQuickAssistProcessor;
import org.eclipse.jdt.internal.corext.codemanipulation.ImportRewrite;
import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory;
import org.eclipse.jdt.internal.corext.dom.Bindings;
import org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder;
import org.eclipse.jdt.internal.corext.dom.NodeFinder;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
/**
*/
public class QuickAssistProcessor implements IQuickAssistProcessor {
public QuickAssistProcessor() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.text.correction.IAssistProcessor#hasAssists(org.eclipse.jdt.internal.ui.text.correction.IAssistContext)
*/
public boolean hasAssists(IInvocationContext context) throws CoreException {
ASTNode coveringNode= getCoveringNode(context);
if (coveringNode != null) {
return getCatchClauseToThrowsProposals(context, coveringNode, null)
|| getRenameLocalProposals(context, coveringNode, null, null)
|| getAssignToVariableProposals(context, coveringNode, null)
|| getUnWrapProposals(context, coveringNode, null)
|| getAssignParamToFieldProposals(context, coveringNode, null)
|| getJoinVariableProposals(context, coveringNode, null)
|| getAddFinallyProposals(context, coveringNode, null)
|| getAddElseProposals(context, coveringNode, null)
|| getSplitVariableProposals(context, coveringNode, null)
|| getAddBlockProposals(context, coveringNode, null)
|| getArrayInitializerToArrayCreation(context, coveringNode, null)
|| getCreateInSuperClassProposals(context, coveringNode, null)
|| getInvertEqualsProposal(context, coveringNode, null);
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.text.correction.IAssistProcessor#getAssists(org.eclipse.jdt.internal.ui.text.correction.IAssistContext, org.eclipse.jdt.internal.ui.text.correction.IProblemLocation[])
*/
public IJavaCompletionProposal[] getAssists(IInvocationContext context, IProblemLocation[] locations) throws CoreException {
ASTNode coveringNode= getCoveringNode(context);
if (coveringNode != null) {
ArrayList resultingCollections= new ArrayList();
// quick assists that show up also if there is an error/warning
getRenameLocalProposals(context, coveringNode, locations, resultingCollections);
if (noErrorsAtLocation(locations)) {
getCatchClauseToThrowsProposals(context, coveringNode, resultingCollections);
getAssignToVariableProposals(context, coveringNode, resultingCollections);
getAssignParamToFieldProposals(context, coveringNode, resultingCollections);
getUnWrapProposals(context, coveringNode, resultingCollections);
getSplitVariableProposals(context, coveringNode, resultingCollections);
getJoinVariableProposals(context, coveringNode, resultingCollections);
getAddFinallyProposals(context, coveringNode, resultingCollections);
getAddElseProposals(context, coveringNode, resultingCollections);
getAddBlockProposals(context, coveringNode, resultingCollections);
getInvertEqualsProposal(context, coveringNode, resultingCollections);
getArrayInitializerToArrayCreation(context, coveringNode, resultingCollections);
getCreateInSuperClassProposals(context, coveringNode, resultingCollections);
}
return (IJavaCompletionProposal[]) resultingCollections.toArray(new IJavaCompletionProposal[resultingCollections.size()]);
}
return null;
}
private boolean noErrorsAtLocation(IProblemLocation[] locations) {
if (locations != null) {
for (int i= 0; i < locations.length; i++) {
if (locations[i].isError()) {
return false;
}
}
}
return true;
}
private boolean getJoinVariableProposals(IInvocationContext context, ASTNode node, Collection resultingCollections) {
ASTNode parent= node.getParent();
if (!(parent instanceof VariableDeclarationFragment)) {
return false;
}
VariableDeclarationFragment fragment= (VariableDeclarationFragment) parent;
IVariableBinding binding= fragment.resolveBinding();
if (fragment.getInitializer() != null || binding == null || binding.isField()) {
return false;
}
if (!(fragment.getParent() instanceof VariableDeclarationStatement)) {
return false;
}
VariableDeclarationStatement statement= (VariableDeclarationStatement) fragment.getParent();
SimpleName[] names= LinkedNodeFinder.findByBinding(statement.getParent(), binding);
if (names.length <= 1 || names[0] != fragment.getName()) {
return false;
}
SimpleName firstAccess= names[1];
if (!(firstAccess.getParent() instanceof Assignment)) {
return false;
}
Assignment assignment= (Assignment) firstAccess.getParent();
if (assignment.getLeftHandSide() != firstAccess) {
return false;
}
ASTNode assignParent= assignment.getParent();
if (!(assignParent instanceof ExpressionStatement || assignParent instanceof ForStatement && ((ForStatement) assignParent).initializers().contains(assignment))) {
return false;
}
if (resultingCollections == null) {
return true;
}
AST ast= statement.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
String label= CorrectionMessages.getString("QuickAssistProcessor.joindeclaration.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, 1, image);
Expression placeholder= (Expression) rewrite.createMoveTarget(assignment.getRightHandSide());
rewrite.set(fragment, VariableDeclarationFragment.INITIALIZER_PROPERTY, placeholder, null);
if (assignParent instanceof ExpressionStatement) {
int statementParent= assignParent.getParent().getNodeType();
if (statementParent == ASTNode.IF_STATEMENT || statementParent == ASTNode.WHILE_STATEMENT || statementParent == ASTNode.DO_STATEMENT
|| statementParent == ASTNode.FOR_STATEMENT) {
Block block= ast.newBlock();
rewrite.replace(assignParent, block, null);
} else {
rewrite.remove(assignParent, null);
}
} else {
rewrite.remove(assignment, null);
}
proposal.setEndPosition(rewrite.track(fragment.getName()));
resultingCollections.add(proposal);
return true;
}
private boolean getSplitVariableProposals(IInvocationContext context, ASTNode node, Collection resultingCollections) {
ASTNode parent= node.getParent();
if (!(parent instanceof VariableDeclarationFragment)) {
return false;
}
VariableDeclarationFragment fragment= (VariableDeclarationFragment) parent;
if (fragment.getInitializer() == null) {
return false;
}
Statement statement;
ASTNode fragParent= fragment.getParent();
if (fragParent instanceof VariableDeclarationStatement) {
statement= (VariableDeclarationStatement) fragParent;
} else if (fragParent instanceof VariableDeclarationExpression) {
statement= (Statement) fragParent.getParent();
} else {
return false;
}
// statement is ForStatement or VariableDeclarationStatement
ASTNode statementParent= statement.getParent();
StructuralPropertyDescriptor property= statement.getLocationInParent();
if (!property.isChildListProperty()) {
return false;
}
List list= (List) statementParent.getStructuralProperty(property);
if (resultingCollections == null) {
return true;
}
AST ast= statement.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
String label= CorrectionMessages.getString("QuickAssistProcessor.splitdeclaration.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 1, image);
Statement newStatement;
int insertIndex= list.indexOf(statement);
Expression placeholder= (Expression) rewrite.createMoveTarget(fragment.getInitializer());
Assignment assignment= ast.newAssignment();
assignment.setRightHandSide(placeholder);
assignment.setLeftHandSide(ast.newSimpleName(fragment.getName().getIdentifier()));
if (statement instanceof VariableDeclarationStatement) {
newStatement= ast.newExpressionStatement(assignment);
insertIndex+= 1; // add after declaration
int modifiers= ((VariableDeclarationStatement) statement).getModifiers();
if (Modifier.isFinal(modifiers)) {
rewrite.set(statement, VariableDeclarationStatement.MODIFIERS_PROPERTY, new Integer(modifiers & ~Modifier.FINAL), null);
}
} else {
rewrite.replace(fragment.getParent(), assignment, null);
VariableDeclarationFragment newFrag= ast.newVariableDeclarationFragment();
newFrag.setName(ast.newSimpleName(fragment.getName().getIdentifier()));
newFrag.setExtraDimensions(fragment.getExtraDimensions());
VariableDeclarationExpression oldVarDecl= (VariableDeclarationExpression) fragParent;
VariableDeclarationStatement newVarDec= ast.newVariableDeclarationStatement(newFrag);
newVarDec.setType((Type) ASTNode.copySubtree(ast, oldVarDecl.getType()));
newVarDec.setModifiers(oldVarDecl.getModifiers() & ~Modifier.FINAL);
newStatement= newVarDec;
}
ListRewrite listRewriter= rewrite.getListRewrite(statementParent, (ChildListPropertyDescriptor) property);
listRewriter.insertAt(newStatement, insertIndex, null);
resultingCollections.add(proposal);
return true;
}
private ASTNode getCoveringNode(IInvocationContext context) {
NodeFinder finder= new NodeFinder(context.getSelectionOffset(), context.getSelectionLength());
context.getASTRoot().accept(finder);
return finder.getCoveringNode();
}
private boolean getAssignToVariableProposals(IInvocationContext context, ASTNode node, Collection resultingCollections) {
Statement statement= ASTResolving.findParentStatement(node);
if (!(statement instanceof ExpressionStatement)) {
return false;
}
ExpressionStatement expressionStatement= (ExpressionStatement) statement;
Expression expression= expressionStatement.getExpression();
if (expression.getNodeType() == ASTNode.ASSIGNMENT) {
return false; // too confusing and not helpful
}
ITypeBinding typeBinding= expression.resolveTypeBinding();
typeBinding= Bindings.normalizeTypeBinding(typeBinding);
if (typeBinding == null) {
return false;
}
if (resultingCollections == null) {
return true;
}
ICompilationUnit cu= context.getCompilationUnit();
AssignToVariableAssistProposal localProposal= new AssignToVariableAssistProposal(cu, AssignToVariableAssistProposal.LOCAL, expressionStatement, typeBinding, 2);
resultingCollections.add(localProposal);
ASTNode type= ASTResolving.findParentType(expression);
if (type != null) {
AssignToVariableAssistProposal fieldProposal= new AssignToVariableAssistProposal(cu, AssignToVariableAssistProposal.FIELD, expressionStatement, typeBinding, 1);
resultingCollections.add(fieldProposal);
}
return false;
}
private boolean getAssignParamToFieldProposals(IInvocationContext context, ASTNode node, Collection resultingCollections) {
ASTNode parent= node.getParent();
if (!(parent instanceof SingleVariableDeclaration) || !(parent.getParent() instanceof MethodDeclaration)) {
return false;
}
SingleVariableDeclaration paramDecl= (SingleVariableDeclaration) parent;
IVariableBinding binding= paramDecl.resolveBinding();
MethodDeclaration methodDecl= (MethodDeclaration) parent.getParent();
if (binding == null || methodDecl.getBody() == null) {
return false;
}
ITypeBinding typeBinding= binding.getType();
if (typeBinding == null) {
return false;
}
if (resultingCollections != null) {
AssignToVariableAssistProposal fieldProposal= new AssignToVariableAssistProposal(context.getCompilationUnit(), paramDecl, typeBinding, 1);
resultingCollections.add(fieldProposal);
}
return true;
}
private boolean getAddFinallyProposals(IInvocationContext context, ASTNode node, Collection resultingCollections) {
TryStatement tryStatement= ASTResolving.findParentTryStatement(node);
if (tryStatement == null || tryStatement.getFinally() != null) {
return false;
}
Statement statement= ASTResolving.findParentStatement(node);
if (tryStatement != statement && tryStatement.getBody() != statement) {
return false; // an node inside a catch or finally block
}
if (resultingCollections == null) {
return true;
}
AST ast= tryStatement.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
Block finallyBody= ast.newBlock();
rewrite.set(tryStatement, TryStatement.FINALLY_PROPERTY, finallyBody, null);
String label= CorrectionMessages.getString("QuickAssistProcessor.addfinallyblock.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_ADD);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 1, image);
resultingCollections.add(proposal);
return true;
}
private boolean getAddElseProposals(IInvocationContext context, ASTNode node, Collection resultingCollections) {
Statement statement= ASTResolving.findParentStatement(node);
if (!(statement instanceof IfStatement)) {
return false;
}
IfStatement ifStatement= (IfStatement) statement;
if (ifStatement.getElseStatement() != null) {
return false;
}
if (resultingCollections == null) {
return true;
}
AST ast= statement.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
Block body= ast.newBlock();
rewrite.set(ifStatement, IfStatement.ELSE_STATEMENT_PROPERTY, body, null);
String label= CorrectionMessages.getString("QuickAssistProcessor.addelseblock.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_ADD);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 1, image);
resultingCollections.add(proposal);
return true;
}
public static boolean getCatchClauseToThrowsProposals(IInvocationContext context, ASTNode node, Collection resultingCollections) {
CatchClause catchClause= (CatchClause) ASTResolving.findAncestor(node, ASTNode.CATCH_CLAUSE);
if (catchClause == null) {
return false;
}
Statement statement= ASTResolving.findParentStatement(node);
if (statement != catchClause.getParent() && statement != catchClause.getBody()) {
return false; // selection is in a statement inside the body
}
Type type= catchClause.getException().getType();
if (!type.isSimpleType()) {
return false;
}
BodyDeclaration bodyDeclaration= ASTResolving.findParentBodyDeclaration(catchClause);
if (!(bodyDeclaration instanceof MethodDeclaration)) {
return false;
}
if (resultingCollections == null) {
return true;
}
AST ast= bodyDeclaration.getAST();
MethodDeclaration methodDeclaration= (MethodDeclaration) bodyDeclaration;
{
ASTRewrite rewrite= ASTRewrite.create(ast);
removeCatchBlock(rewrite, methodDeclaration, catchClause);
ITypeBinding binding= type.resolveBinding();
if (binding == null || isNotYetThrown(binding, methodDeclaration.thrownExceptions())) {
Name name= ((SimpleType) type).getName();
Name newName= (Name) ASTNode.copySubtree(ast, name);
ListRewrite listRewriter= rewrite.getListRewrite(methodDeclaration, MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY);
listRewriter.insertLast(newName, null);
}
String label= CorrectionMessages.getString("QuickAssistProcessor.catchclausetothrows.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 4, image);
resultingCollections.add(proposal);
}
{
ASTRewrite rewrite= ASTRewrite.create(ast);
removeCatchBlock(rewrite, methodDeclaration, catchClause);
String label= CorrectionMessages.getString("QuickAssistProcessor.removecatchclause.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 5, image);
resultingCollections.add(proposal);
}
return true;
}
private static void removeCatchBlock(ASTRewrite rewrite, MethodDeclaration methodDeclaration, CatchClause catchClause) {
TryStatement tryStatement= (TryStatement) catchClause.getParent();
if (tryStatement.catchClauses().size() > 1 || tryStatement.getFinally() != null) {
rewrite.remove(catchClause, null);
} else {
Block block= tryStatement.getBody();
List statements= block.statements();
if (statements.size() > 0) {
ListRewrite listRewrite= rewrite.getListRewrite(block, Block.STATEMENTS_PROPERTY);
ASTNode first= (ASTNode) statements.get(0);
ASTNode last= (ASTNode) statements.get(statements.size() - 1);
ASTNode placeholder= listRewrite.createCopyTarget(first, last);
rewrite.replace(tryStatement, placeholder, null);
} else {
rewrite.remove(tryStatement, null);
}
}
}
private static boolean isNotYetThrown(ITypeBinding binding, List thrownExcpetions) {
for (int i= 0; i < thrownExcpetions.size(); i++) {
Name name= (Name) thrownExcpetions.get(i);
ITypeBinding elem= (ITypeBinding) name.resolveBinding();
if (elem != null) {
if (Bindings.isSuperType(elem, binding)) { // existing exception is base class of new
return false;
}
}
}
return true;
}
private boolean getRenameLocalProposals(IInvocationContext context, ASTNode node, IProblemLocation[] locations, Collection resultingCollections) {
if (!(node instanceof SimpleName)) {
return false;
}
SimpleName name= (SimpleName) node;
IBinding binding= name.resolveBinding();
if (binding != null && binding.getKind() == IBinding.PACKAGE) {
return false;
}
if (locations != null) {
for (int i= 0; i < locations.length; i++) {
switch (locations[i].getProblemId()) {
case IProblem.LocalVariableHidingLocalVariable:
case IProblem.LocalVariableHidingField:
case IProblem.FieldHidingLocalVariable:
case IProblem.FieldHidingField:
case IProblem.ArgumentHidingLocalVariable:
case IProblem.ArgumentHidingField:
return false;
}
}
}
if (resultingCollections == null) {
return true;
}
LinkedNamesAssistProposal proposal= new LinkedNamesAssistProposal(context.getCompilationUnit(), name);
resultingCollections.add(proposal);
return true;
}
private ASTNode getCopyOfInner(ASTRewrite rewrite, ASTNode statement) {
if (statement.getNodeType() == ASTNode.BLOCK) {
Block block= (Block) statement;
List innerStatements= block.statements();
int nStatements= innerStatements.size();
if (nStatements == 1) {
return rewrite.createCopyTarget(((ASTNode) innerStatements.get(0)));
} else if (nStatements > 1) {
ListRewrite listRewrite= rewrite.getListRewrite(block, Block.STATEMENTS_PROPERTY);
ASTNode first= (ASTNode) innerStatements.get(0);
ASTNode last= (ASTNode) innerStatements.get(nStatements - 1);
return listRewrite.createCopyTarget(first, last);
}
return null;
} else {
return rewrite.createCopyTarget(statement);
}
}
private boolean getUnWrapProposals(IInvocationContext context, ASTNode node, Collection resultingCollections) {
ASTNode outer= node;
Block block= null;
if (outer.getNodeType() == ASTNode.BLOCK) {
block= (Block) outer;
outer= block.getParent();
}
ASTNode body= null;
String label= null;
if (outer instanceof IfStatement) {
IfStatement ifStatement= (IfStatement) outer;
Statement elseBlock= ifStatement.getElseStatement();
if (elseBlock == null || ((elseBlock instanceof Block) && ((Block) elseBlock).statements().isEmpty())) {
body= ifStatement.getThenStatement();
}
label= CorrectionMessages.getString("QuickAssistProcessor.unwrap.ifstatement"); //$NON-NLS-1$
} else if (outer instanceof WhileStatement) {
body=((WhileStatement) outer).getBody();
label= CorrectionMessages.getString("QuickAssistProcessor.unwrap.whilestatement"); //$NON-NLS-1$
} else if (outer instanceof ForStatement) {
body=((ForStatement) outer).getBody();
label= CorrectionMessages.getString("QuickAssistProcessor.unwrap.forstatement"); //$NON-NLS-1$
} else if (outer instanceof DoStatement) {
body=((DoStatement) outer).getBody();
label= CorrectionMessages.getString("QuickAssistProcessor.unwrap.dostatement"); //$NON-NLS-1$
} else if (outer instanceof TryStatement) {
TryStatement tryStatement= (TryStatement) outer;
if (tryStatement.catchClauses().isEmpty()) {
body= tryStatement.getBody();
}
label= CorrectionMessages.getString("QuickAssistProcessor.unwrap.trystatement"); //$NON-NLS-1$
} else if (outer instanceof AnonymousClassDeclaration) {
List decls= ((AnonymousClassDeclaration) outer).bodyDeclarations();
for (int i= 0; i < decls.size(); i++) {
ASTNode elem= (ASTNode) decls.get(i);
if (elem instanceof MethodDeclaration) {
Block curr= ((MethodDeclaration) elem).getBody();
if (curr != null && !curr.statements().isEmpty()) {
if (body != null) {
return false;
}
body= curr;
}
} else if (elem instanceof TypeDeclaration) {
return false;
}
}
label= CorrectionMessages.getString("QuickAssistProcessor.unwrap.anonymous"); //$NON-NLS-1$
outer= ASTResolving.findParentStatement(outer);
if (outer == null) {
return false; // private Object o= new Object() { ... };
}
} else if (outer instanceof Block) {
// -> a block in a block
body= block;
outer= block;
label= CorrectionMessages.getString("QuickAssistProcessor.unwrap.block"); //$NON-NLS-1$
} else if (outer instanceof ParenthesizedExpression) {
ParenthesizedExpression expression= (ParenthesizedExpression) outer;
body= expression.getExpression();
label= CorrectionMessages.getString("QuickAssistProcessor.unwrap.parenthesis"); //$NON-NLS-1$
} else if (outer instanceof MethodInvocation) {
MethodInvocation invocation= (MethodInvocation) outer;
if (invocation.arguments().size() == 1) {
body= (ASTNode) invocation.arguments().get(0);
if (invocation.getParent().getNodeType() == ASTNode.EXPRESSION_STATEMENT) {
int kind= body.getNodeType();
if (kind != ASTNode.ASSIGNMENT && kind != ASTNode.PREFIX_EXPRESSION && kind != ASTNode.POSTFIX_EXPRESSION
&& kind != ASTNode.METHOD_INVOCATION && kind != ASTNode.SUPER_METHOD_INVOCATION) {
body= null;
}
}
label= CorrectionMessages.getString("QuickAssistProcessor.unwrap.methodinvocation"); //$NON-NLS-1$
}
}
if (body == null) {
return false;
}
ASTRewrite rewrite= ASTRewrite.create(outer.getAST());
ASTNode inner= getCopyOfInner(rewrite, body);
if (inner == null) {
return false;
}
if (resultingCollections == null) {
return true;
}
rewrite.replace(outer, inner, null);
Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 1, image);
resultingCollections.add(proposal);
return true;
}
private static boolean isControlStatementWithBlock(ASTNode node) {
switch (node.getNodeType()) {
case ASTNode.IF_STATEMENT:
case ASTNode.WHILE_STATEMENT:
case ASTNode.FOR_STATEMENT:
case ASTNode.DO_STATEMENT:
return true;
default:
return false;
}
}
private boolean getAddBlockProposals(IInvocationContext context, ASTNode node, Collection resultingCollections) {
Statement statement= ASTResolving.findParentStatement(node);
if (statement == null) {
return false;
}
if (!isControlStatementWithBlock(statement)) {
if (!isControlStatementWithBlock(statement.getParent())) {
return false;
}
int statementStart= statement.getStartPosition();
int statementEnd= statementStart + statement.getLength();
int offset= context.getSelectionOffset();
int length= context.getSelectionLength();
if (length == 0) {
if (offset != statementEnd) { // cursor at end
return false;
}
} else {
if (offset > statementStart || offset + length < statementEnd) { // statement selected
return false;
}
}
statement= (Statement) statement.getParent();
}
StructuralPropertyDescriptor childProperty= null;
ASTNode child= null;
switch (statement.getNodeType()) {
case ASTNode.IF_STATEMENT:
int selectionStart= context.getSelectionOffset();
int selectionEnd= context.getSelectionOffset() + context.getSelectionLength();
ASTNode then= ((IfStatement) statement).getThenStatement();
if (selectionEnd <= then.getStartPosition() + then.getLength()) {
if (!(then instanceof Block)) {
childProperty= IfStatement.THEN_STATEMENT_PROPERTY;
child= then;
}
} else if (selectionStart >= then.getStartPosition() + then.getLength()) {
ASTNode elseStatement= ((IfStatement) statement).getElseStatement();
if (!(elseStatement instanceof Block)) {
childProperty= IfStatement.ELSE_STATEMENT_PROPERTY;
child= elseStatement;
}
}
break;
case ASTNode.WHILE_STATEMENT:
ASTNode whileBody= ((WhileStatement) statement).getBody();
if (!(whileBody instanceof Block)) {
childProperty= WhileStatement.BODY_PROPERTY;
child= whileBody;
}
break;
case ASTNode.FOR_STATEMENT:
ASTNode forBody= ((ForStatement) statement).getBody();
if (!(forBody instanceof Block)) {
childProperty= ForStatement.BODY_PROPERTY;
child= forBody;
}
break;
case ASTNode.DO_STATEMENT:
ASTNode doBody= ((DoStatement) statement).getBody();
if (!(doBody instanceof Block)) {
childProperty= DoStatement.BODY_PROPERTY;
child= doBody;
}
break;
default:
}
if (child == null) {
return false;
}
if (resultingCollections == null) {
return true;
}
AST ast= statement.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
ASTNode childPlaceholder= rewrite.createMoveTarget(child);
Block replacingBody= ast.newBlock();
replacingBody.statements().add(childPlaceholder);
rewrite.set(statement, childProperty, replacingBody, null);
String label;
if (childProperty == IfStatement.THEN_STATEMENT_PROPERTY) {
label = CorrectionMessages.getString("QuickAssistProcessor.replacethenwithblock.description");//$NON-NLS-1$
} else if (childProperty == IfStatement.ELSE_STATEMENT_PROPERTY) {
label = CorrectionMessages.getString("QuickAssistProcessor.replaceelsewithblock.description");//$NON-NLS-1$
} else {
label = CorrectionMessages.getString("QuickAssistProcessor.replacebodywithblock.description");//$NON-NLS-1$
}
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, 10, image);
proposal.setEndPosition(rewrite.track(child));
resultingCollections.add(proposal);
return true;
}
private boolean getInvertEqualsProposal(IInvocationContext context, ASTNode node, Collection resultingCollections) {
ASTNode parent= node.getParent();
if (!(parent instanceof MethodInvocation)) {
return false;
}
MethodInvocation method= (MethodInvocation) parent;
if (!"equals".equals(method.getName().getIdentifier())) { //$NON-NLS-1$
return false;
}
List arguments= method.arguments();
if (arguments.size() != 1) { //overloaded equals w/ more than 1 arg
return false;
}
Expression right= (Expression) arguments.get(0);
ITypeBinding binding = right.resolveTypeBinding();
if (!(binding.isClass() || binding.isInterface())) { //overloaded equals w/ non-class/interface arg or null
return false;
}
if (resultingCollections == null) {
return true;
}
Expression left= method.getExpression();
AST ast= method.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
if (left == null) { // equals(x) -> x.equals(this)
MethodInvocation replacement= ast.newMethodInvocation();
replacement.setName((SimpleName) rewrite.createCopyTarget(method.getName()));
replacement.arguments().add(ast.newThisExpression());
replacement.setExpression((Expression) rewrite.createCopyTarget(right));
rewrite.replace(method, replacement, null);
} else if (right instanceof ThisExpression) { // x.equals(this) -> equals(x)
MethodInvocation replacement= ast.newMethodInvocation();
replacement.setName((SimpleName) rewrite.createCopyTarget(method.getName()));
replacement.arguments().add(rewrite.createCopyTarget(left));
rewrite.replace(method, replacement, null);
} else {
ASTNode leftExpression= left;
while (leftExpression instanceof ParenthesizedExpression) {
leftExpression= ((ParenthesizedExpression) left).getExpression();
}
rewrite.replace(right, rewrite.createCopyTarget(leftExpression), null);
if ((right instanceof CastExpression)
|| (right instanceof Assignment)
|| (right instanceof ConditionalExpression)
|| (right instanceof InfixExpression)) {
ParenthesizedExpression paren= ast.newParenthesizedExpression();
paren.setExpression((Expression) rewrite.createCopyTarget(right));
rewrite.replace(left, paren, null);
} else {
rewrite.replace(left, rewrite.createCopyTarget(right), null);
}
}
String label= CorrectionMessages.getString("QuickAssistProcessor.invertequals.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, 1, image);
resultingCollections.add(proposal);
return true;
}
private boolean getArrayInitializerToArrayCreation(IInvocationContext context, ASTNode node, Collection resultingCollections) throws CoreException {
if (!(node instanceof ArrayInitializer)) {
return false;
}
ArrayInitializer initializer= (ArrayInitializer) node;
ASTNode parent= initializer.getParent();
while (parent instanceof ArrayInitializer) {
initializer= (ArrayInitializer) parent;
parent= parent.getParent();
}
ITypeBinding typeBinding= initializer.resolveTypeBinding();
if (!(parent instanceof VariableDeclaration) || typeBinding == null || !typeBinding.isArray()) {
return false;
}
if (resultingCollections == null) {
return true;
}
AST ast= node.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
ImportRewrite imports= new ImportRewrite(context.getCompilationUnit());
String typeName= imports.addImport(typeBinding);
ArrayCreation creation= ast.newArrayCreation();
creation.setInitializer((ArrayInitializer) rewrite.createMoveTarget(initializer));
creation.setType((ArrayType) ASTNodeFactory.newType(ast, typeName));
rewrite.replace(initializer, creation, null);
String label= CorrectionMessages.getString("QuickAssistProcessor.typetoarrayInitializer.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, 1, image);
resultingCollections.add(proposal);
return true;
}
private boolean getCreateInSuperClassProposals(IInvocationContext context, ASTNode node, ArrayList resultingCollections) throws CoreException {
if (!(node instanceof SimpleName) || !(node.getParent() instanceof MethodDeclaration)) {
return false;
}
MethodDeclaration decl= (MethodDeclaration) node.getParent();
if (decl.getName() != node || decl.resolveBinding() == null) {
return false;
}
ICompilationUnit cu= context.getCompilationUnit();
CompilationUnit astRoot= context.getASTRoot();
IMethodBinding binding= decl.resolveBinding();
String methodName= binding.getName();
ITypeBinding[] paramTypes= binding.getParameterTypes();
ITypeBinding[] superTypes= Bindings.getAllSuperTypes(binding.getDeclaringClass());
if (resultingCollections == null) {
for (int i= 0; i < superTypes.length; i++) {
ITypeBinding curr= superTypes[i];
if (curr.isFromSource() && Bindings.findMethodInType(curr, methodName, paramTypes) == null) {
return true;
}
}
return false;
}
List params= decl.parameters();
String[] paramNames= new String[paramTypes.length];
for (int i = 0; i < params.size(); i++) {
SingleVariableDeclaration param= (SingleVariableDeclaration) params.get(i);
paramNames[i]= param.getName().getIdentifier();
}
for (int i= 0; i < superTypes.length; i++) {
ITypeBinding curr= superTypes[i];
if (curr.isFromSource()) {
IMethodBinding method= Bindings.findMethodInType(curr, methodName, paramTypes);
if (method == null) {
ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, curr);
if (targetCU != null) {
String label= CorrectionMessages.getFormattedString("QuickAssistProcessor.createmethodinsuper.description", curr.getName()); //$NON-NLS-1$
resultingCollections.add(new NewDefiningMethodProposal(label, targetCU, astRoot, curr, binding, paramNames, 6));
}
}
}
}
return true;
}
}
|
63,554
|
Bug 63554 NPE in QuickAssistProcessor [quick fix]
|
I'm using M9 (Build id: 200405211200), occured sometimes in Java editor. Error Mai 22, 2004 21:01:24.910 Internal Error java.lang.NullPointerException at org.eclipse.jdt.internal.ui.text.correction.QuickAssistProcessor. getCoveringNode(QuickAssistProcessor.java:307) at org.eclipse.jdt.internal.ui.text.correction.QuickAssistProcessor. getAssists(QuickAssistProcessor.java:120) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor. collectAssists(JavaCorrectionProcessor.java:281) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor. processAnnotations(JavaCorrectionProcessor.java:231) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor. computeCompletionProposals(JavaCorrectionProcessor.java:198) at org.eclipse.jface.text.contentassist.ContentAssistant. computeCompletionProposals(ContentAssistant.java:1457) at org.eclipse.jface.text.contentassist.CompletionProposalPopup. computeProposals(CompletionProposalPopup.java:244) at org.eclipse.jface.text.contentassist.CompletionProposalPopup. access$7(CompletionProposalPopup.java:240) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$1. run(CompletionProposalPopup.java:199) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) at org.eclipse.jface.text.contentassist.CompletionProposalPopup. showProposals(CompletionProposalPopup.java:194) at org.eclipse.jface.text.contentassist.ContentAssistant. showPossibleCompletions(ContentAssistant.java:1308) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionAssistant. showPossibleCompletions(JavaCorrectionAssistant.java:158) at org.eclipse.jdt.internal.ui.javaeditor. CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor. java:183) at org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java: 122) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) at org.eclipse.ui.texteditor.TextOperationAction.run(TextOperationAction.java: 120) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:141) at org.eclipse.ui.internal.commands.Command.execute(Command.java:132) at org.eclipse.ui.internal.keys.WorkbenchKeyboard. executeCommand(WorkbenchKeyboard.java:469) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java: 887) at org.eclipse.ui.internal.keys.WorkbenchKeyboard. processKeyEvent(WorkbenchKeyboard.java:928) at org.eclipse.ui.internal.keys.WorkbenchKeyboard. filterKeySequenceBindings(WorkbenchKeyboard.java:546) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$2(WorkbenchKeyboard. java:494) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$1. handleEvent(WorkbenchKeyboard.java:259) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:712) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:795) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:820) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:805) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1724) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1720) at org.eclipse.swt.widgets.Control.WM_KEYDOWN(Control.java:3499) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2978) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3282) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1475) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2380) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:253) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:97) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator. java:307) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:256) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl. java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622)
|
verified fixed
|
46f0a34
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T13:54:34Z
| 2004-05-22T21:06:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/AssistContext.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.correction;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.ui.text.java.IInvocationContext;
import org.eclipse.jdt.internal.corext.dom.NodeFinder;
import org.eclipse.jdt.internal.ui.JavaPlugin;
/**
*/
public class AssistContext implements IInvocationContext {
private ICompilationUnit fCompilationUnit;
private int fOffset;
private int fLength;
private CompilationUnit fASTRoot;
/*
* Constructor for CorrectionContext.
*/
public AssistContext(ICompilationUnit cu, int offset, int length) {
fCompilationUnit= cu;
fOffset= offset;
fLength= length;
fASTRoot= null;
}
/**
* Returns the compilation unit.
* @return Returns a ICompilationUnit
*/
public ICompilationUnit getCompilationUnit() {
return fCompilationUnit;
}
/**
* Returns the length.
* @return int
*/
public int getSelectionLength() {
return fLength;
}
/**
* Returns the offset.
* @return int
*/
public int getSelectionOffset() {
return fOffset;
}
public CompilationUnit getASTRoot() {
if (fASTRoot == null) {
fASTRoot= JavaPlugin.getDefault().getASTProvider().getAST(fCompilationUnit, true, null);
}
return fASTRoot;
}
/**
* @param root The ASTRoot to set.
*/
public void setASTRoot(CompilationUnit root) {
fASTRoot= root;
}
/*(non-Javadoc)
* @see org.eclipse.jdt.ui.text.java.IInvocationContext#getCoveringNode()
*/
public ASTNode getCoveringNode() {
NodeFinder finder= new NodeFinder(fOffset, fLength);
getASTRoot().accept(finder);
return finder.getCoveringNode();
}
/*(non-Javadoc)
* @see org.eclipse.jdt.ui.text.java.IInvocationContext#getCoveredNode()
*/
public ASTNode getCoveredNode() {
NodeFinder finder= new NodeFinder(fOffset, fLength);
getASTRoot().accept(finder);
return finder.getCoveredNode();
}
}
|
64,108
|
Bug 64108 Javadoc keywords settings no longer work in Java Editor
|
Using build I200405260010. I've noticed that Javadoc keywords (ie. tag names in javadoc comments) were no longer highlighted. Trying to see if my preferences were reset and then realized that whatever color or style I set for Javadoc keywords, they stay unchanged...
|
verified fixed
|
b96aeb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T14:32:43Z
| 2004-05-26T14:00:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaCommentScanner.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.IWordDetector;
import org.eclipse.jface.text.rules.WordRule;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ui.text.IColorManager;
import org.eclipse.jdt.ui.text.IJavaColorConstants;
/**
* AbstractJavaCommentScanner.java
*/
public class JavaCommentScanner extends AbstractJavaScanner{
private static class TaskTagDetector implements IWordDetector {
public boolean isWordStart(char c) {
return c == '@' || Character.isJavaIdentifierStart(c);
}
public boolean isWordPart(char c) {
return Character.isJavaIdentifierPart(c);
}
}
/**
* Character scanner returning uppercased characters of the wrapped scanner.
*
* @since 3.0
*/
private class UppercaseScanner implements ICharacterScanner {
/**
* The wrapped scanner.
*/
private ICharacterScanner fScanner;
/**
* Set the scanner
*
* @param scanner the scanner
*/
public void setScanner(ICharacterScanner scanner) {
fScanner= scanner;
}
/*
* @see org.eclipse.jface.text.rules.ICharacterScanner#getLegalLineDelimiters()
*/
public char[][] getLegalLineDelimiters() {
return fScanner.getLegalLineDelimiters();
}
/*
* @see org.eclipse.jface.text.rules.ICharacterScanner#getColumn()
*/
public int getColumn() {
return fScanner.getColumn();
}
/*
* @see org.eclipse.jface.text.rules.ICharacterScanner#read()
*/
public int read() {
int ch= fScanner.read();
return ch != EOF ? Character.toUpperCase((char) ch) : EOF;
}
/*
* @see org.eclipse.jface.text.rules.ICharacterScanner#unread()
*/
public void unread() {
fScanner.unread();
}
}
private class TaskTagRule extends WordRule {
private IToken fToken;
/**
* Uppercase words
* @since 3.0
*/
private Map fUppercaseWords= new HashMap();
/**
* Original words
* @since 3.0
*/
private Map fOriginalWords= fWords;
/**
* Uppercase scanner
* @since 3.0
*/
private UppercaseScanner fUppercaseScanner= new UppercaseScanner();
/**
* <code>true</code> if task tag detection is case-sensitive.
* @since 3.0
*/
private boolean fCaseSensitive= true;
public TaskTagRule(IToken token, IToken defaultToken) {
super(new TaskTagDetector(), defaultToken);
fToken= token;
}
public void clearTaskTags() {
fOriginalWords.clear();
fUppercaseWords.clear();
}
public void addTaskTags(String value) {
String[] tasks= split(value, ","); //$NON-NLS-1$
for (int i= 0; i < tasks.length; i++) {
if (tasks[i].length() > 0) {
addWord(tasks[i], fToken);
}
}
}
private String[] split(String value, String delimiters) {
StringTokenizer tokenizer= new StringTokenizer(value, delimiters);
int size= tokenizer.countTokens();
String[] tokens= new String[size];
int i= 0;
while (i < size)
tokens[i++]= tokenizer.nextToken();
return tokens;
}
/*
* @see org.eclipse.jface.text.rules.WordRule#addWord(java.lang.String, org.eclipse.jface.text.rules.IToken)
* @since 3.0
*/
public void addWord(String word, IToken token) {
Assert.isNotNull(word);
Assert.isNotNull(token);
fOriginalWords.put(word, token);
fUppercaseWords.put(word.toUpperCase(), token);
}
/*
* @see IRule#evaluate(ICharacterScanner)
* @since 3.0
*/
public IToken evaluate(final ICharacterScanner scanner) {
if (fCaseSensitive) {
fWords= fOriginalWords;
return super.evaluate(scanner);
}
fWords= fUppercaseWords;
fUppercaseScanner.setScanner(scanner);
return super.evaluate(fUppercaseScanner);
}
/**
* Is task tag detection case-senstive?
*
* @return <code>true</code> iff task tag detection is case-sensitive
* @since 3.0
*/
public boolean isCaseSensitive() {
return fCaseSensitive;
}
/**
* Enables/disables the case-sensitivity of the task tag detection.
*
* @param caseSensitive <code>true</code> iff case-sensitivity should be enabled
* @since 3.0
*/
public void setCaseSensitive(boolean caseSensitive) {
fCaseSensitive= caseSensitive;
}
}
private static final String COMPILER_TASK_TAGS= JavaCore.COMPILER_TASK_TAGS;
protected static final String TASK_TAG= IJavaColorConstants.TASK_TAG;
/**
* Preference key of a string preference, specifying if task tag detection is case-sensitive.
* @since 3.0
*/
private static final String COMPILER_TASK_CASE_SENSITIVE= JavaCore.COMPILER_TASK_CASE_SENSITIVE;
/**
* Preference value of enabled preferences.
* @since 3.0
*/
private static final String ENABLED= JavaCore.ENABLED;
private TaskTagRule fTaskTagRule;
private Preferences fCorePreferenceStore;
private String fDefaultTokenProperty;
private String[] fTokenProperties;
public JavaCommentScanner(IColorManager manager, IPreferenceStore store, Preferences coreStore, String defaultTokenProperty) {
this(manager, store, coreStore, defaultTokenProperty, new String[] { defaultTokenProperty, TASK_TAG });
}
public JavaCommentScanner(IColorManager manager, IPreferenceStore store, Preferences coreStore, String defaultTokenProperty, String[] tokenProperties) {
super(manager, store);
fCorePreferenceStore= coreStore;
fDefaultTokenProperty= defaultTokenProperty;
fTokenProperties= tokenProperties;
initialize();
}
/**
* Initialize with the given arguments.
*
* @param manager Color manager
* @param store Preference store
* @param defaultTokenProperty Default token property
*
* @since 3.0
*/
public JavaCommentScanner(IColorManager manager, IPreferenceStore store, String defaultTokenProperty) {
this(manager, store, null, defaultTokenProperty, new String[] { defaultTokenProperty, TASK_TAG });
}
/**
* Initialize with the given arguments.
*
* @param manager Color manager
* @param store Preference store
* @param defaultTokenProperty Default token property
* @param tokenProperties Token properties
*
* @since 3.0
*/
public JavaCommentScanner(IColorManager manager, IPreferenceStore store, String defaultTokenProperty, String[] tokenProperties) {
this(manager, store, null, defaultTokenProperty, tokenProperties);
}
/*
* @see AbstractJavaScanner#createRules()
*/
protected List createRules() {
List list= new ArrayList();
// Add rule for Task Tags.
boolean isCaseSensitive= true;
String tasks= null;
if (getPreferenceStore().contains(COMPILER_TASK_TAGS)) {
tasks= getPreferenceStore().getString(COMPILER_TASK_TAGS);
isCaseSensitive= ENABLED.equals(getPreferenceStore().getString(COMPILER_TASK_CASE_SENSITIVE));
} else if (fCorePreferenceStore != null) {
tasks= fCorePreferenceStore.getString(COMPILER_TASK_TAGS);
isCaseSensitive= ENABLED.equals(fCorePreferenceStore.getString(COMPILER_TASK_CASE_SENSITIVE));
}
if (tasks != null) {
fTaskTagRule= new TaskTagRule(getToken(TASK_TAG), getToken(fDefaultTokenProperty));
fTaskTagRule.addTaskTags(tasks);
fTaskTagRule.setCaseSensitive(isCaseSensitive);
list.add(fTaskTagRule);
}
setDefaultReturnToken(getToken(fDefaultTokenProperty));
return list;
}
/*
* @see org.eclipse.jdt.internal.ui.text.AbstractJavaScanner#affectsBehavior(org.eclipse.jface.util.PropertyChangeEvent)
*/
public boolean affectsBehavior(PropertyChangeEvent event) {
return event.getProperty().equals(COMPILER_TASK_TAGS) || event.getProperty().equals(COMPILER_TASK_CASE_SENSITIVE) || super.affectsBehavior(event);
}
/*
* @see org.eclipse.jdt.internal.ui.text.AbstractJavaScanner#adaptToPreferenceChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
public void adaptToPreferenceChange(PropertyChangeEvent event) {
if (fTaskTagRule != null && event.getProperty().equals(COMPILER_TASK_TAGS)) {
Object value= event.getNewValue();
if (value instanceof String) {
fTaskTagRule.clearTaskTags();
fTaskTagRule.addTaskTags((String) value);
}
} else if (fTaskTagRule != null && event.getProperty().equals(COMPILER_TASK_CASE_SENSITIVE)) {
Object value= event.getNewValue();
if (value instanceof String)
fTaskTagRule.setCaseSensitive(ENABLED.equals(value));
} else if (super.affectsBehavior(event))
super.adaptToPreferenceChange(event);
}
/*
* @see org.eclipse.jdt.internal.ui.text.AbstractJavaScanner#getTokenProperties()
*/
protected String[] getTokenProperties() {
return fTokenProperties;
}
}
|
64,105
|
Bug 64105 Cannot set data in clipboard [ccp]
| null |
verified fixed
|
b216293
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T15:04:44Z
| 2004-05-26T14:00:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClipboardOperationAction.java
|
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.javaeditor;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.ResourceBundle;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.dnd.ByteArrayTransfer;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.RTFTransfer;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.dnd.TransferData;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.IRewriteTarget;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.TextEditorAction;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings;
import org.eclipse.jdt.internal.corext.codemanipulation.ImportReferencesCollector;
import org.eclipse.jdt.internal.corext.codemanipulation.ImportsStructure;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
/**
* Action for cut/copy and paste with support for adding imports on paste.
*/
public final class ClipboardOperationAction extends TextEditorAction {
public static class ClipboardData {
private String fOriginHandle;
private String[] fImports;
public ClipboardData(IJavaElement origin, String[] imports) {
fImports= imports;
fOriginHandle= origin.getHandleIdentifier();
}
public ClipboardData(byte[] bytes) throws IOException {
DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(bytes));
fOriginHandle= dataIn.readUTF();
int count= dataIn.readInt();
fImports= new String[count];
for (int i = 0; i < count; i++) {
fImports[i]= dataIn.readUTF();
}
dataIn.close();
}
public String[] getImports() {
return fImports;
}
public boolean isFromSame(IJavaElement elem) {
return fOriginHandle.equals(elem.getHandleIdentifier());
}
public byte[] serialize() throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream(out);
dataOut.writeUTF(fOriginHandle);
dataOut.writeInt(fImports.length);
for (int i = 0; i < fImports.length; i++) {
dataOut.writeUTF(fImports[i]);
}
dataOut.close();
out.close();
return out.toByteArray();
}
}
private static class ClipboardTransfer extends ByteArrayTransfer {
private static final String TYPE_NAME = "source-with-imports-transfer-format" + System.currentTimeMillis(); //$NON-NLS-1$
private static final int TYPEID = registerType(TYPE_NAME);
/* (non-Javadoc)
* @see org.eclipse.swt.dnd.Transfer#getTypeIds()
*/
protected int[] getTypeIds() {
return new int[] { TYPEID };
}
/* (non-Javadoc)
* @see org.eclipse.swt.dnd.Transfer#getTypeNames()
*/
protected String[] getTypeNames() {
return new String[] { TYPE_NAME };
}
/* (non-Javadoc)
* @see org.eclipse.swt.dnd.Transfer#javaToNative(java.lang.Object, org.eclipse.swt.dnd.TransferData)
*/
protected void javaToNative(Object data, TransferData transferData) {
if (data instanceof ClipboardData) {
try {
super.javaToNative(((ClipboardData) data).serialize(), transferData);
} catch (IOException e) {
//it's best to send nothing if there were problems
}
}
}
/* (non-Javadoc)
* Method declared on Transfer.
*/
protected Object nativeToJava(TransferData transferData) {
byte[] bytes = (byte[]) super.nativeToJava(transferData);
if (bytes != null) {
try {
return new ClipboardData(bytes);
} catch (IOException e) {
}
}
return null;
}
}
private static final ClipboardTransfer fgTransferInstance = new ClipboardTransfer();
/** The text operation code */
private int fOperationCode= -1;
/** The text operation target */
private ITextOperationTarget fOperationTarget;
/**
* Creates the action.
*/
public ClipboardOperationAction(ResourceBundle bundle, String prefix, ITextEditor editor, int operationCode) {
super(bundle, prefix, editor);
fOperationCode= operationCode;
if (operationCode == ITextOperationTarget.CUT) {
setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_ACTION);
setActionDefinitionId(ITextEditorActionDefinitionIds.CUT);
} else if (operationCode == ITextOperationTarget.COPY) {
setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_ACTION);
setActionDefinitionId(ITextEditorActionDefinitionIds.COPY);
} else if (operationCode == ITextOperationTarget.PASTE) {
setHelpContextId(IAbstractTextEditorHelpContextIds.PASTE_ACTION);
setActionDefinitionId(ITextEditorActionDefinitionIds.PASTE);
} else {
Assert.isTrue(false, "Invalid operation code"); //$NON-NLS-1$
}
update();
}
private boolean isReadOnlyOperation() {
return fOperationCode == ITextOperationTarget.COPY;
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
if (fOperationCode == -1 || fOperationTarget == null)
return;
ITextEditor editor= getTextEditor();
if (editor == null)
return;
if (!isReadOnlyOperation() && !validateEditorInputState())
return;
BusyIndicator.showWhile(getDisplay(), new Runnable() {
public void run() {
internalDoOperation();
}
});
}
private Display getDisplay() {
ITextEditor editor= getTextEditor();
if (editor != null) {
IWorkbenchPartSite site= editor.getSite();
Shell shell= site.getShell();
if (shell != null && !shell.isDisposed())
return shell.getDisplay();
}
return null;
}
protected final void internalDoOperation() {
if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_IMPORTS_ON_PASTE)) {
if (fOperationCode == ITextOperationTarget.PASTE) {
doPasteWithImportsOperation();
} else {
doCutCopyWithImportsOperation();
}
} else {
fOperationTarget.doOperation(fOperationCode);
}
}
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.IUpdate#update()
*/
public void update() {
super.update();
if (!isReadOnlyOperation() && !canModifyEditor()) {
setEnabled(false);
return;
}
ITextEditor editor= getTextEditor();
if (fOperationTarget == null && editor!= null && fOperationCode != -1)
fOperationTarget= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
setEnabled(isEnabled);
}
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.TextEditorAction#setEditor(org.eclipse.ui.texteditor.ITextEditor)
*/
public void setEditor(ITextEditor editor) {
super.setEditor(editor);
fOperationTarget= null;
}
private void doCutCopyWithImportsOperation() {
ITextEditor editor= getTextEditor();
IJavaElement inputElement= (IJavaElement) editor.getEditorInput().getAdapter(IJavaElement.class);
ISelection selection= editor.getSelectionProvider().getSelection();
Object clipboardData= null;
if (inputElement != null && selection instanceof ITextSelection && !selection.isEmpty()) {
ITextSelection textSelection= (ITextSelection) selection;
if (isNonTrivialSelection(textSelection)) {
clipboardData= getClipboardData(inputElement, textSelection.getOffset(), textSelection.getLength());
}
}
fOperationTarget.doOperation(fOperationCode);
if (clipboardData != null) {
Clipboard clipboard= new Clipboard(getDisplay());
// see bug 61876, I currently make assumptions about what the styled text widget sets
Object textData= clipboard.getContents(TextTransfer.getInstance());
Object rtfData= clipboard.getContents(RTFTransfer.getInstance());
ArrayList datas= new ArrayList(3);
ArrayList transfers= new ArrayList(3);
if (textData != null) {
datas.add(textData);
transfers.add(TextTransfer.getInstance());
}
if (rtfData != null) {
datas.add(rtfData);
transfers.add(RTFTransfer.getInstance());
}
datas.add(clipboardData);
transfers.add(fgTransferInstance);
Transfer[] dataTypes= (Transfer[]) transfers.toArray(new Transfer[transfers.size()]);
Object[] data= datas.toArray();
clipboard.setContents(data, dataTypes);
}
}
private boolean isNonTrivialSelection(ITextSelection selection) {
if (selection.getLength() < 30) {
String text= selection.getText();
for (int i= 0; i < text.length(); i++) {
if (!Character.isJavaIdentifierPart(text.charAt(i))) {
return true;
}
}
return false;
}
return true;
}
private ClipboardData getClipboardData(IJavaElement inputElement, int offset, int length) {
CompilationUnit astRoot= JavaPlugin.getDefault().getASTProvider().getAST(inputElement, true, null);
if (astRoot == null) {
return null;
}
// do process import if selection spans over import declaration or package
List list= astRoot.imports();
if (!list.isEmpty()) {
if (offset < ((ASTNode) list.get(list.size() - 1)).getStartPosition()) {
return null;
}
} else if (astRoot.getPackage() != null) {
if (offset < ((ASTNode) astRoot.getPackage()).getStartPosition()) {
return null;
}
}
ArrayList res= new ArrayList();
ImportReferencesCollector collector= new ImportReferencesCollector(new Region(offset, length), res);
astRoot.accept(collector);
HashSet namesToImport= new HashSet(res.size());
for (int i= 0; i < res.size(); i++) {
SimpleName curr= (SimpleName) res.get(i);
IBinding binding= curr.resolveBinding();
if (binding != null && binding.getKind() == IBinding.TYPE) {
ITypeBinding typeBinding= (ITypeBinding) binding;
if (typeBinding.isArray()) {
typeBinding= typeBinding.getElementType();
}
if (typeBinding.isMember() || typeBinding.isTopLevel()) {
String name= typeBinding.getQualifiedName();
if (name.length() > 0) {
namesToImport.add(name);
}
}
}
}
if (namesToImport.isEmpty()) {
return null;
}
return new ClipboardData(inputElement, (String[]) namesToImport.toArray(new String[namesToImport.size()]));
}
private void doPasteWithImportsOperation() {
ITextEditor editor= getTextEditor();
IJavaElement inputElement= (IJavaElement) editor.getEditorInput().getAdapter(IJavaElement.class);
Clipboard clipboard= new Clipboard(getDisplay());
ClipboardData importsData= (ClipboardData) clipboard.getContents(fgTransferInstance);
if (importsData != null && inputElement instanceof ICompilationUnit && !importsData.isFromSame(inputElement)) {
// combine operation and adding of imports
IRewriteTarget target= editor != null ? (IRewriteTarget) editor.getAdapter(IRewriteTarget.class) : null;
if (target != null) {
target.beginCompoundChange();
}
try {
fOperationTarget.doOperation(fOperationCode);
addImports((ICompilationUnit) inputElement, importsData);
} catch (CoreException e) {
JavaPlugin.log(e);
} finally {
if (target != null) {
target.endCompoundChange();
}
}
} else {
fOperationTarget.doOperation(fOperationCode);
}
}
private void addImports(ICompilationUnit unit, ClipboardData data) throws CoreException {
CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings();
ImportsStructure importsStructure= new ImportsStructure(unit, settings.importOrder, settings.importThreshold, true);
importsStructure.setFindAmbiguousImports(false);
String[] imports= data.getImports();
for (int i= 0; i < imports.length; i++) {
importsStructure.addImport(imports[i]);
}
importsStructure.create(false, null);
}
}
|
62,240
|
Bug 62240 Use of deprecated API SearchEngine#searchAllTypeNames
|
I20040513 + org.eclipse.jdt.core v_428a In org.eclipse.jdt.core v_428a, the version SearchEngine#searchAllTypeNames (...) that takes a matchMode and isCaseSentive is being replaced with a version that takes a matchRule.
|
verified fixed
|
16691ce
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T15:15:27Z
| 2004-05-14T10:20:00Z
|
org.eclipse.jdt.ui/core
| |
62,240
|
Bug 62240 Use of deprecated API SearchEngine#searchAllTypeNames
|
I20040513 + org.eclipse.jdt.core v_428a In org.eclipse.jdt.core v_428a, the version SearchEngine#searchAllTypeNames (...) that takes a matchMode and isCaseSentive is being replaced with a version that takes a matchRule.
|
verified fixed
|
16691ce
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T15:15:27Z
| 2004-05-14T10:20:00Z
|
extension/org/eclipse/jdt/internal/corext/util/AllTypesCache.java
| |
62,240
|
Bug 62240 Use of deprecated API SearchEngine#searchAllTypeNames
|
I20040513 + org.eclipse.jdt.core v_428a In org.eclipse.jdt.core v_428a, the version SearchEngine#searchAllTypeNames (...) that takes a matchMode and isCaseSentive is being replaced with a version that takes a matchRule.
|
verified fixed
|
16691ce
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T15:15:27Z
| 2004-05-14T10:20:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/AddImportOnSelectionAction.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.javaeditor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.window.Window;
import org.eclipse.ui.IEditorActionBarContributor;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.part.EditorActionBarContributor;
import org.eclipse.ui.texteditor.IUpdate;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IImportDeclaration;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.ITypeNameRequestor;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.internal.corext.codemanipulation.AddImportsOperation;
import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.TypeInfo;
import org.eclipse.jdt.internal.corext.util.TypeInfoRequestor;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.actions.ActionUtil;
import org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter;
import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
import org.eclipse.jdt.internal.ui.util.ElementValidator;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
import org.eclipse.jdt.internal.ui.util.ProgressService;
import org.eclipse.jdt.internal.ui.util.TypeInfoLabelProvider;
import org.eclipse.jdt.ui.IWorkingCopyManager;
public class AddImportOnSelectionAction extends Action implements IUpdate {
private CompilationUnitEditor fEditor;
public AddImportOnSelectionAction(CompilationUnitEditor editor) {
super(JavaEditorMessages.getString("AddImportOnSelection.label")); //$NON-NLS-1$
setToolTipText(JavaEditorMessages.getString("AddImportOnSelection.tooltip")); //$NON-NLS-1$
setDescription(JavaEditorMessages.getString("AddImportOnSelection.description")); //$NON-NLS-1$
fEditor= editor;
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.ADD_IMPORT_ON_SELECTION_ACTION);
setEnabled(getCompilationUnit() != null);
}
public void update() {
setEnabled(fEditor != null && getCompilationUnit() != null);
}
private ICompilationUnit getCompilationUnit () {
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
return manager.getWorkingCopy(fEditor.getEditorInput());
}
/*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
ICompilationUnit cu= getCompilationUnit();
if (!ElementValidator.checkValidateEdit(cu, getShell(), JavaEditorMessages.getString("AddImportOnSelection.error.title"))) //$NON-NLS-1$
return;
if (!ActionUtil.isProcessable(getShell(), cu))
return;
if (cu != null) {
ISelection s= fEditor.getSelectionProvider().getSelection();
IDocument doc= fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
ITextSelection selection= (ITextSelection) s;
if (doc != null) {
try {
int nameStart= getNameStart(doc, selection.getOffset());
int nameEnd= getNameEnd(doc, selection.getOffset() + selection.getLength());
int len= nameEnd - nameStart;
String name= doc.get(nameStart, len).trim();
String simpleName= Signature.getSimpleName(name);
String containerName= Signature.getQualifier(name);
IImportDeclaration existingImport= JavaModelUtil.findImport(cu, simpleName);
if (existingImport != null) {
if (!existingImport.getElementName().equals(name)) {
getShell().getDisplay().beep();
IStatusLineManager manager= getStatusLineManager();
if (manager != null) {
String message= JavaEditorMessages.getFormattedString("AddImportOnSelection.error.importclash", existingImport.getElementName()); //$NON-NLS-1$
manager.setErrorMessage(message);
}
} else {
removeQualification(doc, nameStart, containerName);
}
return;
}
IJavaSearchScope searchScope= SearchEngine.createJavaSearchScope(new IJavaElement[] { cu.getJavaProject() });
TypeInfo[] types= findAllTypes(simpleName, searchScope, null);
if (types.length== 0) {
getShell().getDisplay().beep();
return;
}
TypeInfo chosen= selectResult(types, containerName, getShell());
if (chosen == null) {
return;
}
IType type= chosen.resolveType(searchScope);
if (type == null) {
JavaPlugin.logErrorMessage("AddImportOnSelectionAction: Failed to resolve TypeRef: " + chosen.toString()); //$NON-NLS-1$
MessageDialog.openError(getShell(), JavaEditorMessages.getString("AddImportOnSelection.error.title"), JavaEditorMessages.getString("AddImportOnSelection.error.notresolved.message")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
removeQualification(doc, nameStart, chosen.getTypeContainerName());
CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings();
AddImportsOperation op= new AddImportsOperation(cu, new IJavaElement[] { type }, settings, false);
try {
ProgressService.runSuspended(false, true, new WorkbenchRunnableAdapter(op, op.getScheduleRule()));
} catch (InvocationTargetException e) {
ExceptionHandler.handle(e, getShell(), JavaEditorMessages.getString("AddImportOnSelection.error.title"), null); //$NON-NLS-1$
} catch (InterruptedException e) {
// Do nothing. Operation has been canceled.
}
return;
} catch (CoreException e) {
ExceptionHandler.handle(e, getShell(), JavaEditorMessages.getString("AddImportOnSelection.error.title"), null); //$NON-NLS-1$
} catch (BadLocationException e) {
JavaPlugin.log(e);
MessageDialog.openError(getShell(), JavaEditorMessages.getString("AddImportOnSelection.error.title"), e.getMessage()); //$NON-NLS-1$
}
}
}
}
private int getNameStart(IDocument doc, int pos) throws BadLocationException {
while (pos > 0) {
char ch= doc.getChar(pos - 1);
if (!Character.isJavaIdentifierPart(ch) && ch != '.') {
return pos;
}
pos--;
}
return pos;
}
private int getNameEnd(IDocument doc, int pos) throws BadLocationException {
if (pos > 0) {
if (Character.isWhitespace(doc.getChar(pos - 1))) {
return pos;
}
}
int len= doc.getLength();
while (pos < len) {
char ch= doc.getChar(pos);
if (!Character.isJavaIdentifierPart(ch)) {
return pos;
}
pos++;
}
return pos;
}
private void removeQualification(IDocument doc, int nameStart, String containerName) throws BadLocationException {
int containerLen= containerName.length();
int docLen= doc.getLength();
if ((containerLen > 0) && (nameStart + containerLen + 1 < docLen)) {
for (int k= 0; k < containerLen; k++) {
if (doc.getChar(nameStart + k) != containerName.charAt(k)) {
return;
}
}
if (doc.getChar(nameStart + containerLen) == '.') {
doc.replace(nameStart, containerLen + 1, ""); //$NON-NLS-1$
}
}
}
/**
* Finds a type by the simple name.
*/
private static TypeInfo[] findAllTypes(String simpleTypeName, IJavaSearchScope searchScope, IProgressMonitor monitor) throws CoreException {
SearchEngine searchEngine= new SearchEngine();
ArrayList typeRefsFound= new ArrayList(10);
ITypeNameRequestor requestor= new TypeInfoRequestor(typeRefsFound);
searchEngine.searchAllTypeNames(
JavaPlugin.getWorkspace(),
null,
simpleTypeName.toCharArray(),
SearchPattern.R_EXACT_MATCH,
true,
IJavaSearchConstants.TYPE,
searchScope,
requestor,
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
monitor);
return (TypeInfo[]) typeRefsFound.toArray(new TypeInfo[typeRefsFound.size()]);
}
private Shell getShell() {
return fEditor.getSite().getShell();
}
private TypeInfo selectResult(TypeInfo[] results, String containerName, Shell shell) {
int nResults= results.length;
if (nResults == 0) {
return null;
} else if (nResults == 1) {
return results[0];
}
if (containerName.length() != 0) {
for (int i= 0; i < nResults; i++) {
TypeInfo curr= results[i];
if (containerName.equals(curr.getTypeContainerName())) {
return curr;
}
}
}
ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLYQUALIFIED));
dialog.setTitle(JavaEditorMessages.getString("AddImportOnSelection.dialog.title")); //$NON-NLS-1$
dialog.setMessage(JavaEditorMessages.getString("AddImportOnSelection.dialog.message")); //$NON-NLS-1$
dialog.setElements(results);
if (dialog.open() == Window.OK) {
return (TypeInfo) dialog.getFirstResult();
}
return null;
}
private IStatusLineManager getStatusLineManager() {
IEditorActionBarContributor contributor= fEditor.getEditorSite().getActionBarContributor();
if (contributor instanceof EditorActionBarContributor) {
return ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager();
}
return null;
}
/**
* @return Returns the scheduling rule for this operation
*/
public ISchedulingRule getScheduleRule() {
return ResourcesPlugin.getWorkspace().getRoot();
}
}
|
62,880
|
Bug 62880 NLS Wizard: Source folder content assistant shows duplicates [nls] [refactoring]
|
200405190010 - Externalize Strings - in NLS Wizard, click 'Configure...' to open 'Configure Accessor Class' dialog - Ctrl+Space -> Source folder content assistant shows duplicates (e.g. I have 7 times 'org.eclipse.compare/compare')
|
verified fixed
|
2f2c30c
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T15:22:39Z
| 2004-05-19T12:33:20Z
|
org.eclipse.jdt.ui/ui
| |
62,880
|
Bug 62880 NLS Wizard: Source folder content assistant shows duplicates [nls] [refactoring]
|
200405190010 - Externalize Strings - in NLS Wizard, click 'Configure...' to open 'Configure Accessor Class' dialog - Ctrl+Space -> Source folder content assistant shows duplicates (e.g. I have 7 times 'org.eclipse.compare/compare')
|
verified fixed
|
2f2c30c
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T15:22:39Z
| 2004-05-19T12:33:20Z
|
refactoring/org/eclipse/jdt/internal/ui/refactoring/contentassist/JavaSourcePackageFragmentRootCompletionProcessor.java
| |
63,513
|
Bug 63513 Refactoring (moving public static final BigInteger to another type) exception [refactoring]
|
Eclipse M9: Here is the stack trace: !SESSION 22, 2004 07:48:25.934 -------------------------------------------- - eclipse.buildId=I200405211200 java.version=1.4.2_04 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=iw_IL !ENTRY org.eclipse.ui 4 4 22, 2004 07:48:25.954 !MESSAGE Unable to find Action Set: org.eclipse.help.internal.ui.HelpActionSet !ENTRY org.eclipse.ui 4 4 22, 2004 07:48:26.244 !MESSAGE Unable to find Action Set: org.eclipse.ui.Activities !ENTRY org.eclipse.ltk.ui.refactoring 4 10000 22, 2004 07:59:12.463 !MESSAGE Internal Error !STACK 0 java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run (RefactoringWizardDialog2.java:282) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish (RefactoringWizard.java:533) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish (UserInputWizardPage.java:153) at org.eclipse.jdt.internal.ui.refactoring.MoveMembersWizard$MoveMembersInputPage. performFinish(MoveMembersWizard.java:191) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:599) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed (RefactoringWizardDialog2.java:406) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:365) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:505) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.jface.window.Window.runEventLoop(Window.java:668) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.internal.ui.refactoring.actions.MoveStaticMembersAction.startRe factoring(MoveStaticMembersAction.java:163) at org.eclipse.jdt.internal.ui.refactoring.actions.MoveStaticMembersAction.run (MoveStaticMembersAction.java:116) at org.eclipse.jdt.ui.actions.MoveAction.tryMoveStaticMembers (MoveAction.java:163) at org.eclipse.jdt.ui.actions.MoveAction.run(MoveAction.java:138) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:216) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:899) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:850) at org.eclipse.jface.action.ActionContributionItem$7.handleEvent (ActionContributionItem.java:769) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:253) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:97) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:307) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:256) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622) Caused by: java.lang.ClassCastException at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.getDestinationBinding(MoveStaticMembersProcessor.java:822) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.createChange(MoveStaticMembersProcessor.java:760) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.checkFinalConditions(MoveStaticMembersProcessor.java:363) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFi nalConditions(ProcessorBasedRefactoring.java:134) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:114) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run (PerformChangeOperation.java:182) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101) Root exception: java.lang.ClassCastException at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.getDestinationBinding(MoveStaticMembersProcessor.java:822) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.createChange(MoveStaticMembersProcessor.java:760) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.checkFinalConditions(MoveStaticMembersProcessor.java:363) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFi nalConditions(ProcessorBasedRefactoring.java:134) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:114) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run (PerformChangeOperation.java:182) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101) !ENTRY org.eclipse.ltk.ui.refactoring 4 10000 22, 2004 07:59:33.804 !MESSAGE Internal Error !STACK 0 java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run (RefactoringWizardDialog2.java:282) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.createChange (RefactoringWizard.java:559) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage (RefactoringWizard.java:405) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.computeSuccessorPage (UserInputWizardPage.java:74) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.getNextPage (UserInputWizardPage.java:114) at org.eclipse.jdt.internal.ui.refactoring.MoveMembersWizard$MoveMembersInputPage. getNextPage(MoveMembersWizard.java:196) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.previewPressed (RefactoringWizardDialog2.java:429) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.access$3 (RefactoringWizardDialog2.java:427) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2 $1.widgetSelected(RefactoringWizardDialog2.java:562) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.jface.window.Window.runEventLoop(Window.java:668) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.internal.ui.refactoring.actions.MoveStaticMembersAction.startRe factoring(MoveStaticMembersAction.java:163) at org.eclipse.jdt.internal.ui.refactoring.actions.MoveStaticMembersAction.run (MoveStaticMembersAction.java:116) at org.eclipse.jdt.ui.actions.MoveAction.tryMoveStaticMembers (MoveAction.java:163) at org.eclipse.jdt.ui.actions.MoveAction.run(MoveAction.java:138) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:216) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:899) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:850) at org.eclipse.jface.action.ActionContributionItem$7.handleEvent (ActionContributionItem.java:769) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:253) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:97) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:307) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:256) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622) Caused by: java.lang.ClassCastException at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.getDestinationBinding(MoveStaticMembersProcessor.java:822) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.createChange(MoveStaticMembersProcessor.java:760) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.checkFinalConditions(MoveStaticMembersProcessor.java:363) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFi nalConditions(ProcessorBasedRefactoring.java:134) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:114) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101) Root exception: java.lang.ClassCastException at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.getDestinationBinding(MoveStaticMembersProcessor.java:822) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.createChange(MoveStaticMembersProcessor.java:760) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.checkFinalConditions(MoveStaticMembersProcessor.java:363) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFi nalConditions(ProcessorBasedRefactoring.java:134) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:114) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101)
|
verified fixed
|
096ab8f
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T15:51:00Z
| 2004-05-22T07:13:20Z
|
org.eclipse.jdt.ui/core
| |
63,513
|
Bug 63513 Refactoring (moving public static final BigInteger to another type) exception [refactoring]
|
Eclipse M9: Here is the stack trace: !SESSION 22, 2004 07:48:25.934 -------------------------------------------- - eclipse.buildId=I200405211200 java.version=1.4.2_04 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=iw_IL !ENTRY org.eclipse.ui 4 4 22, 2004 07:48:25.954 !MESSAGE Unable to find Action Set: org.eclipse.help.internal.ui.HelpActionSet !ENTRY org.eclipse.ui 4 4 22, 2004 07:48:26.244 !MESSAGE Unable to find Action Set: org.eclipse.ui.Activities !ENTRY org.eclipse.ltk.ui.refactoring 4 10000 22, 2004 07:59:12.463 !MESSAGE Internal Error !STACK 0 java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run (RefactoringWizardDialog2.java:282) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish (RefactoringWizard.java:533) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish (UserInputWizardPage.java:153) at org.eclipse.jdt.internal.ui.refactoring.MoveMembersWizard$MoveMembersInputPage. performFinish(MoveMembersWizard.java:191) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:599) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed (RefactoringWizardDialog2.java:406) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:365) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:505) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.jface.window.Window.runEventLoop(Window.java:668) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.internal.ui.refactoring.actions.MoveStaticMembersAction.startRe factoring(MoveStaticMembersAction.java:163) at org.eclipse.jdt.internal.ui.refactoring.actions.MoveStaticMembersAction.run (MoveStaticMembersAction.java:116) at org.eclipse.jdt.ui.actions.MoveAction.tryMoveStaticMembers (MoveAction.java:163) at org.eclipse.jdt.ui.actions.MoveAction.run(MoveAction.java:138) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:216) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:899) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:850) at org.eclipse.jface.action.ActionContributionItem$7.handleEvent (ActionContributionItem.java:769) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:253) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:97) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:307) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:256) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622) Caused by: java.lang.ClassCastException at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.getDestinationBinding(MoveStaticMembersProcessor.java:822) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.createChange(MoveStaticMembersProcessor.java:760) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.checkFinalConditions(MoveStaticMembersProcessor.java:363) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFi nalConditions(ProcessorBasedRefactoring.java:134) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:114) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run (PerformChangeOperation.java:182) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101) Root exception: java.lang.ClassCastException at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.getDestinationBinding(MoveStaticMembersProcessor.java:822) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.createChange(MoveStaticMembersProcessor.java:760) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.checkFinalConditions(MoveStaticMembersProcessor.java:363) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFi nalConditions(ProcessorBasedRefactoring.java:134) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:114) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run (PerformChangeOperation.java:182) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101) !ENTRY org.eclipse.ltk.ui.refactoring 4 10000 22, 2004 07:59:33.804 !MESSAGE Internal Error !STACK 0 java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run (RefactoringWizardDialog2.java:282) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.createChange (RefactoringWizard.java:559) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage (RefactoringWizard.java:405) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.computeSuccessorPage (UserInputWizardPage.java:74) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.getNextPage (UserInputWizardPage.java:114) at org.eclipse.jdt.internal.ui.refactoring.MoveMembersWizard$MoveMembersInputPage. getNextPage(MoveMembersWizard.java:196) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.previewPressed (RefactoringWizardDialog2.java:429) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.access$3 (RefactoringWizardDialog2.java:427) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2 $1.widgetSelected(RefactoringWizardDialog2.java:562) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.jface.window.Window.runEventLoop(Window.java:668) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.internal.ui.refactoring.actions.MoveStaticMembersAction.startRe factoring(MoveStaticMembersAction.java:163) at org.eclipse.jdt.internal.ui.refactoring.actions.MoveStaticMembersAction.run (MoveStaticMembersAction.java:116) at org.eclipse.jdt.ui.actions.MoveAction.tryMoveStaticMembers (MoveAction.java:163) at org.eclipse.jdt.ui.actions.MoveAction.run(MoveAction.java:138) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:216) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:899) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:850) at org.eclipse.jface.action.ActionContributionItem$7.handleEvent (ActionContributionItem.java:769) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:253) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:97) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:307) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:256) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622) Caused by: java.lang.ClassCastException at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.getDestinationBinding(MoveStaticMembersProcessor.java:822) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.createChange(MoveStaticMembersProcessor.java:760) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.checkFinalConditions(MoveStaticMembersProcessor.java:363) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFi nalConditions(ProcessorBasedRefactoring.java:134) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:114) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101) Root exception: java.lang.ClassCastException at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.getDestinationBinding(MoveStaticMembersProcessor.java:822) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.createChange(MoveStaticMembersProcessor.java:760) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersProcesso r.checkFinalConditions(MoveStaticMembersProcessor.java:363) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFi nalConditions(ProcessorBasedRefactoring.java:134) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:114) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101)
|
verified fixed
|
096ab8f
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T15:51:00Z
| 2004-05-22T07:13:20Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveStaticMembersProcessor.java
| |
63,700
|
Bug 63700 Javadoc problem with project/package formatting
|
I've just downloaded 3.0 M9 and set up the following Javadoc comment setting: "New line after @param tags" UNCHECKED If I manually call format in an open file, param's description goes in the same line as @param, as expected. However, if I right-click a project or package to format several files at once, param's description are incorrectly put in a new line. Actually, if I right-click just one file from the Package Explorer and format it, it mess up the params. The bottom line: this option is respected only when using Ctrl + Shift + F or the associated menu, but not from Package Explorer.
|
verified fixed
|
4fa4663
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T15:54:58Z
| 2004-05-24T14:46:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FormatAllAction.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.ui.actions;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBuffer;
import org.eclipse.core.filebuffers.ITextFileBufferManager;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.formatter.FormattingContextProperties;
import org.eclipse.jface.text.formatter.IFormattingContext;
import org.eclipse.jface.text.formatter.MultiPassContentFormatter;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.actions.ActionMessages;
import org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter;
import org.eclipse.jdt.internal.ui.browsing.LogicalPackage;
import org.eclipse.jdt.internal.ui.dialogs.OptionalMessageDialog;
import org.eclipse.jdt.internal.ui.dialogs.ProblemDialog;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.text.IJavaPartitions;
import org.eclipse.jdt.internal.ui.text.comment.CommentFormattingContext;
import org.eclipse.jdt.internal.ui.text.comment.CommentFormattingStrategy;
import org.eclipse.jdt.internal.ui.text.java.JavaFormattingStrategy;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
/**
* Fomats all selected compilertion units
* <p>
* The action is applicable to selections containing elements of
* type <code>ICompilationUnit</code>, <code>IPackage
* </code>, <code>IPackageFragmentRoot/code> and
* <code>IJavaProject</code>.
*
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*
* @since 3.0
*/
public class FormatAllAction extends SelectionDispatchAction {
/* (non-Javadoc)
* Class implements IObjectActionDelegate
*/
public static class ObjectDelegate implements IObjectActionDelegate {
private FormatAllAction fAction;
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
fAction= new FormatAllAction(targetPart.getSite());
}
public void run(IAction action) {
fAction.run();
}
public void selectionChanged(IAction action, ISelection selection) {
if (fAction == null)
action.setEnabled(false);
}
}
/**
* Creates a new <code>FormatAllAction</code>. The action requires
* that the selection provided by the site's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public FormatAllAction(IWorkbenchSite site) {
super(site);
setText(ActionMessages.getString("FormatAllAction.label")); //$NON-NLS-1$
setToolTipText(ActionMessages.getString("FormatAllAction.tooltip")); //$NON-NLS-1$
setDescription(ActionMessages.getString("FormatAllAction.description")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.FORMAT_ALL);
}
/* (non-Javadoc)
* Method declared on SelectionDispatchAction.
*/
public void selectionChanged(ITextSelection selection) {
// do nothing
}
/* (non-Javadoc)
* Method declared on SelectionDispatchAction.
*/
public void selectionChanged(IStructuredSelection selection) {
setEnabled(isEnabled(selection));
}
private ICompilationUnit[] getCompilationUnits(IStructuredSelection selection) {
HashSet result= new HashSet();
Object[] selected= selection.toArray();
for (int i= 0; i < selected.length; i++) {
try {
if (selected[i] instanceof IJavaElement) {
IJavaElement elem= (IJavaElement) selected[i];
if (elem.exists()) {
switch (elem.getElementType()) {
case IJavaElement.TYPE:
if (elem.getParent().getElementType() == IJavaElement.COMPILATION_UNIT) {
result.add(elem.getParent());
}
break;
case IJavaElement.COMPILATION_UNIT:
result.add(elem);
break;
case IJavaElement.IMPORT_CONTAINER:
result.add(elem.getParent());
break;
case IJavaElement.PACKAGE_FRAGMENT:
collectCompilationUnits((IPackageFragment) elem, result);
break;
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
collectCompilationUnits((IPackageFragmentRoot) elem, result);
break;
case IJavaElement.JAVA_PROJECT:
IPackageFragmentRoot[] roots= ((IJavaProject) elem).getPackageFragmentRoots();
for (int k= 0; k < roots.length; k++) {
collectCompilationUnits(roots[k], result);
}
break;
}
}
} else if (selected[i] instanceof LogicalPackage) {
IPackageFragment[] packageFragments= ((LogicalPackage)selected[i]).getFragments();
for (int k= 0; k < packageFragments.length; k++) {
IPackageFragment pack= packageFragments[k];
if (pack.exists()) {
collectCompilationUnits(pack, result);
}
}
}
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
}
return (ICompilationUnit[]) result.toArray(new ICompilationUnit[result.size()]);
}
private void collectCompilationUnits(IPackageFragment pack, Collection result) throws JavaModelException {
result.addAll(Arrays.asList(pack.getCompilationUnits()));
}
private void collectCompilationUnits(IPackageFragmentRoot root, Collection result) throws JavaModelException {
if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
IJavaElement[] children= root.getChildren();
for (int i= 0; i < children.length; i++) {
collectCompilationUnits((IPackageFragment) children[i], result);
}
}
}
private boolean isEnabled(IStructuredSelection selection) {
Object[] selected= selection.toArray();
for (int i= 0; i < selected.length; i++) {
try {
if (selected[i] instanceof IJavaElement) {
IJavaElement elem= (IJavaElement) selected[i];
if (elem.exists()) {
switch (elem.getElementType()) {
case IJavaElement.TYPE:
return elem.getParent().getElementType() == IJavaElement.COMPILATION_UNIT; // for browsing perspective
case IJavaElement.COMPILATION_UNIT:
return true;
case IJavaElement.IMPORT_CONTAINER:
return true;
case IJavaElement.PACKAGE_FRAGMENT:
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
IPackageFragmentRoot root= (IPackageFragmentRoot) elem.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
return (root.getKind() == IPackageFragmentRoot.K_SOURCE);
case IJavaElement.JAVA_PROJECT:
return hasSourceFolders((IJavaProject) elem);
}
}
} else if (selected[i] instanceof LogicalPackage) {
return true;
}
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
}
return false;
}
private boolean hasSourceFolders(IJavaProject project) throws JavaModelException {
IPackageFragmentRoot[] roots= project.getPackageFragmentRoots();
for (int i= 0; i < roots.length; i++) {
IPackageFragmentRoot root= roots[i];
if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
return true;
}
}
return false;
}
/* (non-Javadoc)
* Method declared on SelectionDispatchAction.
*/
public void run(ITextSelection selection) {
}
/* (non-Javadoc)
* Method declared on SelectionDispatchAction.
*/
public void run(IStructuredSelection selection) {
ICompilationUnit[] cus= getCompilationUnits(selection);
if (cus.length > 1) {
int returnCode= OptionalMessageDialog.open("FormatAll", //$NON-NLS-1$
getShell(),
ActionMessages.getString("FormatAllAction.noundo.title"), //$NON-NLS-1$
null,
ActionMessages.getString("FormatAllAction.noundo.message"), //$NON-NLS-1$
MessageDialog.WARNING,
new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL},
0);
if (returnCode != OptionalMessageDialog.NOT_SHOWN &&
returnCode != Window.OK ) return;
}
runOnMultiple(cus);
}
/**
* Peform format all on the given compilertion units
*/
public void runOnMultiple(final ICompilationUnit[] cus) {
try {
String message= ActionMessages.getString("FormatAllAction.status.description"); //$NON-NLS-1$
final MultiStatus status= new MultiStatus(JavaUI.ID_PLUGIN, IStatus.OK, message, null);
if (cus.length == 1) {
EditorUtility.openInEditor(cus[0]);
}
PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) {
doRunOnMultiple(cus, status, monitor);
}
})); // workspace lock
if (!status.isOK()) {
String title= ActionMessages.getString("FormatAllAction.multi.status.title"); //$NON-NLS-1$
ProblemDialog.open(getShell(), title, null, status);
}
} catch (InvocationTargetException e) {
ExceptionHandler.handle(e, getShell(), ActionMessages.getString("FormatAllAction.error.title"), ActionMessages.getString("FormatAllAction.error.message")); //$NON-NLS-1$ //$NON-NLS-2$
} catch (InterruptedException e) {
// cancelled by user
} catch (CoreException e) {
ExceptionHandler.handle(e, getShell(), ActionMessages.getString("FormatAllAction.error.title"), ActionMessages.getString("FormatAllAction.error.message")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
private static Map getFomatterSettings(IJavaProject project) {
final Map options= project.getOptions(true);
new CommentFormattingContext().storeToMap(PreferenceConstants.getPreferenceStore(), options, true);
return options;
}
private void doFormat(IDocument document, Map options) {
final IFormattingContext context = new CommentFormattingContext();
try {
context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, options);
context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(true));
final MultiPassContentFormatter formatter= new MultiPassContentFormatter(IJavaPartitions.JAVA_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE);
formatter.setMasterStrategy(new JavaFormattingStrategy());
formatter.setSlaveStrategy(new CommentFormattingStrategy(null), IJavaPartitions.JAVA_DOC);
formatter.setSlaveStrategy(new CommentFormattingStrategy(null), IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);
formatter.setSlaveStrategy(new CommentFormattingStrategy(null), IJavaPartitions.JAVA_MULTI_LINE_COMMENT);
formatter.format(document, context);
} finally {
context.dispose();
}
}
private void doRunOnMultiple(ICompilationUnit[] cus, MultiStatus status, IProgressMonitor monitor) throws OperationCanceledException {
if (monitor == null) {
monitor= new NullProgressMonitor();
}
monitor.setTaskName(ActionMessages.getString("FormatAllAction.operation.description")); //$NON-NLS-1$
monitor.beginTask("", cus.length * 4); //$NON-NLS-1$
try {
Map lastOptions= null;
IJavaProject lastProject= null;
for (int i= 0; i < cus.length; i++) {
ICompilationUnit cu= cus[i];
IPath path= cu.getPath();
if (lastProject == null || !lastProject.equals(cu.getJavaProject())) {
lastProject= cu.getJavaProject();
lastOptions= getFomatterSettings(lastProject);
}
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
try {
try {
manager.connect(path, new SubProgressMonitor(monitor, 1));
monitor.subTask(path.makeRelative().toString());
ITextFileBuffer fileBuffer= manager.getTextFileBuffer(path);
formatCompilationUnit(fileBuffer, lastOptions);
if (fileBuffer.isDirty() && !fileBuffer.isShared()) {
fileBuffer.commit(new SubProgressMonitor(monitor, 2), false);
} else {
monitor.worked(2);
}
} finally {
manager.disconnect(path, new SubProgressMonitor(monitor, 1));
}
} catch (CoreException e) {
status.add(e.getStatus());
}
}
} finally {
monitor.done();
}
}
private void formatCompilationUnit(final ITextFileBuffer fileBuffer, final Map options) {
if (fileBuffer.isShared()) {
getShell().getDisplay().syncExec(new Runnable() {
public void run() {
doFormat(fileBuffer.getDocument(), options);
}
});
} else {
doFormat(fileBuffer.getDocument(), options); // run in context thread
}
}
}
|
63,222
|
Bug 63222 problem messages during refactoring are being collapsed [refactoring]
|
i200405200800 I have seen this with other builds as well. When a problem happens during refactoring, the descriptions are collapsed, making it impossible to understand what is wrong. Will attach screenshot.
|
verified fixed
|
6dd7166
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T18:03:56Z
| 2004-05-20T16:20:00Z
|
org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/RefactoringStatusViewer.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ltk.internal.ui.refactoring;
import org.eclipse.compare.CompareUI;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.RefactoringStatusContext;
import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry;
import org.eclipse.ltk.internal.ui.refactoring.util.PixelConverter;
import org.eclipse.ltk.internal.ui.refactoring.util.ViewerPane;
import org.eclipse.ltk.ui.refactoring.IStatusContextViewer;
public class RefactoringStatusViewer extends SashForm {
private static class NullContextViewer implements IStatusContextViewer {
private Label fLabel;
public NullContextViewer() {
}
public void createControl(Composite parent) {
fLabel= new Label(parent, SWT.CENTER | SWT.FLAT);
fLabel.setText(RefactoringUIMessages.getString("ErrorWizardPage.no_context_information_available")); //$NON-NLS-1$
}
public void setInput(RefactoringStatusContext input) {
// do nothing
}
public Control getControl() {
return fLabel;
}
}
private class NextProblem extends Action {
public NextProblem() {
setImageDescriptor(CompareUI.DESC_ETOOL_NEXT);
setDisabledImageDescriptor(CompareUI.DESC_DTOOL_NEXT);
setHoverImageDescriptor(CompareUI.DESC_CTOOL_NEXT);
setToolTipText(RefactoringUIMessages.getString("ErrorWizardPage.next_Change")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IRefactoringHelpContextIds.NEXT_PROBLEM_ACTION);
}
public void run() {
revealElement(true);
}
public void update() {
boolean enabled= false;
if (fStatus != null && fStatus.hasEntries()) {
RefactoringStatusEntry[] entries= fStatus.getEntries();
int index= fTableViewer.getTable().getSelectionIndex();
enabled= index == -1 || index < entries.length - 1;
}
setEnabled(enabled);
}
}
private class PreviousProblem extends Action {
public PreviousProblem() {
setImageDescriptor(CompareUI.DESC_ETOOL_PREV);
setDisabledImageDescriptor(CompareUI.DESC_DTOOL_PREV);
setHoverImageDescriptor(CompareUI.DESC_CTOOL_PREV);
setToolTipText(RefactoringUIMessages.getString("ErrorWizardPage.previous_Change")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IRefactoringHelpContextIds.PREVIOUS_PROBLEM_ACTION);
}
public void run() {
revealElement(false);
}
public void update() {
boolean enabled= false;
if (fStatus != null && fStatus.hasEntries()) {
int index= fTableViewer.getTable().getSelectionIndex();
enabled= index == -1 || index > 0;
}
setEnabled(enabled);
}
}
private static class RefactoringStatusSorter extends ViewerSorter {
public int compare(Viewer viewer, Object e1, Object e2) {
int r1= ((RefactoringStatusEntry)e1).getSeverity();
int r2= ((RefactoringStatusEntry)e2).getSeverity();
if (r1 < r2)
return 1;
if (r2 < r1)
return -1;
return 0;
}
}
private RefactoringStatus fStatus;
private TableViewer fTableViewer;
private PageBook fContextViewerContainer;
private StatusContextViewerDescriptor fCurrentDescriptor;
private IStatusContextViewer fCurrentContextViewer;
private NullContextViewer fNullContextViewer;
private NextProblem fNextProblem;
private PreviousProblem fPreviousProblem;
public RefactoringStatusViewer(Composite parent, int style) {
super(parent, style | SWT.VERTICAL);
createContents();
}
/**
* Sets the refactoring status.
*
* @param status the refactoring status.
*/
public void setStatus(RefactoringStatus status){
fStatus= status;
if (fTableViewer.getInput() != fStatus) {
fTableViewer.setInput(fStatus);
fTableViewer.getTable().getColumn(0).pack();
ISelection selection= fTableViewer.getSelection();
if (selection.isEmpty()) {
RefactoringStatusEntry entry= getFirstEntry();
if (entry != null) {
fTableViewer.setSelection(new StructuredSelection(entry));
showContextViewer(entry);
fTableViewer.getControl().setFocus();
}
}
fNextProblem.update();
fPreviousProblem.update();
}
}
/**
* Returns the currently used <tt>RefactoringStatus</tt>.
* @return the <tt>RefactoringStatus</tt>
*/
public RefactoringStatus getStatus() {
return fStatus;
}
//---- UI creation ----------------------------------------------------------------------
public Point computeSize (int wHint, int hHint, boolean changed) {
PixelConverter converter= new PixelConverter(this);
return new Point(converter.convertWidthInCharsToPixels(90), converter.convertHeightInCharsToPixels(25));
}
private void createContents() {
GridLayout layout= new GridLayout();
layout.numColumns= 1; layout.marginWidth= 0; layout.marginHeight= 0;
setLayout(layout);
ViewerPane contextPane= new ViewerPane(this, SWT.BORDER | SWT.FLAT);
contextPane.setText(RefactoringUIMessages.getString("RefactoringStatusViewer.Found_problems")); //$NON-NLS-1$
ToolBarManager tbm= contextPane.getToolBarManager();
tbm.add(fNextProblem= new NextProblem());
tbm.add(fPreviousProblem= new PreviousProblem());
tbm.update(true);
createTableViewer(contextPane);
contextPane.setContent(fTableViewer.getControl());
fContextViewerContainer= new PageBook(this, SWT.NONE);
fNullContextViewer= new NullContextViewer();
fNullContextViewer.createControl(fContextViewerContainer);
fContextViewerContainer.showPage(fNullContextViewer.getControl());
fCurrentContextViewer= fNullContextViewer;
fCurrentContextViewer= fNullContextViewer;
fCurrentDescriptor= null;
setWeights(new int[]{35, 65});
}
private void createTableViewer(Composite parent) {
fTableViewer= new TableViewer(new Table(parent, SWT.SINGLE | SWT.H_SCROLL));
fTableViewer.setLabelProvider(new RefactoringStatusEntryLabelProvider());
fTableViewer.setContentProvider(new RefactoringStatusContentProvider());
fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
entrySelected(event.getSelection());
fNextProblem.update();
fPreviousProblem.update();
}
});
fTableViewer.setSorter(new RefactoringStatusSorter());
Table tableControl= fTableViewer.getTable();
GridData gd= new GridData(GridData.FILL_BOTH);
tableControl.setLayoutData(gd);
// Add a column so that we can pack it in setVisible.
TableColumn tc= new TableColumn(tableControl, SWT.NONE);
tc.setResizable(false);
}
//---- Feed status entry into context viewer ---------------------------------------------------------
private void entrySelected(ISelection s) {
if (!(s instanceof IStructuredSelection))
return;
Object first= ((IStructuredSelection) s).getFirstElement();
if (! (first instanceof RefactoringStatusEntry))
return;
RefactoringStatusEntry entry= (RefactoringStatusEntry)first;
showContextViewer(entry);
}
private void showContextViewer(RefactoringStatusEntry entry) {
RefactoringStatusContext context= entry.getContext();
if (context == null) {
showNullContextViewer();
} else {
try {
StatusContextViewerDescriptor descriptor= StatusContextViewerDescriptor.get(context);
if (fCurrentDescriptor != descriptor) {
IStatusContextViewer newViewer;
if (descriptor != null) {
newViewer= descriptor.createViewer();
newViewer.createControl(fContextViewerContainer);
} else {
newViewer= fNullContextViewer;
}
fCurrentDescriptor= descriptor;
newViewer.setInput(context);
if (fCurrentContextViewer != null && fCurrentContextViewer != fNullContextViewer)
fCurrentContextViewer.getControl().dispose();
fCurrentContextViewer= newViewer;
fContextViewerContainer.showPage(fCurrentContextViewer.getControl());
} else {
fCurrentContextViewer.setInput(context);
}
} catch (CoreException e) {
showNullContextViewer();
ExceptionHandler.handle(e, getShell(),
RefactoringUIMessages.getString("RefactoringStatusViewer.error.title"), //$NON-NLS-1$
RefactoringUIMessages.getString("RefactoringStatusViewer.error.message")); //$NON-NLS-1$
}
}
}
private void showNullContextViewer() {
fCurrentContextViewer= fNullContextViewer;
fCurrentDescriptor= null;
fContextViewerContainer.showPage(fCurrentContextViewer.getControl());
}
//---- Helpers ----------------------------------------------------------------------------------------
private RefactoringStatusEntry getFirstEntry() {
if (fStatus == null || !fStatus.hasEntries())
return null;
return fStatus.getEntryAt(0);
}
private void revealElement(boolean next) {
RefactoringStatusEntry[] entries= fStatus.getEntries();
if (entries.length == 0) {
return;
}
int index= fTableViewer.getTable().getSelectionIndex();
int last= entries.length - 1;
boolean doIt= true;
if (index == -1) {
index= 0;
} else if (next && index < last) {
index++;
} else if (!next && index > 0) {
index--;
} else {
doIt= false;
}
if (doIt)
fTableViewer.setSelection(new StructuredSelection(entries[index]));
}
}
|
64,015
|
Bug 64015 InvocationTargetException during Extract Constant [refactoring]
|
Version 3.0.m9. I got the InvocationTargetException below when I clicked OK to a Extract Constant refactoring. In the method: byte[] allocateBuffer(String cics, String program, String user, String password, int timeOutSeconds, byte[] data) throws UnsupportedEncodingException { int minLen = IN_BUFLEN_CICS + IN_BUFLEN_PROGRAM + IN_BUFLEN_USER + IN_BUFLEN_PASSWORD + IN_BUFLEN_TIMEOUT + IN_BUFLEN_DATALEN; byte[] buffer = new byte[minLen + data.length]; int index = 0; this.copy(cics, buffer, index, IN_BUFLEN_CICS); index += IN_BUFLEN_CICS; this.copy(program, buffer, index, IN_BUFLEN_PROGRAM); index += IN_BUFLEN_PROGRAM; this.copy(user, buffer, index, IN_BUFLEN_USER); index += IN_BUFLEN_USER; this.copy(password, buffer, index, IN_BUFLEN_PASSWORD); index += IN_BUFLEN_PASSWORD; this.copy(timeOutSeconds, buffer, index, IN_BUFLEN_TIMEOUT); index += IN_BUFLEN_TIMEOUT; this.copy(data.length, buffer, index, IN_BUFLEN_DATALEN); index += IN_BUFLEN_DATALEN; this.copy(data, buffer, index, data.length); index += data.length; return buffer; } I selected: IN_BUFLEN_CICS + IN_BUFLEN_PROGRAM + IN_BUFLEN_USER + IN_BUFLEN_PASSWORD + IN_BUFLEN_TIMEOUT + IN_BUFLEN_DATALEN Then I right-clicked Refactor/Extract Constant, set the name to "MIN_IN_BUFLEN", chose the scope to be package private, click OK and got: !ENTRY org.eclipse.ltk.ui.refactoring 4 10000 May 25, 2004 15:42:57.207 !MESSAGE Internal Error !STACK 0 java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:282) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard.java:533) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:153) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:599) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed(RefactoringWizardDialog2.java:406) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:365) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:505) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.jface.window.Window.runEventLoop(Window.java:668) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExtractConstantAction.run(ExtractConstantAction.java:94) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:216) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:899) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:850) at org.eclipse.jface.action.ActionContributionItem$7.handleEvent(ActionContributionItem.java:769) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:253) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:97) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:307) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:256) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622) Caused by: org.eclipse.jdt.internal.corext.Assert$AssertionFailedException: null argument; at org.eclipse.jdt.internal.corext.Assert.isNotNull(Assert.java:105) at org.eclipse.jdt.internal.corext.Assert.isNotNull(Assert.java:83) at org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory.createFragmentForFullSubtree(ASTFragmentFact ory.java:55) at org.eclipse.jdt.internal.corext.dom.fragments.AssociativeInfixExpressionFragment.getMatchingFragmentsWithNode (AssociativeInfixExpressionFragment.java:136) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.visitNode(ASTMatchingFragmentFinder.j ava:42) at org.eclipse.jdt.internal.corext.dom.GenericVisitor.visit(GenericVisitor.java:338) at org.eclipse.jdt.core.dom.TagElement.accept0(TagElement.java:256) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2526) at org.eclipse.jdt.core.dom.Javadoc.accept0(Javadoc.java:200) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2503) at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:487) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.findMatches(ASTMatchingFragmentFinder .java:34) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.findMatchingFragments(ASTMatchingFrag mentFinder.java:22) at org.eclipse.jdt.internal.corext.dom.fragments.SimpleFragment.getSubFragmentsMatching(SimpleFragment.java:38) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.getFragmentsToReplace(ExtractCons tantRefactoring.java:855) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.createReplaceExpressionWithConsta ntEdits(ExtractConstantRefactoring.java:602) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.getAllEdits(ExtractConstantRefact oring.java:482) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.checkCompilation(ExtractConstantR efactoring.java:421) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.checkFinalConditions(ExtractConst antRefactoring.java:409) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:182) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101) Root exception: org.eclipse.jdt.internal.corext.Assert$AssertionFailedException: null argument; at org.eclipse.jdt.internal.corext.Assert.isNotNull(Assert.java:105) at org.eclipse.jdt.internal.corext.Assert.isNotNull(Assert.java:83) at org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory.createFragmentForFullSubtree(ASTFragmentFact ory.java:55) at org.eclipse.jdt.internal.corext.dom.fragments.AssociativeInfixExpressionFragment.getMatchingFragmentsWithNode (AssociativeInfixExpressionFragment.java:136) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.visitNode(ASTMatchingFragmentFinder.j ava:42) at org.eclipse.jdt.internal.corext.dom.GenericVisitor.visit(GenericVisitor.java:338) at org.eclipse.jdt.core.dom.TagElement.accept0(TagElement.java:256) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2526) at org.eclipse.jdt.core.dom.Javadoc.accept0(Javadoc.java:200) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2503) at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:487) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.findMatches(ASTMatchingFragmentFinder .java:34) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.findMatchingFragments(ASTMatchingFrag mentFinder.java:22) at org.eclipse.jdt.internal.corext.dom.fragments.SimpleFragment.getSubFragmentsMatching(SimpleFragment.java:38) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.getFragmentsToReplace(ExtractCons tantRefactoring.java:855) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.createReplaceExpressionWithConsta ntEdits(ExtractConstantRefactoring.java:602) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.getAllEdits(ExtractConstantRefact oring.java:482) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.checkCompilation(ExtractConstantR efactoring.java:421) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.checkFinalConditions(ExtractConst antRefactoring.java:409) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:182) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
|
verified fixed
|
0072a41
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T18:26:11Z
| 2004-05-26T00:06:40Z
|
org.eclipse.jdt.ui/core
| |
64,015
|
Bug 64015 InvocationTargetException during Extract Constant [refactoring]
|
Version 3.0.m9. I got the InvocationTargetException below when I clicked OK to a Extract Constant refactoring. In the method: byte[] allocateBuffer(String cics, String program, String user, String password, int timeOutSeconds, byte[] data) throws UnsupportedEncodingException { int minLen = IN_BUFLEN_CICS + IN_BUFLEN_PROGRAM + IN_BUFLEN_USER + IN_BUFLEN_PASSWORD + IN_BUFLEN_TIMEOUT + IN_BUFLEN_DATALEN; byte[] buffer = new byte[minLen + data.length]; int index = 0; this.copy(cics, buffer, index, IN_BUFLEN_CICS); index += IN_BUFLEN_CICS; this.copy(program, buffer, index, IN_BUFLEN_PROGRAM); index += IN_BUFLEN_PROGRAM; this.copy(user, buffer, index, IN_BUFLEN_USER); index += IN_BUFLEN_USER; this.copy(password, buffer, index, IN_BUFLEN_PASSWORD); index += IN_BUFLEN_PASSWORD; this.copy(timeOutSeconds, buffer, index, IN_BUFLEN_TIMEOUT); index += IN_BUFLEN_TIMEOUT; this.copy(data.length, buffer, index, IN_BUFLEN_DATALEN); index += IN_BUFLEN_DATALEN; this.copy(data, buffer, index, data.length); index += data.length; return buffer; } I selected: IN_BUFLEN_CICS + IN_BUFLEN_PROGRAM + IN_BUFLEN_USER + IN_BUFLEN_PASSWORD + IN_BUFLEN_TIMEOUT + IN_BUFLEN_DATALEN Then I right-clicked Refactor/Extract Constant, set the name to "MIN_IN_BUFLEN", chose the scope to be package private, click OK and got: !ENTRY org.eclipse.ltk.ui.refactoring 4 10000 May 25, 2004 15:42:57.207 !MESSAGE Internal Error !STACK 0 java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:282) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard.java:533) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:153) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:599) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed(RefactoringWizardDialog2.java:406) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:365) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:505) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.jface.window.Window.runEventLoop(Window.java:668) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExtractConstantAction.run(ExtractConstantAction.java:94) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:216) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:899) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:850) at org.eclipse.jface.action.ActionContributionItem$7.handleEvent(ActionContributionItem.java:769) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:253) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:97) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:307) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:256) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622) Caused by: org.eclipse.jdt.internal.corext.Assert$AssertionFailedException: null argument; at org.eclipse.jdt.internal.corext.Assert.isNotNull(Assert.java:105) at org.eclipse.jdt.internal.corext.Assert.isNotNull(Assert.java:83) at org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory.createFragmentForFullSubtree(ASTFragmentFact ory.java:55) at org.eclipse.jdt.internal.corext.dom.fragments.AssociativeInfixExpressionFragment.getMatchingFragmentsWithNode (AssociativeInfixExpressionFragment.java:136) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.visitNode(ASTMatchingFragmentFinder.j ava:42) at org.eclipse.jdt.internal.corext.dom.GenericVisitor.visit(GenericVisitor.java:338) at org.eclipse.jdt.core.dom.TagElement.accept0(TagElement.java:256) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2526) at org.eclipse.jdt.core.dom.Javadoc.accept0(Javadoc.java:200) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2503) at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:487) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.findMatches(ASTMatchingFragmentFinder .java:34) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.findMatchingFragments(ASTMatchingFrag mentFinder.java:22) at org.eclipse.jdt.internal.corext.dom.fragments.SimpleFragment.getSubFragmentsMatching(SimpleFragment.java:38) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.getFragmentsToReplace(ExtractCons tantRefactoring.java:855) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.createReplaceExpressionWithConsta ntEdits(ExtractConstantRefactoring.java:602) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.getAllEdits(ExtractConstantRefact oring.java:482) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.checkCompilation(ExtractConstantR efactoring.java:421) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.checkFinalConditions(ExtractConst antRefactoring.java:409) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:182) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101) Root exception: org.eclipse.jdt.internal.corext.Assert$AssertionFailedException: null argument; at org.eclipse.jdt.internal.corext.Assert.isNotNull(Assert.java:105) at org.eclipse.jdt.internal.corext.Assert.isNotNull(Assert.java:83) at org.eclipse.jdt.internal.corext.dom.fragments.ASTFragmentFactory.createFragmentForFullSubtree(ASTFragmentFact ory.java:55) at org.eclipse.jdt.internal.corext.dom.fragments.AssociativeInfixExpressionFragment.getMatchingFragmentsWithNode (AssociativeInfixExpressionFragment.java:136) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.visitNode(ASTMatchingFragmentFinder.j ava:42) at org.eclipse.jdt.internal.corext.dom.GenericVisitor.visit(GenericVisitor.java:338) at org.eclipse.jdt.core.dom.TagElement.accept0(TagElement.java:256) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2526) at org.eclipse.jdt.core.dom.Javadoc.accept0(Javadoc.java:200) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2503) at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:487) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.findMatches(ASTMatchingFragmentFinder .java:34) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.findMatchingFragments(ASTMatchingFrag mentFinder.java:22) at org.eclipse.jdt.internal.corext.dom.fragments.SimpleFragment.getSubFragmentsMatching(SimpleFragment.java:38) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.getFragmentsToReplace(ExtractCons tantRefactoring.java:855) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.createReplaceExpressionWithConsta ntEdits(ExtractConstantRefactoring.java:602) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.getAllEdits(ExtractConstantRefact oring.java:482) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.checkCompilation(ExtractConstantR efactoring.java:421) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.checkFinalConditions(ExtractConst antRefactoring.java:409) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:182) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
|
verified fixed
|
0072a41
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-26T18:26:11Z
| 2004-05-26T00:06:40Z
|
extension/org/eclipse/jdt/internal/corext/dom/fragments/ASTMatchingFragmentFinder.java
| |
48,779
|
Bug 48779 Extract local should work in initializers as well [refactoring]
|
I20031211 Title says it all.
|
verified fixed
|
7905560
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T07:27:49Z
| 2003-12-15T20:26:40Z
|
org.eclipse.jdt.ui.tests.refactoring/resources/ExtractTemp/canExtract/A_test79_in.java
| |
48,779
|
Bug 48779 Extract local should work in initializers as well [refactoring]
|
I20031211 Title says it all.
|
verified fixed
|
7905560
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T07:27:49Z
| 2003-12-15T20:26:40Z
|
org.eclipse.jdt.ui.tests.refactoring/resources/ExtractTemp/canExtract/A_test79_out.java
| |
48,779
|
Bug 48779 Extract local should work in initializers as well [refactoring]
|
I20031211 Title says it all.
|
verified fixed
|
7905560
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T07:27:49Z
| 2003-12-15T20:26:40Z
|
org.eclipse.jdt.ui.tests.refactoring/resources/ExtractTemp/canExtract/A_test80_in.java
| |
48,779
|
Bug 48779 Extract local should work in initializers as well [refactoring]
|
I20031211 Title says it all.
|
verified fixed
|
7905560
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T07:27:49Z
| 2003-12-15T20:26:40Z
|
org.eclipse.jdt.ui.tests.refactoring/resources/ExtractTemp/canExtract/A_test80_out.java
| |
48,779
|
Bug 48779 Extract local should work in initializers as well [refactoring]
|
I20031211 Title says it all.
|
verified fixed
|
7905560
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T07:27:49Z
| 2003-12-15T20:26:40Z
|
org.eclipse.jdt.ui.tests.refactoring/test
| |
48,779
|
Bug 48779 Extract local should work in initializers as well [refactoring]
|
I20031211 Title says it all.
|
verified fixed
|
7905560
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T07:27:49Z
| 2003-12-15T20:26:40Z
|
cases/org/eclipse/jdt/ui/tests/refactoring/ExtractTempTests.java
| |
48,779
|
Bug 48779 Extract local should work in initializers as well [refactoring]
|
I20031211 Title says it all.
|
verified fixed
|
7905560
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T07:27:49Z
| 2003-12-15T20:26:40Z
|
org.eclipse.jdt.ui/core
| |
48,779
|
Bug 48779 Extract local should work in initializers as well [refactoring]
|
I20031211 Title says it all.
|
verified fixed
|
7905560
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T07:27:49Z
| 2003-12-15T20:26:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java
| |
64,286
|
Bug 64286 Mark exit points does not mark selected element (inconsistency)
|
I200405250800 in all other occurrence marking things the selected element is also highlighted.
|
verified fixed
|
6f6ef2f
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T07:41:14Z
| 2004-05-27T06:40:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/MethodExitsFinder.java
|
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.search;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
import org.eclipse.jdt.core.dom.Block;
import org.eclipse.jdt.core.dom.CatchClause;
import org.eclipse.jdt.core.dom.ClassInstanceCreation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.ConstructorInvocation;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.ReturnStatement;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.Statement;
import org.eclipse.jdt.core.dom.SuperConstructorInvocation;
import org.eclipse.jdt.core.dom.SuperMethodInvocation;
import org.eclipse.jdt.core.dom.ThrowStatement;
import org.eclipse.jdt.core.dom.TryStatement;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.dom.LocalVariableIndex;
import org.eclipse.jdt.internal.corext.dom.NodeFinder;
import org.eclipse.jdt.internal.corext.refactoring.code.flow.FlowContext;
import org.eclipse.jdt.internal.corext.refactoring.code.flow.FlowInfo;
import org.eclipse.jdt.internal.corext.refactoring.code.flow.InOutFlowAnalyzer;
public class MethodExitsFinder extends ASTVisitor {
private AST fAST;
private MethodDeclaration fMethodDeclaration;
private List fResult;
private List fCatchedExceptions;
public String initialize(CompilationUnit root, int offset, int length) {
fAST= root.getAST();
ASTNode node= NodeFinder.perform(root, offset, length);
Type type= null;
if (node instanceof Type) {
type= (Type)node;
} else if (node instanceof Name) {
Name name= ASTNodes.getTopMostName((Name)node);
if (name.getParent() instanceof Type) {
type= (Type)name.getParent();
}
}
if (type == null)
return SearchMessages.getString("MethodExitsFinder.no_return_type_selected"); //$NON-NLS-1$
type= ASTNodes.getTopMostType(type);
if (!(type.getParent() instanceof MethodDeclaration))
return SearchMessages.getString("MethodExitsFinder.no_return_type_selected"); //$NON-NLS-1$
fMethodDeclaration= (MethodDeclaration)type.getParent();
return null;
}
public List perform() {
fResult= new ArrayList();
fCatchedExceptions= new ArrayList();
fMethodDeclaration.accept(this);
Block block= fMethodDeclaration.getBody();
if (block != null) {
List statements= block.statements();
if (statements.size() > 0) {
Statement last= (Statement)statements.get(statements.size() - 1);
int maxVariableId= LocalVariableIndex.perform(fMethodDeclaration);
FlowContext flowContext= new FlowContext(0, maxVariableId + 1);
flowContext.setConsiderAccessMode(false);
flowContext.setComputeMode(FlowContext.ARGUMENTS);
InOutFlowAnalyzer flowAnalyzer= new InOutFlowAnalyzer(flowContext);
FlowInfo info= flowAnalyzer.perform(new ASTNode[] {last});
if (!info.isNoReturn()) {
if (!info.isPartialReturn())
return fResult;
}
}
SimpleName name= fAST.newSimpleName("x"); //$NON-NLS-1$
name.setSourceRange(fMethodDeclaration.getStartPosition() + fMethodDeclaration.getLength() - 1, 1);
fResult.add(name);
}
return fResult;
}
public boolean visit(TypeDeclaration node) {
// Don't dive into a local type.
return false;
}
public boolean visit(AnonymousClassDeclaration node) {
// Don't dive into a local type.
return false;
}
public boolean visit(ReturnStatement node) {
fResult.add(node);
return super.visit(node);
}
public boolean visit(TryStatement node) {
int currentSize= fCatchedExceptions.size();
List catchClauses= node.catchClauses();
for (Iterator iter= catchClauses.iterator(); iter.hasNext();) {
IVariableBinding variable= ((CatchClause)iter.next()).getException().resolveBinding();
if (variable != null && variable.getType() != null) {
fCatchedExceptions.add(variable.getType());
}
}
node.getBody().accept(this);
int toRemove= fCatchedExceptions.size() - currentSize;
for(int i= toRemove; i > 0; i--) {
fCatchedExceptions.remove(currentSize);
}
// visit catch and finally
for (Iterator iter= catchClauses.iterator(); iter.hasNext(); ) {
((CatchClause)iter.next()).accept(this);
}
if (node.getFinally() != null)
node.getFinally().accept(this);
// return false. We have visited the body by ourselves.
return false;
}
public boolean visit(ThrowStatement node) {
ITypeBinding exception= node.getExpression().resolveTypeBinding();
if (isExitPoint(exception)) {
SimpleName name= fAST.newSimpleName("xxxxx"); //$NON-NLS-1$
name.setSourceRange(node.getStartPosition(), 5);
fResult.add(name);
}
return true;
}
public boolean visit(MethodInvocation node) {
if (isExitPoint(node.resolveMethodBinding())) {
fResult.add(node.getName());
}
return true;
}
public boolean visit(SuperMethodInvocation node) {
if (isExitPoint(node.resolveMethodBinding())) {
fResult.add(node.getName());
}
return true;
}
public boolean visit(ClassInstanceCreation node) {
if (isExitPoint(node.resolveConstructorBinding())) {
fResult.add(node.getName());
}
return true;
}
public boolean visit(ConstructorInvocation node) {
if (isExitPoint(node.resolveConstructorBinding())) {
// mark this
SimpleName name= fAST.newSimpleName("xxxx"); //$NON-NLS-1$
name.setSourceRange(node.getStartPosition(), 4);
fResult.add(name);
}
return true;
}
public boolean visit(SuperConstructorInvocation node) {
if (isExitPoint(node.resolveConstructorBinding())) {
SimpleName name= fAST.newSimpleName("xxxxx"); //$NON-NLS-1$
name.setSourceRange(node.getStartPosition(), 5);
fResult.add(name);
}
return true;
}
private boolean isExitPoint(ITypeBinding binding) {
if (binding == null)
return false;
return !isCatched(binding);
}
private boolean isExitPoint(IMethodBinding binding) {
if (binding == null)
return false;
ITypeBinding[] exceptions= binding.getExceptionTypes();
for (int i= 0; i < exceptions.length; i++) {
if (!isCatched(exceptions[i]))
return true;
}
return false;
}
private boolean isCatched(ITypeBinding binding) {
for (Iterator iter= fCatchedExceptions.iterator(); iter.hasNext();) {
ITypeBinding catchException= (ITypeBinding)iter.next();
if (catches(catchException, binding))
return true;
}
return false;
}
private boolean catches(ITypeBinding catchTypeBinding, ITypeBinding throwTypeBinding) {
while(throwTypeBinding != null) {
if (throwTypeBinding == catchTypeBinding)
return true;
throwTypeBinding= throwTypeBinding.getSuperclass();
}
return false;
}
}
|
61,172
|
Bug 61172 [rulers] quick assist hides quickfix icon
|
1) mistype a method call ->you get a quick fix but the quick fix is overlayed by the quick assist 2) press the quick assist icon ->you the the quick fix proposals
|
verified fixed
|
a254ecf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T07:45:25Z
| 2004-05-06T07:53:20Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.correction;
import java.util.Iterator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationAccessExtension;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IAnnotationPresentation;
import org.eclipse.jface.text.source.ImageUtilities;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.ui.text.java.IInvocationContext;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.viewsupport.ISelectionListenerWithAST;
import org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager;
/**
*
*/
public class QuickAssistLightBulbUpdater {
public static class AssistAnnotation extends Annotation implements IAnnotationPresentation {
//XXX: To be fully correct this should be a non-static fields in QuickAssistLightBulbUpdater
private static final int LAYER;
static {
Annotation annotation= new Annotation("org.eclipse.jdt.ui.error", false, null); //$NON-NLS-1$
AnnotationPreference preference= EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
if (preference != null)
LAYER= preference.getPresentationLayer() + 1;
else
LAYER= IAnnotationAccessExtension.DEFAULT_LAYER + 1;
}
private Image fImage;
public AssistAnnotation() {
}
/*
* @see org.eclipse.jface.text.source.IAnnotationPresentation#getLayer()
*/
public int getLayer() {
return LAYER;
}
private Image getImage() {
if (fImage == null) {
fImage= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_QUICK_ASSIST);
}
return fImage;
}
/* (non-Javadoc)
* @see org.eclipse.jface.text.source.Annotation#paint(org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Canvas, org.eclipse.swt.graphics.Rectangle)
*/
public void paint(GC gc, Canvas canvas, Rectangle r) {
ImageUtilities.drawImage(getImage(), gc, canvas, r, SWT.CENTER, SWT.TOP);
}
}
private final Annotation fAnnotation;
private boolean fIsAnnotationShown;
private IEditorPart fEditor;
private ITextViewer fViewer;
private ISelectionListenerWithAST fListener;
private IPropertyChangeListener fPropertyChangeListener;
public QuickAssistLightBulbUpdater(IEditorPart part, ITextViewer viewer) {
fEditor= part;
fViewer= viewer;
fAnnotation= new AssistAnnotation();
fIsAnnotationShown= false;
fPropertyChangeListener= null;
}
public boolean isSetInPreferences() {
return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB);
}
private void installSelectionListener() {
fListener= new ISelectionListenerWithAST() {
public void selectionChanged(IEditorPart part, ITextSelection selection, CompilationUnit astRoot) {
doSelectionChanged(selection.getOffset(), selection.getLength(), astRoot);
}
};
SelectionListenerWithASTManager.getDefault().addListener(fEditor, fListener);
}
private void uninstallSelectionListener() {
if (fListener != null) {
SelectionListenerWithASTManager.getDefault().removeListener(fEditor, fListener);
fListener= null;
}
IAnnotationModel model= getAnnotationModel();
if (model != null) {
removeLightBulb(model);
}
}
public void install() {
if (isSetInPreferences()) {
installSelectionListener();
}
if (fPropertyChangeListener == null) {
fPropertyChangeListener= new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
doPropertyChanged(event.getProperty());
}
};
PreferenceConstants.getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
}
}
public void uninstall() {
uninstallSelectionListener();
if (fPropertyChangeListener != null) {
PreferenceConstants.getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
fPropertyChangeListener= null;
}
}
protected void doPropertyChanged(String property) {
if (property.equals(PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB)) {
if (isSetInPreferences()) {
ICompilationUnit cu= getCompilationUnit();
if (cu != null) {
installSelectionListener();
Point point= fViewer.getSelectedRange();
ASTParser parser= ASTParser.newParser(AST.JLS2);
parser.setSource(cu);
parser.setResolveBindings(true);
CompilationUnit astRoot= (CompilationUnit) parser.createAST(null);
doSelectionChanged(point.x, point.y, astRoot);
}
} else {
uninstallSelectionListener();
}
}
}
private ICompilationUnit getCompilationUnit() {
IEditorInput input= fEditor.getEditorInput();
Object elem= input.getAdapter(IJavaElement.class);
if (elem instanceof ICompilationUnit) {
return (ICompilationUnit) elem;
}
return null;
}
private IAnnotationModel getAnnotationModel() {
return JavaUI.getDocumentProvider().getAnnotationModel(fEditor.getEditorInput());
}
private IDocument getDocument() {
return JavaUI.getDocumentProvider().getDocument(fEditor.getEditorInput());
}
private void doSelectionChanged(int offset, int length, CompilationUnit astRoot) {
final IAnnotationModel model= getAnnotationModel();
final ICompilationUnit cu= getCompilationUnit();
if (model == null || cu == null) {
return;
}
final AssistContext context= new AssistContext(cu, offset, length);
context.setASTRoot(astRoot);
boolean hasQuickFix= hasQuickFixLightBulb(model, context.getSelectionOffset());
if (hasQuickFix) {
removeLightBulb(model);
return; // there is already a quick fix light bulb at the new location
}
calculateLightBulb(model, context);
}
/*
* Needs to be called synchronized
*/
private void calculateLightBulb(IAnnotationModel model, IInvocationContext context) {
boolean needsAnnotation= JavaCorrectionProcessor.hasAssists(context);
if (fIsAnnotationShown) {
model.removeAnnotation(fAnnotation);
}
if (needsAnnotation) {
model.addAnnotation(fAnnotation, new Position(context.getSelectionOffset(), context.getSelectionLength()));
}
fIsAnnotationShown= needsAnnotation;
}
private void removeLightBulb(IAnnotationModel model) {
synchronized (this) {
if (fIsAnnotationShown) {
model.removeAnnotation(fAnnotation);
fIsAnnotationShown= false;
}
}
}
/*
* Tests if there is already a quick fix light bulb on the current line
*/
private boolean hasQuickFixLightBulb(IAnnotationModel model, int offset) {
try {
IDocument document= getDocument();
if (document == null) {
return false;
}
int currLine= document.getLineOfOffset(offset);
Iterator iter= model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annot= (Annotation) iter.next();
if (JavaCorrectionProcessor.isQuickFixableType(annot)) {
Position pos= model.getPosition(annot);
if (pos != null) {
int startLine= document.getLineOfOffset(pos.getOffset());
if (startLine == currLine && JavaCorrectionProcessor.hasCorrections(annot)) {
return true;
}
}
}
}
} catch (BadLocationException e) {
JavaPlugin.log(e);
}
return false;
}
}
|
62,871
|
Bug 62871 Extract Local Var: Index Out Of Bounds in ExtractTempRefactoring.getFirstReplacedExpression
|
I200405190010 Dumb user selected a field reference (fMB2 in MoneyTest.setup) and then Extract Local Variable. Clicked OK. java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:282) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard.java:533) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:153) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:599) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed(RefactoringWizardDialog2.java:406) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:365) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:505) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.jface.window.Window.runEventLoop(Window.java:668) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExtractTempAction.run(ExtractTempAction.java:93) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:216) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:899) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:850) at org.eclipse.jface.action.ActionContributionItem$7.handleEvent(ActionContributionItem.java:769) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:253) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:97) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:305) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:256) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:184) at org.eclipse.core.launcher.Main.run(Main.java:637) at org.eclipse.core.launcher.Main.main(Main.java:621) Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.getFirstReplacedExpression(ExtractTempRefactoring.java:713) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.getNodeToInsertTempDeclarationBefore(ExtractTempRefactoring.java:628) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.createAndInsertTempDeclaration(ExtractTempRefactoring.java:559) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.createTempDeclarationEdit(ExtractTempRefactoring.java:549) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.getAllEdits(ExtractTempRefactoring.java:534) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.checkFinalConditions(ExtractTempRefactoring.java:397) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:182) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1677) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101) Root exception: java.lang.ArrayIndexOutOfBoundsException: 0 at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.getFirstReplacedExpression(ExtractTempRefactoring.java:713) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.getNodeToInsertTempDeclarationBefore(ExtractTempRefactoring.java:628) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.createAndInsertTempDeclaration(ExtractTempRefactoring.java:559) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.createTempDeclarationEdit(ExtractTempRefactoring.java:549) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.getAllEdits(ExtractTempRefactoring.java:534) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.checkFinalConditions(ExtractTempRefactoring.java:397) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:182) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1677) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
|
verified fixed
|
00f873d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T08:00:24Z
| 2004-05-19T12:33:20Z
|
org.eclipse.jdt.ui/core
| |
62,871
|
Bug 62871 Extract Local Var: Index Out Of Bounds in ExtractTempRefactoring.getFirstReplacedExpression
|
I200405190010 Dumb user selected a field reference (fMB2 in MoneyTest.setup) and then Extract Local Variable. Clicked OK. java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:282) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard.java:533) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:153) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:599) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed(RefactoringWizardDialog2.java:406) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:365) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:505) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.jface.window.Window.runEventLoop(Window.java:668) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExtractTempAction.run(ExtractTempAction.java:93) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:216) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:899) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:850) at org.eclipse.jface.action.ActionContributionItem$7.handleEvent(ActionContributionItem.java:769) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:253) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:97) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:305) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:256) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:184) at org.eclipse.core.launcher.Main.run(Main.java:637) at org.eclipse.core.launcher.Main.main(Main.java:621) Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.getFirstReplacedExpression(ExtractTempRefactoring.java:713) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.getNodeToInsertTempDeclarationBefore(ExtractTempRefactoring.java:628) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.createAndInsertTempDeclaration(ExtractTempRefactoring.java:559) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.createTempDeclarationEdit(ExtractTempRefactoring.java:549) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.getAllEdits(ExtractTempRefactoring.java:534) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.checkFinalConditions(ExtractTempRefactoring.java:397) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:182) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1677) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101) Root exception: java.lang.ArrayIndexOutOfBoundsException: 0 at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.getFirstReplacedExpression(ExtractTempRefactoring.java:713) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.getNodeToInsertTempDeclarationBefore(ExtractTempRefactoring.java:628) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.createAndInsertTempDeclaration(ExtractTempRefactoring.java:559) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.createTempDeclarationEdit(ExtractTempRefactoring.java:549) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.getAllEdits(ExtractTempRefactoring.java:534) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring.checkFinalConditions(ExtractTempRefactoring.java:397) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:182) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1677) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
|
verified fixed
|
00f873d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T08:00:24Z
| 2004-05-19T12:33:20Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java
| |
61,878
|
Bug 61878 Package explorer is filtering out plugin dependencies [package explorer]
|
Build 20040506 When expanding the Plug-in Dependencies container, it is counter-intuitive to hide project dependencies. These are shown in the build path wizard itself, when you expand this container. I would expect to see them all the time.
|
verified fixed
|
8aadc81
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T08:31:01Z
| 2004-05-12T11:06:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/ClassPathContainer.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.packageview;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.jdt.core.ClasspathContainerInitializer;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.JavaElementImageDescriptor;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
/**
* Representation of class path containers in Java UI.
*/
public class ClassPathContainer implements IAdaptable, IWorkbenchAdapter {
private IJavaProject fProject;
private IClasspathEntry fClassPathEntry;
private IClasspathContainer fContainer;
public ClassPathContainer(IJavaProject parent, IClasspathEntry entry) {
fProject= parent;
fClassPathEntry= entry;
try {
fContainer= JavaCore.getClasspathContainer(entry.getPath(), parent);
} catch (JavaModelException e) {
fContainer= null;
}
}
public boolean equals(Object obj) {
if (obj instanceof ClassPathContainer) {
ClassPathContainer other = (ClassPathContainer)obj;
if (fProject.equals(other.fProject) &&
fClassPathEntry.equals(other.fClassPathEntry)) {
return true;
}
}
return false;
}
public int hashCode() {
return fProject.hashCode()*17+fClassPathEntry.hashCode();
}
public Object[] getPackageFragmentRoots() {
return fProject.findPackageFragmentRoots(fClassPathEntry);
}
public Object getAdapter(Class adapter) {
if (adapter == IWorkbenchAdapter.class)
return this;
if ((adapter == IResource.class) && (fContainer instanceof IAdaptable))
return ((IAdaptable)fContainer).getAdapter(IResource.class);
return null;
}
public Object[] getChildren(Object o) {
return getPackageFragmentRoots();
}
public ImageDescriptor getImageDescriptor(Object object) {
ImageDescriptor desc= JavaPluginImages.DESC_OBJS_LIBRARY;
if (fContainer == null) {
desc = new JavaElementImageDescriptor(desc, JavaElementImageDescriptor.ERROR, JavaElementImageProvider.SMALL_SIZE);
}
return desc;
}
public String getLabel(Object o) {
if (fContainer != null)
return fContainer.getDescription();
IPath path= fClassPathEntry.getPath();
String containerId= path.segment(0);
ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerId);
if (initializer != null) {
String description= initializer.getDescription(path, fProject);
return PackagesMessages.getFormattedString("ClassPathContainer.unbound_label", description); //$NON-NLS-1$
}
return PackagesMessages.getFormattedString("ClassPathContainer.unknown_label", path.toString()); //$NON-NLS-1$
}
public Object getParent(Object o) {
return getJavaProject();
}
public IJavaProject getJavaProject() {
return fProject;
}
public IClasspathEntry getClasspathEntry() {
return fClassPathEntry;
}
static boolean contains(IJavaProject project, IClasspathEntry entry, IPackageFragmentRoot root) {
IPackageFragmentRoot[] roots= project.findPackageFragmentRoots(entry);
for (int i= 0; i < roots.length; i++) {
if (roots[i].equals(root))
return true;
}
return false;
}
}
|
61,878
|
Bug 61878 Package explorer is filtering out plugin dependencies [package explorer]
|
Build 20040506 When expanding the Plug-in Dependencies container, it is counter-intuitive to hide project dependencies. These are shown in the build path wizard itself, when you expand this container. I would expect to see them all the time.
|
verified fixed
|
8aadc81
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T08:31:01Z
| 2004-05-12T11:06:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/GotoRequiredProjectAction.java
| |
61,878
|
Bug 61878 Package explorer is filtering out plugin dependencies [package explorer]
|
Build 20040506 When expanding the Plug-in Dependencies container, it is counter-intuitive to hide project dependencies. These are shown in the build path wizard itself, when you expand this container. I would expect to see them all the time.
|
verified fixed
|
8aadc81
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T08:31:01Z
| 2004-05-12T11:06:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerActionGroup.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.packageview;
import org.eclipse.core.resources.IContainer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.OpenStrategy;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.IWorkingSetManager;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.actions.OpenInNewWindowAction;
import org.eclipse.ui.views.framelist.BackAction;
import org.eclipse.ui.views.framelist.ForwardAction;
import org.eclipse.ui.views.framelist.FrameAction;
import org.eclipse.ui.views.framelist.FrameList;
import org.eclipse.ui.views.framelist.GoIntoAction;
import org.eclipse.ui.views.framelist.UpAction;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IOpenable;
import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup;
import org.eclipse.jdt.internal.ui.actions.NewWizardsActionGroup;
import org.eclipse.jdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
import org.eclipse.jdt.ui.IContextMenuConstants;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.ui.actions.BuildActionGroup;
import org.eclipse.jdt.ui.actions.CCPActionGroup;
import org.eclipse.jdt.ui.actions.CustomFiltersActionGroup;
import org.eclipse.jdt.ui.actions.GenerateActionGroup;
import org.eclipse.jdt.ui.actions.ImportActionGroup;
import org.eclipse.jdt.ui.actions.JavaSearchActionGroup;
import org.eclipse.jdt.ui.actions.JdtActionConstants;
import org.eclipse.jdt.ui.actions.NavigateActionGroup;
import org.eclipse.jdt.ui.actions.ProjectActionGroup;
import org.eclipse.jdt.ui.actions.RefactorActionGroup;
class PackageExplorerActionGroup extends CompositeActionGroup {
private PackageExplorerPart fPart;
private GoIntoAction fZoomInAction;
private BackAction fBackAction;
private ForwardAction fForwardAction;
private UpAction fUpAction;
private GotoTypeAction fGotoTypeAction;
private GotoPackageAction fGotoPackageAction;
private GotoResourceAction fGotoResourceAction;
private CollapseAllAction fCollapseAllAction;
private ToggleLinkingAction fToggleLinkingAction;
private RefactorActionGroup fRefactorActionGroup;
private NavigateActionGroup fNavigateActionGroup;
private WorkingSetFilterActionGroup fWorkingSetFilterActionGroup;
private CustomFiltersActionGroup fCustomFiltersActionGroup;
public PackageExplorerActionGroup(PackageExplorerPart part) {
super();
fPart= part;
TreeViewer viewer= part.getViewer();
IPropertyChangeListener workingSetListener= new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
doWorkingSetChanged(event);
}
};
IWorkbenchPartSite site = fPart.getSite();
Shell shell= site.getShell();
setGroups(new ActionGroup[] {
new NewWizardsActionGroup(site),
fNavigateActionGroup= new NavigateActionGroup(fPart),
new CCPActionGroup(fPart),
new GenerateActionGroup(fPart),
fRefactorActionGroup= new RefactorActionGroup(fPart),
new ImportActionGroup(fPart),
new BuildActionGroup(fPart),
new JavaSearchActionGroup(fPart),
new ProjectActionGroup(fPart),
fWorkingSetFilterActionGroup= new WorkingSetFilterActionGroup(JavaUI.ID_PACKAGES, shell, workingSetListener),
fCustomFiltersActionGroup= new CustomFiltersActionGroup(fPart, viewer),
new LayoutActionGroup(part)});
viewer.addFilter(fWorkingSetFilterActionGroup.getWorkingSetFilter());
PackagesFrameSource frameSource= new PackagesFrameSource(fPart);
FrameList frameList= new FrameList(frameSource);
frameSource.connectTo(frameList);
fZoomInAction= new GoIntoAction(frameList);
fBackAction= new BackAction(frameList);
fForwardAction= new ForwardAction(frameList);
fUpAction= new UpAction(frameList);
fGotoTypeAction= new GotoTypeAction(fPart);
fGotoPackageAction= new GotoPackageAction(fPart);
fGotoResourceAction= new GotoResourceAction(fPart);
fCollapseAllAction= new CollapseAllAction(fPart);
fToggleLinkingAction = new ToggleLinkingAction(fPart);
}
public void dispose() {
super.dispose();
}
//---- Persistent state -----------------------------------------------------------------------
/* package */ void restoreFilterAndSorterState(IMemento memento) {
fWorkingSetFilterActionGroup.restoreState(memento);
fCustomFiltersActionGroup.restoreState(memento);
}
/* package */ void saveFilterAndSorterState(IMemento memento) {
fWorkingSetFilterActionGroup.saveState(memento);
fCustomFiltersActionGroup.saveState(memento);
}
//---- Action Bars ----------------------------------------------------------------------------
public void fillActionBars(IActionBars actionBars) {
super.fillActionBars(actionBars);
setGlobalActionHandlers(actionBars);
fillToolBar(actionBars.getToolBarManager());
fillViewMenu(actionBars.getMenuManager());
}
/* package */ void updateActionBars(IActionBars actionBars) {
actionBars.getToolBarManager().removeAll();
actionBars.getMenuManager().removeAll();
fillActionBars(actionBars);
actionBars.updateActionBars();
fZoomInAction.setEnabled(true);
}
private void setGlobalActionHandlers(IActionBars actionBars) {
// Navigate Go Into and Go To actions.
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_INTO, fZoomInAction);
actionBars.setGlobalActionHandler(ActionFactory.BACK.getId(), fBackAction);
actionBars.setGlobalActionHandler(ActionFactory.FORWARD.getId(), fForwardAction);
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.UP, fUpAction);
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_TO_RESOURCE, fGotoResourceAction);
actionBars.setGlobalActionHandler(JdtActionConstants.GOTO_TYPE, fGotoTypeAction);
actionBars.setGlobalActionHandler(JdtActionConstants.GOTO_PACKAGE, fGotoPackageAction);
fRefactorActionGroup.retargetFileMenuActions(actionBars);
}
/* package */ void fillToolBar(IToolBarManager toolBar) {
toolBar.add(fBackAction);
toolBar.add(fForwardAction);
toolBar.add(fUpAction);
toolBar.add(new Separator());
toolBar.add(fCollapseAllAction);
toolBar.add(fToggleLinkingAction);
}
/* package */ void fillViewMenu(IMenuManager menu) {
menu.add(fToggleLinkingAction);
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));//$NON-NLS-1$
}
/* package */ void handleSelectionChanged(SelectionChangedEvent event) {
}
//---- Context menu -------------------------------------------------------------------------
public void fillContextMenu(IMenuManager menu) {
IStructuredSelection selection= (IStructuredSelection)getContext().getSelection();
int size= selection.size();
Object element= selection.getFirstElement();
addGotoMenu(menu, element, size);
addOpenNewWindowAction(menu, element);
super.fillContextMenu(menu);
}
private void addGotoMenu(IMenuManager menu, Object element, int size) {
boolean enabled= size == 1 && fPart.getViewer().isExpandable(element) && (isGoIntoTarget(element) || element instanceof IContainer);
fZoomInAction.setEnabled(enabled);
if (enabled)
menu.appendToGroup(IContextMenuConstants.GROUP_GOTO, fZoomInAction);
}
private boolean isGoIntoTarget(Object element) {
if (element == null)
return false;
if (element instanceof IJavaElement) {
int type= ((IJavaElement)element).getElementType();
return type == IJavaElement.JAVA_PROJECT ||
type == IJavaElement.PACKAGE_FRAGMENT_ROOT ||
type == IJavaElement.PACKAGE_FRAGMENT;
}
return false;
}
private void addOpenNewWindowAction(IMenuManager menu, Object element) {
if (element instanceof IJavaElement) {
element= ((IJavaElement)element).getResource();
}
if (!(element instanceof IContainer))
return;
menu.appendToGroup(
IContextMenuConstants.GROUP_OPEN,
new OpenInNewWindowAction(fPart.getSite().getWorkbenchWindow(), (IContainer)element));
}
//---- Key board and mouse handling ------------------------------------------------------------
/* package*/ void handleDoubleClick(DoubleClickEvent event) {
TreeViewer viewer= fPart.getViewer();
Object element= ((IStructuredSelection)event.getSelection()).getFirstElement();
if (viewer.isExpandable(element)) {
if (doubleClickGoesInto()) {
// don't zoom into compilation units and class files
if (element instanceof ICompilationUnit || element instanceof IClassFile)
return;
if (element instanceof IOpenable || element instanceof IContainer) {
fZoomInAction.run();
}
} else {
IAction openAction= fNavigateActionGroup.getOpenAction();
if (openAction != null && openAction.isEnabled() && OpenStrategy.getOpenMethod() == OpenStrategy.DOUBLE_CLICK)
return;
viewer.setExpandedState(element, !viewer.getExpandedState(element));
}
}
}
/* package */ void handleOpen(OpenEvent event) {
IAction openAction= fNavigateActionGroup.getOpenAction();
if (openAction != null && openAction.isEnabled()) {
openAction.run();
return;
}
}
/* package */ void handleKeyEvent(KeyEvent event) {
if (event.stateMask != 0)
return;
if (event.keyCode == SWT.BS) {
if (fUpAction != null && fUpAction.isEnabled()) {
fUpAction.run();
event.doit= false;
}
}
}
private void doWorkingSetChanged(PropertyChangeEvent event) {
IWorkingSet workingSet= (IWorkingSet) event.getNewValue();
String workingSetName= null;
if (workingSet != null)
workingSetName= workingSet.getName();
fPart.setWorkingSetName(workingSetName);
fPart.updateTitle();
String property= event.getProperty();
if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)) {
TreeViewer viewer= fPart.getViewer();
viewer.getControl().setRedraw(false);
viewer.refresh();
viewer.getControl().setRedraw(true);
}
}
private boolean doubleClickGoesInto() {
return PreferenceConstants.DOUBLE_CLICK_GOES_INTO.equals(PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.DOUBLE_CLICK));
}
public FrameAction getUpAction() {
return fUpAction;
}
public FrameAction getBackAction() {
return fBackAction;
}
public FrameAction getForwardAction() {
return fForwardAction;
}
public WorkingSetFilterActionGroup getWorkingSetActionGroup() {
return fWorkingSetFilterActionGroup;
}
public CustomFiltersActionGroup getCustomFilterActionGroup() {
return fCustomFiltersActionGroup;
}
}
|
61,878
|
Bug 61878 Package explorer is filtering out plugin dependencies [package explorer]
|
Build 20040506 When expanding the Plug-in Dependencies container, it is counter-intuitive to hide project dependencies. These are shown in the build path wizard itself, when you expand this container. I would expect to see them all the time.
|
verified fixed
|
8aadc81
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T08:31:01Z
| 2004-05-12T11:06:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerContentProvider.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.packageview;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.widgets.Control;
import org.eclipse.jface.viewers.IBasicPropertyConstants;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jdt.core.*;
import org.eclipse.jdt.ui.StandardJavaElementContentProvider;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.JavaPlugin;
/**
* Content provider for the PackageExplorer.
*
* <p>
* Since 2.1 this content provider can provide the children for flat or hierarchical
* layout. The hierarchical layout is done by delegating to the <code>PackageFragmentProvider</code>.
* </p>
*
* @see org.eclipse.jdt.ui.StandardJavaElementContentProvider
* @see org.eclipse.jdt.internal.ui.packageview.PackageFragmentProvider
*/
class PackageExplorerContentProvider extends StandardJavaElementContentProvider implements ITreeContentProvider, IElementChangedListener {
TreeViewer fViewer;
private Object fInput;
private boolean fIsFlatLayout;
private PackageFragmentProvider fPackageFragmentProvider= new PackageFragmentProvider();
private int fPendingChanges;
PackageExplorerPart fPart;
/**
* Creates a new content provider for Java elements.
*/
public PackageExplorerContentProvider(PackageExplorerPart part, boolean provideMembers) {
super(provideMembers);
fPart= part;
}
/* (non-Javadoc)
* Method declared on IElementChangedListener.
*/
public void elementChanged(final ElementChangedEvent event) {
try {
processDelta(event.getDelta());
} catch(JavaModelException e) {
JavaPlugin.log(e);
}
}
/* (non-Javadoc)
* Method declared on IContentProvider.
*/
public void dispose() {
super.dispose();
JavaCore.removeElementChangedListener(this);
fPackageFragmentProvider.dispose();
}
// ------ Code which delegates to PackageFragmentProvider ------
private boolean needsToDelegateGetChildren(Object element) {
int type= -1;
if (element instanceof IJavaElement)
type= ((IJavaElement)element).getElementType();
return (!fIsFlatLayout && (type == IJavaElement.PACKAGE_FRAGMENT || type == IJavaElement.PACKAGE_FRAGMENT_ROOT || type == IJavaElement.JAVA_PROJECT));
}
public Object[] getChildren(Object parentElement) {
Object[] children= NO_CHILDREN;
try {
if (parentElement instanceof IJavaModel)
return concatenate(getJavaProjects((IJavaModel)parentElement), getNonJavaProjects((IJavaModel)parentElement));
if (parentElement instanceof ClassPathContainer)
return getContainerPackageFragmentRoots((ClassPathContainer)parentElement);
if (parentElement instanceof IProject)
return ((IProject)parentElement).members();
if (needsToDelegateGetChildren(parentElement)) {
Object[] packageFragments= fPackageFragmentProvider.getChildren(parentElement);
children= getWithParentsResources(packageFragments, parentElement);
} else {
children= super.getChildren(parentElement);
}
if (parentElement instanceof IJavaProject) {
IJavaProject project= (IJavaProject)parentElement;
return rootsAndContainers(project, children);
}
else
return children;
} catch (CoreException e) {
return NO_CHILDREN;
}
}
private Object[] rootsAndContainers(IJavaProject project, Object[] roots) throws JavaModelException {
List result= new ArrayList(roots.length);
Set containers= new HashSet(roots.length);
Set containedRoots= new HashSet(roots.length);
IClasspathEntry[] entries= project.getRawClasspath();
for (int i= 0; i < entries.length; i++) {
IClasspathEntry entry= entries[i];
if (entry != null && entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
IPackageFragmentRoot[] roots1= project.findPackageFragmentRoots(entry);
containedRoots.addAll(Arrays.asList(roots1));
containers.add(entry);
}
}
for (int i= 0; i < roots.length; i++) {
if (roots[i] instanceof IPackageFragmentRoot) {
if (!containedRoots.contains(roots[i])) {
result.add(roots[i]);
}
} else {
result.add(roots[i]);
}
}
for (Iterator each= containers.iterator(); each.hasNext();) {
IClasspathEntry element= (IClasspathEntry) each.next();
result.add(new ClassPathContainer(project, element));
}
return result.toArray();
}
private Object[] getContainerPackageFragmentRoots(ClassPathContainer container) {
return container.getPackageFragmentRoots();
}
private Object[] getNonJavaProjects(IJavaModel model) throws JavaModelException {
return model.getNonJavaResources();
}
public Object getParent(Object child) {
if (needsToDelegateGetParent(child)) {
return fPackageFragmentProvider.getParent(child);
} else
return super.getParent(child);
}
protected Object internalGetParent(Object element) {
// since we insert logical package containers we have to fix
// up the parent for package fragment roots so that they refer
// to the container and containers refere to the project
//
if (element instanceof IPackageFragmentRoot) {
IPackageFragmentRoot root= (IPackageFragmentRoot)element;
IJavaProject project= root.getJavaProject();
try {
IClasspathEntry[] entries= project.getRawClasspath();
for (int i= 0; i < entries.length; i++) {
IClasspathEntry entry= entries[i];
if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
if (ClassPathContainer.contains(project, entry, root))
return new ClassPathContainer(project, entry);
}
}
} catch (JavaModelException e) {
// fall through
}
}
if (element instanceof ClassPathContainer) {
return ((ClassPathContainer)element).getJavaProject();
}
return super.internalGetParent(element);
}
private boolean needsToDelegateGetParent(Object element) {
int type= -1;
if (element instanceof IJavaElement)
type= ((IJavaElement)element).getElementType();
return (!fIsFlatLayout && type == IJavaElement.PACKAGE_FRAGMENT);
}
/**
* Returns the given objects with the resources of the parent.
*/
private Object[] getWithParentsResources(Object[] existingObject, Object parent) {
Object[] objects= super.getChildren(parent);
List list= new ArrayList();
// Add everything that is not a PackageFragment
for (int i= 0; i < objects.length; i++) {
Object object= objects[i];
if (!(object instanceof IPackageFragment)) {
list.add(object);
}
}
if (existingObject != null)
list.addAll(Arrays.asList(existingObject));
return list.toArray();
}
/* (non-Javadoc)
* Method declared on IContentProvider.
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
super.inputChanged(viewer, oldInput, newInput);
fPackageFragmentProvider.inputChanged(viewer, oldInput, newInput);
fViewer= (TreeViewer)viewer;
if (oldInput == null && newInput != null) {
JavaCore.addElementChangedListener(this);
} else if (oldInput != null && newInput == null) {
JavaCore.removeElementChangedListener(this);
}
fInput= newInput;
}
// ------ delta processing ------
/**
* Processes a delta recursively. When more than two children are affected the
* tree is fully refreshed starting at this node. The delta is processed in the
* current thread but the viewer updates are posted to the UI thread.
*/
private void processDelta(IJavaElementDelta delta) throws JavaModelException {
int kind= delta.getKind();
int flags= delta.getFlags();
IJavaElement element= delta.getElement();
int elementType= element.getElementType();
if (elementType != IJavaElement.JAVA_MODEL && elementType != IJavaElement.JAVA_PROJECT) {
IJavaProject proj= element.getJavaProject();
if (proj == null || !proj.getProject().isOpen()) // TODO: Not needed if parent already did the 'open' check!
return;
}
if (!fIsFlatLayout && elementType == IJavaElement.PACKAGE_FRAGMENT) {
fPackageFragmentProvider.processDelta(delta);
if (processResourceDeltas(delta.getResourceDeltas(), element))
return;
IJavaElementDelta[] affectedChildren= delta.getAffectedChildren();
processAffectedChildren(affectedChildren);
return;
}
if (elementType == IJavaElement.COMPILATION_UNIT) {
ICompilationUnit cu= (ICompilationUnit) element;
if (!JavaModelUtil.isPrimary(cu)) {
return;
}
if (!getProvideWorkingCopy() && cu.isWorkingCopy()) {
return;
}
if ((kind == IJavaElementDelta.CHANGED) && !isStructuralCUChange(flags)) {
return; // test moved ahead
}
if (!isOnClassPath(cu)) { // TODO: isOnClassPath expensive! Should be put after all cheap tests
return;
}
}
if (elementType == IJavaElement.JAVA_PROJECT) {
// handle open and closing of a project
if ((flags & (IJavaElementDelta.F_CLOSED | IJavaElementDelta.F_OPENED)) != 0) {
postRefresh(element);
return;
}
// if the raw class path has changed we refresh the entire project
if ((flags & IJavaElementDelta.F_CLASSPATH_CHANGED) != 0) {
postRefresh(element);
return;
}
}
if (kind == IJavaElementDelta.REMOVED) {
Object parent= internalGetParent(element);
postRemove(element);
if (parent instanceof IPackageFragment)
postUpdateIcon((IPackageFragment)parent);
// we are filtering out empty subpackages, so we
// a package becomes empty we remove it from the viewer.
if (isPackageFragmentEmpty(element.getParent())) {
if (fViewer.testFindItem(parent) != null)
postRefresh(internalGetParent(parent));
}
return;
}
if (kind == IJavaElementDelta.ADDED) {
Object parent= internalGetParent(element);
// we are filtering out empty subpackages, so we
// have to handle additions to them specially.
if (parent instanceof IPackageFragment) {
Object grandparent= internalGetParent(parent);
// 1GE8SI6: ITPJUI:WIN98 - Rename is not shown in Packages View
// avoid posting a refresh to an unvisible parent
if (parent.equals(fInput)) {
postRefresh(parent);
} else {
// refresh from grandparent if parent isn't visible yet
if (fViewer.testFindItem(parent) == null)
postRefresh(grandparent);
else {
postRefresh(parent);
}
}
return;
} else {
postAdd(parent, element);
}
}
if (elementType == IJavaElement.COMPILATION_UNIT) {
if (kind == IJavaElementDelta.CHANGED) {
// isStructuralCUChange already performed above
postRefresh(element);
updateSelection(delta);
}
return;
}
// no changes possible in class files
if (elementType == IJavaElement.CLASS_FILE)
return;
if (elementType == IJavaElement.PACKAGE_FRAGMENT_ROOT) {
// the contents of an external JAR has changed
if ((flags & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0) {
postRefresh(element);
return;
}
// the source attachment of a JAR has changed
if ((flags & (IJavaElementDelta.F_SOURCEATTACHED | IJavaElementDelta.F_SOURCEDETACHED)) != 0)
postUpdateIcon(element);
if (isClassPathChange(delta)) {
// throw the towel and do a full refresh of the affected java project.
postRefresh(element.getJavaProject());
return;
}
}
if (processResourceDeltas(delta.getResourceDeltas(), element))
return;
handleAffectedChildren(delta, element);
}
private static boolean isStructuralCUChange(int flags) {
// No refresh on working copy creation (F_PRIMARY_WORKING_COPY)
return ((flags & IJavaElementDelta.F_CHILDREN) != 0) || ((flags & (IJavaElementDelta.F_CONTENT | IJavaElementDelta.F_FINE_GRAINED)) == IJavaElementDelta.F_CONTENT);
}
private void handleAffectedChildren(IJavaElementDelta delta, IJavaElement element) throws JavaModelException {
IJavaElementDelta[] affectedChildren= delta.getAffectedChildren();
if (affectedChildren.length > 1) {
// a package fragment might become non empty refresh from the parent
if (element instanceof IPackageFragment) {
IJavaElement parent= (IJavaElement)internalGetParent(element);
// 1GE8SI6: ITPJUI:WIN98 - Rename is not shown in Packages View
// avoid posting a refresh to an unvisible parent
if (element.equals(fInput)) {
postRefresh(element);
} else {
postRefresh(parent);
}
return;
}
// more than one child changed, refresh from here downwards
if (element instanceof IPackageFragmentRoot)
postRefresh(skipProjectPackageFragmentRoot((IPackageFragmentRoot)element));
else
postRefresh(element);
return;
}
processAffectedChildren(affectedChildren);
}
protected void processAffectedChildren(IJavaElementDelta[] affectedChildren) throws JavaModelException {
for (int i= 0; i < affectedChildren.length; i++) {
processDelta(affectedChildren[i]);
}
}
private boolean isOnClassPath(ICompilationUnit element) {
IJavaProject project= element.getJavaProject();
if (project == null || !project.exists())
return false;
return project.isOnClasspath(element);
}
/**
* Updates the selection. It finds newly added elements
* and selects them.
*/
private void updateSelection(IJavaElementDelta delta) {
final IJavaElement addedElement= findAddedElement(delta);
if (addedElement != null) {
final StructuredSelection selection= new StructuredSelection(addedElement);
postRunnable(new Runnable() {
public void run() {
Control ctrl= fViewer.getControl();
if (ctrl != null && !ctrl.isDisposed()) {
// 19431
// if the item is already visible then select it
if (fViewer.testFindItem(addedElement) != null)
fViewer.setSelection(selection);
}
}
});
}
}
private IJavaElement findAddedElement(IJavaElementDelta delta) {
if (delta.getKind() == IJavaElementDelta.ADDED)
return delta.getElement();
IJavaElementDelta[] affectedChildren= delta.getAffectedChildren();
for (int i= 0; i < affectedChildren.length; i++)
return findAddedElement(affectedChildren[i]);
return null;
}
/**
* Updates the package icon
*/
private void postUpdateIcon(final IJavaElement element) {
postRunnable(new Runnable() {
public void run() {
// 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
Control ctrl= fViewer.getControl();
if (ctrl != null && !ctrl.isDisposed())
fViewer.update(element, new String[]{IBasicPropertyConstants.P_IMAGE});
}
});
}
/**
1 * Process a resource delta.
*
* @return true if the parent got refreshed
*/
private boolean processResourceDelta(IResourceDelta delta, Object parent) {
int status= delta.getKind();
int flags= delta.getFlags();
IResource resource= delta.getResource();
// filter out changes affecting the output folder
if (resource == null)
return false;
// this could be optimized by handling all the added children in the parent
if ((status & IResourceDelta.REMOVED) != 0) {
if (parent instanceof IPackageFragment) {
// refresh one level above to deal with empty package filtering properly
postRefresh(internalGetParent(parent));
return true;
} else
postRemove(resource);
}
if ((status & IResourceDelta.ADDED) != 0) {
if (parent instanceof IPackageFragment) {
// refresh one level above to deal with empty package filtering properly
postRefresh(internalGetParent(parent));
return true;
} else
postAdd(parent, resource);
}
// open/close state change of a project
if ((flags & IResourceDelta.OPEN) != 0) {
postProjectStateChanged(internalGetParent(parent));
return true;
}
processResourceDeltas(delta.getAffectedChildren(), resource);
return false;
}
void setIsFlatLayout(boolean state) {
fIsFlatLayout= state;
}
/**
* Process resource deltas.
*
* @return true if the parent got refreshed
*/
private boolean processResourceDeltas(IResourceDelta[] deltas, Object parent) {
if (deltas == null)
return false;
if (deltas.length > 1) {
// more than one child changed, refresh from here downwards
postRefresh(parent);
return true;
}
for (int i= 0; i < deltas.length; i++) {
if (processResourceDelta(deltas[i], parent))
return true;
}
return false;
}
private void postRefresh(Object root) {
// JFace doesn't refresh when object isn't part of the viewer
// Therefore move the refresh start down to the viewer's input
if (isParent(root, fInput))
root= fInput;
postRefresh(root, true);
}
boolean isParent(Object root, Object child) {
Object parent= getParent(child);
if (parent == null)
return false;
if (parent.equals(root))
return true;
return isParent(root, parent);
}
private void postRefresh(final Object root, final boolean updateLabels) {
postRunnable(new Runnable() {
public void run() {
Control ctrl= fViewer.getControl();
if (ctrl != null && !ctrl.isDisposed()){
fViewer.refresh(root, updateLabels);
}
}
});
}
private void postAdd(final Object parent, final Object element) {
postRunnable(new Runnable() {
public void run() {
Control ctrl= fViewer.getControl();
if (ctrl != null && !ctrl.isDisposed()){
// TODO workaround for 39754 New projects being added to the TreeViewer twice
if (fViewer.testFindItem(element) == null)
fViewer.add(parent, element);
}
}
});
}
private void postRemove(final Object element) {
postRunnable(new Runnable() {
public void run() {
Control ctrl= fViewer.getControl();
if (ctrl != null && !ctrl.isDisposed()) {
fViewer.remove(element);
}
}
});
}
private void postProjectStateChanged(final Object root) {
postRunnable(new Runnable() {
public void run() {
fPart.projectStateChanged(root);
}
});
}
private void postRunnable(final Runnable r) {
Control ctrl= fViewer.getControl();
final Runnable trackedRunnable= new Runnable() {
public void run() {
try {
r.run();
} finally {
removePendingChange();
}
}
};
if (ctrl != null && !ctrl.isDisposed()) {
addPendingChange();
try {
ctrl.getDisplay().asyncExec(trackedRunnable);
} catch (RuntimeException e) {
removePendingChange();
throw e;
} catch (Error e) {
removePendingChange();
throw e;
}
}
}
// ------ Pending change management due to the use of asyncExec in postRunnable.
public synchronized boolean hasPendingChanges() {
return fPendingChanges > 0;
}
private synchronized void addPendingChange() {
fPendingChanges++;
// System.out.print(fPendingChanges);
}
synchronized void removePendingChange() {
fPendingChanges--;
if (fPendingChanges < 0)
fPendingChanges= 0;
// System.out.print(fPendingChanges);
}
}
|
63,940
|
Bug 63940 Quickfix shows same text for 5 method options
|
build M9 - open class UIPreferenceInitializer in org.eclipse.ui.internal - change the following line FROM: store.setDefault(IWorkbenchPreferenceConstants.OPEN_NEW_PERSPECTIVE, IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE); TO: store.setddDefault(IWorkbenchPreferenceConstants.OPEN_NEW_PERSPECTIVE, IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE); - now save it - now select the quickfix option from the left hand side of the editor - note that the popup window has 5 versions of the same text, even though there is space for more text - compare with the Ctrl+space popup it seems that there could be more information here
|
verified fixed
|
440f3c5
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T09:02:28Z
| 2004-05-25T18:33:20Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Renaud Waldura <renaud+eclipse@waldura.com> - New class/interface with wizard
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.correction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.core.dom.*;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.ui.JavaElementImageDescriptor;
import org.eclipse.jdt.ui.text.java.IInvocationContext;
import org.eclipse.jdt.ui.text.java.IProblemLocation;
import org.eclipse.jdt.internal.corext.codemanipulation.ImportRewrite;
import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility;
import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory;
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.dom.Bindings;
import org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer;
import org.eclipse.jdt.internal.corext.dom.TypeRules;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.TypeFilter;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.text.correction.ChangeMethodSignatureProposal.ChangeDescription;
import org.eclipse.jdt.internal.ui.text.correction.ChangeMethodSignatureProposal.EditDescription;
import org.eclipse.jdt.internal.ui.text.correction.ChangeMethodSignatureProposal.InsertDescription;
import org.eclipse.jdt.internal.ui.text.correction.ChangeMethodSignatureProposal.RemoveDescription;
import org.eclipse.jdt.internal.ui.text.correction.ChangeMethodSignatureProposal.SwapDescription;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
public class UnresolvedElementsSubProcessor {
public static void getVariableProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException {
ICompilationUnit cu= context.getCompilationUnit();
CompilationUnit astRoot= context.getASTRoot();
ASTNode selectedNode= problem.getCoveredNode(astRoot);
if (selectedNode == null) {
return;
}
// type that defines the variable
ITypeBinding binding= null;
ITypeBinding declaringTypeBinding= Bindings.getBindingOfParentType(selectedNode);
if (declaringTypeBinding == null) {
return;
}
// possible type kind of the node
boolean suggestVariableProposals= true;
int typeKind= 0;
while (selectedNode instanceof ParenthesizedExpression) {
selectedNode= ((ParenthesizedExpression) selectedNode).getExpression();
}
Name node= null;
switch (selectedNode.getNodeType()) {
case ASTNode.SIMPLE_NAME:
node= (SimpleName) selectedNode;
ASTNode parent= node.getParent();
if (parent instanceof MethodInvocation && node.equals(((MethodInvocation)parent).getExpression())) {
typeKind= SimilarElementsRequestor.CLASSES;
} else if (parent instanceof SimpleType) {
suggestVariableProposals= false;
typeKind= SimilarElementsRequestor.REF_TYPES;
} else if (parent instanceof QualifiedName) {
Name qualifier= ((QualifiedName) parent).getQualifier();
if (qualifier != node) {
binding= qualifier.resolveTypeBinding();
} else {
typeKind= SimilarElementsRequestor.REF_TYPES;
}
ASTNode outerParent= parent.getParent();
while (outerParent instanceof QualifiedName) {
outerParent= outerParent.getParent();
}
if (outerParent instanceof SimpleType) {
typeKind= SimilarElementsRequestor.REF_TYPES;
suggestVariableProposals= false;
}
}
break;
case ASTNode.QUALIFIED_NAME:
QualifiedName qualifierName= (QualifiedName) selectedNode;
ITypeBinding qualifierBinding= qualifierName.getQualifier().resolveTypeBinding();
if (qualifierBinding != null) {
node= qualifierName.getName();
binding= qualifierBinding;
} else {
node= qualifierName.getQualifier();
typeKind= SimilarElementsRequestor.REF_TYPES;
suggestVariableProposals= node.isSimpleName();
}
if (selectedNode.getParent() instanceof SimpleType) {
typeKind= SimilarElementsRequestor.REF_TYPES;
suggestVariableProposals= false;
}
break;
case ASTNode.FIELD_ACCESS:
FieldAccess access= (FieldAccess) selectedNode;
Expression expression= access.getExpression();
if (expression != null) {
binding= expression.resolveTypeBinding();
if (binding != null) {
node= access.getName();
}
}
break;
case ASTNode.SUPER_FIELD_ACCESS:
binding= declaringTypeBinding.getSuperclass();
node= ((SuperFieldAccess) selectedNode).getName();
break;
default:
}
if (node == null) {
return;
}
// add type proposals
if (typeKind != 0) {
int relevance= Character.isUpperCase(ASTNodes.getSimpleNameIdentifier(node).charAt(0)) ? 3 : 0;
addSimilarTypeProposals(typeKind, cu, node, relevance + 1, proposals);
addNewTypeProposals(cu, node, SimilarElementsRequestor.REF_TYPES, relevance, proposals);
}
if (!suggestVariableProposals) {
return;
}
SimpleName simpleName= node.isSimpleName() ? (SimpleName) node : ((QualifiedName) node).getName();
boolean isWriteAccess= ASTResolving.isWriteAccess(node);
// similar variables
addSimilarVariableProposals(cu, astRoot, binding, simpleName, isWriteAccess, proposals);
// new fields
addNewFieldProposals(cu, astRoot, binding, declaringTypeBinding, simpleName, isWriteAccess, proposals);
// new parameters and local variables
if (binding == null) {
addNewVariableProposals(cu, node, simpleName, proposals);
}
}
private static void addNewVariableProposals(ICompilationUnit cu, Name node, SimpleName simpleName, Collection proposals) {
String name= simpleName.getIdentifier();
BodyDeclaration bodyDeclaration= ASTResolving.findParentBodyDeclaration(node);
int type= bodyDeclaration.getNodeType();
if (type == ASTNode.METHOD_DECLARATION) {
int relevance= StubUtility.hasParameterName(cu.getJavaProject(), name) ? 8 : 5;
String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createparameter.description", simpleName.getIdentifier()); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);
proposals.add(new NewVariableCompletionProposal(label, cu, NewVariableCompletionProposal.PARAM, simpleName, null, relevance, image));
}
if (type == ASTNode.METHOD_DECLARATION || type == ASTNode.INITIALIZER) {
int relevance= StubUtility.hasLocalVariableName(cu.getJavaProject(), name) ? 10 : 7;
String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createlocal.description", simpleName.getIdentifier()); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);
proposals.add(new NewVariableCompletionProposal(label, cu, NewVariableCompletionProposal.LOCAL, simpleName, null, relevance, image));
}
if (node.getParent().getNodeType() == ASTNode.ASSIGNMENT) {
Assignment assignment= (Assignment) node.getParent();
if (assignment.getLeftHandSide() == node && assignment.getParent().getNodeType() == ASTNode.EXPRESSION_STATEMENT) {
ASTNode statement= assignment.getParent();
ASTRewrite rewrite= ASTRewrite.create(statement.getAST());
rewrite.remove(statement, null);
String label= CorrectionMessages.getString("UnresolvedElementsSubProcessor.removestatement.description"); //$NON-NLS-1$
Image image= JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, 4, image);
proposals.add(proposal);
}
}
}
private static void addNewFieldProposals(ICompilationUnit cu, CompilationUnit astRoot, ITypeBinding binding, ITypeBinding declaringTypeBinding, SimpleName simpleName, boolean isWriteAccess, Collection proposals) throws JavaModelException {
// new variables
ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, binding);
ITypeBinding senderBinding= binding != null ? binding : declaringTypeBinding;
if (!senderBinding.isFromSource() || targetCU == null || !JavaModelUtil.isEditable(targetCU)) {
return;
}
ITypeBinding outsideAnonymous= null;
if (binding == null && senderBinding.isAnonymous()) {
ASTNode anonymDecl= astRoot.findDeclaringNode(senderBinding);
if (anonymDecl != null) {
ITypeBinding bind= Bindings.getBindingOfParentType(anonymDecl.getParent());
if (!bind.isAnonymous()) {
outsideAnonymous= bind;
}
}
}
String name= simpleName.getIdentifier();
int relevance= StubUtility.hasFieldName(cu.getJavaProject(), name) ? 9 : 6;
String label;
Image image;
if (binding == null) {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createfield.description", name); //$NON-NLS-1$
image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE);
} else {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createfield.other.description", new Object[] { name, binding.getName() } ); //$NON-NLS-1$
image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
}
proposals.add(new NewVariableCompletionProposal(label, targetCU, NewVariableCompletionProposal.FIELD, simpleName, senderBinding, relevance, image));
// create field in outer class (if inside anonymous)
if (outsideAnonymous != null) {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createfield.other.description", new Object[] { name, outsideAnonymous.getName() } ); //$NON-NLS-1$
image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
proposals.add(new NewVariableCompletionProposal(label, targetCU, NewVariableCompletionProposal.FIELD, simpleName, outsideAnonymous, relevance + 1, image));
}
// create constant
if (!isWriteAccess) {
relevance= StubUtility.hasConstantName(name) ? 9 : 4;
ITypeBinding target= (outsideAnonymous != null) ? outsideAnonymous : senderBinding;
if (binding == null) {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createconst.description", name); //$NON-NLS-1$
image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE);
} else {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createconst.other.description", new Object[] { name, binding.getName() } ); //$NON-NLS-1$
image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
}
proposals.add(new NewVariableCompletionProposal(label, targetCU, NewVariableCompletionProposal.CONST_FIELD, simpleName, target, relevance, image));
}
}
private static void addSimilarVariableProposals(ICompilationUnit cu, CompilationUnit astRoot, ITypeBinding binding, SimpleName node, boolean isWriteAccess, Collection proposals) {
IBinding[] varsInScope= (new ScopeAnalyzer(astRoot)).getDeclarationsInScope(node, ScopeAnalyzer.VARIABLES | ScopeAnalyzer.CHECK_VISIBILITY);
if (varsInScope.length > 0) {
// avoid corrections like int i= i;
String otherNameInAssign= null;
// help with x.getString() -> y.getString()
String methodSenderName= null;
String fieldSenderName= null;
ASTNode parent= node.getParent();
switch (parent.getNodeType()) {
case ASTNode.VARIABLE_DECLARATION_FRAGMENT:
// node must be initializer
otherNameInAssign= ((VariableDeclarationFragment) parent).getName().getIdentifier();
break;
case ASTNode.ASSIGNMENT:
Assignment assignment= (Assignment) parent;
if (isWriteAccess && assignment.getRightHandSide() instanceof SimpleName) {
otherNameInAssign= ((SimpleName) assignment.getRightHandSide()).getIdentifier();
} else if (!isWriteAccess && assignment.getLeftHandSide() instanceof SimpleName) {
otherNameInAssign= ((SimpleName) assignment.getLeftHandSide()).getIdentifier();
}
break;
case ASTNode.METHOD_INVOCATION:
MethodInvocation inv= (MethodInvocation) parent;
if (inv.getExpression() == node) {
methodSenderName= inv.getName().getIdentifier();
}
break;
case ASTNode.QUALIFIED_NAME:
QualifiedName qualName= (QualifiedName) parent;
if (qualName.getQualifier() == node) {
fieldSenderName= qualName.getName().getIdentifier();
}
break;
}
ITypeBinding guessedType= ASTResolving.guessBindingForReference(node);
if (astRoot.getAST().resolveWellKnownType("java.lang.Object") == guessedType) { //$NON-NLS-1$
guessedType= null; // too many suggestions
}
String identifier= node.getIdentifier();
for (int i= 0; i < varsInScope.length; i++) {
IVariableBinding curr= (IVariableBinding) varsInScope[i];
String currName= curr.getName();
boolean isFinal= Modifier.isFinal(curr.getModifiers());
if (!currName.equals(otherNameInAssign) && !(isFinal && curr.isField() && isWriteAccess)) {
int relevance= 0;
if (NameMatcher.isSimilarName(currName, identifier)) {
relevance += 3; // variable with a similar name than the unresolved variable
}
if (currName.equalsIgnoreCase(identifier)) {
relevance+= 5;
}
ITypeBinding varType= curr.getType();
if (varType != null) {
if (guessedType != null) {
// var type is compatible with the guessed type
if (!isWriteAccess && TypeRules.canAssign(varType, guessedType)
|| isWriteAccess && TypeRules.canAssign(guessedType, varType)) {
relevance += 2; // unresolved variable can be assign to this variable
}
}
if (methodSenderName != null && hasMethodWithName(varType, methodSenderName)) {
relevance += 2;
}
if (fieldSenderName != null && hasFieldWithName(varType, fieldSenderName)) {
relevance += 2;
}
}
if (relevance > 0) {
String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changevariable.description", currName); //$NON-NLS-1$
proposals.add(new RenameNodeCompletionProposal(label, cu, node.getStartPosition(), node.getLength(), currName, relevance));
}
}
}
}
if (binding != null && binding.isArray()) {
String idLength= "length"; //$NON-NLS-1$
String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changevariable.description", idLength); //$NON-NLS-1$
proposals.add(new RenameNodeCompletionProposal(label, cu, node.getStartPosition(), node.getLength(), idLength, 8)); //$NON-NLS-1$
}
}
private static boolean hasMethodWithName(ITypeBinding typeBinding, String name) {
IVariableBinding[] fields= typeBinding.getDeclaredFields();
for (int i= 0; i < fields.length; i++) {
if (fields[i].getName().equals(name)) {
return true;
}
}
ITypeBinding superclass= typeBinding.getSuperclass();
if (superclass != null) {
return hasMethodWithName(superclass, name);
}
return false;
}
private static boolean hasFieldWithName(ITypeBinding typeBinding, String name) {
IMethodBinding[] methods= typeBinding.getDeclaredMethods();
for (int i= 0; i < methods.length; i++) {
if (methods[i].getName().equals(name)) {
return true;
}
}
ITypeBinding superclass= typeBinding.getSuperclass();
if (superclass != null) {
return hasMethodWithName(superclass, name);
}
return false;
}
public static void getTypeProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException {
ICompilationUnit cu= context.getCompilationUnit();
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
if (selectedNode == null) {
return;
}
int kind= SimilarElementsRequestor.ALL_TYPES;
ASTNode parent= selectedNode.getParent();
while (parent.getLength() == selectedNode.getLength()) { // get parent of type or variable fragment
parent= parent.getParent();
}
switch (parent.getNodeType()) {
case ASTNode.TYPE_DECLARATION:
TypeDeclaration typeDeclaration=(TypeDeclaration) parent;
if (typeDeclaration.superInterfaces().contains(selectedNode)) {
kind= SimilarElementsRequestor.INTERFACES;
} else if (selectedNode.equals(typeDeclaration.getSuperclass())) {
kind= SimilarElementsRequestor.CLASSES;
}
break;
case ASTNode.METHOD_DECLARATION:
MethodDeclaration methodDeclaration= (MethodDeclaration) parent;
if (methodDeclaration.thrownExceptions().contains(selectedNode)) {
kind= SimilarElementsRequestor.CLASSES;
} else if (selectedNode.equals(methodDeclaration.getReturnType())) {
kind= SimilarElementsRequestor.ALL_TYPES | SimilarElementsRequestor.VOIDTYPE;
}
break;
case ASTNode.INSTANCEOF_EXPRESSION:
kind= SimilarElementsRequestor.REF_TYPES;
break;
case ASTNode.THROW_STATEMENT:
kind= SimilarElementsRequestor.REF_TYPES;
break;
case ASTNode.CLASS_INSTANCE_CREATION:
if (((ClassInstanceCreation) parent).getAnonymousClassDeclaration() == null) {
kind= SimilarElementsRequestor.CLASSES;
} else {
kind= SimilarElementsRequestor.REF_TYPES;
}
break;
case ASTNode.SINGLE_VARIABLE_DECLARATION:
int superParent= parent.getParent().getNodeType();
if (superParent == ASTNode.CATCH_CLAUSE) {
kind= SimilarElementsRequestor.CLASSES;
}
break;
case ASTNode.TAG_ELEMENT:
kind= SimilarElementsRequestor.REF_TYPES;
break;
default:
}
Name node= null;
if (selectedNode instanceof SimpleType) {
node= ((SimpleType) selectedNode).getName();
} else if (selectedNode instanceof ArrayType) {
Type elementType= ((ArrayType) selectedNode).getElementType();
if (elementType.isSimpleType()) {
node= ((SimpleType) elementType).getName();
}
} else if (selectedNode instanceof Name) {
node= (Name) selectedNode;
} else {
return;
}
// change to similar type proposals
addSimilarTypeProposals(kind, cu, node, 3, proposals);
// add type
addNewTypeProposals(cu, node, kind, 0, proposals);
}
private static void addSimilarTypeProposals(int kind, ICompilationUnit cu, Name node, int relevance, Collection proposals) throws CoreException {
SimilarElement[] elements= SimilarElementsRequestor.findSimilarElement(cu, node, kind);
// try to resolve type in context -> highest severity
String resolvedTypeName= null;
ITypeBinding binding= ASTResolving.guessBindingForTypeReference(node);
if (binding != null) {
if (binding.isArray()) {
binding= binding.getElementType();
}
resolvedTypeName= binding.getQualifiedName();
proposals.add(createTypeRefChangeProposal(cu, resolvedTypeName, node, relevance + 2));
}
// add all similar elements
for (int i= 0; i < elements.length; i++) {
SimilarElement elem= elements[i];
if ((elem.getKind() & SimilarElementsRequestor.ALL_TYPES) != 0) {
String fullName= elem.getName();
if (!fullName.equals(resolvedTypeName)) {
proposals.add(createTypeRefChangeProposal(cu, fullName, node, relevance));
}
}
}
}
private static CUCorrectionProposal createTypeRefChangeProposal(ICompilationUnit cu, String fullName, Name node, int relevance) throws CoreException {
ImportRewrite importRewrite= new ImportRewrite(cu);
importRewrite.setFindAmbiguosImports(true);
String simpleName= importRewrite.addImport(fullName);
String packName= Signature.getQualifier(fullName);
String[] arg= { simpleName, packName };
CUCorrectionProposal proposal;
if (node.isSimpleName() && simpleName.equals(((SimpleName) node).getIdentifier())) { // import only
// import only
String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.importtype.description", arg); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_IMPDECL);
proposal= new CUCorrectionProposal(label, cu, relevance + 100, image);
} else {
String label;
if (packName.length() == 0) {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changetype.nopack.description", simpleName); //$NON-NLS-1$
} else {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changetype.description", arg); //$NON-NLS-1$
}
proposal= new RenameNodeCompletionProposal(label, cu, node.getStartPosition(), node.getLength(), simpleName, relevance); //$NON-NLS-1$
}
proposal.setImportRewrite(importRewrite);
return proposal;
}
private static void addNewTypeProposals(ICompilationUnit cu, Name refNode, int kind, int relevance, Collection proposals) throws JavaModelException {
Name node= refNode;
do {
String typeName= ASTNodes.getSimpleNameIdentifier(node);
Name qualifier= null;
// only propose to create types for qualifiers when the name starts with upper case
boolean isPossibleName= Character.isUpperCase(typeName.charAt(0)) || (node == refNode);
if (isPossibleName) {
IPackageFragment enclosingPackage= null;
IType enclosingType= null;
if (node.isSimpleName()) {
enclosingPackage= (IPackageFragment) cu.getParent();
// don't suggest member type, user can select it in wizard
} else {
Name qualifierName= ((QualifiedName) node).getQualifier();
// 24347
// IBinding binding= qualifierName.resolveBinding();
// if (binding instanceof ITypeBinding) {
// enclosingType= Binding2JavaModel.find((ITypeBinding) binding, cu.getJavaProject());
IJavaElement[] res= cu.codeSelect(qualifierName.getStartPosition(), qualifierName.getLength());
if (res!= null && res.length > 0 && res[0] instanceof IType) {
enclosingType= (IType) res[0];
} else {
qualifier= qualifierName;
enclosingPackage= JavaModelUtil.getPackageFragmentRoot(cu).getPackageFragment(ASTResolving.getFullName(qualifierName));
}
}
// new top level type
if (enclosingPackage != null && !enclosingPackage.getCompilationUnit(typeName + ".java").exists()) { //$NON-NLS-1$
if ((kind & SimilarElementsRequestor.CLASSES) != 0) {
proposals.add(new NewCUCompletionUsingWizardProposal(cu, node, true, enclosingPackage, relevance));
}
if ((kind & SimilarElementsRequestor.INTERFACES) != 0) {
proposals.add(new NewCUCompletionUsingWizardProposal(cu, node, false, enclosingPackage, relevance));
}
}
// new member type
if (enclosingType != null && !enclosingType.isReadOnly() && !enclosingType.getType(typeName).exists()) {
if ((kind & SimilarElementsRequestor.CLASSES) != 0) {
proposals.add(new NewCUCompletionUsingWizardProposal(cu, node, true, enclosingType, relevance));
}
if ((kind & SimilarElementsRequestor.INTERFACES) != 0) {
proposals.add(new NewCUCompletionUsingWizardProposal(cu, node, false, enclosingType, relevance));
}
}
}
node= qualifier;
} while (node != null);
}
public static void getMethodProposals(IInvocationContext context, IProblemLocation problem, boolean isOnlyParameterMismatch, Collection proposals) throws CoreException {
ICompilationUnit cu= context.getCompilationUnit();
CompilationUnit astRoot= context.getASTRoot();
ASTNode selectedNode= problem.getCoveringNode(astRoot);
if (!(selectedNode instanceof SimpleName)) {
return;
}
SimpleName nameNode= (SimpleName) selectedNode;
List arguments;
Expression sender;
boolean isSuperInvocation;
ASTNode invocationNode= nameNode.getParent();
if (invocationNode instanceof MethodInvocation) {
MethodInvocation methodImpl= (MethodInvocation) invocationNode;
arguments= methodImpl.arguments();
sender= methodImpl.getExpression();
isSuperInvocation= false;
} else if (invocationNode instanceof SuperMethodInvocation) {
SuperMethodInvocation methodImpl= (SuperMethodInvocation) invocationNode;
arguments= methodImpl.arguments();
sender= methodImpl.getQualifier();
isSuperInvocation= true;
} else {
return;
}
String methodName= nameNode.getIdentifier();
int nArguments= arguments.size();
// corrections
IBinding[] bindings= (new ScopeAnalyzer(astRoot)).getDeclarationsInScope(nameNode, ScopeAnalyzer.METHODS);
ArrayList parameterMismatchs= new ArrayList();
for (int i= 0; i < bindings.length; i++) {
IMethodBinding binding= (IMethodBinding) bindings[i];
String curr= binding.getName();
if (curr.equals(methodName) && isOnlyParameterMismatch) {
parameterMismatchs.add(binding);
} else if (binding.getParameterTypes().length == nArguments && NameMatcher.isSimilarName(methodName, curr)) {
String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changemethod.description", curr); //$NON-NLS-1$
proposals.add(new RenameNodeCompletionProposal(label, context.getCompilationUnit(), problem.getOffset(), problem.getLength(), curr, 6));
}
}
addParameterMissmatchProposals(context, problem, parameterMismatchs, invocationNode, arguments, proposals);
// new method
ITypeBinding binding= null;
if (sender != null) {
binding= sender.resolveTypeBinding();
} else {
binding= Bindings.getBindingOfParentType(invocationNode);
if (isSuperInvocation && binding != null) {
binding= binding.getSuperclass();
}
}
if (binding != null && binding.isFromSource()) {
ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, binding);
if (targetCU != null) {
String label;
Image image;
String sig= getMethodSignature(methodName, arguments);
if (cu.equals(targetCU)) {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createmethod.description", sig); //$NON-NLS-1$
image= JavaPluginImages.get(JavaPluginImages.IMG_MISC_PRIVATE);
} else {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createmethod.other.description", new Object[] { sig, targetCU.getElementName() } ); //$NON-NLS-1$
image= JavaPluginImages.get(JavaPluginImages.IMG_MISC_PUBLIC);
}
proposals.add(new NewMethodCompletionProposal(label, targetCU, invocationNode, arguments, binding, 5, image));
if (binding.isAnonymous() && cu.equals(targetCU) && sender == null && Bindings.findMethodInHierarchy(binding, methodName, null) == null) { // no covering method
ASTNode anonymDecl= astRoot.findDeclaringNode(binding);
if (anonymDecl != null) {
binding= Bindings.getBindingOfParentType(anonymDecl.getParent());
if (!binding.isAnonymous()) {
String[] args= new String[] { sig, binding.getName() };
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createmethod.other.description", args); //$NON-NLS-1$
image= JavaPluginImages.get(JavaPluginImages.IMG_MISC_PROTECTED);
proposals.add(new NewMethodCompletionProposal(label, targetCU, invocationNode, arguments, binding, 5, image));
}
}
}
}
}
if (!isOnlyParameterMismatch && !isSuperInvocation && sender != null) {
addMissingCastParentsProposal(cu, (MethodInvocation) invocationNode, proposals);
}
if (!isSuperInvocation && sender == null && invocationNode.getParent() instanceof ThrowStatement) {
String str= "new "; //$NON-NLS-1$ // do it the manual way, copting all the arguments is nasty
String label= CorrectionMessages.getString("UnresolvedElementsSubProcessor.addnewkeyword.description"); //$NON-NLS-1$
int relevance= Character.isUpperCase(methodName.charAt(0)) ? 7 : 4;
ReplaceCorrectionProposal proposal= new ReplaceCorrectionProposal(label, cu, invocationNode.getStartPosition(), 0, str, relevance);
proposals.add(proposal);
}
}
private static void addMissingCastParentsProposal(ICompilationUnit cu, MethodInvocation invocationNode, Collection proposals) {
Expression sender= invocationNode.getExpression();
if (sender instanceof ThisExpression) {
return;
}
ITypeBinding senderBinding= sender.resolveTypeBinding();
if (senderBinding == null || Modifier.isFinal(senderBinding.getModifiers())) {
return;
}
if (sender instanceof Name && ((Name) sender).resolveBinding() instanceof ITypeBinding) {
return; // static access
}
ASTNode parent= invocationNode.getParent();
while (parent instanceof Expression && parent.getNodeType() != ASTNode.CAST_EXPRESSION) {
parent= parent.getParent();
}
boolean hasCastProposal= false;
if (parent instanceof CastExpression) {
// (TestCase) x.getName() -> ((TestCase) x).getName
hasCastProposal= useExistingParentCastProposal(cu, (CastExpression) parent, sender, invocationNode.getName(), getArgumentTypes(invocationNode.arguments()), proposals);
}
if (!hasCastProposal) {
// x.getName() -> ((TestCase) x).getName
Expression target= sender;
while (target instanceof ParenthesizedExpression) {
target= ((ParenthesizedExpression) target).getExpression();
}
String label;
if (target.getNodeType() != ASTNode.CAST_EXPRESSION) {
String targetName= null;
if (target.getLength() <= 18) {
targetName= ASTNodes.asString(target);
}
if (targetName == null) {
label= CorrectionMessages.getString("UnresolvedElementsSubProcessor.methodtargetcast.description"); //$NON-NLS-1$
} else {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.methodtargetcast2.description", targetName); //$NON-NLS-1$
}
} else {
String targetName= null;
if (target.getLength() <= 18) {
targetName= ASTNodes.asString(((CastExpression)target).getExpression());
}
if (targetName == null) {
label= CorrectionMessages.getString("UnresolvedElementsSubProcessor.changemethodtargetcast.description"); //$NON-NLS-1$
} else {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changemethodtargetcast2.description", targetName); //$NON-NLS-1$
}
}
proposals.add(new CastCompletionProposal(label, cu, target, null, 3));
}
}
private static boolean useExistingParentCastProposal(ICompilationUnit cu, CastExpression expression, Expression accessExpression, SimpleName accessSelector, ITypeBinding[] paramTypes, Collection proposals) {
ITypeBinding castType= expression.getType().resolveBinding();
if (castType == null) {
return false;
}
if (paramTypes != null) {
if (Bindings.findMethodInHierarchy(castType, accessSelector.getIdentifier(), paramTypes) == null) {
return false;
}
} else if (Bindings.findFieldInHierarchy(castType, accessSelector.getIdentifier()) == null) {
return false;
}
ITypeBinding bindingToCast= accessExpression.resolveTypeBinding();
if (bindingToCast != null && !TypeRules.canCast(castType, bindingToCast)) {
return false;
}
IMethodBinding res= Bindings.findMethodInHierarchy(castType, accessSelector.getIdentifier(), paramTypes);
if (res != null) {
AST ast= expression.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
CastExpression newCast= ast.newCastExpression();
newCast.setType((Type) ASTNode.copySubtree(ast, expression.getType()));
newCast.setExpression((Expression) rewrite.createCopyTarget(accessExpression));
ParenthesizedExpression parents= ast.newParenthesizedExpression();
parents.setExpression(newCast);
ASTNode node= rewrite.createCopyTarget(expression.getExpression());
rewrite.replace(expression, node, null);
rewrite.replace(accessExpression, parents, null);
String label= CorrectionMessages.getString("UnresolvedElementsSubProcessor.missingcastbrackets.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, 8, image);
proposals.add(proposal);
return true;
}
return false;
}
private static void addParameterMissmatchProposals(IInvocationContext context, IProblemLocation problem, List similarElements, ASTNode invocationNode, List arguments, Collection proposals) throws CoreException {
int nSimilarElements= similarElements.size();
ITypeBinding[] argTypes= getArgumentTypes(arguments);
if (argTypes == null || nSimilarElements == 0) {
return;
}
for (int i= 0; i < nSimilarElements; i++) {
IMethodBinding elem = (IMethodBinding) similarElements.get(i);
int diff= elem.getParameterTypes().length - argTypes.length;
if (diff == 0) {
int nProposals= proposals.size();
doEqualNumberOfParameters(context, invocationNode, problem, arguments, argTypes, elem, proposals);
if (nProposals != proposals.size()) {
return; // only suggest for one method (avoid duplicated proposals)
}
} else if (diff > 0) {
doMoreParameters(context, problem, invocationNode, arguments, argTypes, elem, proposals);
} else {
doMoreArguments(context, problem, invocationNode, arguments, argTypes, elem, proposals);
}
}
}
private static void doMoreParameters(IInvocationContext context, IProblemLocation problem, ASTNode invocationNode, List arguments, ITypeBinding[] argTypes, IMethodBinding methodBinding, Collection proposals) throws CoreException {
ITypeBinding[] paramTypes= methodBinding.getParameterTypes();
int k= 0, nSkipped= 0;
int diff= paramTypes.length - argTypes.length;
int[] indexSkipped= new int[diff];
for (int i= 0; i < paramTypes.length; i++) {
if (k < argTypes.length && TypeRules.canAssign(argTypes[k], paramTypes[i])) {
k++; // match
} else {
if (nSkipped >= diff) {
return; // too different
}
indexSkipped[nSkipped++]= i;
}
}
ITypeBinding declaringType= methodBinding.getDeclaringClass();
ICompilationUnit cu= context.getCompilationUnit();
CompilationUnit astRoot= context.getASTRoot();
// add arguments
{
String[] arg= new String[] { getMethodSignature(methodBinding, false) };
String label;
if (diff == 1) {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addargument.description", arg); //$NON-NLS-1$
} else {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addarguments.description", arg); //$NON-NLS-1$
}
AddArgumentCorrectionProposal proposal= new AddArgumentCorrectionProposal(label, context.getCompilationUnit(), invocationNode, indexSkipped, paramTypes, 8);
proposal.setImage(JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_ADD));
proposals.add(proposal);
}
// remove parameters
if (!declaringType.isFromSource()) {
return;
}
ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, declaringType);
if (targetCU != null) {
ChangeDescription[] changeDesc= new ChangeDescription[paramTypes.length];
ITypeBinding[] changedTypes= new ITypeBinding[diff];
for (int i= diff - 1; i >= 0; i--) {
int idx= indexSkipped[i];
changeDesc[idx]= new RemoveDescription();
changedTypes[i]= paramTypes[idx];
}
String[] arg= new String[] { getMethodSignature(methodBinding, !cu.equals(targetCU)), getTypeNames(changedTypes) };
String label;
if (methodBinding.isConstructor()) {
if (diff == 1) {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.removeparam.constr.description", arg); //$NON-NLS-1$
} else {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.removeparams.constr.description", arg); //$NON-NLS-1$
}
} else {
if (diff == 1) {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.removeparam.description", arg); //$NON-NLS-1$
} else {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.removeparams.description", arg); //$NON-NLS-1$
}
}
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_REMOVE);
ChangeMethodSignatureProposal proposal= new ChangeMethodSignatureProposal(label, targetCU, invocationNode, methodBinding, changeDesc, null, 5, image);
proposals.add(proposal);
}
}
private static String getTypeNames(ITypeBinding[] types) {
StringBuffer buf= new StringBuffer();
for (int i= 0; i < types.length; i++) {
if (i > 0) {
buf.append(", "); //$NON-NLS-1$
}
buf.append(types[i].getName());
}
return buf.toString();
}
private static String getArgumentName(ICompilationUnit cu, List arguments, int index) {
String def= String.valueOf(index + 1);
ASTNode expr= (ASTNode) arguments.get(index);
if (expr.getLength() > 18) {
return def;
}
ASTMatcher matcher= new ASTMatcher();
for (int i= 0; i < arguments.size(); i++) {
if (i != index && matcher.safeSubtreeMatch(expr, arguments.get(i))) {
return def;
}
}
return '\'' + ASTNodes.asString(expr) + '\'';
}
private static void doMoreArguments(IInvocationContext context, IProblemLocation problem, ASTNode invocationNode, List arguments, ITypeBinding[] argTypes, IMethodBinding methodBinding, Collection proposals) throws CoreException {
ITypeBinding[] paramTypes= methodBinding.getParameterTypes();
int k= 0, nSkipped= 0;
int diff= argTypes.length - paramTypes.length;
int[] indexSkipped= new int[diff];
for (int i= 0; i < argTypes.length; i++) {
if (k < paramTypes.length && TypeRules.canAssign(argTypes[i], paramTypes[k])) {
k++; // match
} else {
if (nSkipped >= diff) {
return; // too different
}
indexSkipped[nSkipped++]= i;
}
}
ITypeBinding declaringType= methodBinding.getDeclaringClass();
ICompilationUnit cu= context.getCompilationUnit();
CompilationUnit astRoot= context.getASTRoot();
// remove arguments
{
ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
for (int i= diff - 1; i >= 0; i--) {
rewrite.remove((Expression) arguments.get(indexSkipped[i]), null);
}
String[] arg= new String[] { getMethodSignature(methodBinding, false) };
String label;
if (diff == 1) {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.removeargument.description", arg); //$NON-NLS-1$
} else {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.removearguments.description", arg); //$NON-NLS-1$
}
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_REMOVE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 8, image);
proposals.add(proposal);
}
// add parameters
if (!declaringType.isFromSource()) {
return;
}
ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, declaringType);
if (targetCU != null) {
boolean isDifferentCU= !cu.equals(targetCU);
if (isImplicitConstructor(methodBinding, targetCU)) {
return;
}
ChangeDescription[] changeDesc= new ChangeDescription[argTypes.length];
ITypeBinding[] changeTypes= new ITypeBinding[diff];
for (int i= diff - 1; i >= 0; i--) {
int idx= indexSkipped[i];
Expression arg= (Expression) arguments.get(idx);
String name= arg instanceof SimpleName ? ((SimpleName) arg).getIdentifier() : null;
ITypeBinding newType= Bindings.normalizeTypeBinding(argTypes[idx]);
if (newType == null) {
newType= astRoot.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$
}
changeDesc[idx]= new InsertDescription(newType, name);
changeTypes[i]= newType;
}
String[] arg= new String[] { getMethodSignature(methodBinding, isDifferentCU), getTypeNames(changeTypes) };
String label;
if (methodBinding.isConstructor()) {
if (diff == 1) {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addparam.constr.description", arg); //$NON-NLS-1$
} else {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addparams.constr.description", arg); //$NON-NLS-1$
}
} else {
if (diff == 1) {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addparam.description", arg); //$NON-NLS-1$
} else {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addparams.description", arg); //$NON-NLS-1$
}
}
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_ADD);
ChangeMethodSignatureProposal proposal= new ChangeMethodSignatureProposal(label, targetCU, invocationNode, methodBinding, changeDesc, null, 5, image);
proposals.add(proposal);
}
}
private static boolean isImplicitConstructor(IMethodBinding meth, ICompilationUnit targetCU) {
if (meth.isConstructor() && meth.getParameterTypes().length == 0) {
IMethodBinding[] bindings= meth.getDeclaringClass().getDeclaredMethods();
// implicit constructors must be the only constructor
for (int i= 0; i < bindings.length; i++) {
IMethodBinding curr= bindings[i];
if (curr.isConstructor() && curr != meth) {
return false;
}
}
ASTParser parser= ASTParser.newParser(AST.JLS2);
parser.setSource(targetCU);
parser.setFocalPosition(0);
parser.setResolveBindings(true);
CompilationUnit unit= (CompilationUnit) parser.createAST(null);
return unit.findDeclaringNode(meth.getKey()) == null;
}
return false;
}
private static String getMethodSignature(IMethodBinding binding, boolean inOtherCU) {
StringBuffer buf= new StringBuffer();
if (inOtherCU && !binding.isConstructor()) {
buf.append(binding.getDeclaringClass().getName()).append('.');
}
buf.append(binding.getName());
return getMethodSignature(buf.toString(), binding.getParameterTypes());
}
private static String getMethodSignature(String name, List args) {
ITypeBinding[] params= new ITypeBinding[args.size()];
for (int i= 0; i < args.size(); i++) {
Expression expr= (Expression) args.get(i);
ITypeBinding curr= Bindings.normalizeTypeBinding(expr.resolveTypeBinding());
if (curr == null) {
curr= expr.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$
}
params[i]= curr;
}
return getMethodSignature(name, params);
}
private static String getMethodSignature(String name, ITypeBinding[] params) {
StringBuffer buf= new StringBuffer();
buf.append(name).append('(');
for (int i= 0; i < params.length; i++) {
if (i > 0) {
buf.append(", "); //$NON-NLS-1$
}
buf.append(params[i].getName());
}
buf.append(')');
return buf.toString();
}
private static void doEqualNumberOfParameters(IInvocationContext context, ASTNode invocationNode, IProblemLocation problem, List arguments, ITypeBinding[] argTypes, IMethodBinding methodBinding, Collection proposals) throws CoreException {
ITypeBinding[] paramTypes= methodBinding.getParameterTypes();
int[] indexOfDiff= new int[paramTypes.length];
int nDiffs= 0;
for (int n= 0; n < argTypes.length; n++) {
if (!TypeRules.canAssign(argTypes[n], paramTypes[n])) {
indexOfDiff[nDiffs++]= n;
}
}
ITypeBinding declaringType= methodBinding.getDeclaringClass();
ICompilationUnit cu= context.getCompilationUnit();
CompilationUnit astRoot= context.getASTRoot();
ASTNode nameNode= problem.getCoveringNode(astRoot);
if (nameNode == null) {
return;
}
if (nDiffs == 0) {
if (nameNode.getParent() instanceof MethodInvocation) {
MethodInvocation inv= (MethodInvocation) nameNode.getParent();
if (inv.getExpression() == null) {
addQualifierToOuterProposal(context, inv, methodBinding, proposals);
}
}
return;
}
if (nDiffs == 1) { // one argument mismatching: try to fix
int idx= indexOfDiff[0];
Expression nodeToCast= (Expression) arguments.get(idx);
ITypeBinding castType= paramTypes[idx];
ITypeBinding binding= nodeToCast.resolveTypeBinding();
if (binding == null || TypeRules.canCast(castType, binding)) {
String castTypeName= castType.getQualifiedName();
ASTRewriteCorrectionProposal proposal= TypeMismatchSubProcessor.createCastProposal(context, castTypeName, nodeToCast, 6);
String[] arg= new String[] { getArgumentName(cu, arguments, idx), castTypeName};
proposal.setDisplayName(CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addargumentcast.description", arg)); //$NON-NLS-1$
proposals.add(proposal);
}
TypeMismatchSubProcessor.addChangeSenderTypeProposals(context, nodeToCast, castType, false, 5, proposals);
}
if (nDiffs == 2) { // try to swap
int idx1= indexOfDiff[0];
int idx2= indexOfDiff[1];
boolean canSwap= TypeRules.canAssign(argTypes[idx1], paramTypes[idx2]) && TypeRules.canAssign(argTypes[idx2], paramTypes[idx1]);
if (canSwap) {
Expression arg1= (Expression) arguments.get(idx1);
Expression arg2= (Expression) arguments.get(idx2);
ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
rewrite.replace(arg1, rewrite.createCopyTarget(arg2), null);
rewrite.replace(arg2, rewrite.createCopyTarget(arg1), null);
{
String[] arg= new String[] { getArgumentName(cu, arguments, idx1), getArgumentName(cu, arguments, idx2) };
String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.swaparguments.description", arg); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 8, image);
proposals.add(proposal);
}
if (declaringType.isFromSource()) {
ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, declaringType);
if (targetCU != null) {
ChangeDescription[] changeDesc= new ChangeDescription[paramTypes.length];
for (int i= 0; i < nDiffs; i++) {
changeDesc[idx1]= new SwapDescription(idx2);
}
ITypeBinding[] swappedTypes= new ITypeBinding[] { paramTypes[idx1], paramTypes[idx2] };
String[] args= new String[] { getMethodSignature(methodBinding, !targetCU.equals(cu)), getTypeNames(swappedTypes) };
String label;
if (methodBinding.isConstructor()) {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.swapparams.constr.description", args); //$NON-NLS-1$
} else {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.swapparams.description", args); //$NON-NLS-1$
}
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ChangeMethodSignatureProposal proposal= new ChangeMethodSignatureProposal(label, targetCU, invocationNode, methodBinding, changeDesc, null, 5, image);
proposals.add(proposal);
}
}
return;
}
}
if (declaringType.isFromSource()) {
ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, declaringType);
if (targetCU != null) {
ChangeDescription[] changeDesc= new ChangeDescription[paramTypes.length];
for (int i= 0; i < nDiffs; i++) {
int diffIndex= indexOfDiff[i];
Expression arg= (Expression) arguments.get(diffIndex);
String name= arg instanceof SimpleName ? ((SimpleName) arg).getIdentifier() : null;
changeDesc[diffIndex]= new EditDescription(argTypes[diffIndex], name);
}
ITypeBinding[] newParamTypes= new ITypeBinding[changeDesc.length];
for (int i= 0; i < newParamTypes.length; i++) {
newParamTypes[i]= changeDesc[i] == null ? paramTypes[i] : ((EditDescription) changeDesc[i]).type;
}
String[] args= new String[] { getMethodSignature(methodBinding, !targetCU.equals(cu)), getMethodSignature(methodBinding.getName(), newParamTypes) };
String label;
if (methodBinding.isConstructor()) {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changeparamsignature.constr.description", args); //$NON-NLS-1$
} else {
label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changeparamsignature.description", args); //$NON-NLS-1$
}
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ChangeMethodSignatureProposal proposal= new ChangeMethodSignatureProposal(label, targetCU, invocationNode, methodBinding, changeDesc, null, 7, image);
proposals.add(proposal);
}
}
}
private static ITypeBinding[] getArgumentTypes(List arguments) {
ITypeBinding[] res= new ITypeBinding[arguments.size()];
for (int i= 0; i < res.length; i++) {
Expression expression= (Expression) arguments.get(i);
ITypeBinding curr= expression.resolveTypeBinding();
if (curr == null) {
return null;
}
if (!curr.isNullType()) { // don't normalize null type
curr= Bindings.normalizeTypeBinding(curr);
if (curr == null) {
curr= expression.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$
}
}
res[i]= curr;
}
return res;
}
private static void addQualifierToOuterProposal(IInvocationContext context, MethodInvocation invocationNode, IMethodBinding binding, Collection proposals) throws CoreException {
ITypeBinding declaringType= binding.getDeclaringClass();
ITypeBinding parentType= Bindings.getBindingOfParentType(invocationNode);
ITypeBinding currType= parentType;
boolean isInstanceMethod= !Modifier.isStatic(binding.getModifiers());
while (currType != null && !Bindings.isSuperType(declaringType, currType)) {
if (isInstanceMethod && Modifier.isStatic(currType.getModifiers())) {
return;
}
currType= currType.getDeclaringClass();
}
if (currType == null || currType == parentType) {
return;
}
ASTRewrite rewrite= ASTRewrite.create(invocationNode.getAST());
ImportRewrite imports= new ImportRewrite(context.getCompilationUnit());
AST ast= invocationNode.getAST();
String qualifier= imports.addImport(currType);
Name name= ASTNodeFactory.newName(ast, qualifier);
Expression newExpression;
if (isInstanceMethod) {
ThisExpression expr= ast.newThisExpression();
expr.setQualifier(name);
newExpression= expr;
} else {
newExpression= name;
}
rewrite.set(invocationNode, MethodInvocation.EXPRESSION_PROPERTY, newExpression, null);
String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changetoouter.description", currType.getName()); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 8, image);
proposal.setImportRewrite(imports);
proposals.add(proposal);
}
public static void getConstructorProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException {
ICompilationUnit cu= context.getCompilationUnit();
CompilationUnit astRoot= context.getASTRoot();
ASTNode selectedNode= problem.getCoveringNode(astRoot);
if (selectedNode == null) {
return;
}
ITypeBinding targetBinding= null;
List arguments= null;
IMethodBinding recursiveConstructor= null;
int type= selectedNode.getNodeType();
if (type == ASTNode.CLASS_INSTANCE_CREATION) {
ClassInstanceCreation creation= (ClassInstanceCreation) selectedNode;
IBinding binding= creation.getName().resolveBinding();
if (binding instanceof ITypeBinding) {
targetBinding= (ITypeBinding) binding;
arguments= creation.arguments();
}
} else if (type == ASTNode.SUPER_CONSTRUCTOR_INVOCATION) {
ITypeBinding typeBinding= Bindings.getBindingOfParentType(selectedNode);
if (typeBinding != null && !typeBinding.isAnonymous()) {
targetBinding= typeBinding.getSuperclass();
arguments= ((SuperConstructorInvocation) selectedNode).arguments();
}
} else if (type == ASTNode.CONSTRUCTOR_INVOCATION) {
ITypeBinding typeBinding= Bindings.getBindingOfParentType(selectedNode);
if (typeBinding != null && !typeBinding.isAnonymous()) {
targetBinding= typeBinding;
arguments= ((ConstructorInvocation) selectedNode).arguments();
recursiveConstructor= ASTResolving.findParentMethodDeclaration(selectedNode).resolveBinding();
}
}
if (targetBinding == null) {
return;
}
IMethodBinding[] methods= targetBinding.getDeclaredMethods();
ArrayList similarElements= new ArrayList();
for (int i= 0; i < methods.length; i++) {
IMethodBinding curr= methods[i];
if (curr.isConstructor() && recursiveConstructor != curr) {
similarElements.add(curr); // similar elements can contain a implicit default constructor
}
}
addParameterMissmatchProposals(context, problem, similarElements, selectedNode, arguments, proposals);
if (targetBinding.isFromSource()) {
ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, targetBinding);
if (targetCU != null) {
String[] args= new String[] { getMethodSignature( targetBinding.getName(), arguments) };
String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createconstructor.description", args); //$NON-NLS-1$
Image image= JavaElementImageProvider.getDecoratedImage(JavaPluginImages.DESC_MISC_PUBLIC, JavaElementImageDescriptor.CONSTRUCTOR, JavaElementImageProvider.SMALL_SIZE);
proposals.add(new NewMethodCompletionProposal(label, targetCU, selectedNode, arguments, targetBinding, 5, image));
}
}
}
public static void getAmbiguosTypeReferenceProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException {
final ICompilationUnit cu= context.getCompilationUnit();
int offset= problem.getOffset();
int len= problem.getLength();
IJavaElement[] elements= cu.codeSelect(offset, len);
for (int i= 0; i < elements.length; i++) {
IJavaElement curr= elements[i];
if (curr instanceof IType && !TypeFilter.isFiltered((IType) curr)) {
String qualifiedTypeName= JavaModelUtil.getFullyQualifiedName((IType) curr);
ImportRewrite imports= new ImportRewrite(cu);
imports.setFindAmbiguosImports(true);
imports.addImport(qualifiedTypeName);
String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.importexplicit.description", qualifiedTypeName); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_IMPDECL);
CUCorrectionProposal proposal= new CUCorrectionProposal(label, cu, 5, image);
proposal.setImportRewrite(imports);
proposals.add(proposal);
}
}
}
public static void getArrayAccessProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) {
CompilationUnit root= context.getASTRoot();
ASTNode selectedNode= problem.getCoveringNode(root);
if (!(selectedNode instanceof MethodInvocation)) {
return;
}
MethodInvocation decl= (MethodInvocation) selectedNode;
SimpleName nameNode= decl.getName();
String methodName= nameNode.getIdentifier();
IBinding[] bindings= (new ScopeAnalyzer(root)).getDeclarationsInScope(nameNode, ScopeAnalyzer.METHODS);
for (int i= 0; i < bindings.length; i++) {
String currName= bindings[i].getName();
if (NameMatcher.isSimilarName(methodName, currName)) {
String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.arraychangetomethod.description", currName); //$NON-NLS-1$
proposals.add(new RenameNodeCompletionProposal(label, context.getCompilationUnit(), nameNode.getStartPosition(), nameNode.getLength(), currName, 6));
}
}
// always suggest 'length'
String lengthId= "length"; //$NON-NLS-1$
String label= CorrectionMessages.getString("UnresolvedElementsSubProcessor.arraychangetolength.description"); //$NON-NLS-1$
int offset= nameNode.getStartPosition();
int length= decl.getStartPosition() + decl.getLength() - offset;
proposals.add(new RenameNodeCompletionProposal(label, context.getCompilationUnit(), offset, length, lengthId, 7));
}
}
|
53,860
|
Bug 53860 Extract Local does not work on static parameter in call to constructor [refactoring]
|
I20040304 Extract Local on "SWT.NORMAL" in the following statement does not work: fRanges.add(new StyleRange(j, word.length(), fLocalColor, null, SWT.NORMAL)); Error Message: Cannot extract this name - try selecting the whole instance creation expression.
|
verified fixed
|
3de942a
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T09:05:36Z
| 2004-03-05T15:20:00Z
|
org.eclipse.jdt.ui.tests.refactoring/resources/ExtractTemp/canExtract/A_test81_in.java
| |
53,860
|
Bug 53860 Extract Local does not work on static parameter in call to constructor [refactoring]
|
I20040304 Extract Local on "SWT.NORMAL" in the following statement does not work: fRanges.add(new StyleRange(j, word.length(), fLocalColor, null, SWT.NORMAL)); Error Message: Cannot extract this name - try selecting the whole instance creation expression.
|
verified fixed
|
3de942a
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T09:05:36Z
| 2004-03-05T15:20:00Z
|
org.eclipse.jdt.ui.tests.refactoring/resources/ExtractTemp/canExtract/A_test81_out.java
| |
53,860
|
Bug 53860 Extract Local does not work on static parameter in call to constructor [refactoring]
|
I20040304 Extract Local on "SWT.NORMAL" in the following statement does not work: fRanges.add(new StyleRange(j, word.length(), fLocalColor, null, SWT.NORMAL)); Error Message: Cannot extract this name - try selecting the whole instance creation expression.
|
verified fixed
|
3de942a
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T09:05:36Z
| 2004-03-05T15:20:00Z
|
org.eclipse.jdt.ui.tests.refactoring/test
| |
53,860
|
Bug 53860 Extract Local does not work on static parameter in call to constructor [refactoring]
|
I20040304 Extract Local on "SWT.NORMAL" in the following statement does not work: fRanges.add(new StyleRange(j, word.length(), fLocalColor, null, SWT.NORMAL)); Error Message: Cannot extract this name - try selecting the whole instance creation expression.
|
verified fixed
|
3de942a
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T09:05:36Z
| 2004-03-05T15:20:00Z
|
cases/org/eclipse/jdt/ui/tests/refactoring/ExtractTempTests.java
| |
53,860
|
Bug 53860 Extract Local does not work on static parameter in call to constructor [refactoring]
|
I20040304 Extract Local on "SWT.NORMAL" in the following statement does not work: fRanges.add(new StyleRange(j, word.length(), fLocalColor, null, SWT.NORMAL)); Error Message: Cannot extract this name - try selecting the whole instance creation expression.
|
verified fixed
|
3de942a
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T09:05:36Z
| 2004-03-05T15:20:00Z
|
org.eclipse.jdt.ui/core
| |
53,860
|
Bug 53860 Extract Local does not work on static parameter in call to constructor [refactoring]
|
I20040304 Extract Local on "SWT.NORMAL" in the following statement does not work: fRanges.add(new StyleRange(j, word.length(), fLocalColor, null, SWT.NORMAL)); Error Message: Cannot extract this name - try selecting the whole instance creation expression.
|
verified fixed
|
3de942a
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T09:05:36Z
| 2004-03-05T15:20:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java
| |
47,337
|
Bug 47337 Placement of exisiting comments after Add javadoc [code manipulation]
| null |
verified fixed
|
c0d6d66
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T12:57:09Z
| 2003-11-24T13:20:00Z
|
org.eclipse.jdt.ui/core
| |
47,337
|
Bug 47337 Placement of exisiting comments after Add javadoc [code manipulation]
| null |
verified fixed
|
c0d6d66
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T12:57:09Z
| 2003-11-24T13:20:00Z
|
extension/org/eclipse/jdt/internal/corext/codemanipulation/AddJavaDocStubOperation.java
| |
64,330
|
Bug 64330 Pull-Up: error message should be more clear when all super types are binary
| null |
verified fixed
|
b85e1e9
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T13:45:23Z
| 2004-05-27T15:00:00Z
|
org.eclipse.jdt.ui/core
| |
64,330
|
Bug 64330 Pull-Up: error message should be more clear when all super types are binary
| null |
verified fixed
|
b85e1e9
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T13:45:23Z
| 2004-05-27T15:00:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoring.java
| |
60,978
|
Bug 60978 JUnit scroll lock not working [JUnit]
|
Build I20040504 The JUnit view's scroll lock button has no affect. The the list of failures scrolls as new entries are added.
|
verified fixed
|
3a95f06
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T14:50:36Z
| 2004-05-04T22:33:20Z
|
org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Julien Ruaux: jruaux@octo.com see bug 25324 Ability to know when tests are finished [junit]
* Vincent Massol: vmassol@octo.com 25324 Ability to know when tests are finished [junit]
* Sebastian Davids: sdavids@gmx.de 35762 JUnit View wasting a lot of screen space [JUnit]
******************************************************************************/
package org.eclipse.jdt.internal.junit.ui;
import java.net.MalformedURLException;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jdt.core.ElementChangedEvent;
import org.eclipse.jdt.core.IElementChangedListener;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaElementDelta;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.junit.launcher.JUnitBaseLaunchConfiguration;
import org.eclipse.jdt.junit.ITestRunListener;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.ViewForm;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorActionBarContributor;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.part.EditorActionBarContributor;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.progress.UIJob;
/**
* A ViewPart that shows the results of a test run.
*/
public class TestRunnerViewPart extends ViewPart implements ITestRunListener3, IPropertyChangeListener {
public static final String NAME= "org.eclipse.jdt.junit.ResultView"; //$NON-NLS-1$
public static final String ID_EXTENSION_POINT_TESTRUN_TABS= JUnitPlugin.PLUGIN_ID + "." + "internal-testRunTabs"; //$NON-NLS-1$ //$NON-NLS-2$
static final int REFRESH_INTERVAL= 200;
/**
* Number of executed tests during a test run
*/
protected volatile int fExecutedTests;
/**
* Number of errors during this test run
*/
protected volatile int fErrorCount;
/**
* Number of failures during this test run
*/
protected volatile int fFailureCount;
/**
* Number of tests run
*/
protected volatile int fTestCount;
/**
* Whether the output scrolls and reveals tests as they are executed.
*/
protected boolean fAutoScroll = true;
/**
* The current orientation; either <code>VIEW_ORIENTATION_HORIZONTAL</code>
* <code>VIEW_ORIENTATION_VERTICAL</code>, or <code>VIEW_ORIENTATION_AUTOMATIC</code>.
*/
private int fOrientation= VIEW_ORIENTATION_AUTOMATIC;
/**
* The current orientation; either <code>VIEW_ORIENTATION_HORIZONTAL</code>
* <code>VIEW_ORIENTATION_VERTICAL</code>.
*/
private int fCurrentOrientation;
/**
* Map storing TestInfos for each executed test keyed by
* the test name.
*/
private Map fTestInfos= new HashMap();
/**
* The first failure of a test run. Used to reveal the
* first failed tests at the end of a run.
*/
private List fFailures= new ArrayList();
protected JUnitProgressBar fProgressBar;
protected ProgressImages fProgressImages;
protected Image fViewImage;
protected CounterPanel fCounterPanel;
protected boolean fShowOnErrorOnly= false;
protected Clipboard fClipboard;
protected volatile String fStatus;
/**
* The tab that shows the stack trace of a failure
*/
private FailureTrace fFailureTrace;
/**
* The collection of ITestRunTabs
*/
protected Vector fTestRunTabs = new Vector();
/**
* The currently active run tab
*/
private TestRunTab fActiveRunTab;
/**
* Is the UI disposed
*/
private boolean fIsDisposed= false;
/**
* The launched project
*/
private IJavaProject fTestProject;
/**
* The launcher that has started the test
*/
private String fLaunchMode;
private ILaunch fLastLaunch;
/**
* Actions
*/
private Action fRerunLastTestAction;
private ScrollLockAction fScrollLockAction;
private ToggleOrientationAction[] fToggleOrientationActions;
/**
* The client side of the remote test runner
*/
private RemoteTestRunnerClient fTestRunnerClient;
final Image fStackViewIcon= TestRunnerViewPart.createImage("eview16/stackframe.gif");//$NON-NLS-1$
final Image fTestRunOKIcon= TestRunnerViewPart.createImage("eview16/junitsucc.gif"); //$NON-NLS-1$
final Image fTestRunFailIcon= TestRunnerViewPart.createImage("eview16/juniterr.gif"); //$NON-NLS-1$
final Image fTestRunOKDirtyIcon= TestRunnerViewPart.createImage("eview16/junitsuccq.gif"); //$NON-NLS-1$
final Image fTestRunFailDirtyIcon= TestRunnerViewPart.createImage("eview16/juniterrq.gif"); //$NON-NLS-1$
// Persistence tags.
static final String TAG_PAGE= "page"; //$NON-NLS-1$
static final String TAG_RATIO= "ratio"; //$NON-NLS-1$
static final String TAG_TRACEFILTER= "tracefilter"; //$NON-NLS-1$
static final String TAG_ORIENTATION= "orientation"; //$NON-NLS-1$
static final String TAG_SCROLL= "scroll"; //$NON-NLS-1$
//orientations
static final int VIEW_ORIENTATION_VERTICAL= 0;
static final int VIEW_ORIENTATION_HORIZONTAL= 1;
static final int VIEW_ORIENTATION_AUTOMATIC= 2;
private IMemento fMemento;
Image fOriginalViewImage;
IElementChangedListener fDirtyListener;
private CTabFolder fTabFolder;
private SashForm fSashForm;
private Action fNextAction;
private Action fPreviousAction;
private Composite fCounterComposite;
private Composite fParent;
private UpdateUIJob fUpdateJob;
private StopAction fStopAction;
private class StopAction extends Action {
public StopAction() {
setText(JUnitMessages.getString("TestRunnerViewPart.stopaction.text"));//$NON-NLS-1$
setToolTipText(JUnitMessages.getString("TestRunnerViewPart.stopaction.tooltip"));//$NON-NLS-1$
setDisabledImageDescriptor(JUnitPlugin.getImageDescriptor("dlcl16/stop.gif")); //$NON-NLS-1$
setHoverImageDescriptor(JUnitPlugin.getImageDescriptor("elcl16/stop.gif")); //$NON-NLS-1$
setImageDescriptor(JUnitPlugin.getImageDescriptor("elcl16/stop.gif")); //$NON-NLS-1$
}
public void run() {
stopTest();
}
}
private class RerunLastAction extends Action {
public RerunLastAction() {
setText(JUnitMessages.getString("TestRunnerViewPart.rerunaction.label")); //$NON-NLS-1$
setToolTipText(JUnitMessages.getString("TestRunnerViewPart.rerunaction.tooltip")); //$NON-NLS-1$
setDisabledImageDescriptor(JUnitPlugin.getImageDescriptor("dlcl16/relaunch.gif")); //$NON-NLS-1$
setHoverImageDescriptor(JUnitPlugin.getImageDescriptor("elcl16/relaunch.gif")); //$NON-NLS-1$
setImageDescriptor(JUnitPlugin.getImageDescriptor("elcl16/relaunch.gif")); //$NON-NLS-1$
}
public void run(){
rerunTestRun();
}
}
private class ToggleOrientationAction extends Action {
private final int fActionOrientation;
public ToggleOrientationAction(TestRunnerViewPart v, int orientation) {
super("", AS_RADIO_BUTTON); //$NON-NLS-1$
if (orientation == TestRunnerViewPart.VIEW_ORIENTATION_HORIZONTAL) {
setText(JUnitMessages.getString("TestRunnerViewPart.toggle.horizontal.label")); //$NON-NLS-1$
setImageDescriptor(JUnitPlugin.getImageDescriptor("elcl16/th_horizontal.gif")); //$NON-NLS-1$
} else if (orientation == TestRunnerViewPart.VIEW_ORIENTATION_VERTICAL) {
setText(JUnitMessages.getString("TestRunnerViewPart.toggle.vertical.label")); //$NON-NLS-1$
setImageDescriptor(JUnitPlugin.getImageDescriptor("elcl16/th_vertical.gif")); //$NON-NLS-1$
} else if (orientation == TestRunnerViewPart.VIEW_ORIENTATION_AUTOMATIC) {
setText(JUnitMessages.getString("TestRunnerViewPart.toggle.automatic.label")); //$NON-NLS-1$
setImageDescriptor(JUnitPlugin.getImageDescriptor("elcl16/th_automatic.gif")); //$NON-NLS-1$
}
fActionOrientation= orientation;
WorkbenchHelp.setHelp(this, IJUnitHelpContextIds.RESULTS_VIEW_TOGGLE_ORIENTATION_ACTION);
}
public int getOrientation() {
return fActionOrientation;
}
public void run() {
if (isChecked()) {
fOrientation= fActionOrientation;
computeOrientation();
}
}
}
/**
* Listen for for modifications to Java elements
*/
private class DirtyListener implements IElementChangedListener {
public void elementChanged(ElementChangedEvent event) {
processDelta(event.getDelta());
}
private boolean processDelta(IJavaElementDelta delta) {
int kind= delta.getKind();
int details= delta.getFlags();
int type= delta.getElement().getElementType();
switch (type) {
// Consider containers for class files.
case IJavaElement.JAVA_MODEL:
case IJavaElement.JAVA_PROJECT:
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
case IJavaElement.PACKAGE_FRAGMENT:
// If we did some different than changing a child we flush the the undo / redo stack.
if (kind != IJavaElementDelta.CHANGED || details != IJavaElementDelta.F_CHILDREN) {
codeHasChanged();
return false;
}
break;
case IJavaElement.COMPILATION_UNIT:
// if we have changed a primary working copy (e.g created, removed, ...)
// then we do nothing.
if ((details & IJavaElementDelta.F_PRIMARY_WORKING_COPY) != 0)
return true;
codeHasChanged();
return false;
case IJavaElement.CLASS_FILE:
// Don't examine children of a class file but keep on examining siblings.
return true;
default:
codeHasChanged();
return false;
}
IJavaElementDelta[] affectedChildren= delta.getAffectedChildren();
if (affectedChildren == null)
return true;
for (int i= 0; i < affectedChildren.length; i++) {
if (!processDelta(affectedChildren[i]))
return false;
}
return true;
}
}
public void init(IViewSite site, IMemento memento) throws PartInitException {
super.init(site, memento);
fMemento= memento;
}
private void restoreLayoutState(IMemento memento) {
Integer page= memento.getInteger(TAG_PAGE);
if (page != null) {
int p= page.intValue();
fTabFolder.setSelection(p);
fActiveRunTab= (TestRunTab)fTestRunTabs.get(p);
}
Integer ratio= memento.getInteger(TAG_RATIO);
if (ratio != null)
fSashForm.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue()} );
Integer orientation= memento.getInteger(TAG_ORIENTATION);
if (orientation != null)
fOrientation= orientation.intValue();
computeOrientation();
String scrollLock= memento.getString(TAG_SCROLL);
if (scrollLock != null)
fScrollLockAction.setChecked(scrollLock.equals("true")); //$NON-NLS-1$
}
/**
* Stops the currently running test and shuts down the RemoteTestRunner
*/
public void stopTest() {
if (fTestRunnerClient != null)
fTestRunnerClient.stopTest();
}
/**
* Stops the currently running test and shuts down the RemoteTestRunner
*/
public void rerunTestRun() {
if (lastLaunchIsKeptAlive()) {
// prompt for terminating the existing run
if (MessageDialog.openQuestion(getSite().getShell(), JUnitMessages.getString("TestRunnerViewPart.terminate.title"), JUnitMessages.getString("TestRunnerViewPart.terminate.message"))) { //$NON-NLS-1$ //$NON-NLS-2$
if (fTestRunnerClient != null)
fTestRunnerClient.stopTest();
}
}
if (fLastLaunch != null && fLastLaunch.getLaunchConfiguration() != null) {
DebugUITools.launch(fLastLaunch.getLaunchConfiguration(), fLastLaunch.getLaunchMode());
}
}
public void setAutoScroll(boolean scroll) {
fAutoScroll = scroll;
}
public boolean isAutoScroll() {
return fAutoScroll;
}
/*
* @see ITestRunListener#testRunStarted(testCount)
*/
public void testRunStarted(final int testCount){
reset(testCount);
fShowOnErrorOnly= JUnitPreferencePage.getShowOnErrorOnly();
fExecutedTests++;
fUpdateJob= new UpdateUIJob(JUnitMessages.getString("TestRunnerViewPart.jobName")); //$NON-NLS-1$
fUpdateJob.schedule(REFRESH_INTERVAL);
}
public void selectNextFailure() {
fActiveRunTab.selectNext();
}
public void selectPreviousFailure() {
fActiveRunTab.selectPrevious();
}
public void showTest(TestRunInfo test) {
fActiveRunTab.setSelectedTest(test.getTestId());
handleTestSelected(test.getTestId());
new OpenTestAction(this, test.getClassName(), test.getTestMethodName()).run();
}
public void reset(){
reset(0);
setViewPartTitle(null);
clearStatus();
resetViewIcon();
}
/*
* @see ITestRunListener#testRunEnded
*/
public void testRunEnded(long elapsedTime){
fExecutedTests--;
String[] keys= {elapsedTimeAsString(elapsedTime)};
String msg= JUnitMessages.getFormattedString("TestRunnerViewPart.message.finish", keys); //$NON-NLS-1$
if (hasErrorsOrFailures())
postError(msg);
else
setInfoMessage(msg);
postSyncRunnable(new Runnable() {
public void run() {
if(isDisposed())
return;
fStopAction.setEnabled(false);
if (fFailures.size() > 0) {
selectFirstFailure();
}
updateViewIcon();
if (fDirtyListener == null) {
fDirtyListener= new DirtyListener();
JavaCore.addElementChangedListener(fDirtyListener);
}
for (Enumeration e= fTestRunTabs.elements(); e.hasMoreElements();) {
TestRunTab v= (TestRunTab) e.nextElement();
v.aboutToEnd();
}
}
});
fUpdateJob.stop();
}
protected void selectFirstFailure() {
TestRunInfo firstFailure= (TestRunInfo)fFailures.get(0);
if (firstFailure != null && fAutoScroll) {
fActiveRunTab.setSelectedTest(firstFailure.getTestId());
handleTestSelected(firstFailure.getTestId());
}
}
private void updateViewIcon() {
if (hasErrorsOrFailures())
fViewImage= fTestRunFailIcon;
else
fViewImage= fTestRunOKIcon;
firePropertyChange(IWorkbenchPart.PROP_TITLE);
}
private boolean hasErrorsOrFailures() {
return fErrorCount+fFailureCount > 0;
}
private String elapsedTimeAsString(long runTime) {
return NumberFormat.getInstance().format((double)runTime/1000);
}
/*
* @see ITestRunListener#testRunStopped
*/
public void testRunStopped(final long elapsedTime) {
String msg= JUnitMessages.getString("TestRunnerViewPart.message.stopped"); //$NON-NLS-1$
setInfoMessage(msg);
handleStopped();
}
private void handleStopped() {
postSyncRunnable(new Runnable() {
public void run() {
if(isDisposed())
return;
resetViewIcon();
fStopAction.setEnabled(false);
fProgressBar.stopped();
}
});
fUpdateJob.stop();
}
private void resetViewIcon() {
fViewImage= fOriginalViewImage;
firePropertyChange(IWorkbenchPart.PROP_TITLE);
}
/*
* @see ITestRunListener#testRunTerminated
*/
public void testRunTerminated() {
String msg= JUnitMessages.getString("TestRunnerViewPart.message.terminated"); //$NON-NLS-1$
showMessage(msg);
handleStopped();
}
private void showMessage(String msg) {
//showInformation(msg);
postError(msg);
}
/*
* @see ITestRunListener#testStarted
*/
public void testStarted(String testId, String testName) {
postStartTest(testId, testName);
// reveal the part when the first test starts
if (!fShowOnErrorOnly && fExecutedTests == 1)
postShowTestResultsView();
TestRunInfo testInfo= getTestInfo(testId);
if (testInfo == null) {
testInfo= new TestRunInfo(testId, testName);
fTestInfos.put(testId, testInfo);
}
String className= testInfo.getClassName();
String method= testInfo.getTestMethodName();
String status= JUnitMessages.getFormattedString("TestRunnerViewPart.message.started", new String[] { className, method }); //$NON-NLS-1$
setInfoMessage(status);
}
/*
* @see ITestRunListener#testEnded
*/
public void testEnded(String testId, String testName){
postEndTest(testId, testName);
fExecutedTests++;
}
/*
* @see ITestRunListener#testFailed
*/
public void testFailed(int status, String testId, String testName, String trace){
testFailed(status, testId, testName, trace, null, null);
}
/*
* @see ITestRunListener#testFailed
*/
public void testFailed(int status, String testId, String testName, String trace, String expected, String actual) {
TestRunInfo testInfo= getTestInfo(testId);
if (testInfo == null) {
testInfo= new TestRunInfo(testId, testName);
fTestInfos.put(testName, testInfo);
}
testInfo.setTrace(trace);
testInfo.setStatus(status);
if (expected != null) {
testInfo.setExpected(expected.substring(0, expected.length()-1));
}
if (actual != null)
testInfo.setActual(actual.substring(0, actual.length()-1));
if (status == ITestRunListener.STATUS_ERROR)
fErrorCount++;
else
fFailureCount++;
fFailures.add(testInfo);
// show the view on the first error only
if (fShowOnErrorOnly && (fErrorCount + fFailureCount == 1))
postShowTestResultsView();
}
/*
* @see ITestRunListener#testReran
*/
public void testReran(String testId, String className, String testName, int status, String trace) {
if (status == ITestRunListener.STATUS_ERROR) {
String msg= JUnitMessages.getFormattedString("TestRunnerViewPart.message.error", new String[]{testName, className}); //$NON-NLS-1$
postError(msg);
} else if (status == ITestRunListener.STATUS_FAILURE) {
String msg= JUnitMessages.getFormattedString("TestRunnerViewPart.message.failure", new String[]{testName, className}); //$NON-NLS-1$
postError(msg);
} else {
String msg= JUnitMessages.getFormattedString("TestRunnerViewPart.message.success", new String[]{testName, className}); //$NON-NLS-1$
setInfoMessage(msg);
}
TestRunInfo info= getTestInfo(testId);
updateTest(info, status);
if (info.getTrace() == null || !info.getTrace().equals(trace)) {
info.setTrace(trace);
showFailure(info);
}
}
public void testReran(String testId, String className, String testName, int statusCode, String trace, String expectedResult, String actualResult) {
testReran(testId, className, testName, statusCode, trace);
TestRunInfo info= getTestInfo(testId);
info.setActual(actualResult);
info.setExpected(expectedResult);
fFailureTrace.updateEnablement(info);
}
private void updateTest(TestRunInfo info, final int status) {
if (status == info.getStatus())
return;
if (info.getStatus() == ITestRunListener.STATUS_OK) {
if (status == ITestRunListener.STATUS_FAILURE)
fFailureCount++;
else if (status == ITestRunListener.STATUS_ERROR)
fErrorCount++;
} else if (info.getStatus() == ITestRunListener.STATUS_ERROR) {
if (status == ITestRunListener.STATUS_OK)
fErrorCount--;
else if (status == ITestRunListener.STATUS_FAILURE) {
fErrorCount--;
fFailureCount++;
}
} else if (info.getStatus() == ITestRunListener.STATUS_FAILURE) {
if (status == ITestRunListener.STATUS_OK)
fFailureCount--;
else if (status == ITestRunListener.STATUS_ERROR) {
fFailureCount--;
fErrorCount++;
}
}
info.setStatus(status);
final TestRunInfo finalInfo= info;
postSyncRunnable(new Runnable() {
public void run() {
//refreshCounters();
for (Enumeration e= fTestRunTabs.elements(); e.hasMoreElements();) {
TestRunTab v= (TestRunTab) e.nextElement();
v.testStatusChanged(finalInfo);
}
}
});
}
/*
* @see ITestRunListener#testTreeEntry
*/
public void testTreeEntry(final String treeEntry){
postSyncRunnable(new Runnable() {
public void run() {
if(isDisposed())
return;
for (Enumeration e= fTestRunTabs.elements(); e.hasMoreElements();) {
TestRunTab v= (TestRunTab) e.nextElement();
v.newTreeEntry(treeEntry);
}
}
});
}
public void startTestRunListening(IJavaElement type, int port, ILaunch launch) {
fTestProject= type.getJavaProject();
fLaunchMode= launch.getLaunchMode();
aboutToLaunch();
if (fTestRunnerClient != null) {
stopTest();
}
fTestRunnerClient= new RemoteTestRunnerClient();
// add the TestRunnerViewPart to the list of registered listeners
List listeners= JUnitPlugin.getDefault().getTestRunListeners();
ITestRunListener[] listenerArray= new ITestRunListener[listeners.size()+1];
listeners.toArray(listenerArray);
System.arraycopy(listenerArray, 0, listenerArray, 1, listenerArray.length-1);
listenerArray[0]= this;
fTestRunnerClient.startListening(listenerArray, port);
fLastLaunch= launch;
setViewPartTitle(type);
if (type instanceof IType)
setTitleToolTip(((IType)type).getFullyQualifiedName());
else
setTitleToolTip(type.getElementName());
}
private void setViewPartTitle(IJavaElement type) {
String title;
if (type == null)
title= " "; //$NON-NLS-1$
else
title= type.getElementName();
setTitle(title);
}
protected void aboutToLaunch() {
String msg= JUnitMessages.getString("TestRunnerViewPart.message.launching"); //$NON-NLS-1$
//showInformation(msg);
setInfoMessage(msg);
fViewImage= fOriginalViewImage;
firePropertyChange(IWorkbenchPart.PROP_TITLE);
}
public synchronized void dispose(){
fIsDisposed= true;
stopTest();
if (fProgressImages != null)
fProgressImages.dispose();
JUnitPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
fTestRunOKIcon.dispose();
fTestRunFailIcon.dispose();
fStackViewIcon.dispose();
fTestRunOKDirtyIcon.dispose();
fTestRunFailDirtyIcon.dispose();
if (fClipboard != null)
fClipboard.dispose();
}
protected void start(final int total) {
resetProgressBar(total);
fCounterPanel.setTotal(total);
fCounterPanel.setRunValue(0);
}
private void resetProgressBar(final int total) {
fProgressBar.reset();
fProgressBar.setMaximum(total);
}
private void postSyncRunnable(Runnable r) {
if (!isDisposed())
getDisplay().syncExec(r);
}
private void aboutToStart() {
postSyncRunnable(new Runnable() {
public void run() {
if (!isDisposed()) {
for (Enumeration e= fTestRunTabs.elements(); e.hasMoreElements();) {
TestRunTab v= (TestRunTab) e.nextElement();
v.aboutToStart();
}
fNextAction.setEnabled(false);
fPreviousAction.setEnabled(false);
}
}
});
}
private void postEndTest(final String testId, final String testName) {
postSyncRunnable(new Runnable() {
public void run() {
if(isDisposed())
return;
handleEndTest();
for (Enumeration e= fTestRunTabs.elements(); e.hasMoreElements();) {
TestRunTab v= (TestRunTab) e.nextElement();
v.endTest(testId);
}
if (fFailureCount + fErrorCount > 0) {
fNextAction.setEnabled(true);
fPreviousAction.setEnabled(true);
}
}
});
}
private void postStartTest(final String testId, final String testName) {
postSyncRunnable(new Runnable() {
public void run() {
if(isDisposed())
return;
for (Enumeration e= fTestRunTabs.elements(); e.hasMoreElements();) {
TestRunTab v= (TestRunTab) e.nextElement();
v.startTest(testId);
}
}
});
}
private void handleEndTest() {
//refreshCounters();
fProgressBar.step(fFailureCount+fErrorCount);
if (fShowOnErrorOnly) {
Image progress= fProgressImages.getImage(fExecutedTests, fTestCount, fErrorCount, fFailureCount);
if (progress != fViewImage) {
fViewImage= progress;
firePropertyChange(IWorkbenchPart.PROP_TITLE);
}
}
}
private void refreshCounters() {
fCounterPanel.setErrorValue(fErrorCount);
fCounterPanel.setFailureValue(fFailureCount);
fCounterPanel.setRunValue(fExecutedTests);
fProgressBar.refresh(fErrorCount+fFailureCount> 0);
}
protected void postShowTestResultsView() {
postSyncRunnable(new Runnable() {
public void run() {
if (isDisposed())
return;
showTestResultsView();
}
});
}
public void showTestResultsView() {
IWorkbenchWindow window= getSite().getWorkbenchWindow();
IWorkbenchPage page= window.getActivePage();
TestRunnerViewPart testRunner= null;
if (page != null) {
try { // show the result view
testRunner= (TestRunnerViewPart)page.findView(TestRunnerViewPart.NAME);
if(testRunner == null) {
IWorkbenchPart activePart= page.getActivePart();
testRunner= (TestRunnerViewPart)page.showView(TestRunnerViewPart.NAME);
//restore focus stolen by the creation of the console
page.activate(activePart);
} else {
page.bringToTop(testRunner);
}
} catch (PartInitException pie) {
JUnitPlugin.log(pie);
}
}
}
class UpdateUIJob extends UIJob {
private boolean fRunning= true;
public UpdateUIJob(String name) {
super(name);
setSystem(true);
}
public IStatus runInUIThread(IProgressMonitor monitor) {
if (!isDisposed()) {
doShowStatus();
refreshCounters();
}
schedule(REFRESH_INTERVAL);
return Status.OK_STATUS;
}
public void stop() {
fRunning= false;
}
public boolean shouldSchedule() {
return fRunning;
}
}
protected void doShowStatus() {
setTitle(fStatus);
// getStatusLine().setErrorMessage(null);
// getStatusLine().setMessage(fStatus);
}
protected void setInfoMessage(final String message) {
fStatus= message;
}
protected void postError(final String message) {
fStatus= message;
}
protected void showInformation(final String info){
postSyncRunnable(new Runnable() {
public void run() {
if (!isDisposed())
fFailureTrace.setInformation(info);
}
});
}
protected CTabFolder createTestRunTabs(Composite parent) {
CTabFolder tabFolder= new CTabFolder(parent, SWT.TOP);
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
loadTestRunTabs(tabFolder);
tabFolder.setSelection(0);
fActiveRunTab= (TestRunTab)fTestRunTabs.firstElement();
tabFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
testTabChanged(event);
}
});
return tabFolder;
}
private void loadTestRunTabs(CTabFolder tabFolder) {
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(ID_EXTENSION_POINT_TESTRUN_TABS);
if (extensionPoint == null) {
return;
}
IConfigurationElement[] configs= extensionPoint.getConfigurationElements();
MultiStatus status= new MultiStatus(JUnitPlugin.PLUGIN_ID, IStatus.OK, "Could not load some testRunTabs extension points", null); //$NON-NLS-1$
for (int i= 0; i < configs.length; i++) {
try {
TestRunTab testRunTab= (TestRunTab) configs[i].createExecutableExtension("class"); //$NON-NLS-1$
testRunTab.createTabControl(tabFolder, fClipboard, this);
fTestRunTabs.addElement(testRunTab);
} catch (CoreException e) {
status.add(e.getStatus());
}
}
if (!status.isOK()) {
JUnitPlugin.log(status);
}
}
private void testTabChanged(SelectionEvent event) {
for (Enumeration e= fTestRunTabs.elements(); e.hasMoreElements();) {
TestRunTab v= (TestRunTab) e.nextElement();
if (((CTabFolder) event.widget).getSelection().getText() == v.getName()){
v.setSelectedTest(fActiveRunTab.getSelectedTestId());
fActiveRunTab= v;
fActiveRunTab.activate();
}
}
}
private SashForm createSashForm(Composite parent) {
fSashForm= new SashForm(parent, SWT.VERTICAL);
ViewForm top= new ViewForm(fSashForm, SWT.NONE);
fTabFolder= createTestRunTabs(top);
fTabFolder.setLayoutData(new TabFolderLayout());
top.setContent(fTabFolder);
ViewForm bottom= new ViewForm(fSashForm, SWT.NONE);
CLabel label= new CLabel(bottom, SWT.NONE);
label.setText(JUnitMessages.getString("TestRunnerViewPart.label.failure")); //$NON-NLS-1$
label.setImage(fStackViewIcon);
bottom.setTopLeft(label);
ToolBar failureToolBar= new ToolBar(bottom, SWT.FLAT | SWT.WRAP);
bottom.setTopCenter(failureToolBar);
fFailureTrace= new FailureTrace(bottom, fClipboard, this, failureToolBar);
bottom.setContent(fFailureTrace.getComposite());
fSashForm.setWeights(new int[]{50, 50});
return fSashForm;
}
private void reset(final int testCount) {
postSyncRunnable(new Runnable() {
public void run() {
if (isDisposed())
return;
fCounterPanel.reset();
fFailureTrace.clear();
fProgressBar.reset();
fStopAction.setEnabled(true);
clearStatus();
start(testCount);
}
});
fExecutedTests= 0;
fFailureCount= 0;
fErrorCount= 0;
fTestCount= testCount;
aboutToStart();
fTestInfos.clear();
fFailures= new ArrayList();
}
private void clearStatus() {
getStatusLine().setMessage(null);
getStatusLine().setErrorMessage(null);
}
public void setFocus() {
if (fActiveRunTab != null)
fActiveRunTab.setFocus();
}
public void createPartControl(Composite parent) {
fParent= parent;
addResizeListener(parent);
fClipboard= new Clipboard(parent.getDisplay());
GridLayout gridLayout= new GridLayout();
gridLayout.marginWidth= 0;
gridLayout.marginHeight= 0;
parent.setLayout(gridLayout);
configureToolBar();
fCounterComposite= createProgressCountPanel(parent);
fCounterComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
SashForm sashForm= createSashForm(parent);
sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
IActionBars actionBars= getViewSite().getActionBars();
actionBars.setGlobalActionHandler(
ActionFactory.COPY.getId(),
new CopyTraceAction(fFailureTrace, fClipboard));
JUnitPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
fOriginalViewImage= getTitleImage();
fProgressImages= new ProgressImages();
WorkbenchHelp.setHelp(parent, IJUnitHelpContextIds.RESULTS_VIEW);
if (fMemento != null) {
restoreLayoutState(fMemento);
}
fMemento= null;
}
private void addResizeListener(Composite parent) {
parent.addControlListener(new ControlListener() {
public void controlMoved(ControlEvent e) {
}
public void controlResized(ControlEvent e) {
computeOrientation();
}
});
}
void computeOrientation() {
if (fOrientation != VIEW_ORIENTATION_AUTOMATIC) {
fCurrentOrientation= fOrientation;
setOrientation(fCurrentOrientation);
}
else {
Point size= fParent.getSize();
if (size.x != 0 && size.y != 0) {
if (size.x > size.y)
setOrientation(VIEW_ORIENTATION_HORIZONTAL);
else
setOrientation(VIEW_ORIENTATION_VERTICAL);
}
}
}
public void saveState(IMemento memento) {
if (fSashForm == null) {
// part has not been created
if (fMemento != null) //Keep the old state;
memento.putMemento(fMemento);
return;
}
int activePage= fTabFolder.getSelectionIndex();
memento.putInteger(TAG_PAGE, activePage);
memento.putString(TAG_SCROLL, fScrollLockAction.isChecked() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
int weigths[]= fSashForm.getWeights();
int ratio= (weigths[0] * 1000) / (weigths[0] + weigths[1]);
memento.putInteger(TAG_RATIO, ratio);
memento.putInteger(TAG_ORIENTATION, fOrientation);
}
private void configureToolBar() {
IActionBars actionBars= getViewSite().getActionBars();
IToolBarManager toolBar= actionBars.getToolBarManager();
IMenuManager viewMenu = actionBars.getMenuManager();
fRerunLastTestAction= new RerunLastAction();
fScrollLockAction= new ScrollLockAction(this);
fToggleOrientationActions =
new ToggleOrientationAction[] {
new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL),
new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL),
new ToggleOrientationAction(this, VIEW_ORIENTATION_AUTOMATIC)};
fNextAction= new ShowNextFailureAction(this);
fPreviousAction= new ShowPreviousFailureAction(this);
fStopAction= new StopAction();
fNextAction.setEnabled(false);
fPreviousAction.setEnabled(false);
fStopAction.setEnabled(false);
actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNextAction);
actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPreviousAction);
toolBar.add(fNextAction);
toolBar.add(fPreviousAction);
toolBar.add(fStopAction);
toolBar.add(new Separator());
toolBar.add(fRerunLastTestAction);
toolBar.add(fScrollLockAction);
for (int i = 0; i < fToggleOrientationActions.length; ++i)
viewMenu.add(fToggleOrientationActions[i]);
fScrollLockAction.setChecked(!fAutoScroll);
actionBars.updateActionBars();
}
private IStatusLineManager getStatusLine() {
// we want to show messages globally hence we
// have to go through the active part
IViewSite site= getViewSite();
IWorkbenchPage page= site.getPage();
IWorkbenchPart activePart= page.getActivePart();
if (activePart instanceof IViewPart) {
IViewPart activeViewPart= (IViewPart)activePart;
IViewSite activeViewSite= activeViewPart.getViewSite();
return activeViewSite.getActionBars().getStatusLineManager();
}
if (activePart instanceof IEditorPart) {
IEditorPart activeEditorPart= (IEditorPart)activePart;
IEditorActionBarContributor contributor= activeEditorPart.getEditorSite().getActionBarContributor();
if (contributor instanceof EditorActionBarContributor)
return ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager();
}
// no active part
return getViewSite().getActionBars().getStatusLineManager();
}
protected Composite createProgressCountPanel(Composite parent) {
Composite composite= new Composite(parent, SWT.NONE);
GridLayout layout= new GridLayout();
composite.setLayout(layout);
setCounterColumns(layout);
fCounterPanel = new CounterPanel(composite);
fCounterPanel.setLayoutData(
new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
fProgressBar = new JUnitProgressBar(composite);
fProgressBar.setLayoutData(
new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
return composite;
}
public TestRunInfo getTestInfo(String testId) {
if (testId == null)
return null;
return (TestRunInfo) fTestInfos.get(testId);
}
public void handleTestSelected(String testId) {
TestRunInfo testInfo= getTestInfo(testId);
if (testInfo == null) {
showFailure(null); //$NON-NLS-1$
} else {
showFailure(testInfo);
}
}
private void showFailure(final TestRunInfo failure) {
postSyncRunnable(new Runnable() {
public void run() {
if (!isDisposed())
fFailureTrace.showFailure(failure);
}
});
}
public IJavaProject getLaunchedProject() {
return fTestProject;
}
public ILaunch getLastLaunch() {
return fLastLaunch;
}
public static Image createImage(String path) {
try {
ImageDescriptor id= ImageDescriptor.createFromURL(JUnitPlugin.makeIconFileURL(path));
return id.createImage();
} catch (MalformedURLException e) {
// fall through
}
return null;
}
private boolean isDisposed() {
return fIsDisposed || fCounterPanel.isDisposed();
}
private Display getDisplay() {
return getViewSite().getShell().getDisplay();
}
/**
* @see IWorkbenchPart#getTitleImage()
*/
public Image getTitleImage() {
if (fOriginalViewImage == null)
fOriginalViewImage= super.getTitleImage();
if (fViewImage == null)
return super.getTitleImage();
return fViewImage;
}
public void propertyChange(PropertyChangeEvent event) {
if (isDisposed())
return;
if (IJUnitPreferencesConstants.SHOW_ON_ERROR_ONLY.equals(event.getProperty())) {
if (!JUnitPreferencePage.getShowOnErrorOnly()) {
fViewImage= fOriginalViewImage;
firePropertyChange(IWorkbenchPart.PROP_TITLE);
}
}
}
void codeHasChanged() {
if (fDirtyListener != null) {
JavaCore.removeElementChangedListener(fDirtyListener);
fDirtyListener= null;
}
if (fViewImage == fTestRunOKIcon)
fViewImage= fTestRunOKDirtyIcon;
else if (fViewImage == fTestRunFailIcon)
fViewImage= fTestRunFailDirtyIcon;
Runnable r= new Runnable() {
public void run() {
if (isDisposed())
return;
firePropertyChange(IWorkbenchPart.PROP_TITLE);
}
};
if (!isDisposed())
getDisplay().asyncExec(r);
}
boolean isCreated() {
return fCounterPanel != null;
}
public void rerunTest(String testId, String className, String testName, String launchMode) {
DebugUITools.saveAndBuildBeforeLaunch();
if (lastLaunchIsKeptAlive())
fTestRunnerClient.rerunTest(testId, className, testName);
else if (fLastLaunch != null) {
// run the selected test using the previous launch configuration
ILaunchConfiguration launchConfiguration= fLastLaunch.getLaunchConfiguration();
if (launchConfiguration != null) {
try {
String name= className;
if (testName != null)
name+= "."+testName; //$NON-NLS-1$
ILaunchConfigurationWorkingCopy tmp= launchConfiguration.copy("Rerun "+name); //$NON-NLS-1$
if (testName != null) {
tmp.setAttribute(JUnitBaseLaunchConfiguration.TESTNAME_ATTR, testName);
// String args= "-rerun "+testId;
// tmp.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args);
}
tmp.launch(launchMode, null);
return;
} catch (CoreException e) {
ErrorDialog.openError(getSite().getShell(),
JUnitMessages.getString("TestRunnerViewPart.error.cannotrerun"), e.getMessage(), e.getStatus() //$NON-NLS-1$
);
}
}
MessageDialog.openInformation(getSite().getShell(),
JUnitMessages.getString("TestRunnerViewPart.cannotrerun.title"), //$NON-NLS-1$
JUnitMessages.getString("TestRunnerViewPart.cannotrerurn.message") //$NON-NLS-1$
);
}
}
public boolean lastLaunchIsKeptAlive() {
return fTestRunnerClient != null && fTestRunnerClient.isRunning() && ILaunchManager.DEBUG_MODE.equals(fLaunchMode);
}
private void setOrientation(int orientation) {
if ((fSashForm == null) || fSashForm.isDisposed())
return;
boolean horizontal = orientation == VIEW_ORIENTATION_HORIZONTAL;
fSashForm.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);
for (int i = 0; i < fToggleOrientationActions.length; ++i)
fToggleOrientationActions[i].setChecked(fOrientation == fToggleOrientationActions[i].getOrientation());
fCurrentOrientation = orientation;
GridLayout layout= (GridLayout) fCounterComposite.getLayout();
setCounterColumns(layout);
fParent.layout();
}
private void setCounterColumns(GridLayout layout) {
if (fCurrentOrientation == VIEW_ORIENTATION_HORIZONTAL)
layout.numColumns= 2;
else
layout.numColumns= 1;
}
}
|
57,751
|
Bug 57751 1) Export javadoc not based on package explorer selection but on open editor [javadoc] [export]
|
build: eclipse r3.0 M8 I find that when making a selection of a project in the Package Explorer view, then open the popup menu and select Export > javadoc and press the Next button, the selected export option is based on the file selected in the editor and not the project in the package explorer. When exporting to jar for example the scope of the export is defined by the selection in the package explorer.
|
verified fixed
|
be2144b
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T15:31:43Z
| 2004-04-07T15:00:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocWizard.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Sebastian Davids <sdavids@gmx.de> bug 38692
*******************************************************************************/
package org.eclipse.jdt.internal.ui.javadocexport;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IExportWizard;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IDebugEventSetListener;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.Launch;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.actions.OpenBrowserUtil;
import org.eclipse.jdt.internal.ui.dialogs.OptionalMessageDialog;
import org.eclipse.jdt.internal.ui.jarpackager.ConfirmSaveModifiedResourcesDialog;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
import org.eclipse.jdt.internal.ui.util.PixelConverter;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.ui.JavaUI;
public class JavadocWizard extends Wizard implements IExportWizard {
private JavadocTreeWizardPage fJTWPage;
private JavadocSpecificsWizardPage fJSWPage;
private JavadocStandardWizardPage fJSpWPage;
private IPath fDestination;
private boolean fWriteCustom;
private boolean fOpenInBrowser;
private final String TREE_PAGE_DESC= "JavadocTreePage"; //$NON-NLS-1$
private final String SPECIFICS_PAGE_DESC= "JavadocSpecificsPage"; //$NON-NLS-1$
private final String STANDARD_PAGE_DESC= "JavadocStandardPage"; //$NON-NLS-1$
private final int YES= 0;
private final int YES_TO_ALL= 1;
private final int NO= 2;
private final int NO_TO_ALL= 3;
private final String JAVADOC_ANT_INFORMATION_DIALOG= "javadocAntInformationDialog";//$NON-NLS-1$
private JavadocOptionsManager fStore;
private IWorkspaceRoot fRoot;
private IFile fXmlJavadocFile;
private static final String ID_JAVADOC_PROCESS_TYPE= "org.eclipse.jdt.ui.javadocProcess"; //$NON-NLS-1$
public static void openJavadocWizard(JavadocWizard wizard, Shell shell, IStructuredSelection selection ) {
wizard.init(PlatformUI.getWorkbench(), selection);
PixelConverter converter= new PixelConverter(shell);
WizardDialog dialog= new WizardDialog(shell, wizard);
dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(100), converter.convertHeightInCharsToPixels(20));
dialog.open();
}
public JavadocWizard() {
this(null);
}
public JavadocWizard(IFile xmlJavadocFile) {
super();
setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_EXPORT_JAVADOC);
setWindowTitle(JavadocExportMessages.getString("JavadocWizard.javadocwizard.title")); //$NON-NLS-1$
setDialogSettings(JavaPlugin.getDefault().getDialogSettings());
fRoot= ResourcesPlugin.getWorkspace().getRoot();
fXmlJavadocFile= xmlJavadocFile;
fWriteCustom= false;
}
/*
* @see IWizard#performFinish()
*/
public boolean performFinish() {
IJavaProject[] checkedProjects= fJTWPage.getCheckedProjects();
updateStore(checkedProjects);
//If the wizard was not launched from an ant file store the setttings
if (fXmlJavadocFile == null) {
fStore.updateDialogSettings(getDialogSettings(), checkedProjects);
}
// Wizard will not run with unsaved files.
if (!checkPreconditions(fStore.getSourceElements())) {
return false;
}
fDestination= new Path(fStore.getDestination());
fDestination.toFile().mkdirs();
fOpenInBrowser= fStore.doOpenInBrowser();
//Ask if you wish to set the javadoc location for the projects (all) to
//the location of the newly generated javadoc
if (fStore.isFromStandard()) {
try {
URL newURL= fDestination.toFile().toURL();
List projs= new ArrayList();
//get javadoc locations for all projects
for (int i= 0; i < checkedProjects.length; i++) {
IJavaProject curr= checkedProjects[i];
URL currURL= JavaUI.getProjectJavadocLocation(curr);
if (!newURL.equals(currURL)) { // currURL can be null
//if not all projects have the same javadoc location ask if you want to change
//them to have the same javadoc location
projs.add(curr);
}
}
if (!projs.isEmpty()) {
setAllJavadocLocations((IJavaProject[]) projs.toArray(new IJavaProject[projs.size()]), newURL);
}
} catch (MalformedURLException e) {
JavaPlugin.log(e);
}
}
if (fJSWPage.generateAnt()) {
//@Improve: make a better message
OptionalMessageDialog.open(JAVADOC_ANT_INFORMATION_DIALOG, getShell(), JavadocExportMessages.getString("JavadocWizard.antInformationDialog.title"), null, JavadocExportMessages.getString("JavadocWizard.antInformationDialog.message"), MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0); //$NON-NLS-1$ //$NON-NLS-2$
try {
fStore.createXML(checkedProjects);
} catch (CoreException e) {
ExceptionHandler.handle(e, getShell(),JavadocExportMessages.getString("JavadocWizard.error.writeANT.title"), JavadocExportMessages.getString("JavadocWizard.error.writeANT.message")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
if (!executeJavadocGeneration())
return false;
return true;
}
private void updateStore(IJavaProject[] checkedProjects) {
//writes the new settings to store
fJTWPage.updateStore(checkedProjects);
if (!fJTWPage.getCustom())
fJSpWPage.updateStore();
fJSWPage.updateStore();
}
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.IWizard#performCancel()
*/
public boolean performCancel() {
IJavaProject[] checkedProjects= fJTWPage.getCheckedProjects();
updateStore(checkedProjects);
//If the wizard was not launched from an ant file store the setttings
if (fXmlJavadocFile == null) {
fStore.updateDialogSettings(getDialogSettings(), checkedProjects);
}
return super.performCancel();
}
private void setAllJavadocLocations(IJavaProject[] projects, URL newURL) {
Shell shell= getShell();
Image image= shell == null ? null : shell.getDisplay().getSystemImage(SWT.ICON_QUESTION);
String[] buttonlabels= new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL };
for (int j= 0; j < projects.length; j++) {
IJavaProject iJavaProject= projects[j];
String message= JavadocExportMessages.getFormattedString("JavadocWizard.updatejavadoclocation.message", new String[] { iJavaProject.getElementName(), fDestination.toOSString()}); //$NON-NLS-1$
MessageDialog dialog= new MessageDialog(shell, JavadocExportMessages.getString("JavadocWizard.updatejavadocdialog.label"), image, message, 4, buttonlabels, 1);//$NON-NLS-1$
switch (dialog.open()) {
case YES :
JavaUI.setProjectJavadocLocation(iJavaProject, newURL);
break;
case YES_TO_ALL :
for (int i= j; i < projects.length; i++) {
iJavaProject= projects[i];
JavaUI.setProjectJavadocLocation(iJavaProject, newURL);
j++;
}
break;
case NO_TO_ALL :
j= projects.length;
break;
case NO :
default :
break;
}
}
}
private boolean executeJavadocGeneration() {
Process process= null;
try {
ArrayList vmArgs= new ArrayList();
ArrayList progArgs= new ArrayList();
fStore.getArgumentArray(vmArgs, progArgs);
File file= File.createTempFile("javadoc-arguments", ".tmp"); //$NON-NLS-1$//$NON-NLS-2$
vmArgs.add('@' + file.getAbsolutePath());
FileWriter writer= new FileWriter(file);
try {
for (int i= 0; i < progArgs.size(); i++) {
String curr= (String) progArgs.get(i);
curr= checkForSpaces(curr);
writer.write(curr);
writer.write(' ');
}
} finally {
writer.close();
}
String[] args= (String[]) vmArgs.toArray(new String[vmArgs.size()]);
process= Runtime.getRuntime().exec(args);
if (process != null) {
// construct a formatted command line for the process properties
StringBuffer buf= new StringBuffer();
for (int i= 0; i < args.length; i++) {
buf.append(args[i]);
buf.append(' ');
}
IDebugEventSetListener listener= new JavadocDebugEventListener(getShell().getDisplay(), file);
DebugPlugin.getDefault().addDebugEventListener(listener);
ILaunchConfigurationWorkingCopy wc= null;
try {
ILaunchConfigurationType lcType= DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
String name= JavadocExportMessages.getString("JavadocWizard.launchconfig.name"); //$NON-NLS-1$
wc= lcType.newInstance(null, name);
wc.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
ILaunch newLaunch= new Launch(wc, ILaunchManager.RUN_MODE, null);
IProcess iprocess= DebugPlugin.newProcess(newLaunch, process, JavadocExportMessages.getString("JavadocWizard.javadocprocess.label")); //$NON-NLS-1$
iprocess.setAttribute(IProcess.ATTR_CMDLINE, buf.toString());
iprocess.setAttribute(IProcess.ATTR_PROCESS_TYPE, ID_JAVADOC_PROCESS_TYPE);
DebugPlugin.getDefault().getLaunchManager().addLaunch(newLaunch);
} catch (CoreException e) {
String title= JavadocExportMessages.getString("JavadocWizard.error.title"); //$NON-NLS-1$
String message= JavadocExportMessages.getString("JavadocWizard.launch.error.message"); //$NON-NLS-1$
ExceptionHandler.handle(e, getShell(), title, message);
}
return true;
}
} catch (IOException e) {
String title= JavadocExportMessages.getString("JavadocWizard.error.title"); //$NON-NLS-1$
String message= JavadocExportMessages.getString("JavadocWizard.exec.error.message"); //$NON-NLS-1$
IStatus status= new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IStatus.ERROR, e.getMessage(), e);
ExceptionHandler.handle(new CoreException(status), getShell(), title, message);
return false;
}
return false;
}
private String checkForSpaces(String curr) {
if (curr.indexOf(' ') == -1) {
return curr;
}
StringBuffer buf= new StringBuffer();
buf.append('\'');
for (int i= 0; i < curr.length(); i++) {
char ch= curr.charAt(i);
if (ch == '\\' || ch == '\'') {
buf.append('\\');
}
buf.append(ch);
}
buf.append('\'');
return buf.toString();
}
/**
* Creates a list of all CompilationUnits and extracts from that list a list of dirty
* files. The user is then asked to confirm if those resources should be saved or
* not.
*
* @param elements
* @return <code>true</code> if all preconditions are satisfied otherwise false
*/
private boolean checkPreconditions(IJavaElement[] elements) {
ArrayList resources= new ArrayList();
for (int i= 0; i < elements.length; i++) {
if (elements[i] instanceof ICompilationUnit) {
resources.add(elements[i].getResource());
}
}
//message could be null
IFile[] unSavedFiles= getUnsavedFiles(resources);
return saveModifiedResourcesIfUserConfirms(unSavedFiles);
}
/**
* Returns the files which are not saved and which are
* part of the files being exported.
*
* @param resources
* @return an array of unsaved files
*/
private IFile[] getUnsavedFiles(List resources) {
IEditorPart[] dirtyEditors= JavaPlugin.getDirtyEditors();
Set unsavedFiles= new HashSet(dirtyEditors.length);
if (dirtyEditors.length > 0) {
for (int i= 0; i < dirtyEditors.length; i++) {
if (dirtyEditors[i].getEditorInput() instanceof IFileEditorInput) {
IFile dirtyFile= ((IFileEditorInput) dirtyEditors[i].getEditorInput()).getFile();
if (resources.contains(dirtyFile)) {
unsavedFiles.add(dirtyFile);
}
}
}
}
return (IFile[]) unsavedFiles.toArray(new IFile[unsavedFiles.size()]);
}
/**
* Asks to confirm to save the modified resources
* and save them if OK is pressed. Must be run in the display thread.
*
* @param dirtyFiles
* @return true if user pressed OK and save was successful.
*/
private boolean saveModifiedResourcesIfUserConfirms(IFile[] dirtyFiles) {
if (confirmSaveModifiedResources(dirtyFiles)) {
try {
if (saveModifiedResources(dirtyFiles))
return true;
} catch (CoreException e) {
ExceptionHandler.handle(e, getShell(), JavadocExportMessages.getString("JavadocWizard.saveresourcedialogCE.title"), JavadocExportMessages.getString("JavadocWizard.saveresourcedialogCE.message")); //$NON-NLS-1$ //$NON-NLS-2$
} catch (InvocationTargetException e) {
ExceptionHandler.handle(e, getShell(), JavadocExportMessages.getString("JavadocWizard.saveresourcedialogITE.title"), JavadocExportMessages.getString("JavadocWizard.saveresourcedialogITE.message")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
return false;
}
/**
* Asks the user to confirm to save the modified resources.
*
* @param dirtyFiles
* @return true if user pressed OK.
*/
private boolean confirmSaveModifiedResources(IFile[] dirtyFiles) {
if (dirtyFiles == null || dirtyFiles.length == 0)
return true;
// Get display for further UI operations
Display display= getShell().getDisplay();
if (display == null || display.isDisposed())
return false;
// Ask user to confirm saving of all files
final ConfirmSaveModifiedResourcesDialog dlg= new ConfirmSaveModifiedResourcesDialog(getShell(), dirtyFiles);
final int[] intResult= new int[1];
Runnable runnable= new Runnable() {
public void run() {
intResult[0]= dlg.open();
}
};
display.syncExec(runnable);
return intResult[0] == IDialogConstants.OK_ID;
}
/**
* Save all of the editors in the workbench. Must be run in the display thread.
*
* @param dirtyFiles
* @return true if successful.
* @throws CoreException
* @throws InvocationTargetException
*/
private boolean saveModifiedResources(final IFile[] dirtyFiles) throws CoreException, InvocationTargetException {
IWorkspace workspace= ResourcesPlugin.getWorkspace();
IWorkspaceDescription description= workspace.getDescription();
boolean autoBuild= description.isAutoBuilding();
description.setAutoBuilding(false);
try {
workspace.setDescription(description);
// This save operation can not be cancelled.
try {
PlatformUI.getWorkbench().getProgressService().runInUI(
PlatformUI.getWorkbench().getProgressService(),
createSaveModifiedResourcesRunnable(dirtyFiles),
workspace.getRoot());
} finally {
description.setAutoBuilding(autoBuild);
workspace.setDescription(description);
}
} catch (InterruptedException ex) {
return false;
}
return true;
}
private IRunnableWithProgress createSaveModifiedResourcesRunnable(final IFile[] dirtyFiles) {
return new IRunnableWithProgress() {
public void run(IProgressMonitor pm) {
if (pm == null) {
pm= new NullProgressMonitor();
}
IEditorPart[] editorsToSave= JavaPlugin.getDirtyEditors();
String name= JavadocExportMessages.getString("JavadocWizard.savetask.name"); //$NON-NLS-1$
pm.beginTask(name, editorsToSave.length);
try {
List dirtyFilesList= Arrays.asList(dirtyFiles);
for (int i= 0; i < editorsToSave.length; i++) {
if (editorsToSave[i].getEditorInput() instanceof IFileEditorInput) {
IFile dirtyFile= ((IFileEditorInput) editorsToSave[i].getEditorInput()).getFile();
if (dirtyFilesList.contains((dirtyFile)))
editorsToSave[i].doSave(new SubProgressMonitor(pm, 1));
}
pm.worked(1);
}
} finally {
pm.done();
}
}
};
}
/*
* @see IWizard#addPages()
*/
public void addPages() {
fJTWPage= new JavadocTreeWizardPage(TREE_PAGE_DESC, fStore);
fJSWPage= new JavadocSpecificsWizardPage(SPECIFICS_PAGE_DESC, fJTWPage, fStore);
fJSpWPage= new JavadocStandardWizardPage(STANDARD_PAGE_DESC, fJTWPage, fStore);
super.addPage(fJTWPage);
super.addPage(fJSpWPage);
super.addPage(fJSWPage);
fJTWPage.init();
fJSpWPage.init();
fJSWPage.init();
}
public void init(IWorkbench workbench, IStructuredSelection structuredSelection) {
List selected= structuredSelection.toList();
if (selected.isEmpty()) {
IJavaElement element= EditorUtility.getActiveEditorJavaInput();
selected= new ArrayList();
selected.add(element);
}
fStore= new JavadocOptionsManager(fXmlJavadocFile, getDialogSettings(), selected);
}
private void refresh(IPath path) {
if (fRoot.findContainersForLocation(path).length > 0) {
try {
fRoot.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
JavaPlugin.log(e);
}
}
}
private void spawnInBrowser(Display display) {
if (fOpenInBrowser) {
try {
IPath indexFile= fDestination.append("index.html"); //$NON-NLS-1$
URL url= indexFile.toFile().toURL();
OpenBrowserUtil.open(url, display, getWindowTitle());
} catch (MalformedURLException e) {
JavaPlugin.log(e);
}
}
}
private class JavadocDebugEventListener implements IDebugEventSetListener {
private Display fDisplay;
private File fFile;
public JavadocDebugEventListener(Display display, File file) {
fDisplay= display;
fFile= file;
}
public void handleDebugEvents(DebugEvent[] events) {
for (int i= 0; i < events.length; i++) {
if (events[i].getKind() == DebugEvent.TERMINATE) {
try {
if (!fWriteCustom) {
fFile.delete();
refresh(fDestination); //If destination of javadoc is in workspace then refresh workspace
spawnInBrowser(fDisplay);
}
} finally {
DebugPlugin.getDefault().removeDebugEventListener(this);
}
return;
}
}
}
}
public IWizardPage getNextPage(IWizardPage page) {
if (page instanceof JavadocTreeWizardPage) {
if (!fJTWPage.getCustom()) {
return fJSpWPage;
}
return fJSWPage;
} else if (page instanceof JavadocSpecificsWizardPage) {
return null;
} else if (page instanceof JavadocStandardWizardPage)
return fJSWPage;
else
return null;
}
public IWizardPage getPreviousPage(IWizardPage page) {
if (page instanceof JavadocSpecificsWizardPage) {
if (!fJTWPage.getCustom()) {
return fJSpWPage;
}
return fJSWPage;
} else if (page instanceof JavadocTreeWizardPage) {
return null;
} else if (page instanceof JavadocStandardWizardPage)
return fJTWPage;
else
return null;
}
}
|
51,851
|
Bug 51851 [navigation] Outliner is not updated correctly
|
build 20040212 1) create the following class public class X { int aaa } 2) place your cursor just after 'aaa' 3) type "bbb,ccc" the outliner contain -------------- X +-ccc : int -------------- 'aaa' and 'bbb' are missing (sometimes the problem does not occur) Java delta seems correct FIRING POST_CHANGE Delta [Thread [org.eclipse.jdt.internal.ui.text.JavaReconciler,1,main]]: <NONE> FIRING POST_RECONCILE Delta [Thread [org.eclipse.jdt.internal.ui.text.JavaReconciler,1,main]]: [Working copy] X.java[*]: {CHILDREN | FINE GRAINED} X[*]: {CHILDREN | FINE GRAINED} bbb[+]: {} ccc[+]: {}
|
verified fixed
|
ac497ba
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T17:03:09Z
| 2004-02-12T15:33:20Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaOutlinePage.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.javaeditor;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
import java.util.Vector;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.ElementChangedEvent;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IElementChangedListener;
import org.eclipse.jdt.core.IInitializer;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaElementDelta;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IParent;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.ISourceReference;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.ListenerList;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.IPostSelectionProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.model.WorkbenchAdapter;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.part.IShowInSource;
import org.eclipse.ui.part.IShowInTarget;
import org.eclipse.ui.part.IShowInTargetList;
import org.eclipse.ui.part.Page;
import org.eclipse.ui.part.ShowInContext;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.IUpdate;
import org.eclipse.ui.texteditor.TextEditorAction;
import org.eclipse.ui.texteditor.TextOperationAction;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.actions.AbstractToggleLinkingAction;
import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup;
import org.eclipse.jdt.internal.ui.dnd.DelegatingDropAdapter;
import org.eclipse.jdt.internal.ui.dnd.JdtViewerDragAdapter;
import org.eclipse.jdt.internal.ui.dnd.TransferDragSourceListener;
import org.eclipse.jdt.internal.ui.dnd.TransferDropTargetListener;
import org.eclipse.jdt.internal.ui.packageview.SelectionTransferDragAdapter;
import org.eclipse.jdt.internal.ui.packageview.SelectionTransferDropAdapter;
import org.eclipse.jdt.internal.ui.preferences.MembersOrderPreferenceCache;
import org.eclipse.jdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
import org.eclipse.jdt.internal.ui.viewsupport.DecoratingJavaLabelProvider;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLabels;
import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater;
import org.eclipse.jdt.ui.JavaElementSorter;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.ui.ProblemsLabelDecorator.ProblemsLabelChangedEvent;
import org.eclipse.jdt.ui.actions.CCPActionGroup;
import org.eclipse.jdt.ui.actions.CustomFiltersActionGroup;
import org.eclipse.jdt.ui.actions.GenerateActionGroup;
import org.eclipse.jdt.ui.actions.JavaSearchActionGroup;
import org.eclipse.jdt.ui.actions.JdtActionConstants;
import org.eclipse.jdt.ui.actions.MemberFilterActionGroup;
import org.eclipse.jdt.ui.actions.OpenViewActionGroup;
import org.eclipse.jdt.ui.actions.RefactorActionGroup;
/**
* The content outline page of the Java editor. The viewer implements a proprietary
* update mechanism based on Java model deltas. It does not react on domain changes.
* It is specified to show the content of ICompilationUnits and IClassFiles.
* Publishes its context menu under <code>JavaPlugin.getDefault().getPluginId() + ".outline"</code>.
*/
public class JavaOutlinePage extends Page implements IContentOutlinePage, IAdaptable , IPostSelectionProvider {
static Object[] NO_CHILDREN= new Object[0];
/**
* The element change listener of the java outline viewer.
* @see IElementChangedListener
*/
class ElementChangedListener implements IElementChangedListener {
public void elementChanged(final ElementChangedEvent e) {
if (getControl() == null)
return;
Display d= getControl().getDisplay();
if (d != null) {
d.asyncExec(new Runnable() {
public void run() {
ICompilationUnit cu= (ICompilationUnit) fInput;
IJavaElement base= cu;
if (fTopLevelTypeOnly) {
base= getMainType(cu);
if (base == null) {
if (fOutlineViewer != null)
fOutlineViewer.refresh(true);
return;
}
}
IJavaElementDelta delta= findElement(base, e.getDelta());
if (delta != null && fOutlineViewer != null) {
fOutlineViewer.reconcile(delta);
}
}
});
}
}
private boolean isPossibleStructuralChange(IJavaElementDelta cuDelta) {
if (cuDelta.getKind() != IJavaElementDelta.CHANGED) {
return true; // add or remove
}
int flags= cuDelta.getFlags();
if ((flags & IJavaElementDelta.F_CHILDREN) != 0) {
return true;
}
return (flags & (IJavaElementDelta.F_CONTENT | IJavaElementDelta.F_FINE_GRAINED)) == IJavaElementDelta.F_CONTENT;
}
protected IJavaElementDelta findElement(IJavaElement unit, IJavaElementDelta delta) {
if (delta == null || unit == null)
return null;
IJavaElement element= delta.getElement();
if (unit.equals(element)) {
if (isPossibleStructuralChange(delta)) {
return delta;
}
return null;
}
if (element.getElementType() > IJavaElement.CLASS_FILE)
return null;
IJavaElementDelta[] children= delta.getAffectedChildren();
if (children == null || children.length == 0)
return null;
for (int i= 0; i < children.length; i++) {
IJavaElementDelta d= findElement(unit, children[i]);
if (d != null)
return d;
}
return null;
}
}
static class NoClassElement extends WorkbenchAdapter implements IAdaptable {
/*
* @see java.lang.Object#toString()
*/
public String toString() {
return JavaEditorMessages.getString("JavaOutlinePage.error.NoTopLevelType"); //$NON-NLS-1$
}
/*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
*/
public Object getAdapter(Class clas) {
if (clas == IWorkbenchAdapter.class)
return this;
return null;
}
}
/**
* Content provider for the children of an ICompilationUnit or
* an IClassFile
* @see ITreeContentProvider
*/
class ChildrenProvider implements ITreeContentProvider {
private Object[] NO_CLASS= new Object[] {new NoClassElement()};
private ElementChangedListener fListener;
protected boolean matches(IJavaElement element) {
if (element.getElementType() == IJavaElement.METHOD) {
String name= element.getElementName();
return (name != null && name.indexOf('<') >= 0);
}
return false;
}
protected IJavaElement[] filter(IJavaElement[] children) {
boolean initializers= false;
for (int i= 0; i < children.length; i++) {
if (matches(children[i])) {
initializers= true;
break;
}
}
if (!initializers)
return children;
Vector v= new Vector();
for (int i= 0; i < children.length; i++) {
if (matches(children[i]))
continue;
v.addElement(children[i]);
}
IJavaElement[] result= new IJavaElement[v.size()];
v.copyInto(result);
return result;
}
public Object[] getChildren(Object parent) {
if (parent instanceof IParent) {
IParent c= (IParent) parent;
try {
return filter(c.getChildren());
} catch (JavaModelException x) {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=38341
// don't log NotExist exceptions as this is a valid case
// since we might have been posted and the element
// removed in the meantime.
if (JavaPlugin.isDebug() || !x.isDoesNotExist())
JavaPlugin.log(x);
}
}
return NO_CHILDREN;
}
public Object[] getElements(Object parent) {
if (fTopLevelTypeOnly) {
if (parent instanceof ICompilationUnit) {
try {
IType type= getMainType((ICompilationUnit) parent);
return type != null ? type.getChildren() : NO_CLASS;
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
} else if (parent instanceof IClassFile) {
try {
IType type= getMainType((IClassFile) parent);
return type != null ? type.getChildren() : NO_CLASS;
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
}
}
return getChildren(parent);
}
public Object getParent(Object child) {
if (child instanceof IJavaElement) {
IJavaElement e= (IJavaElement) child;
return e.getParent();
}
return null;
}
public boolean hasChildren(Object parent) {
if (parent instanceof IParent) {
IParent c= (IParent) parent;
try {
IJavaElement[] children= filter(c.getChildren());
return (children != null && children.length > 0);
} catch (JavaModelException x) {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=38341
// don't log NotExist exceptions as this is a valid case
// since we might have been posted and the element
// removed in the meantime.
if (JavaPlugin.isDebug() || !x.isDoesNotExist())
JavaPlugin.log(x);
}
}
return false;
}
public boolean isDeleted(Object o) {
return false;
}
public void dispose() {
if (fListener != null) {
JavaCore.removeElementChangedListener(fListener);
fListener= null;
}
}
/*
* @see IContentProvider#inputChanged(Viewer, Object, Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
boolean isCU= (newInput instanceof ICompilationUnit);
if (isCU && fListener == null) {
fListener= new ElementChangedListener();
JavaCore.addElementChangedListener(fListener);
} else if (!isCU && fListener != null) {
JavaCore.removeElementChangedListener(fListener);
fListener= null;
}
}
}
class JavaOutlineViewer extends TreeViewer {
/**
* Indicates an item which has been reused. At the point of
* its reuse it has been expanded. This field is used to
* communicate between <code>internalExpandToLevel</code> and
* <code>reuseTreeItem</code>.
*/
private Item fReusedExpandedItem;
private boolean fReorderedMembers;
private boolean fForceFireSelectionChanged;
public JavaOutlineViewer(Tree tree) {
super(tree);
setAutoExpandLevel(ALL_LEVELS);
setUseHashlookup(true);
}
/**
* Investigates the given element change event and if affected
* incrementally updates the Java outline.
*
* @param delta the Java element delta used to reconcile the Java outline
*/
public void reconcile(IJavaElementDelta delta) {
fReorderedMembers= false;
fForceFireSelectionChanged= false;
if (getSorter() == null) {
if (fTopLevelTypeOnly
&& delta.getElement() instanceof IType
&& (delta.getKind() & IJavaElementDelta.ADDED) != 0)
{
refresh(true);
} else {
Widget w= findItem(fInput);
if (w != null && !w.isDisposed())
update(w, delta);
if (fForceFireSelectionChanged)
fireSelectionChanged(new SelectionChangedEvent(getSite().getSelectionProvider(), this.getSelection()));
if (fReorderedMembers) {
refresh(false);
fReorderedMembers= false;
}
}
} else {
// just for now
refresh(true);
}
}
/*
* @see TreeViewer#internalExpandToLevel
*/
protected void internalExpandToLevel(Widget node, int level) {
if (node instanceof Item) {
Item i= (Item) node;
if (i.getData() instanceof IJavaElement) {
IJavaElement je= (IJavaElement) i.getData();
if (je.getElementType() == IJavaElement.IMPORT_CONTAINER || isInnerType(je)) {
if (i != fReusedExpandedItem) {
setExpanded(i, false);
return;
}
}
}
}
super.internalExpandToLevel(node, level);
}
protected void reuseTreeItem(Item item, Object element) {
// remove children
Item[] c= getChildren(item);
if (c != null && c.length > 0) {
if (getExpanded(item))
fReusedExpandedItem= item;
for (int k= 0; k < c.length; k++) {
if (c[k].getData() != null)
disassociate(c[k]);
c[k].dispose();
}
}
updateItem(item, element);
updatePlus(item, element);
internalExpandToLevel(item, ALL_LEVELS);
fReusedExpandedItem= null;
fForceFireSelectionChanged= true;
}
protected boolean mustUpdateParent(IJavaElementDelta delta, IJavaElement element) {
if (element instanceof IMethod) {
if ((delta.getKind() & IJavaElementDelta.ADDED) != 0) {
try {
return ((IMethod)element).isMainMethod();
} catch (JavaModelException e) {
JavaPlugin.log(e.getStatus());
}
}
return "main".equals(element.getElementName()); //$NON-NLS-1$
}
return false;
}
protected ISourceRange getSourceRange(IJavaElement element) throws JavaModelException {
if (element instanceof ISourceReference)
return ((ISourceReference) element).getSourceRange();
if (element instanceof IMember && !(element instanceof IInitializer))
return ((IMember) element).getNameRange();
return null;
}
protected boolean overlaps(ISourceRange range, int start, int end) {
return start <= (range.getOffset() + range.getLength() - 1) && range.getOffset() <= end;
}
protected boolean filtered(IJavaElement parent, IJavaElement child) {
Object[] result= new Object[] { child };
ViewerFilter[] filters= getFilters();
for (int i= 0; i < filters.length; i++) {
result= filters[i].filter(this, parent, result);
if (result.length == 0)
return true;
}
return false;
}
protected void update(Widget w, IJavaElementDelta delta) {
Item item;
IJavaElement parent= delta.getElement();
IJavaElementDelta[] affected= delta.getAffectedChildren();
Item[] children= getChildren(w);
boolean doUpdateParent= false;
boolean doUpdateParentsPlus= false;
Vector deletions= new Vector();
Vector additions= new Vector();
for (int i= 0; i < affected.length; i++) {
IJavaElementDelta affectedDelta= affected[i];
IJavaElement affectedElement= affectedDelta.getElement();
int status= affected[i].getKind();
// find tree item with affected element
int j;
for (j= 0; j < children.length; j++)
if (affectedElement.equals(children[j].getData()))
break;
if (j == children.length) {
// remove from collapsed parent
if ((status & IJavaElementDelta.REMOVED) != 0) {
doUpdateParentsPlus= true;
continue;
}
// addition
if ((status & IJavaElementDelta.CHANGED) != 0 &&
(affectedDelta.getFlags() & IJavaElementDelta.F_MODIFIERS) != 0 &&
!filtered(parent, affectedElement))
{
additions.addElement(affectedDelta);
}
continue;
}
item= children[j];
// removed
if ((status & IJavaElementDelta.REMOVED) != 0) {
deletions.addElement(item);
doUpdateParent= doUpdateParent || mustUpdateParent(affectedDelta, affectedElement);
// changed
} else if ((status & IJavaElementDelta.CHANGED) != 0) {
int change= affectedDelta.getFlags();
doUpdateParent= doUpdateParent || mustUpdateParent(affectedDelta, affectedElement);
if ((change & IJavaElementDelta.F_MODIFIERS) != 0) {
if (filtered(parent, affectedElement))
deletions.addElement(item);
else
updateItem(item, affectedElement);
}
if ((change & IJavaElementDelta.F_CONTENT) != 0)
updateItem(item, affectedElement);
if ((change & IJavaElementDelta.F_CHILDREN) != 0)
update(item, affectedDelta);
if ((change & IJavaElementDelta.F_REORDER) != 0)
fReorderedMembers= true;
}
}
// find all elements to add
IJavaElementDelta[] add= delta.getAddedChildren();
if (additions.size() > 0) {
IJavaElementDelta[] tmp= new IJavaElementDelta[add.length + additions.size()];
System.arraycopy(add, 0, tmp, 0, add.length);
for (int i= 0; i < additions.size(); i++)
tmp[i + add.length]= (IJavaElementDelta) additions.elementAt(i);
add= tmp;
}
// add at the right position
go2: for (int i= 0; i < add.length; i++) {
try {
IJavaElement e= add[i].getElement();
if (filtered(parent, e))
continue go2;
doUpdateParent= doUpdateParent || mustUpdateParent(add[i], e);
ISourceRange rng= getSourceRange(e);
int start= rng.getOffset();
int end= start + rng.getLength() - 1;
Item last= null;
item= null;
children= getChildren(w);
for (int j= 0; j < children.length; j++) {
item= children[j];
IJavaElement r= (IJavaElement) item.getData();
if (r == null) {
// parent node collapsed and not be opened before -> do nothing
continue go2;
}
try {
rng= getSourceRange(r);
boolean fieldsOnSameLine= r.getElementType() == IJavaElement.FIELD && e.getElementType() == IJavaElement.FIELD
&& rng.getOffset() == start && rng.getLength() == end - start + 1;
if (!fieldsOnSameLine && overlaps(rng, start, end)) {
// be tolerant if the delta is not correct, or if
// the tree has been updated other than by a delta
reuseTreeItem(item, e);
continue go2;
} else if (rng.getOffset() > start) {
if (last != null && deletions.contains(last)) {
// reuse item
deletions.removeElement(last);
reuseTreeItem(last, e);
} else {
// nothing to reuse
createTreeItem(w, e, j);
}
continue go2;
}
} catch (JavaModelException x) {
// stumbled over deleted element
}
last= item;
}
// add at the end of the list
if (last != null && deletions.contains(last)) {
// reuse item
deletions.removeElement(last);
reuseTreeItem(last, e);
} else {
// nothing to reuse
createTreeItem(w, e, -1);
}
} catch (JavaModelException x) {
// the element to be added is not present -> don't add it
}
}
// remove items which haven't been reused
Enumeration e= deletions.elements();
while (e.hasMoreElements()) {
item= (Item) e.nextElement();
disassociate(item);
item.dispose();
}
if (doUpdateParent)
updateItem(w, delta.getElement());
if (!doUpdateParent && doUpdateParentsPlus && w instanceof Item)
updatePlus((Item)w, delta.getElement());
}
/*
* @see ContentViewer#handleLabelProviderChanged(LabelProviderChangedEvent)
*/
protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
Object input= getInput();
if (event instanceof ProblemsLabelChangedEvent) {
ProblemsLabelChangedEvent e= (ProblemsLabelChangedEvent) event;
if (e.isMarkerChange() && input instanceof ICompilationUnit) {
return; // marker changes can be ignored
}
}
// look if the underlying resource changed
Object[] changed= event.getElements();
if (changed != null) {
IResource resource= getUnderlyingResource();
if (resource != null) {
for (int i= 0; i < changed.length; i++) {
if (changed[i] != null && changed[i].equals(resource)) {
// change event to a full refresh
event= new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource());
break;
}
}
}
}
super.handleLabelProviderChanged(event);
}
private IResource getUnderlyingResource() {
Object input= getInput();
if (input instanceof ICompilationUnit) {
ICompilationUnit cu= (ICompilationUnit) input;
cu= JavaModelUtil.toOriginal(cu);
return cu.getResource();
} else if (input instanceof IClassFile) {
return ((IClassFile) input).getResource();
}
return null;
}
}
class LexicalSortingAction extends Action {
private JavaElementSorter fSorter= new JavaElementSorter();
public LexicalSortingAction() {
super();
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.LEXICAL_SORTING_OUTLINE_ACTION);
setText(JavaEditorMessages.getString("JavaOutlinePage.Sort.label")); //$NON-NLS-1$
JavaPluginImages.setLocalImageDescriptors(this, "alphab_sort_co.gif"); //$NON-NLS-1$
setToolTipText(JavaEditorMessages.getString("JavaOutlinePage.Sort.tooltip")); //$NON-NLS-1$
setDescription(JavaEditorMessages.getString("JavaOutlinePage.Sort.description")); //$NON-NLS-1$
boolean checked= JavaPlugin.getDefault().getPreferenceStore().getBoolean("LexicalSortingAction.isChecked"); //$NON-NLS-1$
valueChanged(checked, false);
}
public void run() {
valueChanged(isChecked(), true);
}
private void valueChanged(final boolean on, boolean store) {
setChecked(on);
BusyIndicator.showWhile(fOutlineViewer.getControl().getDisplay(), new Runnable() {
public void run() {
fOutlineViewer.setSorter(on ? fSorter : null); }
});
if (store)
JavaPlugin.getDefault().getPreferenceStore().setValue("LexicalSortingAction.isChecked", on); //$NON-NLS-1$
}
}
class ClassOnlyAction extends Action {
public ClassOnlyAction() {
super();
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.GO_INTO_TOP_LEVEL_TYPE_ACTION);
setText(JavaEditorMessages.getString("JavaOutlinePage.GoIntoTopLevelType.label")); //$NON-NLS-1$
setToolTipText(JavaEditorMessages.getString("JavaOutlinePage.GoIntoTopLevelType.tooltip")); //$NON-NLS-1$
setDescription(JavaEditorMessages.getString("JavaOutlinePage.GoIntoTopLevelType.description")); //$NON-NLS-1$
JavaPluginImages.setLocalImageDescriptors(this, "gointo_toplevel_type.gif"); //$NON-NLS-1$
IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();
boolean showclass= preferenceStore.getBoolean("GoIntoTopLevelTypeAction.isChecked"); //$NON-NLS-1$
setTopLevelTypeOnly(showclass);
}
/*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
setTopLevelTypeOnly(!fTopLevelTypeOnly);
}
private void setTopLevelTypeOnly(boolean show) {
fTopLevelTypeOnly= show;
setChecked(show);
fOutlineViewer.refresh(false);
IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();
preferenceStore.setValue("GoIntoTopLevelTypeAction.isChecked", show); //$NON-NLS-1$
}
}
/**
* This action toggles whether this Java Outline page links
* its selection to the active editor.
*
* @since 3.0
*/
public class ToggleLinkingAction extends AbstractToggleLinkingAction {
JavaOutlinePage fJavaOutlinePage;
/**
* Constructs a new action.
*
* @param outlinePage the Java outline page
*/
public ToggleLinkingAction(JavaOutlinePage outlinePage) {
boolean isLinkingEnabled= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
setChecked(isLinkingEnabled);
fJavaOutlinePage= outlinePage;
}
/**
* Runs the action.
*/
public void run() {
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, isChecked());
if (isChecked() && fEditor != null)
fEditor.synchronizeOutlinePage(fEditor.computeHighlightRangeSourceReference(), false);
}
}
/** A flag to show contents of top level type only */
private boolean fTopLevelTypeOnly;
private IJavaElement fInput;
private String fContextMenuID;
private Menu fMenu;
private JavaOutlineViewer fOutlineViewer;
private JavaEditor fEditor;
private MemberFilterActionGroup fMemberFilterActionGroup;
private ListenerList fSelectionChangedListeners= new ListenerList();
private ListenerList fPostSelectionChangedListeners= new ListenerList();
private Hashtable fActions= new Hashtable();
private TogglePresentationAction fTogglePresentation;
private GotoAnnotationAction fPreviousAnnotation;
private GotoAnnotationAction fNextAnnotation;
private TextEditorAction fShowJavadoc;
private TextOperationAction fUndo;
private TextOperationAction fRedo;
private ToggleLinkingAction fToggleLinkingAction;
private CompositeActionGroup fActionGroups;
private IPropertyChangeListener fPropertyChangeListener;
/**
* Custom filter action group.
* @since 3.0
*/
private CustomFiltersActionGroup fCustomFiltersActionGroup;
public JavaOutlinePage(String contextMenuID, JavaEditor editor) {
super();
Assert.isNotNull(editor);
fContextMenuID= contextMenuID;
fEditor= editor;
fTogglePresentation= new TogglePresentationAction();
fPreviousAnnotation= new GotoAnnotationAction("PreviousAnnotation.", false); //$NON-NLS-1$
fNextAnnotation= new GotoAnnotationAction("NextAnnotation.", true); //$NON-NLS-1$
fShowJavadoc= (TextEditorAction) fEditor.getAction("ShowJavaDoc"); //$NON-NLS-1$
fUndo= (TextOperationAction) fEditor.getAction(ITextEditorActionConstants.UNDO);
fRedo= (TextOperationAction) fEditor.getAction(ITextEditorActionConstants.REDO);
fTogglePresentation.setEditor(editor);
fPreviousAnnotation.setEditor(editor);
fNextAnnotation.setEditor(editor);
fPropertyChangeListener= new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
doPropertyChange(event);
}
};
JavaPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
}
/**
* Returns the primary type of a compilation unit (has the same
* name as the compilation unit).
*
* @param compilationUnit the compilation unit
* @return returns the primary type of the compilation unit, or
* <code>null</code> if is does not have one
*/
protected IType getMainType(ICompilationUnit compilationUnit) {
if (compilationUnit == null)
return null;
String name= compilationUnit.getElementName();
int index= name.indexOf('.');
if (index != -1)
name= name.substring(0, index);
IType type= compilationUnit.getType(name);
return type.exists() ? type : null;
}
/**
* Returns the primary type of a class file.
*
* @param classFile the class file
* @return returns the primary type of the class file, or <code>null</code>
* if is does not have one
*/
protected IType getMainType(IClassFile classFile) {
try {
IType type= classFile.getType();
return type != null && type.exists() ? type : null;
} catch (JavaModelException e) {
return null;
}
}
/* (non-Javadoc)
* Method declared on Page
*/
public void init(IPageSite pageSite) {
super.init(pageSite);
}
private void doPropertyChange(PropertyChangeEvent event) {
if (fOutlineViewer != null) {
if (MembersOrderPreferenceCache.isMemberOrderProperty(event.getProperty())) {
fOutlineViewer.refresh(false);
}
}
}
/*
* @see ISelectionProvider#addSelectionChangedListener(ISelectionChangedListener)
*/
public void addSelectionChangedListener(ISelectionChangedListener listener) {
if (fOutlineViewer != null)
fOutlineViewer.addSelectionChangedListener(listener);
else
fSelectionChangedListeners.add(listener);
}
/*
* @see ISelectionProvider#removeSelectionChangedListener(ISelectionChangedListener)
*/
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
if (fOutlineViewer != null)
fOutlineViewer.removeSelectionChangedListener(listener);
else
fSelectionChangedListeners.remove(listener);
}
/*
* @see ISelectionProvider#setSelection(ISelection)
*/
public void setSelection(ISelection selection) {
if (fOutlineViewer != null)
fOutlineViewer.setSelection(selection);
}
/*
* @see ISelectionProvider#getSelection()
*/
public ISelection getSelection() {
if (fOutlineViewer == null)
return StructuredSelection.EMPTY;
return fOutlineViewer.getSelection();
}
/*
* @see org.eclipse.jface.text.IPostSelectionProvider#addPostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
*/
public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
if (fOutlineViewer != null)
fOutlineViewer.addPostSelectionChangedListener(listener);
else
fPostSelectionChangedListeners.add(listener);
}
/*
* @see org.eclipse.jface.text.IPostSelectionProvider#removePostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
*/
public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
if (fOutlineViewer != null)
fOutlineViewer.removePostSelectionChangedListener(listener);
else
fPostSelectionChangedListeners.remove(listener);
}
private void registerToolbarActions(IActionBars actionBars) {
IToolBarManager toolBarManager= actionBars.getToolBarManager();
if (toolBarManager != null) {
toolBarManager.add(new LexicalSortingAction());
fMemberFilterActionGroup= new MemberFilterActionGroup(fOutlineViewer, "org.eclipse.jdt.ui.JavaOutlinePage"); //$NON-NLS-1$
fMemberFilterActionGroup.contributeToToolBar(toolBarManager);
fCustomFiltersActionGroup.fillActionBars(actionBars);
IMenuManager menu= actionBars.getMenuManager();
menu.add(new Separator("EndFilterGroup")); //$NON-NLS-1$
fToggleLinkingAction= new ToggleLinkingAction(this);
menu.add(new ClassOnlyAction());
menu.add(fToggleLinkingAction);
}
}
/*
* @see IPage#createControl
*/
public void createControl(Composite parent) {
Tree tree= new Tree(parent, SWT.MULTI);
AppearanceAwareLabelProvider lprovider= new AppearanceAwareLabelProvider(
AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaElementLabels.F_APP_TYPE_SIGNATURE,
AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS
);
fOutlineViewer= new JavaOutlineViewer(tree);
initDragAndDrop();
fOutlineViewer.setContentProvider(new ChildrenProvider());
fOutlineViewer.setLabelProvider(new DecoratingJavaLabelProvider(lprovider));
Object[] listeners= fSelectionChangedListeners.getListeners();
for (int i= 0; i < listeners.length; i++) {
fSelectionChangedListeners.remove(listeners[i]);
fOutlineViewer.addSelectionChangedListener((ISelectionChangedListener) listeners[i]);
}
listeners= fPostSelectionChangedListeners.getListeners();
for (int i= 0; i < listeners.length; i++) {
fPostSelectionChangedListeners.remove(listeners[i]);
fOutlineViewer.addPostSelectionChangedListener((ISelectionChangedListener) listeners[i]);
}
MenuManager manager= new MenuManager(fContextMenuID, fContextMenuID);
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager m) {
contextMenuAboutToShow(m);
}
});
fMenu= manager.createContextMenu(tree);
tree.setMenu(fMenu);
IPageSite site= getSite();
site.registerContextMenu(JavaPlugin.getPluginId() + ".outline", manager, fOutlineViewer); //$NON-NLS-1$
site.setSelectionProvider(fOutlineViewer);
// we must create the groups after we have set the selection provider to the site
fActionGroups= new CompositeActionGroup(new ActionGroup[] {
new OpenViewActionGroup(this),
new CCPActionGroup(this),
new GenerateActionGroup(this),
new RefactorActionGroup(this),
new JavaSearchActionGroup(this)});
// register global actions
IActionBars bars= site.getActionBars();
bars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, fUndo);
bars.setGlobalActionHandler(ITextEditorActionConstants.REDO, fRedo);
bars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, fPreviousAnnotation);
bars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, fNextAnnotation);
bars.setGlobalActionHandler(JdtActionConstants.SHOW_JAVA_DOC, fShowJavadoc);
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, fNextAnnotation);
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, fPreviousAnnotation);
fActionGroups.fillActionBars(bars);
IStatusLineManager statusLineManager= bars.getStatusLineManager();
if (statusLineManager != null) {
StatusBarUpdater updater= new StatusBarUpdater(statusLineManager);
fOutlineViewer.addPostSelectionChangedListener(updater);
}
// Custom filter group
fCustomFiltersActionGroup= new CustomFiltersActionGroup("org.eclipse.jdt.ui.JavaOutlinePage", fOutlineViewer); //$NON-NLS-1$
registerToolbarActions(bars);
fOutlineViewer.setInput(fInput);
}
public void dispose() {
if (fEditor == null)
return;
if (fMemberFilterActionGroup != null) {
fMemberFilterActionGroup.dispose();
fMemberFilterActionGroup= null;
}
if (fCustomFiltersActionGroup != null) {
fCustomFiltersActionGroup.dispose();
fCustomFiltersActionGroup= null;
}
fEditor.outlinePageClosed();
fEditor= null;
fSelectionChangedListeners.clear();
fSelectionChangedListeners= null;
fPostSelectionChangedListeners.clear();
fPostSelectionChangedListeners= null;
if (fPropertyChangeListener != null) {
JavaPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
fPropertyChangeListener= null;
}
if (fMenu != null && !fMenu.isDisposed()) {
fMenu.dispose();
fMenu= null;
}
if (fActionGroups != null)
fActionGroups.dispose();
fTogglePresentation.setEditor(null);
fPreviousAnnotation.setEditor(null);
fNextAnnotation.setEditor(null);
fOutlineViewer= null;
super.dispose();
}
public Control getControl() {
if (fOutlineViewer != null)
return fOutlineViewer.getControl();
return null;
}
public void setInput(IJavaElement inputElement) {
fInput= inputElement;
if (fOutlineViewer != null)
fOutlineViewer.setInput(fInput);
}
public void select(ISourceReference reference) {
if (fOutlineViewer != null) {
ISelection s= fOutlineViewer.getSelection();
if (s instanceof IStructuredSelection) {
IStructuredSelection ss= (IStructuredSelection) s;
List elements= ss.toList();
if (!elements.contains(reference)) {
s= (reference == null ? StructuredSelection.EMPTY : new StructuredSelection(reference));
fOutlineViewer.setSelection(s, true);
}
}
}
}
public void setAction(String actionID, IAction action) {
Assert.isNotNull(actionID);
if (action == null)
fActions.remove(actionID);
else
fActions.put(actionID, action);
}
public IAction getAction(String actionID) {
Assert.isNotNull(actionID);
return (IAction) fActions.get(actionID);
}
/*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
public Object getAdapter(Class key) {
if (key == IShowInSource.class) {
return getShowInSource();
}
if (key == IShowInTargetList.class) {
return new IShowInTargetList() {
public String[] getShowInTargetIds() {
return new String[] { JavaUI.ID_PACKAGES };
}
};
}
if (key == IShowInTarget.class) {
return getShowInTarget();
}
return null;
}
/**
* Convenience method to add the action installed under the given actionID to the
* specified group of the menu.
*
* @param menu the menu manager
* @param group the group to which to add the action
* @param actionID the ID of the new action
*/
protected void addAction(IMenuManager menu, String group, String actionID) {
IAction action= getAction(actionID);
if (action != null) {
if (action instanceof IUpdate)
((IUpdate) action).update();
if (action.isEnabled()) {
IMenuManager subMenu= menu.findMenuUsingPath(group);
if (subMenu != null)
subMenu.add(action);
else
menu.appendToGroup(group, action);
}
}
}
protected void contextMenuAboutToShow(IMenuManager menu) {
JavaPlugin.createStandardGroups(menu);
IStructuredSelection selection= (IStructuredSelection)getSelection();
fActionGroups.setContext(new ActionContext(selection));
fActionGroups.fillContextMenu(menu);
}
/*
* @see Page#setFocus()
*/
public void setFocus() {
if (fOutlineViewer != null)
fOutlineViewer.getControl().setFocus();
}
/**
* Checks whether a given Java element is an inner type.
*
* @param element the java element
* @return <code>true</code> iff the given element is an inner type
*/
private boolean isInnerType(IJavaElement element) {
if (element != null && element.getElementType() == IJavaElement.TYPE) {
IType type= (IType)element;
try {
return type.isMember();
} catch (JavaModelException e) {
IJavaElement parent= type.getParent();
if (parent != null) {
int parentElementType= parent.getElementType();
return (parentElementType != IJavaElement.COMPILATION_UNIT && parentElementType != IJavaElement.CLASS_FILE);
}
}
}
return false;
}
/**
* Returns the <code>IShowInSource</code> for this view.
*
* @return the {@link IShowInSource}
*/
protected IShowInSource getShowInSource() {
return new IShowInSource() {
public ShowInContext getShowInContext() {
return new ShowInContext(
null,
getSite().getSelectionProvider().getSelection());
}
};
}
/**
* Returns the <code>IShowInTarget</code> for this view.
*
* @return the {@link IShowInTarget}
*/
protected IShowInTarget getShowInTarget() {
return new IShowInTarget() {
public boolean show(ShowInContext context) {
ISelection sel= context.getSelection();
if (sel instanceof ITextSelection) {
ITextSelection tsel= (ITextSelection) sel;
int offset= tsel.getOffset();
IJavaElement element= fEditor.getElementAt(offset);
if (element != null) {
setSelection(new StructuredSelection(element));
return true;
}
}
return false;
}
};
}
private void initDragAndDrop() {
int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
Transfer[] transfers= new Transfer[] {
LocalSelectionTransfer.getInstance()
};
// Drop Adapter
TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
new SelectionTransferDropAdapter(fOutlineViewer)
};
fOutlineViewer.addDropSupport(ops | DND.DROP_DEFAULT, transfers, new DelegatingDropAdapter(dropListeners));
// Drag Adapter
TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
new SelectionTransferDragAdapter(fOutlineViewer)
};
fOutlineViewer.addDragSupport(ops, transfers, new JdtViewerDragAdapter(fOutlineViewer, dragListeners));
}
}
|
64,011
|
Bug 64011 JavaProjectSourceContainer does not search for non-Java files
|
Java project source containers can only find Java Source and nothing else. It will only look java files from <JavaProject>/<JavaSource> directory. The Java Project may contain more than just Java files. For example, a web project which is also a Java Project contains JSP and HTML files. In this case, these other sources cannot be located by JavaProjectSourceContainer even though the project is part of the source lookup path. Adding a raw project source container to look for non-Java files may interfere with the source location function of the Java Project Source Container (depending on the order of which the projects are specified). If a Raw Project Source Container is placed in front of the Java Project Container, the Raw Project Source Container may not compute source for a Java file correctly due to its lack of knowledge about classpaths, source inclusion/exclusion filters, etc. JavaProjectSourceContainer should find source for non-Java files and it should look in directories other than the Java-Source directory.
|
verified fixed
|
f3c8d2a
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T18:35:51Z
| 2004-05-25T21:20:00Z
|
org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jsp/launching/TomcatSourcePathComputer.java
|
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jsp.launching;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer;
import org.eclipse.jdt.launching.sourcelookup.containers.JavaSourcePathComputer;
/**
* Computes the default source lookup path for a Tomcat launch config.
* The source path is the same as for a Java project with the addition
* of the folder containing the JSPs.
*/
public class TomcatSourcePathComputer extends JavaSourcePathComputer {
/* (non-Javadoc)
* @see org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor)
*/
public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
ISourceContainer[] containers = super.computeSourceContainers(configuration, monitor);
String root = configuration.getAttribute(TomcatLaunchDelegate.ATTR_WEB_APP_ROOT, (String)null);
ISourceContainer folder = null;
if (root != null) {
IPath path = new Path(root);
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
if (resource != null && resource instanceof IFolder) {
folder = new FolderSourceContainer((IFolder)resource, true);
}
}
if (folder == null) {
return containers;
} else {
ISourceContainer[] all = new ISourceContainer[containers.length + 1];
System.arraycopy(containers, 0, all, 0, containers.length);
all[containers.length] = folder;
return all;
}
}
}
|
64,419
|
Bug 64419 Tomcat example does not need "web app root" attribute
|
The Tomcat/JSP launching example currently requires the user specify a "web app root" on the main tab. However, all we need is the project (in order to compute a classpath for extra java files and source lookup path). We used to require the attribute for source lookup.
|
verified fixed
|
cf9abd6
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T21:03:15Z
| 2004-05-27T17:46:40Z
|
org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jsp/launching/TomcatLaunchDelegate.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jsp.launching;
import java.io.File;
import java.text.MessageFormat;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.variables.IValueVariable;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.jdt.internal.launching.JavaLocalApplicationLaunchConfigurationDelegate;
import org.eclipse.jsp.JspUIPlugin;
/**
* Launch delegate for a local Tomcat server
*/
public class TomcatLaunchDelegate extends JavaLocalApplicationLaunchConfigurationDelegate {
/**
* Identifier for Tomcat launch configurations.
*/
public static final String ID_TOMCAT_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.jsp.TomcatConfigurationType"; //$NON-NLS-1$
/**
* Identifier for Tomcat classpath provider.
*/
public static final String ID_TOMCAT_CLASSPATH_PROVIDER = "org.eclipse.jsp.tomcatClasspathProvider"; //$NON-NLS-1$
/**
* Launch configuration attribute - value is path to local installation of Tomcat.
* The path may be encoded in a launch variable.
*/
public static final String ATTR_CATALINA_HOME = "org.eclipse.jsp.CATALINA_HOME"; //$NON-NLS-1$
/**
* Launch configuration attribute - value is a workspace relative path to the root
* folder of a web application.
*/
public static final String ATTR_WEB_APP_ROOT= "org.eclipse.jsp.WEB_APP_ROOT"; //$NON-NLS-1$
/**
* Constructs a new launch delegate
*/
public TomcatLaunchDelegate() {
super();
}
/**
* Returns the value of the <code>${catalina_home}</code> launch variable.
*
* @return the value of the <code>${catalina_home}</code> launch variable
* @exception CoreException if the variable or value is undefined
*/
public static String getCatalinaHome() throws CoreException {
IValueVariable variable = VariablesPlugin.getDefault().getStringVariableManager().getValueVariable("catalina_home"); //$NON-NLS-1$
IStatus err = null;
if (variable == null) {
err = new Status(IStatus.ERROR, JspUIPlugin.getDefault().getDescriptor().getUniqueIdentifier(), 0, LaunchingMessages.getString("TomcatLaunchDelegate.9"), null); //$NON-NLS-1$
} else {
String home = variable.getValue();
if (home != null && home.length() > 0) {
File file = new File(home);
if (file.exists() && file.isDirectory()) {
return home;
} else {
err = new Status(IStatus.ERROR, JspUIPlugin.getDefault().getDescriptor().getUniqueIdentifier(), 0, MessageFormat.format(LaunchingMessages.getString("TomcatLaunchDelegate.7"), new String[]{home}), null); //$NON-NLS-1$
}
} else {
err = new Status(IStatus.ERROR, JspUIPlugin.getDefault().getDescriptor().getUniqueIdentifier(), 0, LaunchingMessages.getString("TomcatLaunchDelegate.8"), null); //$NON-NLS-1$
}
}
throw new CoreException(err);
}
}
|
64,419
|
Bug 64419 Tomcat example does not need "web app root" attribute
|
The Tomcat/JSP launching example currently requires the user specify a "web app root" on the main tab. However, all we need is the project (in order to compute a classpath for extra java files and source lookup path). We used to require the attribute for source lookup.
|
verified fixed
|
cf9abd6
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-27T21:03:15Z
| 2004-05-27T17:46:40Z
|
org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jsp/launching/TomcatTab.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jsp.launching;
import java.io.File;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.window.Window;
import org.eclipse.jsp.JspPluginImages;
import org.eclipse.jsp.JspUIPlugin;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.dialogs.ISelectionStatusValidator;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.views.navigator.ResourceSorter;
/**
* Specifies the install location of Tomcat.
*/
public class TomcatTab extends AbstractLaunchConfigurationTab {
// Tomcat location
private Button fBrowseButton;
private Text fTomcatDir;
// WebApp location
private Button fWebAppButton;
private Text fWebAppDir;
/**
* Constructs a new Tomcat tab
*/
public TomcatTab() {
super();
}
/**
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(Composite)
*/
public void createControl(Composite parent) {
Font font = parent.getFont();
Composite composite = new Composite(parent, SWT.NONE);
GridLayout workingDirLayout = new GridLayout();
workingDirLayout.numColumns = 3;
workingDirLayout.marginHeight = 0;
workingDirLayout.marginWidth = 0;
composite.setLayout(workingDirLayout);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
composite.setLayoutData(gd);
composite.setFont(font);
setControl(composite);
createVerticalSpacer(composite, 3);
Label label = new Label(composite, SWT.NONE);
label.setText(LaunchingMessages.getString("TomcatTab.3")); //$NON-NLS-1$
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalSpan = 3;
label.setLayoutData(gd);
label.setFont(font);
fTomcatDir = new Text(composite, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
fTomcatDir.setLayoutData(gd);
fTomcatDir.setFont(font);
fTomcatDir.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) {
updateLaunchConfigurationDialog();
}
});
fBrowseButton = createPushButton(composite, LaunchingMessages.getString("TomcatTab.21"), null); //$NON-NLS-1$
fBrowseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
handleTomcatBrowseButtonSelected();
}
});
createVerticalSpacer(composite, 3);
label = new Label(composite, SWT.NONE);
label.setText(LaunchingMessages.getString("TomcatTab.22")); //$NON-NLS-1$
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalSpan = 3;
label.setLayoutData(gd);
label.setFont(font);
fWebAppDir = new Text(composite, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
fWebAppDir.setLayoutData(gd);
fWebAppDir.setFont(font);
fWebAppDir.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) {
updateLaunchConfigurationDialog();
}
});
fWebAppButton = createPushButton(composite, LaunchingMessages.getString("TomcatTab.23"), null); //$NON-NLS-1$
fWebAppButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
handleWebAppBrowseButtonSelected();
}
});
}
/**
* Show a dialog that lets the user select a root WebApp directory
* from the workspace
*/
protected void handleWebAppBrowseButtonSelected() {
ISelectionStatusValidator validator= new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
if (selection.length != 1) {
return new Status(IStatus.ERROR, JspUIPlugin.getDefault().getDescriptor().getUniqueIdentifier(), 0, LaunchingMessages.getString("TomcatTab.24"), null); //$NON-NLS-1$
}
if (!(selection[0] instanceof IContainer)) {
return new Status(IStatus.ERROR, JspUIPlugin.getDefault().getDescriptor().getUniqueIdentifier(), 0, LaunchingMessages.getString("TomcatTab.25"), null); //$NON-NLS-1$
}
// check for "WEB-INF"
IContainer container = (IContainer)selection[0];
if (!container.getFolder(new Path("WEB-INF")).exists()) { //$NON-NLS-1$
return new Status(IStatus.WARNING, JspUIPlugin.getDefault().getDescriptor().getUniqueIdentifier(), 0, LaunchingMessages.getString("TomcatTab.27"), null); //$NON-NLS-1$
}
return new Status(IStatus.OK, JspUIPlugin.getDefault().getDescriptor().getUniqueIdentifier(), 0, "", null); //$NON-NLS-1$
}
};
ILabelProvider lp= new WorkbenchLabelProvider();
ITreeContentProvider cp= new WorkbenchContentProvider();
ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
dialog.setSorter(new ResourceSorter(ResourceSorter.NAME));
dialog.addFilter(new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
return element instanceof IContainer;
}
});
dialog.setValidator(validator);
dialog.setTitle(LaunchingMessages.getString("TomcatTab.28")); //$NON-NLS-1$
dialog.setMessage(LaunchingMessages.getString("TomcatTab.29")); //$NON-NLS-1$
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
if (dialog.open() == Window.OK) {
Object[] elements= dialog.getResult();
if (elements != null && elements.length == 1) {
fWebAppDir.setText(((IResource)elements[0]).getFullPath().toString());
}
}
}
/**
* Show a dialog that lets the user select a tomcat install directory
*/
protected void handleTomcatBrowseButtonSelected() {
DirectoryDialog dialog = new DirectoryDialog(getShell());
dialog.setMessage(LaunchingMessages.getString("TomcatTab.4")); //$NON-NLS-1$
String currentWorkingDir = fTomcatDir.getText();
if (!currentWorkingDir.trim().equals("")) { //$NON-NLS-1$
File path = new File(currentWorkingDir);
if (path.exists()) {
dialog.setFilterPath(currentWorkingDir);
}
}
String selectedDirectory = dialog.open();
if (selectedDirectory != null) {
fTomcatDir.setText(selectedDirectory);
}
}
/**
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose()
*/
public void dispose() {
// empty implementation
}
/**
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(ILaunchConfiguration)
*/
public boolean isValid(ILaunchConfiguration config) {
setErrorMessage(null);
setMessage(null);
String workingDirPath = fTomcatDir.getText().trim();
// resolve variables (if any)
String expansion;
try {
expansion = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(workingDirPath);
} catch (CoreException e) {
setErrorMessage(e.getMessage());
return false;
}
if (workingDirPath.length() > 0) {
File dir = new File(expansion);
if (!dir.exists()) {
setErrorMessage(LaunchingMessages.getString("TomcatTab.5")); //$NON-NLS-1$
return false;
}
if (!dir.isDirectory()) {
setErrorMessage(LaunchingMessages.getString("TomcatTab.6")); //$NON-NLS-1$
return false;
}
}
String webappDirPath = fWebAppDir.getText().trim();
if (webappDirPath.length() > 0) {
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(webappDirPath));
if (resource == null) {
setErrorMessage(LaunchingMessages.getString("TomcatTab.30")); //$NON-NLS-1$
return false;
}
if (!(resource instanceof IContainer)) {
setErrorMessage(LaunchingMessages.getString("TomcatTab.31")); //$NON-NLS-1$
return false;
}
}
return true;
}
/**
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy)
*/
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
config.setAttribute(TomcatLaunchDelegate.ATTR_CATALINA_HOME, "${catalina_home}"); //$NON-NLS-1$
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, TomcatLaunchDelegate.ID_TOMCAT_CLASSPATH_PROVIDER);
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "org.apache.catalina.startup.Bootstrap"); //$NON-NLS-1$
}
/**
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration)
*/
public void initializeFrom(ILaunchConfiguration configuration) {
try {
fTomcatDir.setText(configuration.getAttribute(TomcatLaunchDelegate.ATTR_CATALINA_HOME, "")); //$NON-NLS-1$
fWebAppDir.setText(configuration.getAttribute(TomcatLaunchDelegate.ATTR_WEB_APP_ROOT, "")); //$NON-NLS-1$
if (configuration.isWorkingCopy()) {
// set VM args
ILaunchConfigurationWorkingCopy workingCopy = (ILaunchConfigurationWorkingCopy)configuration;
String home = TomcatLaunchDelegate.getCatalinaHome();
IPath endorsed = new Path(home).append("common").append("endorsed"); //$NON-NLS-1$//$NON-NLS-2$
IPath temp = new Path(home).append("temp"); //$NON-NLS-1$
StringBuffer args = new StringBuffer();
args.append("-Djava.endorsed.dirs=\""); //$NON-NLS-1$
args.append(endorsed.toOSString());
args.append("\" "); //$NON-NLS-1$
args.append("-Dcatalina.base=\""); //$NON-NLS-1$
args.append(home);
args.append("\" "); //$NON-NLS-1$
args.append("-Dcatalina.home=\""); //$NON-NLS-1$
args.append(home);
args.append("\" "); //$NON-NLS-1$
args.append("-Djava.io.tmpdir=\""); //$NON-NLS-1$
args.append(temp.toOSString());
args.append("\""); //$NON-NLS-1$
workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, args.toString());
workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "start"); //$NON-NLS-1$
}
} catch (CoreException e) {
setErrorMessage(e.getMessage());
DebugPlugin.log(e);
}
}
/**
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy)
*/
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(TomcatLaunchDelegate.ATTR_CATALINA_HOME, getAttributeValueFrom(fTomcatDir));
String webApp = getAttributeValueFrom(fWebAppDir);
configuration.setAttribute(TomcatLaunchDelegate.ATTR_WEB_APP_ROOT, webApp);
// set project (if there is one)
if (webApp != null) {
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(webApp));
if (resource != null) {
configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, resource.getProject().getName());
}
}
}
/**
* Retuns the string in the text widget, or <code>null</code> if empty.
*
* @return text or <code>null</code>
*/
protected String getAttributeValueFrom(Text text) {
String content = text.getText().trim();
if (content.length() > 0) {
return content;
}
return null;
}
/**
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
*/
public String getName() {
return LaunchingMessages.getString("TomcatTab.7"); //$NON-NLS-1$
}
/**
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
*/
public Image getImage() {
return JspPluginImages.getImage(JspPluginImages.IMG_OBJ_TOMCAT);
}
}
|
64,339
|
Bug 64339 Javadoc export fails with ArrayIndexOutOfBoundsException [javadoc]
|
M9 I'm running Eclipse with a JRE. When I selected File/Export/Javadoc nothing happens and I get the log entry below. I had to copy the Javadoc executables from my JDK directory to the JRE directory to workaround. I should get an error message saying that the Javadoc command could not be found and that I need a JDK in order to use Javadoc export. It would be nice if the system search path would be used to find the Javadoc executable. !ENTRY org.eclipse.ui 4 0 May 26, 2004 17:35:31.317 !MESSAGE 1 !STACK 0 java.lang.ArrayIndexOutOfBoundsException: 1 at org.eclipse.jdt.internal.ui.javadocexport.JavadocOptionsManager.findJavaDocCommand(JavadocOptionsManager.java:1091) at org.eclipse.jdt.internal.ui.javadocexport.JavadocOptionsManager.initJavadocCommandDefault(JavadocOptionsManager.java:1069) at org.eclipse.jdt.internal.ui.javadocexport.JavadocOptionsManager.<init>(JavadocOptionsManager.java:162) at org.eclipse.jdt.internal.ui.javadocexport.JavadocWizard.init(JavadocWizard.java:510) at org.eclipse.ui.internal.dialogs.WorkbenchWizardNode.getWizard(WorkbenchWizardNode.java:157) at org.eclipse.jface.wizard.WizardSelectionPage.getNextPage(WizardSelectionPage.java:96) at org.eclipse.ui.internal.dialogs.WorkbenchWizardSelectionPage.getNextPage(WorkbenchWizardSelectionPage.java:82) at org.eclipse.jface.wizard.WizardDialog.nextPressed(WizardDialog.java:672) at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:300) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:505) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.jface.window.Window.runEventLoop(Window.java:668) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ui.actions.ExportResourcesAction.run(ExportResourcesAction.java:162) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:899) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:850) at org.eclipse.jface.action.ActionContributionItem$7.handleEvent(ActionContributionItem.java:769) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:253) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:97) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:307) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:256) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622)
|
verified fixed
|
791fec5
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-28T11:54:14Z
| 2004-05-27T15:00:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocOptionsManager.java
|
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Sebastian Davids <sdavids@gmx.de> bug 38692
*******************************************************************************/
package org.eclipse.jdt.internal.ui.javadocexport;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.eclipse.jdt.launching.ExecutionArguments;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.IVMInstallType;
import org.eclipse.jdt.launching.JavaRuntime;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaUIStatus;
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
public class JavadocOptionsManager {
private IFile fXmlfile;
private StatusInfo fWizardStatus;
private String[] fJavadocCommandHistory;
private IJavaElement[] fSelectedElements;
private IJavaElement[] fInitialElements;
private String fAccess;
private String fDocletpath;
private String fDocletname;
private boolean fFromStandard;
private String fStylesheet;
private String fAdditionalParams;
private String fVMParams;
private String fOverview;
private String fTitle;
private String[] fHRefs;
private IPath[] fSourcepath;
private IPath[] fClasspath;
private boolean fNotree;
private boolean fNoindex;
private boolean fSplitindex;
private boolean fNonavbar;
private boolean fNodeprecated;
private boolean fNoDeprecatedlist;
private boolean fAuthor;
private boolean fVersion;
private boolean fUse;
private boolean fJDK14Mode;
private boolean fOpenInBrowser;
private RecentSettingsStore fRecentSettings;
//add-on for multi-project version
private String fDestination;
private String fAntpath;
public final String PRIVATE= "private"; //$NON-NLS-1$
public final String PROTECTED= "protected"; //$NON-NLS-1$
public final String PACKAGE= "package"; //$NON-NLS-1$
public final String PUBLIC= "public"; //$NON-NLS-1$
public final String USE= "use"; //$NON-NLS-1$
public final String NOTREE= "notree"; //$NON-NLS-1$
public final String NOINDEX= "noindex"; //$NON-NLS-1$
public final String NONAVBAR= "nonavbar"; //$NON-NLS-1$
public final String NODEPRECATED= "nodeprecated"; //$NON-NLS-1$
public final String NODEPRECATEDLIST= "nodeprecatedlist"; //$NON-NLS-1$
public final String VERSION= "version"; //$NON-NLS-1$
public final String AUTHOR= "author"; //$NON-NLS-1$
public final String SPLITINDEX= "splitindex"; //$NON-NLS-1$
public final String STYLESHEETFILE= "stylesheetfile"; //$NON-NLS-1$
public final String OVERVIEW= "overview"; //$NON-NLS-1$
public final String DOCLETNAME= "docletname"; //$NON-NLS-1$
public final String DOCLETPATH= "docletpath"; //$NON-NLS-1$
public final String SOURCEPATH= "sourcepath"; //$NON-NLS-1$
public final String CLASSPATH= "classpath"; //$NON-NLS-1$
public final String DESTINATION= "destdir"; //$NON-NLS-1$
public final String OPENINBROWSER= "openinbrowser"; //$NON-NLS-1$
public final String VISIBILITY= "access"; //$NON-NLS-1$
public final String PACKAGENAMES= "packagenames"; //$NON-NLS-1$
public final String SOURCEFILES= "sourcefiles"; //$NON-NLS-1$
public final String EXTRAOPTIONS= "additionalparam"; //$NON-NLS-1$
public final String VMOPTIONS= "vmparam"; //$NON-NLS-1$
//public final String JAVADOCCOMMAND= "javadoccommand"; //$NON-NLS-1$
public final String TITLE= "doctitle"; //$NON-NLS-1$
public final String HREF= "href"; //$NON-NLS-1$
public final String NAME= "name"; //$NON-NLS-1$
public final String PATH= "path"; //$NON-NLS-1$
public final String FROMSTANDARD= "fromStandard"; //$NON-NLS-1$
public final String ANTPATH= "antpath"; //$NON-NLS-1$
public final String SOURCE= "source"; //$NON-NLS-1$
private final String SECTION_JAVADOC= "javadoc"; //$NON-NLS-1$
private static final String JAVADOC_COMMAND_HISTORY= "javadoc_command_history"; //$NON-NLS-1$
public JavadocOptionsManager(IFile xmlJavadocFile, IDialogSettings dialogSettings, List currSelection) {
fXmlfile= xmlJavadocFile;
fWizardStatus= new StatusInfo();
IDialogSettings javadocSection= dialogSettings.getSection(SECTION_JAVADOC); //$NON-NLS-1$
String commandHistory= null; //$NON-NLS-1$
if (javadocSection != null) {
commandHistory= javadocSection.get(JAVADOC_COMMAND_HISTORY);
}
if (commandHistory == null || commandHistory.length() == 0) {
commandHistory= initJavadocCommandDefault();
}
fJavadocCommandHistory= arrayFromFlatString(commandHistory);
fRecentSettings= new RecentSettingsStore(javadocSection);
if (xmlJavadocFile != null) {
try {
JavadocReader reader= new JavadocReader(xmlJavadocFile.getContents());
Element element= reader.readXML();
if (element != null) {
loadFromXML(element);
return;
}
fWizardStatus.setWarning(JavadocExportMessages.getString("JavadocOptionsManager.antfileincorrectCE.warning")); //$NON-NLS-1$
} catch (CoreException e) {
JavaPlugin.log(e);
fWizardStatus.setWarning(JavadocExportMessages.getString("JavadocOptionsManager.antfileincorrectCE.warning")); //$NON-NLS-1$
} catch (IOException e) {
JavaPlugin.log(e);
fWizardStatus.setWarning(JavadocExportMessages.getString("JavadocOptionsManager.antfileincorrectIOE.warning")); //$NON-NLS-1$
} catch (SAXException e) {
fWizardStatus.setWarning(JavadocExportMessages.getString("JavadocOptionsManager.antfileincorrectSAXE.warning")); //$NON-NLS-1$
}
}
if (javadocSection != null) {
loadFromDialogStore(javadocSection, currSelection);
} else {
loadDefaults(currSelection);
}
}
/*
* Returns the the Java project that is parent top all selected elements or null if
* the elements are from several projects.
*/
private IJavaProject getSingleProjectFromInitialSelection() {
IJavaProject res= null;
for (int i= 0; i < fInitialElements.length; i++) {
IJavaProject curr= fInitialElements[i].getJavaProject();
if (res == null) {
res= curr;
} else if (!res.equals(curr)) {
return null;
}
}
return res;
}
private void loadFromDialogStore(IDialogSettings settings, List sel) {
fInitialElements= getInitialElementsFromSelection(sel);
IJavaProject project= getSingleProjectFromInitialSelection();
fAccess= settings.get(VISIBILITY);
if (fAccess == null)
fAccess= PROTECTED;
//this is defaulted to false.
fFromStandard= settings.getBoolean(FROMSTANDARD);
//doclet is loaded even if the standard doclet is being used
fDocletpath= settings.get(DOCLETPATH);
fDocletname= settings.get(DOCLETNAME);
if (fDocletpath == null || fDocletname == null) {
fFromStandard= true;
fDocletpath= ""; //$NON-NLS-1$
fDocletname= ""; //$NON-NLS-1$
}
if (project != null) {
fAntpath= getRecentSettings().getAntpath(project);
} else {
fAntpath= settings.get(ANTPATH);
if (fAntpath == null) {
fAntpath= ""; //$NON-NLS-1$
}
}
if (project != null) {
fDestination= getRecentSettings().getDestination(project);
} else {
fDestination= settings.get(DESTINATION);
if (fDestination == null) {
fDestination= ""; //$NON-NLS-1$
}
}
fTitle= settings.get(TITLE);
if (fTitle == null)
fTitle= ""; //$NON-NLS-1$
fStylesheet= settings.get(STYLESHEETFILE);
if (fStylesheet == null)
fStylesheet= ""; //$NON-NLS-1$
fVMParams= settings.get(VMOPTIONS);
if (fVMParams == null)
fVMParams= ""; //$NON-NLS-1$
fAdditionalParams= settings.get(EXTRAOPTIONS);
if (fAdditionalParams == null)
fAdditionalParams= ""; //$NON-NLS-1$
fOverview= settings.get(OVERVIEW);
if (fOverview == null)
fOverview= ""; //$NON-NLS-1$
fUse= loadBoolean(settings.get(USE));
fAuthor= loadBoolean(settings.get(AUTHOR));
fVersion= loadBoolean(settings.get(VERSION));
fNodeprecated= loadBoolean(settings.get(NODEPRECATED));
fNoDeprecatedlist= loadBoolean(settings.get(NODEPRECATEDLIST));
fNonavbar= loadBoolean(settings.get(NONAVBAR));
fNoindex= loadBoolean(settings.get(NOINDEX));
fNotree= loadBoolean(settings.get(NOTREE));
fSplitindex= loadBoolean(settings.get(SPLITINDEX));
fOpenInBrowser= loadBoolean(settings.get(OPENINBROWSER));
fJDK14Mode= loadBoolean(settings.get(SOURCE));
if (project != null) {
fHRefs= getRecentSettings().getHRefs(project);
} else {
fHRefs= new String[0];
}
}
//loads defaults for wizard (nothing is stored)
private void loadDefaults(List sel) {
fInitialElements= getInitialElementsFromSelection(sel);
IJavaProject project= getSingleProjectFromInitialSelection();
if (project != null) {
fAntpath= getRecentSettings().getAntpath(project);
fDestination= getRecentSettings().getDestination(project);
fHRefs= getRecentSettings().getHRefs(project);
} else {
fAntpath= ""; //$NON-NLS-1$
fDestination= ""; //$NON-NLS-1$
fHRefs= new String[0];
}
fAccess= PUBLIC;
fDocletname= ""; //$NON-NLS-1$
fDocletpath= ""; //$NON-NLS-1$
fTitle= ""; //$NON-NLS-1$
fStylesheet= ""; //$NON-NLS-1$
fVMParams= ""; //$NON-NLS-1$
fAdditionalParams= ""; //$NON-NLS-1$
fOverview= ""; //$NON-NLS-1$
fUse= true;
fAuthor= true;
fVersion= true;
fNodeprecated= false;
fNoDeprecatedlist= false;
fNonavbar= false;
fNoindex= false;
fNotree= false;
fSplitindex= true;
fOpenInBrowser= false;
fJDK14Mode= false;
//by default it is empty all project map to the empty string
fFromStandard= true;
}
private void loadFromXML(Element element) {
fAccess= element.getAttribute(VISIBILITY);
if (fAccess.length() == 0)
fAccess= PROTECTED;
//Since the selected packages are stored we must locate the project
String destination= element.getAttribute(DESTINATION);
fDestination= makeAbsolutePathFromRelative(destination).toOSString();
fFromStandard= true;
fDocletname= ""; //$NON-NLS-1$
fDocletpath= ""; //$NON-NLS-1$
if (destination.length() == 0) { //$NON-NLS-1$
NodeList list= element.getChildNodes();
for (int i= 0; i < list.getLength(); i++) {
Node child= list.item(i);
if (child.getNodeName().equals("doclet")) { //$NON-NLS-1$
fDocletpath= ((Element) child).getAttribute(PATH);
fDocletname= ((Element) child).getAttribute(NAME);
if (fDocletpath.length() != 0 || fDocletname.length() != 0) {
fFromStandard= false;
} else {
fDocletname= ""; //$NON-NLS-1$
fDocletpath= ""; //$NON-NLS-1$
}
break;
}
}
}
fInitialElements= getSelectedElementsFromAnt(element);
//find all the links stored in the ant script
NodeList children= element.getChildNodes();
fHRefs= new String[children.getLength()];
for (int i= 0; i < fHRefs.length; i++) {
Node child= children.item(i);
if (child.getNodeName().equals("link")) { //$NON-NLS-1$
fHRefs[i]= ((Element) child).getAttribute(HREF);
}
}
//get tree elements
IPath p= fXmlfile.getLocation();
if (p != null)
fAntpath= p.toOSString();
else
fAntpath= ""; //$NON-NLS-1$
fStylesheet= element.getAttribute(STYLESHEETFILE);
fTitle= element.getAttribute(TITLE);
StringBuffer additionals= new StringBuffer();
StringBuffer vmargs= new StringBuffer();
String extraOptions= element.getAttribute(EXTRAOPTIONS);
if (extraOptions.length() > 0) {
ExecutionArguments tokens= new ExecutionArguments("", extraOptions); //$NON-NLS-1$
String[] args= tokens.getProgramArgumentsArray();
boolean vmarg= false;
for (int i= 0; i < args.length; i++) {
String curr= args[i];
if (curr.length() > 0 && curr.charAt(0) == '-') {
// an command
vmarg=(curr.length() > 1 && curr.charAt(1) == 'J');
}
if (vmarg) {
vmargs.append(curr).append(' ');
} else {
additionals.append(curr).append(' ');
}
}
}
fAdditionalParams= additionals.toString();
fVMParams= vmargs.toString();
fOverview= element.getAttribute(OVERVIEW);
fUse= loadBoolean(element.getAttribute(USE));
fAuthor= loadBoolean(element.getAttribute(AUTHOR));
fVersion= loadBoolean(element.getAttribute(VERSION));
fNodeprecated= loadBoolean(element.getAttribute(NODEPRECATED));
fNoDeprecatedlist= loadBoolean(element.getAttribute(NODEPRECATEDLIST));
fNonavbar= loadBoolean(element.getAttribute(NONAVBAR));
fNoindex= loadBoolean(element.getAttribute(NOINDEX));
fNotree= loadBoolean(element.getAttribute(NOTREE));
fSplitindex= loadBoolean(element.getAttribute(SPLITINDEX));
}
/*
* Method creates an absolute path to the project. If the path is already
* absolute it returns the path. If it encounters any difficulties in
* creating the absolute path, the method returns null.
*
* @param pathStr
* @return IPath
*/
private IPath makeAbsolutePathFromRelative(String pathStr) {
IPath path= new Path(pathStr);
if (!path.isAbsolute()) {
if (fXmlfile == null) {
return null;
}
IPath basePath= fXmlfile.getParent().getLocation(); // relative to the ant file location
if (basePath == null) {
return null;
}
return basePath.append(pathStr);
}
return path;
}
private IContainer[] getSourceContainers(Element element) {
String sourcePaths= element.getAttribute(SOURCEPATH);
StringTokenizer tokenizer= new StringTokenizer(sourcePaths, String.valueOf(File.pathSeparatorChar));
ArrayList res= new ArrayList();
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
while (tokenizer.hasMoreTokens()) {
IPath path= makeAbsolutePathFromRelative(tokenizer.nextToken().trim());
if (path != null) {
IContainer[] containers= root.findContainersForLocation(path);
for (int i= 0; i < containers.length; i++) {
res.add(containers[i]);
}
}
}
return (IContainer[]) res.toArray(new IContainer[res.size()]);
}
private IJavaElement[] getSelectedElementsFromAnt(Element element) {
List res= new ArrayList();
// get all the packages listed in the ANT file
String packagenames= element.getAttribute(PACKAGENAMES);
if (packagenames != null) {
IContainer[] containers= getSourceContainers(element);
StringTokenizer tokenizer= new StringTokenizer(packagenames, ","); //$NON-NLS-1$
while (tokenizer.hasMoreTokens()) {
IPath relPackagePath= new Path(tokenizer.nextToken().trim().replace('.', '/'));
for (int i= 0; i < containers.length; i++) {
IContainer curr= containers[i];
IResource resource= curr.findMember(relPackagePath);
if (resource != null) {
IJavaElement javaElem= JavaCore.create(resource);
if (javaElem instanceof IPackageFragment) {
res.add(javaElem);
}
}
}
}
}
//get all CompilationUnites listed in the ANT file
String sourcefiles= element.getAttribute(SOURCEFILES);
if (sourcefiles != null) {
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
StringTokenizer tokenizer= new StringTokenizer(sourcefiles, ","); //$NON-NLS-1$
while (tokenizer.hasMoreTokens()) {
String name= tokenizer.nextToken().trim();
if (name.endsWith(".java")) { //$NON-NLS-1$
IPath path= makeAbsolutePathFromRelative(name);
//if unable to create an absolute path the the resource skip it
if (path != null) {
IFile[] files= root.findFilesForLocation(path);
for (int i= 0; i < files.length; i++) {
IJavaElement el= JavaCore.createCompilationUnitFrom(files[i]);
if (el != null) {
res.add(el);
}
}
}
}
}
}
return (IJavaElement[]) res.toArray(new IJavaElement[res.size()]);
}
/**
* @return Returns the javadocCommandHistory.
*/
public String[] getJavadocCommandHistory() {
return fJavadocCommandHistory;
}
//it is possible that the package list is empty
public StatusInfo getWizardStatus() {
return fWizardStatus;
}
public IJavaElement[] getInitialElements() {
return fInitialElements;
}
public IJavaElement[] getSourceElements() {
return fSelectedElements;
}
public String getAccess() {
return fAccess;
}
public String getAntpath() {
return fAntpath;
}
public boolean isFromStandard() {
return fFromStandard;
}
public String getDestination() {
return fDestination;
}
public String getDocletPath() {
return fDocletpath;
}
public String getDocletName() {
return fDocletname;
}
public String getStyleSheet() {
return fStylesheet;
}
public String getOverview() {
return fOverview;
}
public String getAdditionalParams() {
return fAdditionalParams;
}
public String getVMParams() {
return fVMParams;
}
public IPath[] getClasspath() {
return fClasspath;
}
public IPath[] getSourcepath() {
return fSourcepath;
}
public String getTitle() {
return fTitle;
}
public boolean doOpenInBrowser() {
return fOpenInBrowser;
}
public String[] getHRefs() {
return fHRefs;
}
public boolean getBoolean(String flag) {
if (flag.equals(AUTHOR))
return fAuthor;
else if (flag.equals(VERSION))
return fVersion;
else if (flag.equals(USE))
return fUse;
else if (flag.equals(NODEPRECATED))
return fNodeprecated;
else if (flag.equals(NODEPRECATEDLIST))
return fNoDeprecatedlist;
else if (flag.equals(NOINDEX))
return fNoindex;
else if (flag.equals(NOTREE))
return fNotree;
else if (flag.equals(SPLITINDEX))
return fSplitindex;
else if (flag.equals(NONAVBAR))
return fNonavbar;
else
return false;
}
private boolean loadBoolean(String value) {
if (value == null || value.length() == 0) //$NON-NLS-1$
return false;
else {
if (value.equals("true")) //$NON-NLS-1$
return true;
else
return false;
}
}
private String flatPathList(IPath[] paths) {
StringBuffer buf= new StringBuffer();
for (int i= 0; i < paths.length; i++) {
if (i > 0) {
buf.append(File.pathSeparatorChar);
}
buf.append(paths[i].toOSString());
}
return buf.toString();
}
private String flatStringList(String[] paths) {
StringBuffer buf= new StringBuffer();
for (int i= 0; i < paths.length; i++) {
if (i > 0) {
buf.append(File.pathSeparatorChar);
}
buf.append(paths[i]);
}
return buf.toString();
}
private String[] arrayFromFlatString(String str) {
StringTokenizer tok= new StringTokenizer(str, File.pathSeparator);
String[] res= new String[tok.countTokens()];
for (int i= 0; i < res.length; i++) {
res[i]= tok.nextToken();
}
return res;
}
public void getArgumentArray(List vmArgs, List toolArgs) {
//bug 38692
vmArgs.add(getJavadocCommandHistory()[0]);
if (fFromStandard) {
toolArgs.add("-d"); //$NON-NLS-1$
toolArgs.add(fDestination);
} else {
if (fAdditionalParams.length() + fVMParams.length() != 0) {
ExecutionArguments tokens= new ExecutionArguments(fVMParams, fAdditionalParams); //$NON-NLS-1$
String[] vmArgsArray= tokens.getVMArgumentsArray();
for (int i= 0; i < vmArgsArray.length; i++) {
vmArgs.add(vmArgsArray[i]);
}
String[] argsArray= tokens.getProgramArgumentsArray();
for (int i= 0; i < argsArray.length; i++) {
toolArgs.add(argsArray[i]);
}
}
toolArgs.add("-doclet"); //$NON-NLS-1$
toolArgs.add(fDocletname);
toolArgs.add("-docletpath"); //$NON-NLS-1$
toolArgs.add(fDocletpath);
}
toolArgs.add("-sourcepath"); //$NON-NLS-1$
toolArgs.add(flatPathList(fSourcepath));
toolArgs.add("-classpath"); //$NON-NLS-1$
toolArgs.add(flatPathList(fClasspath));
toolArgs.add("-" + fAccess); //$NON-NLS-1$
if (fFromStandard) {
if (fJDK14Mode) {
toolArgs.add("-source"); //$NON-NLS-1$
toolArgs.add("1.4"); //$NON-NLS-1$
}
if (fUse)
toolArgs.add("-use"); //$NON-NLS-1$
if (fVersion)
toolArgs.add("-version"); //$NON-NLS-1$
if (fAuthor)
toolArgs.add("-author"); //$NON-NLS-1$
if (fNonavbar)
toolArgs.add("-nonavbar"); //$NON-NLS-1$
if (fNoindex)
toolArgs.add("-noindex"); //$NON-NLS-1$
if (fNotree)
toolArgs.add("-notree"); //$NON-NLS-1$
if (fNodeprecated)
toolArgs.add("-nodeprecated"); //$NON-NLS-1$
if (fNoDeprecatedlist)
toolArgs.add("-nodeprecatedlist"); //$NON-NLS-1$
if (fSplitindex)
toolArgs.add("-splitindex"); //$NON-NLS-1$
if (fTitle.length() != 0) { //$NON-NLS-1$
toolArgs.add("-doctitle"); //$NON-NLS-1$
toolArgs.add(fTitle);
}
if (fStylesheet.length() != 0) { //$NON-NLS-1$
toolArgs.add("-stylesheetfile"); //$NON-NLS-1$
toolArgs.add(fStylesheet);
}
if (fAdditionalParams.length() + fVMParams.length() != 0) {
ExecutionArguments tokens= new ExecutionArguments(fVMParams, fAdditionalParams); //$NON-NLS-1$
String[] vmArgsArray= tokens.getVMArgumentsArray();
for (int i= 0; i < vmArgsArray.length; i++) {
vmArgs.add(vmArgsArray[i]);
}
String[] argsArray= tokens.getProgramArgumentsArray();
for (int i= 0; i < argsArray.length; i++) {
toolArgs.add(argsArray[i]);
}
}
for (int i= 0; i < fHRefs.length; i++) {
toolArgs.add("-link"); //$NON-NLS-1$
toolArgs.add(fHRefs[i]);
}
} //end standard options
if (fOverview.length() != 0) { //$NON-NLS-1$
toolArgs.add("-overview"); //$NON-NLS-1$
toolArgs.add(fOverview);
}
for (int i= 0; i < fSelectedElements.length; i++) {
IJavaElement curr= fSelectedElements[i];
if (curr instanceof IPackageFragment) {
toolArgs.add(curr.getElementName());
} else if (curr instanceof ICompilationUnit) {
IPath p= curr.getResource().getLocation();
if (p != null)
toolArgs.add(p.toOSString());
}
}
}
public void createXML(IJavaProject[] projects) throws CoreException {
FileOutputStream objectStreamOutput= null;
//@change
//for now only writting ant files for single project selection
String antpath= fAntpath;
try {
if (antpath.length() > 0) {
File file= new File(antpath);
IPath antPath= new Path(antpath);
IPath antDir= antPath.removeLastSegments(1);
IPath basePath= null;
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
if (root.findFilesForLocation(antPath).length > 0) {
basePath= antDir; // only do relative path if ant file is stored in the workspace
}
antDir.toFile().mkdirs();
objectStreamOutput= new FileOutputStream(file);
JavadocWriter writer= new JavadocWriter(objectStreamOutput, basePath, projects);
writer.writeXML(this);
}
} catch (IOException e) {
String message= JavadocExportMessages.getString("JavadocOptionsManager.createXM.error"); //$NON-NLS-1$
throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, message, e));
} catch (ParserConfigurationException e) {
String message= JavadocExportMessages.getString("JavadocOptionsManager.createXM.error"); //$NON-NLS-1$
throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, message, e));
} catch (TransformerException e) {
String message= JavadocExportMessages.getString("JavadocOptionsManager.createXM.error"); //$NON-NLS-1$
throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, message, e));
} finally {
if (objectStreamOutput != null) {
try {
objectStreamOutput.close();
} catch (IOException e) {
}
}
}
}
public void updateDialogSettings(IDialogSettings dialogSettings, IJavaProject[] checkedProjects) {
IDialogSettings settings= dialogSettings.addNewSection(SECTION_JAVADOC);
settings.put(JAVADOC_COMMAND_HISTORY, flatStringList(fJavadocCommandHistory));
if (fJavadocCommandHistory.length > 0) {
IPreferenceStore store= PreferenceConstants.getPreferenceStore();
store.setValue(PreferenceConstants.JAVADOC_COMMAND, fJavadocCommandHistory[0]);
}
settings.put(FROMSTANDARD, fFromStandard);
settings.put(DOCLETNAME, fDocletname);
settings.put(DOCLETPATH, fDocletpath);
settings.put(VISIBILITY, fAccess);
settings.put(USE, fUse);
settings.put(AUTHOR, fAuthor);
settings.put(VERSION, fVersion);
settings.put(NODEPRECATED, fNodeprecated);
settings.put(NODEPRECATEDLIST, fNoDeprecatedlist);
settings.put(SPLITINDEX, fSplitindex);
settings.put(NOINDEX, fNoindex);
settings.put(NOTREE, fNotree);
settings.put(NONAVBAR, fNonavbar);
settings.put(OPENINBROWSER, fOpenInBrowser);
settings.put(SOURCE, fJDK14Mode);
if (fAntpath.length() != 0) //$NON-NLS-1$
settings.put(ANTPATH, fAntpath);
if (fDestination.length() != 0) //$NON-NLS-1$
settings.put(DESTINATION, fDestination);
if (fAdditionalParams.length() != 0) //$NON-NLS-1$
settings.put(EXTRAOPTIONS, fAdditionalParams);
if (fVMParams.length() != 0) //$NON-NLS-1$
settings.put(VMOPTIONS, fVMParams);
if (fOverview.length() != 0) //$NON-NLS-1$
settings.put(OVERVIEW, fOverview);
if (fStylesheet.length() != 0) //$NON-NLS-1$
settings.put(STYLESHEETFILE, fStylesheet);
if (fTitle.length() != 0) //$NON-NLS-1$
settings.put(TITLE, fTitle);
if (checkedProjects.length == 1) {
updateRecentSettings(checkedProjects[0]);
}
getRecentSettings().store(settings);
}
public void setJavadocCommandHistory(String[] javadocCommandHistory) {
fJavadocCommandHistory= javadocCommandHistory;
}
public void setAccess(String access) {
fAccess= access;
}
public void setDestination(String destination) {
fDestination= destination;
}
public void setDocletPath(String docletpath) {
fDocletpath= docletpath;
}
public void setDocletName(String docletname) {
fDocletname= docletname;
}
public void setStyleSheet(String stylesheet) {
fStylesheet= stylesheet;
}
public void setOverview(String overview) {
fOverview= overview;
}
public void setAdditionalParams(String params) {
fAdditionalParams= params;
}
public void setVMParams(String params) {
fVMParams= params;
}
public void setGeneralAntpath(String antpath) {
fAntpath= antpath;
}
public void setClasspath(IPath[] classpath) {
fClasspath= classpath;
}
public void setSourcepath(IPath[] sourcepath) {
fSourcepath= sourcepath;
}
public void setSelectedElements(IJavaElement[] elements) {
fSelectedElements= elements;
}
public void setFromStandard(boolean fromStandard) {
fFromStandard= fromStandard;
}
public void setTitle(String title) {
fTitle= title;
}
public void setOpenInBrowser(boolean openInBrowser) {
fOpenInBrowser= openInBrowser;
}
public void setHRefs(String[] hrefs) {
fHRefs= hrefs;
}
public void setBoolean(String flag, boolean value) {
if (flag.equals(AUTHOR))
fAuthor= value;
else if (flag.equals(USE))
fUse= value;
else if (flag.equals(VERSION))
fVersion= value;
else if (flag.equals(NODEPRECATED))
fNodeprecated= value;
else if (flag.equals(NODEPRECATEDLIST))
fNoDeprecatedlist= value;
else if (flag.equals(NOINDEX))
fNoindex= value;
else if (flag.equals(NOTREE))
fNotree= value;
else if (flag.equals(SPLITINDEX))
fSplitindex= value;
else if (flag.equals(NONAVBAR))
fNonavbar= value;
}
public boolean isJDK14Mode() {
return fJDK14Mode;
}
public void setJDK14Mode(boolean jdk14Mode) {
fJDK14Mode= jdk14Mode;
}
private IJavaElement[] getInitialElementsFromSelection(List candidates) {
ArrayList res= new ArrayList();
for (int i= 0; i < candidates.size(); i++) {
try {
IJavaElement elem= getSelectableJavaElement(candidates.get(i));
if (elem != null) {
res.add(elem);
}
} catch (JavaModelException ignore) {
// ignore this
}
}
return (IJavaElement[]) res.toArray(new IJavaElement[res.size()]);
}
private IJavaElement getSelectableJavaElement(Object obj) throws JavaModelException {
IJavaElement je= null;
if (obj instanceof IAdaptable) {
je= (IJavaElement) ((IAdaptable) obj).getAdapter(IJavaElement.class);
}
if (je != null) {
switch (je.getElementType()) {
case IJavaElement.JAVA_MODEL :
case IJavaElement.JAVA_PROJECT :
case IJavaElement.CLASS_FILE :
break;
case IJavaElement.PACKAGE_FRAGMENT_ROOT :
if (containsCompilationUnits((IPackageFragmentRoot) je)) {
return je;
}
break;
case IJavaElement.PACKAGE_FRAGMENT :
if (containsCompilationUnits((IPackageFragment) je)) {
return je;
}
break;
default :
ICompilationUnit cu= (ICompilationUnit) je.getAncestor(IJavaElement.COMPILATION_UNIT);
if (cu != null) {
return cu;
}
}
IJavaProject project= je.getJavaProject();
if (isValidProject(project))
return project;
}
return null;
}
private boolean isValidProject(IJavaProject project) throws JavaModelException {
if (project != null && project.exists()) {
IPackageFragmentRoot[] roots= project.getPackageFragmentRoots();
for (int i= 0; i < roots.length; i++) {
if (containsCompilationUnits(roots[i])) {
return true;
}
}
}
return false;
}
private boolean containsCompilationUnits(IPackageFragmentRoot root) throws JavaModelException {
if (root.getKind() != IPackageFragmentRoot.K_SOURCE) {
return false;
}
IJavaElement[] elements= root.getChildren();
for (int i= 0; i < elements.length; i++) {
if (elements[i] instanceof IPackageFragment) {
IPackageFragment fragment= (IPackageFragment) elements[i];
if (containsCompilationUnits(fragment)) {
return true;
}
}
}
return false;
}
private boolean containsCompilationUnits(IPackageFragment pack) throws JavaModelException {
return pack.getCompilationUnits().length > 0;
}
public RecentSettingsStore getRecentSettings() {
return fRecentSettings;
}
/**
* @param project
*/
public void updateRecentSettings(IJavaProject project) {
fRecentSettings.setProjectSettings(project, fDestination, fAntpath, fHRefs);
}
private static String initJavadocCommandDefault() {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
String cmd= store.getString(PreferenceConstants.JAVADOC_COMMAND); // old location
if (cmd != null && cmd.length() > 0) {
store.setToDefault(PreferenceConstants.JAVADOC_COMMAND);
return cmd;
}
File file= findJavaDocCommand();
if (file != null) {
return file.getPath();
}
return ""; //$NON-NLS-1$
}
private static File findJavaDocCommand() {
IVMInstall install= JavaRuntime.getDefaultVMInstall();
if (install != null) {
File res= getCommand(install);
if (res != null) {
return res;
}
}
IVMInstallType[] jreTypes= JavaRuntime.getVMInstallTypes();
for (int i= 0; i < jreTypes.length; i++) {
IVMInstallType jreType= jreTypes[i];
IVMInstall[] installs= jreType.getVMInstalls();
for (int k= 0; k < installs.length; k++) {
File res= getCommand(installs[i]);
if (res != null) {
return res;
}
}
}
return null;
}
private static File getCommand(IVMInstall install) {
File installLocation= install.getInstallLocation();
if (installLocation != null) {
File javaDocCommand= new File(installLocation, "bin/javadoc"); //$NON-NLS-1$
if (javaDocCommand.isFile()) {
return javaDocCommand;
}
javaDocCommand= new File(installLocation, "bin/javadoc.exe"); //$NON-NLS-1$
if (javaDocCommand.isFile()) {
return javaDocCommand;
}
}
return null;
}
}
|
64,298
|
Bug 64298 JAR files already in build path still shown when adding JARs.
|
When adding JARs to the Java build path in 3.0M9, the JAR's that are already added do not get filtered out anymore like with all previous builds (M8 and lower). Instead, the complete list of all available JARs is shown.
|
verified fixed
|
7a4b704
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-28T13:15:42Z
| 2004-05-27T09:26:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/LibrariesWorkbookPage.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.wizards.buildpaths;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.ui.PlatformUI;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
import org.eclipse.jdt.internal.ui.util.PixelConverter;
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.TreeListDialogField;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
public class LibrariesWorkbookPage extends BuildPathBasePage {
private ListDialogField fClassPathList;
private IJavaProject fCurrJProject;
private TreeListDialogField fLibrariesList;
private IWorkspaceRoot fWorkspaceRoot;
private Control fSWTControl;
private final int IDX_ADDJAR= 0;
private final int IDX_ADDEXT= 1;
private final int IDX_ADDVAR= 2;
private final int IDX_ADDLIB= 3;
private final int IDX_ADDFOL= 4;
private final int IDX_EDIT= 6;
private final int IDX_REMOVE= 7;
public LibrariesWorkbookPage(IWorkspaceRoot root, ListDialogField classPathList) {
fClassPathList= classPathList;
fWorkspaceRoot= root;
fSWTControl= null;
String[] buttonLabels= new String[] {
/* IDX_ADDJAR*/ NewWizardMessages.getString("LibrariesWorkbookPage.libraries.addjar.button"), //$NON-NLS-1$
/* IDX_ADDEXT */ NewWizardMessages.getString("LibrariesWorkbookPage.libraries.addextjar.button"), //$NON-NLS-1$
/* IDX_ADDVAR */ NewWizardMessages.getString("LibrariesWorkbookPage.libraries.addvariable.button"), //$NON-NLS-1$
/* IDX_ADDLIB */ NewWizardMessages.getString("LibrariesWorkbookPage.libraries.addlibrary.button"), //$NON-NLS-1$
/* IDX_ADDFOL */ NewWizardMessages.getString("LibrariesWorkbookPage.libraries.addclassfolder.button"), //$NON-NLS-1$
/* */ null,
/* IDX_EDIT */ NewWizardMessages.getString("LibrariesWorkbookPage.libraries.edit.button"), //$NON-NLS-1$
/* IDX_REMOVE */ NewWizardMessages.getString("LibrariesWorkbookPage.libraries.remove.button") //$NON-NLS-1$
};
LibrariesAdapter adapter= new LibrariesAdapter();
fLibrariesList= new TreeListDialogField(adapter, buttonLabels, new CPListLabelProvider());
fLibrariesList.setDialogFieldListener(adapter);
fLibrariesList.setLabelText(NewWizardMessages.getString("LibrariesWorkbookPage.libraries.label")); //$NON-NLS-1$
fLibrariesList.enableButton(IDX_REMOVE, false);
fLibrariesList.enableButton(IDX_EDIT, false);
fLibrariesList.setViewerSorter(new CPListElementSorter());
}
public void init(IJavaProject jproject) {
fCurrJProject= jproject;
updateLibrariesList();
}
private void updateLibrariesList() {
List cpelements= fClassPathList.getElements();
List libelements= new ArrayList(cpelements.size());
int nElements= cpelements.size();
for (int i= 0; i < nElements; i++) {
CPListElement cpe= (CPListElement)cpelements.get(i);
if (isEntryKind(cpe.getEntryKind())) {
libelements.add(cpe);
}
}
fLibrariesList.setElements(libelements);
}
// -------- UI creation
public Control getControl(Composite parent) {
PixelConverter converter= new PixelConverter(parent);
Composite composite= new Composite(parent, SWT.NONE);
LayoutUtil.doDefaultLayout(composite, new DialogField[] { fLibrariesList }, true, SWT.DEFAULT, SWT.DEFAULT);
LayoutUtil.setHorizontalGrabbing(fLibrariesList.getTreeControl(null));
int buttonBarWidth= converter.convertWidthInCharsToPixels(24);
fLibrariesList.setButtonsMinWidth(buttonBarWidth);
fLibrariesList.getTreeViewer().setSorter(new CPListElementSorter());
fSWTControl= composite;
return composite;
}
private Shell getShell() {
if (fSWTControl != null) {
return fSWTControl.getShell();
}
return JavaPlugin.getActiveWorkbenchShell();
}
private class LibrariesAdapter implements IDialogFieldListener, ITreeListAdapter {
private final Object[] EMPTY_ARR= new Object[0];
// -------- IListAdapter --------
public void customButtonPressed(TreeListDialogField field, int index) {
libaryPageCustomButtonPressed(field, index);
}
public void selectionChanged(TreeListDialogField field) {
libaryPageSelectionChanged(field);
}
public void doubleClicked(TreeListDialogField field) {
libaryPageDoubleClicked(field);
}
public void keyPressed(TreeListDialogField field, KeyEvent event) {
libaryPageKeyPressed(field, event);
}
public Object[] getChildren(TreeListDialogField field, Object element) {
if (element instanceof CPListElement) {
return ((CPListElement) element).getChildren(false);
}
return EMPTY_ARR;
}
public Object getParent(TreeListDialogField field, Object element) {
if (element instanceof CPListElementAttribute) {
return ((CPListElementAttribute) element).getParent();
}
return null;
}
public boolean hasChildren(TreeListDialogField field, Object element) {
return getChildren(field, element).length > 0;
}
// ---------- IDialogFieldListener --------
public void dialogFieldChanged(DialogField field) {
libaryPageDialogFieldChanged(field);
}
}
private void libaryPageCustomButtonPressed(DialogField field, int index) {
CPListElement[] libentries= null;
switch (index) {
case IDX_ADDJAR: /* add jar */
libentries= openJarFileDialog(null);
break;
case IDX_ADDEXT: /* add external jar */
libentries= openExtJarFileDialog(null);
break;
case IDX_ADDVAR: /* add variable */
libentries= openVariableSelectionDialog(null);
break;
case IDX_ADDLIB: /* add library */
libentries= openContainerSelectionDialog(null);
break;
case IDX_ADDFOL: /* add folder */
libentries= openClassFolderDialog(null);
break;
case IDX_EDIT: /* edit */
editEntry();
return;
case IDX_REMOVE: /* remove */
removeEntry();
return;
}
if (libentries != null) {
int nElementsChosen= libentries.length;
// remove duplicates
List cplist= fLibrariesList.getElements();
List elementsToAdd= new ArrayList(nElementsChosen);
for (int i= 0; i < nElementsChosen; i++) {
CPListElement curr= libentries[i];
if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
elementsToAdd.add(curr);
curr.setAttribute(CPListElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(curr));
curr.setAttribute(CPListElement.JAVADOC, JavaUI.getLibraryJavadocLocation(curr.getPath()));
}
}
if (!elementsToAdd.isEmpty() && (index == IDX_ADDFOL)) {
askForAddingExclusionPatternsDialog(elementsToAdd);
}
fLibrariesList.addElements(elementsToAdd);
if (index == IDX_ADDLIB) {
fLibrariesList.refresh();
}
fLibrariesList.postSetSelection(new StructuredSelection(libentries));
}
}
private void askForAddingExclusionPatternsDialog(List newEntries) {
HashSet modified= new HashSet();
fixNestingConflicts(newEntries, fClassPathList.getElements(), modified);
if (!modified.isEmpty()) {
String title= NewWizardMessages.getString("LibrariesWorkbookPage.exclusion_added.title"); //$NON-NLS-1$
String message= NewWizardMessages.getString("LibrariesWorkbookPage.exclusion_added.message"); //$NON-NLS-1$
MessageDialog.openInformation(getShell(), title, message);
}
}
protected void libaryPageDoubleClicked(TreeListDialogField field) {
List selection= fLibrariesList.getSelectedElements();
if (canEdit(selection)) {
editEntry();
}
}
protected void libaryPageKeyPressed(TreeListDialogField field, KeyEvent event) {
if (field == fLibrariesList) {
if (event.character == SWT.DEL && event.stateMask == 0) {
List selection= field.getSelectedElements();
if (canRemove(selection)) {
removeEntry();
}
}
}
}
private void removeEntry() {
List selElements= fLibrariesList.getSelectedElements();
for (int i= selElements.size() - 1; i >= 0 ; i--) {
Object elem= selElements.get(i);
if (elem instanceof CPListElementAttribute) {
CPListElementAttribute attrib= (CPListElementAttribute) elem;
attrib.getParent().setAttribute(attrib.getKey(), null);
selElements.remove(i);
}
}
if (selElements.isEmpty()) {
fLibrariesList.refresh();
fClassPathList.dialogFieldChanged(); // validate
} else {
fLibrariesList.removeElements(selElements);
}
}
private boolean canRemove(List selElements) {
if (selElements.size() == 0) {
return false;
}
for (int i= 0; i < selElements.size(); i++) {
Object elem= selElements.get(i);
if (elem instanceof CPListElementAttribute) {
if (((CPListElementAttribute)elem).getValue() == null) {
return false;
}
} else if (elem instanceof CPListElement) {
CPListElement curr= (CPListElement) elem;
if (curr.getParentContainer() != null) {
return false;
}
}
}
return true;
}
/**
* Method editEntry.
*/
private void editEntry() {
List selElements= fLibrariesList.getSelectedElements();
if (selElements.size() != 1) {
return;
}
Object elem= selElements.get(0);
if (fLibrariesList.getIndexOfElement(elem) != -1) {
editElementEntry((CPListElement) elem);
} else if (elem instanceof CPListElementAttribute) {
editAttributeEntry((CPListElementAttribute) elem);
}
}
private void editAttributeEntry(CPListElementAttribute elem) {
String key= elem.getKey();
if (key.equals(CPListElement.SOURCEATTACHMENT)) {
CPListElement selElement= elem.getParent();
IPath containerPath= null;
boolean applyChanges= false;
Object parentContainer= selElement.getParentContainer();
if (parentContainer instanceof CPListElement) {
containerPath= ((CPListElement) parentContainer).getPath();
applyChanges= true;
}
Shell shell= getShell();
IClasspathEntry result= BuildPathDialogAccess.configureSourceAttachment(shell, selElement.getClasspathEntry());
if (result != null) {
if (applyChanges) {
try {
IRunnableWithProgress runnable= SourceAttachmentBlock.getRunnable(shell, result, fCurrJProject, containerPath);
PlatformUI.getWorkbench().getProgressService().run(true, true, runnable);
} catch (InvocationTargetException e) {
String title= NewWizardMessages.getString("LibrariesWorkbookPage.configurecontainer.error.title"); //$NON-NLS-1$
String message= NewWizardMessages.getString("LibrariesWorkbookPage.configurecontainer.error.message"); //$NON-NLS-1$
ExceptionHandler.handle(e, shell, title, message);
} catch (InterruptedException e) {
return;
}
}
selElement.setAttribute(CPListElement.SOURCEATTACHMENT, result.getSourceAttachmentPath());
fLibrariesList.refresh();
fClassPathList.refresh(); // images
}
} else if (key.equals(CPListElement.JAVADOC)) {
CPListElement selElement= elem.getParent();
URL initialLocation= (URL) selElement.getAttribute(CPListElement.JAVADOC);
String elementName= new CPListLabelProvider().getText(selElement);
URL[] result= BuildPathDialogAccess.configureJavadocLocation(getShell(), elementName, initialLocation);
if (result != null) {
selElement.setAttribute(CPListElement.JAVADOC, result[0]);
fLibrariesList.refresh();
}
}
}
private void editElementEntry(CPListElement elem) {
CPListElement[] res= null;
switch (elem.getEntryKind()) {
case IClasspathEntry.CPE_CONTAINER:
res= openContainerSelectionDialog(elem);
break;
case IClasspathEntry.CPE_LIBRARY:
IResource resource= elem.getResource();
if (resource == null) {
res= openExtJarFileDialog(elem);
} else if (resource.getType() == IResource.FOLDER) {
if (resource.exists()) {
res= openClassFolderDialog(elem);
} else {
res= openNewClassFolderDialog(elem);
}
} else if (resource.getType() == IResource.FILE) {
res= openJarFileDialog(elem);
}
break;
case IClasspathEntry.CPE_VARIABLE:
res= openVariableSelectionDialog(elem);
break;
}
if (res != null && res.length > 0) {
CPListElement curr= res[0];
curr.setExported(elem.isExported());
fLibrariesList.replaceElement(elem, curr);
}
}
private void libaryPageSelectionChanged(DialogField field) {
List selElements= fLibrariesList.getSelectedElements();
fLibrariesList.enableButton(IDX_EDIT, canEdit(selElements));
fLibrariesList.enableButton(IDX_REMOVE, canRemove(selElements));
}
private boolean canEdit(List selElements) {
if (selElements.size() != 1) {
return false;
}
Object elem= selElements.get(0);
if (elem instanceof CPListElement) {
CPListElement curr= (CPListElement) elem;
return !(curr.getResource() instanceof IFolder) && curr.getParentContainer() == null;
}
if (elem instanceof CPListElementAttribute) {
return true;
}
return false;
}
private void libaryPageDialogFieldChanged(DialogField field) {
if (fCurrJProject != null) {
// already initialized
updateClasspathList();
}
}
private void updateClasspathList() {
List projelements= fLibrariesList.getElements();
List cpelements= fClassPathList.getElements();
int nEntries= cpelements.size();
// backwards, as entries will be deleted
int lastRemovePos= nEntries;
for (int i= nEntries - 1; i >= 0; i--) {
CPListElement cpe= (CPListElement)cpelements.get(i);
int kind= cpe.getEntryKind();
if (isEntryKind(kind)) {
if (!projelements.remove(cpe)) {
cpelements.remove(i);
lastRemovePos= i;
}
}
}
cpelements.addAll(lastRemovePos, projelements);
if (lastRemovePos != nEntries || !projelements.isEmpty()) {
fClassPathList.setElements(cpelements);
}
}
private CPListElement[] openNewClassFolderDialog(CPListElement existing) {
String title= (existing == null) ? NewWizardMessages.getString("LibrariesWorkbookPage.NewClassFolderDialog.new.title") : NewWizardMessages.getString("LibrariesWorkbookPage.NewClassFolderDialog.edit.title"); //$NON-NLS-1$ //$NON-NLS-2$
IProject currProject= fCurrJProject.getProject();
NewContainerDialog dialog= new NewContainerDialog(getShell(), title, currProject, getUsedContainers(existing), existing);
IPath projpath= currProject.getFullPath();
dialog.setMessage(NewWizardMessages.getFormattedString("LibrariesWorkbookPage.NewClassFolderDialog.description", projpath.toString())); //$NON-NLS-1$
if (dialog.open() == Window.OK) {
IFolder folder= dialog.getFolder();
return new CPListElement[] { newCPLibraryElement(folder) };
}
return null;
}
private CPListElement[] openClassFolderDialog(CPListElement existing) {
if (existing == null) {
IPath[] selected= BuildPathDialogAccess.chooseClassFolderEntries(getShell(), fCurrJProject.getPath(), getUsedContainers(existing));
if (selected != null) {
ArrayList res= new ArrayList();
for (int i= 0; i < selected.length; i++) {
IPath curr= selected[i];
IResource resource= fWorkspaceRoot.findMember(curr);
if (resource instanceof IContainer) {
res.add(newCPLibraryElement(resource));
}
}
return (CPListElement[]) res.toArray(new CPListElement[res.size()]);
}
} else {
// disabled
}
return null;
}
private CPListElement[] openJarFileDialog(CPListElement existing) {
if (existing == null) {
IPath[] selected= BuildPathDialogAccess.chooseJAREntries(getShell(), fCurrJProject.getPath(), getUsedContainers(existing));
if (selected != null) {
ArrayList res= new ArrayList();
for (int i= 0; i < selected.length; i++) {
IPath curr= selected[i];
IResource resource= fWorkspaceRoot.findMember(curr);
if (resource instanceof IFile) {
res.add(newCPLibraryElement(resource));
}
}
return (CPListElement[]) res.toArray(new CPListElement[res.size()]);
}
} else {
IPath configured= BuildPathDialogAccess.configureJAREntry(getShell(), existing.getPath(), getUsedJARFiles(existing));
if (configured != null) {
IResource resource= fWorkspaceRoot.findMember(configured);
if (resource instanceof IFile) {
return new CPListElement[] { newCPLibraryElement(resource) };
}
}
}
return null;
}
private IPath[] getUsedContainers(CPListElement existing) {
ArrayList res= new ArrayList();
if (fCurrJProject.exists()) {
try {
IPath outputLocation= fCurrJProject.getOutputLocation();
if (outputLocation != null && outputLocation.segmentCount() > 1) { // != Project
res.add(outputLocation);
}
} catch (JavaModelException e) {
// ignore it here, just log
JavaPlugin.log(e.getStatus());
}
}
List cplist= fLibrariesList.getElements();
for (int i= 0; i < cplist.size(); i++) {
CPListElement elem= (CPListElement)cplist.get(i);
if (elem.getEntryKind() == IClasspathEntry.CPE_LIBRARY && (elem != existing)) {
IResource resource= elem.getResource();
if (resource instanceof IContainer && !resource.equals(existing)) {
res.add(resource.getFullPath());
}
}
}
return (IPath[]) res.toArray(new IPath[res.size()]);
}
private IPath[] getUsedJARFiles(CPListElement existing) {
List res= new ArrayList();
List cplist= fLibrariesList.getElements();
for (int i= 0; i < cplist.size(); i++) {
CPListElement elem= (CPListElement)cplist.get(i);
if (elem.getEntryKind() == IClasspathEntry.CPE_LIBRARY && (elem != existing)) {
IResource resource= elem.getResource();
if (resource instanceof IFile) {
res.add(resource.getFullPath());
}
}
}
return (IPath[]) res.toArray(new IPath[res.size()]);
}
private CPListElement newCPLibraryElement(IResource res) {
return new CPListElement(fCurrJProject, IClasspathEntry.CPE_LIBRARY, res.getFullPath(), res);
}
private CPListElement[] openExtJarFileDialog(CPListElement existing) {
if (existing == null) {
IPath[] selected= BuildPathDialogAccess.chooseExternalJAREntries(getShell());
if (selected != null) {
ArrayList res= new ArrayList();
for (int i= 0; i < selected.length; i++) {
res.add(new CPListElement(fCurrJProject, IClasspathEntry.CPE_LIBRARY, selected[i], null));
}
return (CPListElement[]) res.toArray(new CPListElement[res.size()]);
}
} else {
IPath configured= BuildPathDialogAccess.configureExternalJAREntry(getShell(), existing.getPath());
if (configured != null) {
return new CPListElement[] { new CPListElement(fCurrJProject, IClasspathEntry.CPE_LIBRARY, configured, null) };
}
}
return null;
}
private CPListElement[] openVariableSelectionDialog(CPListElement existing) {
List existingElements= fLibrariesList.getElements();
ArrayList existingPaths= new ArrayList(existingElements.size());
for (int i= 0; i < existingElements.size(); i++) {
CPListElement elem= (CPListElement) existingElements.get(i);
if (elem.getEntryKind() == IClasspathEntry.CPE_VARIABLE) {
existingPaths.add(elem.getPath());
}
}
IPath[] existingPathsArray= (IPath[]) existingPaths.toArray(new IPath[existingPaths.size()]);
if (existing == null) {
IPath[] paths= BuildPathDialogAccess.chooseVariableEntries(getShell(), existingPathsArray);
if (paths != null) {
ArrayList result= new ArrayList();
for (int i = 0; i < paths.length; i++) {
CPListElement elem= new CPListElement(fCurrJProject, IClasspathEntry.CPE_VARIABLE, paths[i], null);
IPath resolvedPath= JavaCore.getResolvedVariablePath(paths[i]);
elem.setIsMissing((resolvedPath == null) || !resolvedPath.toFile().exists());
if (!existingElements.contains(elem)) {
result.add(elem);
}
}
return (CPListElement[]) result.toArray(new CPListElement[result.size()]);
}
} else {
IPath path= BuildPathDialogAccess.configureVariableEntry(getShell(), existing.getPath(), existingPathsArray);
if (path != null) {
CPListElement elem= new CPListElement(fCurrJProject, IClasspathEntry.CPE_VARIABLE, path, null);
return new CPListElement[] { elem };
}
}
return null;
}
private CPListElement[] openContainerSelectionDialog(CPListElement existing) {
if (existing == null) {
IClasspathEntry[] created= BuildPathDialogAccess.chooseContainerEntries(getShell(), fCurrJProject, getRawClasspath());
if (created != null) {
CPListElement[] res= new CPListElement[created.length];
for (int i= 0; i < res.length; i++) {
res[i]= new CPListElement(fCurrJProject, IClasspathEntry.CPE_CONTAINER, created[i].getPath(), null);
}
return res;
}
} else {
IClasspathEntry created= BuildPathDialogAccess.configureContainerEntry(getShell(), existing.getClasspathEntry(), fCurrJProject, getRawClasspath());
if (created != null) {
CPListElement elem= new CPListElement(fCurrJProject, IClasspathEntry.CPE_CONTAINER, created.getPath(), null);
return new CPListElement[] { elem };
}
}
return null;
}
private IClasspathEntry[] getRawClasspath() {
IClasspathEntry[] currEntries= new IClasspathEntry[fClassPathList.getSize()];
for (int i= 0; i < currEntries.length; i++) {
CPListElement curr= (CPListElement) fClassPathList.getElement(i);
currEntries[i]= curr.getClasspathEntry();
}
return currEntries;
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathBasePage#isEntryKind(int)
*/
public boolean isEntryKind(int kind) {
return kind == IClasspathEntry.CPE_LIBRARY || kind == IClasspathEntry.CPE_VARIABLE || kind == IClasspathEntry.CPE_CONTAINER;
}
/*
* @see BuildPathBasePage#getSelection
*/
public List getSelection() {
return fLibrariesList.getSelectedElements();
}
/*
* @see BuildPathBasePage#setSelection
*/
public void setSelection(List selElements) {
fLibrariesList.selectElements(new StructuredSelection(selElements));
}
}
|
64,418
|
Bug 64418 [refactor] Change method signature causes InvocationTargetException
|
Version 3.0.m9. The InvocationTargetException is at the end of this post. I have a method: public void testBigDecimalConverter(BigDecimal expected) throws ModelIOException, ParseException { CobolRecordDefinition rec = this.getTestUtil().getTmDataRecordDefinition(); CobolComp3FieldDefinition data3 = this.getTestUtil().getData3Field(rec); CobolComp3FieldDefinition data4 = this.getTestUtil().getData3Field(rec); CobolRecordBuffer buffer = new CobolRecordBuffer(rec.getLength()); byte[] bytes = buffer.getBuffer(); buffer.setComp3(expected, 0, data3.getItemLength(), data3.getScale(), data3.isSigned()); Assert.assertEquals(expected, buffer.getComp3BigDecimal(0, data3.getItemLength(), data3.getScale())); buffer.setComp3(expected, 4, data4.getItemLength(), data4.getScale(), data4.isSigned()); Assert.assertEquals(expected, buffer.getComp3BigDecimal(0, data3.getItemLength(), data3.getScale())); Assert.assertEquals(expected, buffer.getComp3BigDecimal(4, data4.getItemLength(), data4.getScale())); } I invoke Change Method Signature and add a parameter: boolean dumpBuffer. There are 3 call sites: public void testBigDecimal_88_00_Converter() throws ModelIOException, ParseException { this.testBigDecimalConverter(BigDecimal.valueOf(8800, 2)); } public void testBigDecimalConverter1() throws ModelIOException, ParseException { for (long i = 0; i < 80; i++) { this.testBigDecimalConverter(BigDecimal.valueOf(i * 100, 2)); } } public void testBigDecimalConverter2() throws ModelIOException, ParseException { for (long i = 90; i < 100; i++) { this.testBigDecimalConverter(BigDecimal.valueOf(i * 100, 2)); } } Click Preview or OK: !ENTRY org.eclipse.ltk.ui.refactoring 4 10000 May 27, 2004 11:33:05.249 !MESSAGE Internal Error !STACK 0 java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:282) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.createChange(RefactoringWizard.java:559) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:405) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.computeSuccessorPage(UserInputWizardPage.java:74) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.getNextPage(UserInputWizardPage.java:114) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.previewPressed(RefactoringWizardDialog2.java :429) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.access$3(RefactoringWizardDialog2.java:427) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2$1.widgetSelected(RefactoringWizardDialog2.ja va:562) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.jface.window.Window.runEventLoop(Window.java:668) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.internal.ui.refactoring.UserInterfaceStarter.activate(UserInterfaceStarter.java:54) at org.eclipse.jdt.ui.actions.ModifyParametersAction$1.activate(ModifyParametersAction.java:249) at org.eclipse.jdt.ui.actions.ModifyParametersAction.startRefactoring(ModifyParametersAction.java:254) at org.eclipse.jdt.ui.actions.ModifyParametersAction.run(ModifyParametersAction.java:142) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.ui.actions.RetargetAction.runWithEvent(RetargetAction.java:212) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:211) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:141) at org.eclipse.ui.internal.commands.Command.execute(Command.java:132) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:469) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:887) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:928) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:546) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$2(WorkbenchKeyboard.java:494) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$1.handleEvent(WorkbenchKeyboard.java:259) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:712) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:795) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:820) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:805) at org.eclipse.swt.widgets.Control.traverse(Control.java:2704) at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:2545) at org.eclipse.swt.widgets.Composite.translateMnemonic(Composite.java:540) at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:2563) at org.eclipse.swt.widgets.Display.translateMnemonic(Display.java:3135) at org.eclipse.swt.widgets.Display.filterMessage(Display.java:726) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2378) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:253) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:97) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:307) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:256) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622) Caused by: java.lang.IllegalArgumentException: Node is not an existing node at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.validateIsInsideAST(ASTRewrite.java:364) at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.createTargetNode(ASTRewrite.java:427) at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.createMoveTarget(ASTRewrite.java:469) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring$OccurrenceUpdate.reshuffleEl ements(ChangeSignatureRefactoring.java:1183) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring$DeclarationUpdate.updateNode (ChangeSignatureRefactoring.java:1397) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring.createChangeManager(ChangeSi gnatureRefactoring.java:960) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring.checkFinalConditions(ChangeS ignatureRefactoring.java:571) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101) Root exception: java.lang.IllegalArgumentException: Node is not an existing node at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.validateIsInsideAST(ASTRewrite.java:364) at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.createTargetNode(ASTRewrite.java:427) at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.createMoveTarget(ASTRewrite.java:469) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring$OccurrenceUpdate.reshuffleEl ements(ChangeSignatureRefactoring.java:1183) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring$DeclarationUpdate.updateNode (ChangeSignatureRefactoring.java:1397) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring.createChangeManager(ChangeSi gnatureRefactoring.java:960) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring.checkFinalConditions(ChangeS ignatureRefactoring.java:571) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
|
verified fixed
|
a6d791d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-06-03T08:54:34Z
| 2004-05-27T17:46:40Z
|
org.eclipse.jdt.ui/core
| |
64,418
|
Bug 64418 [refactor] Change method signature causes InvocationTargetException
|
Version 3.0.m9. The InvocationTargetException is at the end of this post. I have a method: public void testBigDecimalConverter(BigDecimal expected) throws ModelIOException, ParseException { CobolRecordDefinition rec = this.getTestUtil().getTmDataRecordDefinition(); CobolComp3FieldDefinition data3 = this.getTestUtil().getData3Field(rec); CobolComp3FieldDefinition data4 = this.getTestUtil().getData3Field(rec); CobolRecordBuffer buffer = new CobolRecordBuffer(rec.getLength()); byte[] bytes = buffer.getBuffer(); buffer.setComp3(expected, 0, data3.getItemLength(), data3.getScale(), data3.isSigned()); Assert.assertEquals(expected, buffer.getComp3BigDecimal(0, data3.getItemLength(), data3.getScale())); buffer.setComp3(expected, 4, data4.getItemLength(), data4.getScale(), data4.isSigned()); Assert.assertEquals(expected, buffer.getComp3BigDecimal(0, data3.getItemLength(), data3.getScale())); Assert.assertEquals(expected, buffer.getComp3BigDecimal(4, data4.getItemLength(), data4.getScale())); } I invoke Change Method Signature and add a parameter: boolean dumpBuffer. There are 3 call sites: public void testBigDecimal_88_00_Converter() throws ModelIOException, ParseException { this.testBigDecimalConverter(BigDecimal.valueOf(8800, 2)); } public void testBigDecimalConverter1() throws ModelIOException, ParseException { for (long i = 0; i < 80; i++) { this.testBigDecimalConverter(BigDecimal.valueOf(i * 100, 2)); } } public void testBigDecimalConverter2() throws ModelIOException, ParseException { for (long i = 90; i < 100; i++) { this.testBigDecimalConverter(BigDecimal.valueOf(i * 100, 2)); } } Click Preview or OK: !ENTRY org.eclipse.ltk.ui.refactoring 4 10000 May 27, 2004 11:33:05.249 !MESSAGE Internal Error !STACK 0 java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:282) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.createChange(RefactoringWizard.java:559) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:405) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.computeSuccessorPage(UserInputWizardPage.java:74) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.getNextPage(UserInputWizardPage.java:114) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.previewPressed(RefactoringWizardDialog2.java :429) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.access$3(RefactoringWizardDialog2.java:427) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2$1.widgetSelected(RefactoringWizardDialog2.ja va:562) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.jface.window.Window.runEventLoop(Window.java:668) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.internal.ui.refactoring.UserInterfaceStarter.activate(UserInterfaceStarter.java:54) at org.eclipse.jdt.ui.actions.ModifyParametersAction$1.activate(ModifyParametersAction.java:249) at org.eclipse.jdt.ui.actions.ModifyParametersAction.startRefactoring(ModifyParametersAction.java:254) at org.eclipse.jdt.ui.actions.ModifyParametersAction.run(ModifyParametersAction.java:142) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.ui.actions.RetargetAction.runWithEvent(RetargetAction.java:212) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:211) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:141) at org.eclipse.ui.internal.commands.Command.execute(Command.java:132) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:469) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:887) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:928) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:546) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$2(WorkbenchKeyboard.java:494) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$1.handleEvent(WorkbenchKeyboard.java:259) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:712) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:795) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:820) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:805) at org.eclipse.swt.widgets.Control.traverse(Control.java:2704) at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:2545) at org.eclipse.swt.widgets.Composite.translateMnemonic(Composite.java:540) at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:2563) at org.eclipse.swt.widgets.Display.translateMnemonic(Display.java:3135) at org.eclipse.swt.widgets.Display.filterMessage(Display.java:726) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2378) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:253) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:97) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:307) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:256) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622) Caused by: java.lang.IllegalArgumentException: Node is not an existing node at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.validateIsInsideAST(ASTRewrite.java:364) at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.createTargetNode(ASTRewrite.java:427) at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.createMoveTarget(ASTRewrite.java:469) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring$OccurrenceUpdate.reshuffleEl ements(ChangeSignatureRefactoring.java:1183) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring$DeclarationUpdate.updateNode (ChangeSignatureRefactoring.java:1397) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring.createChangeManager(ChangeSi gnatureRefactoring.java:960) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring.checkFinalConditions(ChangeS ignatureRefactoring.java:571) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101) Root exception: java.lang.IllegalArgumentException: Node is not an existing node at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.validateIsInsideAST(ASTRewrite.java:364) at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.createTargetNode(ASTRewrite.java:427) at org.eclipse.jdt.core.dom.rewrite.ASTRewrite.createMoveTarget(ASTRewrite.java:469) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring$OccurrenceUpdate.reshuffleEl ements(ChangeSignatureRefactoring.java:1183) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring$DeclarationUpdate.updateNode (ChangeSignatureRefactoring.java:1397) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring.createChangeManager(ChangeSi gnatureRefactoring.java:960) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactoring.checkFinalConditions(ChangeS ignatureRefactoring.java:571) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1672) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
|
verified fixed
|
a6d791d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-06-03T08:54:34Z
| 2004-05-27T17:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeSignatureRefactoring.java
| |
64,634
|
Bug 64634 Navigate/Show in/Package Explorer doesn't work
|
With build I200405281200, if I select a Java file in the Navigator in the Java Perspective and then choose Navigate/Show in/Package Explorer, the Package Explorer is shown but the java file from the navigator is not visible or selected (i.e. the view doesn't expand the project or folder containing the java file).
|
verified fixed
|
64f2541
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-06-03T09:09:46Z
| 2004-05-28T21:33:20Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerPart.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.packageview;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaModel;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.IElementComparer;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.ITreeViewerListener;
import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeExpansionEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.part.ISetSelectionTarget;
import org.eclipse.ui.part.IShowInSource;
import org.eclipse.ui.part.IShowInTarget;
import org.eclipse.ui.part.IShowInTargetList;
import org.eclipse.ui.part.ResourceTransfer;
import org.eclipse.ui.part.ShowInContext;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.views.framelist.FrameAction;
import org.eclipse.ui.views.framelist.FrameList;
import org.eclipse.ui.views.framelist.IFrameSource;
import org.eclipse.ui.views.framelist.TreeFrame;
import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.dnd.DelegatingDropAdapter;
import org.eclipse.jdt.internal.ui.dnd.JdtViewerDragAdapter;
import org.eclipse.jdt.internal.ui.dnd.ResourceTransferDragAdapter;
import org.eclipse.jdt.internal.ui.dnd.TransferDragSourceListener;
import org.eclipse.jdt.internal.ui.dnd.TransferDropTargetListener;
import org.eclipse.jdt.internal.ui.filters.OutputFolderFilter;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput;
import org.eclipse.jdt.internal.ui.javaeditor.JarEntryEditorInput;
import org.eclipse.jdt.internal.ui.preferences.MembersOrderPreferenceCache;
import org.eclipse.jdt.internal.ui.util.JavaUIHelp;
import org.eclipse.jdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
import org.eclipse.jdt.internal.ui.viewsupport.DecoratingJavaLabelProvider;
import org.eclipse.jdt.internal.ui.viewsupport.FilterUpdater;
import org.eclipse.jdt.internal.ui.viewsupport.IViewPartInputProvider;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLabels;
import org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer;
import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater;
import org.eclipse.jdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
import org.eclipse.jdt.ui.IPackagesViewPart;
import org.eclipse.jdt.ui.JavaElementSorter;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.ui.StandardJavaElementContentProvider;
import org.eclipse.jdt.ui.actions.CustomFiltersActionGroup;
/**
* The ViewPart for the ProjectExplorer. It listens to part activation events.
* When selection linking with the editor is enabled the view selection tracks
* the active editor page. Similarly when a resource is selected in the packages
* view the corresponding editor is activated.
*/
public class PackageExplorerPart extends ViewPart
implements ISetSelectionTarget, IMenuListener,
IShowInTarget,
IPackagesViewPart, IPropertyChangeListener,
IViewPartInputProvider {
private boolean fIsCurrentLayoutFlat; // true means flat, false means hierachical
private static final int HIERARCHICAL_LAYOUT= 0x1;
private static final int FLAT_LAYOUT= 0x2;
public final static String VIEW_ID= JavaUI.ID_PACKAGES;
// Persistance tags.
static final String TAG_SELECTION= "selection"; //$NON-NLS-1$
static final String TAG_EXPANDED= "expanded"; //$NON-NLS-1$
static final String TAG_ELEMENT= "element"; //$NON-NLS-1$
static final String TAG_PATH= "path"; //$NON-NLS-1$
static final String TAG_VERTICAL_POSITION= "verticalPosition"; //$NON-NLS-1$
static final String TAG_HORIZONTAL_POSITION= "horizontalPosition"; //$NON-NLS-1$
static final String TAG_FILTERS = "filters"; //$NON-NLS-1$
static final String TAG_FILTER = "filter"; //$NON-NLS-1$
static final String TAG_LAYOUT= "layout"; //$NON-NLS-1$
static final String TAG_CURRENT_FRAME= "currentFramge"; //$NON-NLS-1$
private PackageExplorerContentProvider fContentProvider;
private FilterUpdater fFilterUpdater;
private PackageExplorerActionGroup fActionSet;
private ProblemTreeViewer fViewer;
private Menu fContextMenu;
private IMemento fMemento;
private ISelectionChangedListener fSelectionListener;
private String fWorkingSetName;
private IPartListener fPartListener= new IPartListener() {
public void partActivated(IWorkbenchPart part) {
if (part instanceof IEditorPart)
editorActivated((IEditorPart) part);
}
public void partBroughtToTop(IWorkbenchPart part) {
}
public void partClosed(IWorkbenchPart part) {
}
public void partDeactivated(IWorkbenchPart part) {
}
public void partOpened(IWorkbenchPart part) {
}
};
private ITreeViewerListener fExpansionListener= new ITreeViewerListener() {
public void treeCollapsed(TreeExpansionEvent event) {
}
public void treeExpanded(TreeExpansionEvent event) {
Object element= event.getElement();
if (element instanceof ICompilationUnit ||
element instanceof IClassFile)
expandMainType(element);
}
};
private class PackageExplorerProblemTreeViewer extends ProblemTreeViewer {
boolean fInChangeInput;
public PackageExplorerProblemTreeViewer(Composite parent, int style) {
super(parent, style);
}
protected void inputChanged(Object input, Object oldInput) {
fInChangeInput= true;
try {
super.inputChanged(input, oldInput);
} finally {
fInChangeInput= false;
}
}
public void add(Object parentElement, Object[] childElements) {
if (!fInChangeInput)
super.add(parentElement, childElements);
}
public void remove(Object[] elements) {
if (!fInChangeInput)
super.remove(elements);
}
public void refresh(Object element, boolean updateLabels) {
if (!fInChangeInput)
super.refresh(element, updateLabels);
}
/*
* @see org.eclipse.jface.viewers.StructuredViewer#filter(java.lang.Object)
*/
protected Object[] getFilteredChildren(Object parent) {
List list = new ArrayList();
ViewerFilter[] filters = fViewer.getFilters();
Object[] children = ((ITreeContentProvider) fViewer.getContentProvider()).getChildren(parent);
for (int i = 0; i < children.length; i++) {
Object object = children[i];
if (!isEssential(object)) {
object = filter(object, parent, filters);
if (object != null) {
list.add(object);
}
} else
list.add(object);
}
return list.toArray();
}
/*
* @see AbstractTreeViewer#isExpandable(java.lang.Object)
*/
public boolean isExpandable(Object parent) {
if (isFlatLayout())
return super.isExpandable(parent);
ViewerFilter[] filters= fViewer.getFilters();
Object[] children= ((ITreeContentProvider) fViewer.getContentProvider()).getChildren(parent);
for (int i = 0; i < children.length; i++) {
Object object= children[i];
if (isEssential(object))
return true;
object= filter(object, parent, filters);
if (object != null)
return true;
}
return false;
}
// Sends the object through the given filters
private Object filter(Object object, Object parent, ViewerFilter[] filters) {
for (int i = 0; i < filters.length; i++) {
ViewerFilter filter = filters[i];
if (!filter.select(fViewer, parent, object))
return null;
}
return object;
}
/*
* @see org.eclipse.jface.viewers.StructuredViewer#filter(java.lang.Object[])
* @since 3.0
*/
protected Object[] filter(Object[] elements) {
if (isFlatLayout())
return super.filter(elements);
ViewerFilter[] filters= getFilters();
if (filters == null || filters.length == 0)
return elements;
ArrayList filtered= new ArrayList(elements.length);
Object root= getRoot();
for (int i= 0; i < elements.length; i++) {
boolean add= true;
if (!isEssential(elements[i])) {
for (int j = 0; j < filters.length; j++) {
add= filters[j].select(this, root,
elements[i]);
if (!add)
break;
}
}
if (add)
filtered.add(elements[i]);
}
return filtered.toArray();
}
/* Checks if a filtered object in essential (ie. is a parent that
* should not be removed).
*/
private boolean isEssential(Object object) {
try {
if (!isFlatLayout() && object instanceof IPackageFragment) {
IPackageFragment fragment = (IPackageFragment) object;
return !fragment.isDefaultPackage() && fragment.hasSubpackages();
}
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
return false;
}
protected void handleInvalidSelection(ISelection invalidSelection, ISelection newSelection) {
IStructuredSelection is= (IStructuredSelection)invalidSelection;
List ns= null;
if (newSelection instanceof IStructuredSelection) {
ns= new ArrayList(((IStructuredSelection)newSelection).toList());
} else {
ns= new ArrayList();
}
boolean changed= false;
for (Iterator iter= is.iterator(); iter.hasNext();) {
Object element= iter.next();
if (element instanceof IJavaProject) {
IProject project= ((IJavaProject)element).getProject();
if (!project.isOpen()) {
ns.add(project);
changed= true;
}
} else if (element instanceof IProject) {
IProject project= (IProject)element;
if (project.isOpen()) {
IJavaProject jProject= JavaCore.create(project);
if (jProject != null && jProject.exists())
ns.add(jProject);
changed= true;
}
}
}
if (changed) {
newSelection= new StructuredSelection(ns);
setSelection(newSelection);
}
super.handleInvalidSelection(invalidSelection, newSelection);
}
}
private PackageExplorerLabelProvider fLabelProvider;
/* (non-Javadoc)
* Method declared on IViewPart.
*/
private boolean fLinkingEnabled;
public void init(IViewSite site, IMemento memento) throws PartInitException {
super.init(site, memento);
fMemento= memento;
restoreLayoutState(memento);
}
private void restoreLayoutState(IMemento memento) {
Integer state= null;
if (memento != null)
state= memento.getInteger(TAG_LAYOUT);
// If no memento try an restore from preference store
if(state == null) {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
state= new Integer(store.getInt(TAG_LAYOUT));
}
if (state.intValue() == FLAT_LAYOUT)
fIsCurrentLayoutFlat= true;
else if (state.intValue() == HIERARCHICAL_LAYOUT)
fIsCurrentLayoutFlat= false;
else
fIsCurrentLayoutFlat= true;
}
/**
* Returns the package explorer part of the active perspective. If
* there isn't any package explorer part <code>null</code> is returned.
*/
public static PackageExplorerPart getFromActivePerspective() {
IWorkbenchPage activePage= JavaPlugin.getActivePage();
if (activePage == null)
return null;
IViewPart view= activePage.findView(VIEW_ID);
if (view instanceof PackageExplorerPart)
return (PackageExplorerPart)view;
return null;
}
/**
* Makes the package explorer part visible in the active perspective. If there
* isn't a package explorer part registered <code>null</code> is returned.
* Otherwise the opened view part is returned.
*/
public static PackageExplorerPart openInActivePerspective() {
try {
return (PackageExplorerPart)JavaPlugin.getActivePage().showView(VIEW_ID);
} catch(PartInitException pe) {
return null;
}
}
public void dispose() {
if (fContextMenu != null && !fContextMenu.isDisposed())
fContextMenu.dispose();
getSite().getPage().removePartListener(fPartListener);
JavaPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
if (fViewer != null)
fViewer.removeTreeListener(fExpansionListener);
if (fActionSet != null)
fActionSet.dispose();
if (fFilterUpdater != null)
ResourcesPlugin.getWorkspace().removeResourceChangeListener(fFilterUpdater);
super.dispose();
}
/**
* Implementation of IWorkbenchPart.createPartControl(Composite)
*/
public void createPartControl(Composite parent) {
fViewer= createViewer(parent);
fViewer.setUseHashlookup(true);
if (!JavaPlugin.USE_WORKING_COPY_OWNERS) {
fViewer.setComparer(new PackageExplorerElementComparer());
}
initDragAndDrop();
setProviders();
JavaPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
MenuManager menuMgr= new MenuManager("#PopupMenu"); //$NON-NLS-1$
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(this);
fContextMenu= menuMgr.createContextMenu(fViewer.getTree());
fViewer.getTree().setMenu(fContextMenu);
// Register viewer with site. This must be done before making the actions.
IWorkbenchPartSite site= getSite();
site.registerContextMenu(menuMgr, fViewer);
site.setSelectionProvider(fViewer);
site.getPage().addPartListener(fPartListener);
if (fMemento != null) {
restoreLinkingEnabled(fMemento);
}
makeActions(); // call before registering for selection changes
// Set input after filter and sorter has been set. This avoids resorting and refiltering.
restoreFilterAndSorter();
fViewer.setInput(findInputElement());
initFrameActions();
initKeyListener();
fViewer.addPostSelectionChangedListener(fSelectionListener);
fViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
fActionSet.handleDoubleClick(event);
}
});
fViewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
fActionSet.handleOpen(event);
}
});
IStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager();
fViewer.addSelectionChangedListener(new StatusBarUpdater(slManager));
fViewer.addTreeListener(fExpansionListener);
if (fMemento != null)
restoreUIState(fMemento);
fMemento= null;
// Set help for the view
JavaUIHelp.setHelp(fViewer, IJavaHelpContextIds.PACKAGES_VIEW);
fillActionBars();
updateTitle();
fFilterUpdater= new FilterUpdater(fViewer);
ResourcesPlugin.getWorkspace().addResourceChangeListener(fFilterUpdater);
}
private void initFrameActions() {
fActionSet.getUpAction().update();
fActionSet.getBackAction().update();
fActionSet.getForwardAction().update();
}
/**
* This viewer ensures that non-leaves in the hierarchical
* layout are not removed by any filters.
*
* @since 2.1
*/
private ProblemTreeViewer createViewer(Composite composite) {
return new PackageExplorerProblemTreeViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
}
/**
* Answers whether this part shows the packages flat or hierarchical.
*
* @since 2.1
*/
boolean isFlatLayout() {
return fIsCurrentLayoutFlat;
}
private void setProviders() {
//content provider must be set before the label provider
fContentProvider= createContentProvider();
fContentProvider.setIsFlatLayout(fIsCurrentLayoutFlat);
fViewer.setContentProvider(fContentProvider);
fLabelProvider= createLabelProvider();
fLabelProvider.setIsFlatLayout(fIsCurrentLayoutFlat);
fViewer.setLabelProvider(new DecoratingJavaLabelProvider(fLabelProvider, false));
// problem decoration provided by PackageLabelProvider
}
void toggleLayout() {
// Update current state and inform content and label providers
fIsCurrentLayoutFlat= !fIsCurrentLayoutFlat;
saveLayoutState(null);
fContentProvider.setIsFlatLayout(isFlatLayout());
fLabelProvider.setIsFlatLayout(isFlatLayout());
fViewer.getControl().setRedraw(false);
fViewer.refresh();
fViewer.getControl().setRedraw(true);
}
/**
* This method should only be called inside this class
* and from test cases.
*/
public PackageExplorerContentProvider createContentProvider() {
IPreferenceStore store= PreferenceConstants.getPreferenceStore();
boolean showCUChildren= store.getBoolean(PreferenceConstants.SHOW_CU_CHILDREN);
return new PackageExplorerContentProvider(this, showCUChildren);
}
private PackageExplorerLabelProvider createLabelProvider() {
return new PackageExplorerLabelProvider(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaElementLabels.P_COMPRESSED,
AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | JavaElementImageProvider.SMALL_ICONS,
fContentProvider);
}
private void fillActionBars() {
IActionBars actionBars= getViewSite().getActionBars();
fActionSet.fillActionBars(actionBars);
}
private Object findInputElement() {
Object input= getSite().getPage().getInput();
if (input instanceof IWorkspace) {
return JavaCore.create(((IWorkspace)input).getRoot());
} else if (input instanceof IContainer) {
IJavaElement element= JavaCore.create((IContainer)input);
if (element != null && element.exists())
return element;
return input;
}
//1GERPRT: ITPJUI:ALL - Packages View is empty when shown in Type Hierarchy Perspective
// we can't handle the input
// fall back to show the workspace
return JavaCore.create(JavaPlugin.getWorkspace().getRoot());
}
/**
* Answer the property defined by key.
*/
public Object getAdapter(Class key) {
if (key.equals(ISelectionProvider.class))
return fViewer;
if (key == IShowInSource.class) {
return getShowInSource();
}
if (key == IShowInTargetList.class) {
return new IShowInTargetList() {
public String[] getShowInTargetIds() {
return new String[] { IPageLayout.ID_RES_NAV };
}
};
}
return super.getAdapter(key);
}
/**
* Returns the tool tip text for the given element.
*/
String getToolTipText(Object element) {
String result;
if (!(element instanceof IResource)) {
if (element instanceof IJavaModel)
result= PackagesMessages.getString("PackageExplorerPart.workspace"); //$NON-NLS-1$
else
result= JavaElementLabels.getTextLabel(element, AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS);
} else {
IPath path= ((IResource) element).getFullPath();
if (path.isRoot()) {
result= PackagesMessages.getString("PackageExplorer.title"); //$NON-NLS-1$
} else {
result= path.makeRelative().toString();
}
}
if (fWorkingSetName == null)
return result;
String wsstr= PackagesMessages.getFormattedString("PackageExplorer.toolTip", new String[] { fWorkingSetName }); //$NON-NLS-1$
if (result.length() == 0)
return wsstr;
return PackagesMessages.getFormattedString("PackageExplorer.toolTip2", new String[] { result, fWorkingSetName }); //$NON-NLS-1$
}
public String getTitleToolTip() {
if (fViewer == null)
return super.getTitleToolTip();
return getToolTipText(fViewer.getInput());
}
/**
* @see IWorkbenchPart#setFocus()
*/
public void setFocus() {
fViewer.getTree().setFocus();
}
/**
* Returns the current selection.
*/
private ISelection getSelection() {
return fViewer.getSelection();
}
//---- Action handling ----------------------------------------------------------
/**
* Called when the context menu is about to open. Override
* to add your own context dependent menu contributions.
*/
public void menuAboutToShow(IMenuManager menu) {
JavaPlugin.createStandardGroups(menu);
fActionSet.setContext(new ActionContext(getSelection()));
fActionSet.fillContextMenu(menu);
fActionSet.setContext(null);
}
private void makeActions() {
fActionSet= new PackageExplorerActionGroup(this);
}
//---- Event handling ----------------------------------------------------------
private void initDragAndDrop() {
initDrag();
initDrop();
}
private void initDrag() {
int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
Transfer[] transfers= new Transfer[] {
LocalSelectionTransfer.getInstance(),
ResourceTransfer.getInstance(),
FileTransfer.getInstance()};
TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
new SelectionTransferDragAdapter(fViewer),
new ResourceTransferDragAdapter(fViewer),
new FileTransferDragAdapter(fViewer)
};
fViewer.addDragSupport(ops, transfers, new JdtViewerDragAdapter(fViewer, dragListeners));
}
private void initDrop() {
int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK | DND.DROP_DEFAULT;
Transfer[] transfers= new Transfer[] {
LocalSelectionTransfer.getInstance(),
FileTransfer.getInstance()};
TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
new SelectionTransferDropAdapter(fViewer),
new FileTransferDropAdapter(fViewer)
};
fViewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners));
}
/**
* Handles selection changed in viewer.
* Updates global actions.
* Links to editor (if option enabled)
*/
private void handleSelectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection= (IStructuredSelection) event.getSelection();
fActionSet.handleSelectionChanged(event);
if (isLinkingEnabled())
linkToEditor(selection);
}
public void selectReveal(ISelection selection) {
selectReveal(selection, 0);
}
private void selectReveal(final ISelection selection, final int count) {
Control ctrl= getViewer().getControl();
if (ctrl == null || ctrl.isDisposed())
return;
ISelection javaSelection= convertSelection(selection);
fViewer.setSelection(javaSelection, true);
PackageExplorerContentProvider provider= (PackageExplorerContentProvider)getViewer().getContentProvider();
ISelection cs= fViewer.getSelection();
// If we have Pending changes and the element could not be selected then
// we try it again on more time by posting the select and reveal asynchronuoulsy
// to the event queue. See PR http://bugs.eclipse.org/bugs/show_bug.cgi?id=30700
// for a discussion of the underlying problem.
if (count == 0 && provider.hasPendingChanges() && !javaSelection.equals(cs)) {
ctrl.getDisplay().asyncExec(new Runnable() {
public void run() {
selectReveal(selection, count + 1);
}
});
}
}
private ISelection convertSelection(ISelection s) {
if (!(s instanceof IStructuredSelection))
return s;
Object[] elements= ((StructuredSelection)s).toArray();
if (!containsResources(elements))
return s;
for (int i= 0; i < elements.length; i++) {
Object o= elements[i];
if (!(o instanceof IJavaElement)) {
if (o instanceof IResource) {
IJavaElement jElement= JavaCore.create((IResource)o);
if (jElement != null && jElement.exists())
elements[i]= jElement;
}
else if (o instanceof IAdaptable) {
IResource r= (IResource)((IAdaptable)o).getAdapter(IResource.class);
if (r != null) {
IJavaElement jElement= JavaCore.create(r);
if (jElement != null && jElement.exists())
elements[i]= jElement;
else
elements[i]= r;
}
}
}
}
return new StructuredSelection(elements);
}
private boolean containsResources(Object[] elements) {
for (int i = 0; i < elements.length; i++) {
Object o= elements[i];
if (!(o instanceof IJavaElement)) {
if (o instanceof IResource)
return true;
if ((o instanceof IAdaptable) && ((IAdaptable)o).getAdapter(IResource.class) != null)
return true;
}
}
return false;
}
public void selectAndReveal(Object element) {
selectReveal(new StructuredSelection(element));
}
boolean isLinkingEnabled() {
return fLinkingEnabled;
}
/**
* Initializes the linking enabled setting from the preference store.
*/
private void initLinkingEnabled() {
fLinkingEnabled= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.LINK_PACKAGES_TO_EDITOR);
}
/**
* Links to editor (if option enabled)
*/
private void linkToEditor(IStructuredSelection selection) {
// ignore selection changes if the package explorer is not the active part.
// In this case the selection change isn't triggered by a user.
if (!isActivePart())
return;
Object obj= selection.getFirstElement();
if (selection.size() == 1) {
IEditorPart part= EditorUtility.isOpenInEditor(obj);
if (part != null) {
IWorkbenchPage page= getSite().getPage();
page.bringToTop(part);
if (obj instanceof IJavaElement)
EditorUtility.revealInEditor(part, (IJavaElement)obj);
}
}
}
private boolean isActivePart() {
return this == getSite().getPage().getActivePart();
}
public void saveState(IMemento memento) {
if (fViewer == null) {
// part has not been created
if (fMemento != null) //Keep the old state;
memento.putMemento(fMemento);
return;
}
// disable the persisting of state which can trigger expensive operations as
// a side effect: see bug 52474 and 53958
saveCurrentFrame(memento);
// saveExpansionState(memento);
// saveSelectionState(memento);
saveLayoutState(memento);
saveLinkingEnabled(memento);
// commented out because of http://bugs.eclipse.org/bugs/show_bug.cgi?id=4676
//saveScrollState(memento, fViewer.getTree());
fActionSet.saveFilterAndSorterState(memento);
}
private void saveCurrentFrame(IMemento memento) {
FrameAction action = fActionSet.getUpAction();
FrameList frameList= action.getFrameList();
if (frameList.getCurrentIndex() > 0) {
TreeFrame currentFrame = (TreeFrame) frameList.getCurrentFrame();
IMemento frameMemento = memento.createChild(TAG_CURRENT_FRAME);
currentFrame.saveState(frameMemento);
}
}
private void saveLinkingEnabled(IMemento memento) {
memento.putInteger(PreferenceConstants.LINK_PACKAGES_TO_EDITOR, fLinkingEnabled ? 1 : 0);
}
/**
* Saves the current layout state.
*
* @param memento the memento to save the state into or
* <code>null</code> to store the state in the preferences
* @since 2.1
*/
private void saveLayoutState(IMemento memento) {
if (memento != null) {
memento.putInteger(TAG_LAYOUT, getLayoutAsInt());
} else {
//if memento is null save in preference store
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
store.setValue(TAG_LAYOUT, getLayoutAsInt());
}
}
private int getLayoutAsInt() {
if (fIsCurrentLayoutFlat)
return FLAT_LAYOUT;
else
return HIERARCHICAL_LAYOUT;
}
protected void saveScrollState(IMemento memento, Tree tree) {
ScrollBar bar= tree.getVerticalBar();
int position= bar != null ? bar.getSelection() : 0;
memento.putString(TAG_VERTICAL_POSITION, String.valueOf(position));
//save horizontal position
bar= tree.getHorizontalBar();
position= bar != null ? bar.getSelection() : 0;
memento.putString(TAG_HORIZONTAL_POSITION, String.valueOf(position));
}
protected void saveSelectionState(IMemento memento) {
Object elements[]= ((IStructuredSelection) fViewer.getSelection()).toArray();
if (elements.length > 0) {
IMemento selectionMem= memento.createChild(TAG_SELECTION);
for (int i= 0; i < elements.length; i++) {
IMemento elementMem= selectionMem.createChild(TAG_ELEMENT);
// we can only persist JavaElements for now
Object o= elements[i];
if (o instanceof IJavaElement)
elementMem.putString(TAG_PATH, ((IJavaElement) elements[i]).getHandleIdentifier());
}
}
}
protected void saveExpansionState(IMemento memento) {
Object expandedElements[]= fViewer.getVisibleExpandedElements();
if (expandedElements.length > 0) {
IMemento expandedMem= memento.createChild(TAG_EXPANDED);
for (int i= 0; i < expandedElements.length; i++) {
IMemento elementMem= expandedMem.createChild(TAG_ELEMENT);
// we can only persist JavaElements for now
Object o= expandedElements[i];
if (o instanceof IJavaElement)
elementMem.putString(TAG_PATH, ((IJavaElement) expandedElements[i]).getHandleIdentifier());
}
}
}
private void restoreFilterAndSorter() {
fViewer.addFilter(new OutputFolderFilter());
fViewer.setSorter(new JavaElementSorter());
if (fMemento != null)
fActionSet.restoreFilterAndSorterState(fMemento);
}
private void restoreUIState(IMemento memento) {
// see comment in save state
restoreCurrentFrame(memento);
//restoreExpansionState(memento);
//restoreSelectionState(memento);
// commented out because of http://bugs.eclipse.org/bugs/show_bug.cgi?id=4676
//restoreScrollState(memento, fViewer.getTree());
}
private void restoreCurrentFrame(IMemento memento) {
IMemento frameMemento = memento.getChild(TAG_CURRENT_FRAME);
if (frameMemento != null) {
FrameAction action = fActionSet.getUpAction();
FrameList frameList= action.getFrameList();
TreeFrame frame = new TreeFrame(fViewer);
frame.restoreState(frameMemento);
frame.setName(getFrameName(frame.getInput()));
frame.setToolTipText(getToolTipText(frame.getInput()));
frameList.gotoFrame(frame);
}
}
private void restoreLinkingEnabled(IMemento memento) {
Integer val= memento.getInteger(PreferenceConstants.LINK_PACKAGES_TO_EDITOR);
if (val != null) {
fLinkingEnabled= val.intValue() != 0;
}
}
protected void restoreScrollState(IMemento memento, Tree tree) {
ScrollBar bar= tree.getVerticalBar();
if (bar != null) {
try {
String posStr= memento.getString(TAG_VERTICAL_POSITION);
int position;
position= new Integer(posStr).intValue();
bar.setSelection(position);
} catch (NumberFormatException e) {
// ignore, don't set scrollposition
}
}
bar= tree.getHorizontalBar();
if (bar != null) {
try {
String posStr= memento.getString(TAG_HORIZONTAL_POSITION);
int position;
position= new Integer(posStr).intValue();
bar.setSelection(position);
} catch (NumberFormatException e) {
// ignore don't set scroll position
}
}
}
protected void restoreSelectionState(IMemento memento) {
IMemento childMem;
childMem= memento.getChild(TAG_SELECTION);
if (childMem != null) {
ArrayList list= new ArrayList();
IMemento[] elementMem= childMem.getChildren(TAG_ELEMENT);
for (int i= 0; i < elementMem.length; i++) {
Object element= JavaCore.create(elementMem[i].getString(TAG_PATH));
if (element != null)
list.add(element);
}
fViewer.setSelection(new StructuredSelection(list));
}
}
protected void restoreExpansionState(IMemento memento) {
IMemento childMem= memento.getChild(TAG_EXPANDED);
if (childMem != null) {
ArrayList elements= new ArrayList();
IMemento[] elementMem= childMem.getChildren(TAG_ELEMENT);
for (int i= 0; i < elementMem.length; i++) {
Object element= JavaCore.create(elementMem[i].getString(TAG_PATH));
if (element != null)
elements.add(element);
}
fViewer.setExpandedElements(elements.toArray());
}
}
/**
* Create the KeyListener for doing the refresh on the viewer.
*/
private void initKeyListener() {
fViewer.getControl().addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent event) {
fActionSet.handleKeyEvent(event);
}
});
}
/**
* An editor has been activated. Set the selection in this Packages Viewer
* to be the editor's input, if linking is enabled.
*/
void editorActivated(IEditorPart editor) {
if (!isLinkingEnabled())
return;
Object input= getElementOfInput(editor.getEditorInput());
if (input == null)
return;
if (!inputIsSelected(editor.getEditorInput()))
showInput(input);
}
private boolean inputIsSelected(IEditorInput input) {
IStructuredSelection selection= (IStructuredSelection)fViewer.getSelection();
if (selection.size() != 1)
return false;
IEditorInput selectionAsInput= null;
try {
selectionAsInput= EditorUtility.getEditorInput(selection.getFirstElement());
} catch (JavaModelException e1) {
return false;
}
return input.equals(selectionAsInput);
}
boolean showInput(Object input) {
Object element= null;
if (input instanceof IFile && isOnClassPath((IFile)input)) {
element= JavaCore.create((IFile)input);
}
if (element == null) // try a non Java resource
element= input;
if (element != null) {
ISelection newSelection= new StructuredSelection(element);
if (fViewer.getSelection().equals(newSelection)) {
fViewer.reveal(element);
} else {
try {
fViewer.removeSelectionChangedListener(fSelectionListener);
fViewer.setSelection(newSelection, true);
while (element != null && fViewer.getSelection().isEmpty()) {
// Try to select parent in case element is filtered
element= getParent(element);
if (element != null) {
newSelection= new StructuredSelection(element);
fViewer.setSelection(newSelection, true);
}
}
} finally {
fViewer.addSelectionChangedListener(fSelectionListener);
}
}
return true;
}
return false;
}
private boolean isOnClassPath(IFile file) {
IJavaProject jproject= JavaCore.create(file.getProject());
return jproject.isOnClasspath(file);
}
/**
* Returns the element's parent.
*
* @return the parent or <code>null</code> if there's no parent
*/
private Object getParent(Object element) {
if (element instanceof IJavaElement)
return ((IJavaElement)element).getParent();
else if (element instanceof IResource)
return ((IResource)element).getParent();
// else if (element instanceof IStorage) {
// can't get parent - see bug 22376
// }
return null;
}
/**
* A compilation unit or class was expanded, expand
* the main type.
*/
void expandMainType(Object element) {
try {
IType type= null;
if (element instanceof ICompilationUnit) {
ICompilationUnit cu= (ICompilationUnit)element;
IType[] types= cu.getTypes();
if (types.length > 0)
type= types[0];
}
else if (element instanceof IClassFile) {
IClassFile cf= (IClassFile)element;
type= cf.getType();
}
if (type != null) {
final IType type2= type;
Control ctrl= fViewer.getControl();
if (ctrl != null && !ctrl.isDisposed()) {
ctrl.getDisplay().asyncExec(new Runnable() {
public void run() {
Control ctrl2= fViewer.getControl();
if (ctrl2 != null && !ctrl2.isDisposed())
fViewer.expandToLevel(type2, 1);
}
});
}
}
} catch(JavaModelException e) {
// no reveal
}
}
/**
* Returns the element contained in the EditorInput
*/
Object getElementOfInput(IEditorInput input) {
if (input instanceof IClassFileEditorInput)
return ((IClassFileEditorInput)input).getClassFile();
else if (input instanceof IFileEditorInput)
return ((IFileEditorInput)input).getFile();
else if (input instanceof JarEntryEditorInput)
return ((JarEntryEditorInput)input).getStorage();
return null;
}
/**
* Returns the Viewer.
*/
TreeViewer getViewer() {
return fViewer;
}
/**
* Returns the TreeViewer.
*/
public TreeViewer getTreeViewer() {
return fViewer;
}
boolean isExpandable(Object element) {
if (fViewer == null)
return false;
return fViewer.isExpandable(element);
}
void setWorkingSetName(String workingSetName) {
fWorkingSetName= workingSetName;
}
/**
* Updates the title text and title tool tip.
* Called whenever the input of the viewer changes.
*/
void updateTitle() {
Object input= fViewer.getInput();
String viewName= getConfigurationElement().getAttribute("name"); //$NON-NLS-1$
if (input == null
|| (input instanceof IJavaModel)) {
setTitle(viewName);
setTitleToolTip(""); //$NON-NLS-1$
} else {
String inputText= JavaElementLabels.getTextLabel(input, AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS);
String title= PackagesMessages.getFormattedString("PackageExplorer.argTitle", new String[] { viewName, inputText }); //$NON-NLS-1$
setTitle(title);
setTitleToolTip(getToolTipText(input));
}
}
/**
* Sets the decorator for the package explorer.
*
* @param decorator a label decorator or <code>null</code> for no decorations.
* @deprecated To be removed
*/
public void setLabelDecorator(ILabelDecorator decorator) {
}
/*
* @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
*/
public void propertyChange(PropertyChangeEvent event) {
if (fViewer == null)
return;
boolean refreshViewer= false;
if (PreferenceConstants.SHOW_CU_CHILDREN.equals(event.getProperty())) {
fActionSet.updateActionBars(getViewSite().getActionBars());
boolean showCUChildren= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.SHOW_CU_CHILDREN);
((StandardJavaElementContentProvider)fViewer.getContentProvider()).setProvideMembers(showCUChildren);
refreshViewer= true;
} else if (MembersOrderPreferenceCache.isMemberOrderProperty(event.getProperty())) {
refreshViewer= true;
}
if (refreshViewer)
fViewer.refresh();
}
/* (non-Javadoc)
* @see IViewPartInputProvider#getViewPartInput()
*/
public Object getViewPartInput() {
if (fViewer != null) {
return fViewer.getInput();
}
return null;
}
public void collapseAll() {
try {
fViewer.getControl().setRedraw(false);
fViewer.collapseToLevel(getViewPartInput(), AbstractTreeViewer.ALL_LEVELS);
} finally {
fViewer.getControl().setRedraw(true);
}
}
public PackageExplorerPart() {
initLinkingEnabled();
fSelectionListener= new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
handleSelectionChanged(event);
}
};
}
public boolean show(ShowInContext context) {
Object input= context.getInput();
if (input instanceof IEditorInput) {
Object elementOfInput= getElementOfInput((IEditorInput)context.getInput());
if (elementOfInput == null)
return false;
return tryToReveal(elementOfInput);
}
ISelection selection= context.getSelection();
if (selection != null) {
selectReveal(selection);
return true;
}
return false;
}
/**
* Returns the <code>IShowInSource</code> for this view.
*/
protected IShowInSource getShowInSource() {
return new IShowInSource() {
public ShowInContext getShowInContext() {
return new ShowInContext(
getViewer().getInput(),
getViewer().getSelection());
}
};
}
/*
* @see org.eclipse.ui.views.navigator.IResourceNavigator#setLinkingEnabled(boolean)
* @since 2.1
*/
public void setLinkingEnabled(boolean enabled) {
fLinkingEnabled= enabled;
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.LINK_PACKAGES_TO_EDITOR, enabled);
if (enabled) {
IEditorPart editor = getSite().getPage().getActiveEditor();
if (editor != null) {
editorActivated(editor);
}
}
}
/**
* Returns the name for the given element.
* Used as the name for the current frame.
*/
String getFrameName(Object element) {
if (element instanceof IJavaElement) {
return ((IJavaElement) element).getElementName();
} else {
return ((ILabelProvider) getTreeViewer().getLabelProvider()).getText(element);
}
}
void projectStateChanged(Object root) {
Control ctrl= fViewer.getControl();
if (ctrl != null && !ctrl.isDisposed()) {
fViewer.refresh(root, true);
// trigger a syntetic selection change so that action refresh their
// enable state.
fViewer.setSelection(fViewer.getSelection());
}
}
public boolean tryToReveal(Object element) {
if (revealElementOrParent(element))
return true;
WorkingSetFilterActionGroup workingSetGroup = fActionSet.getWorkingSetActionGroup();
IWorkingSet workingSet = workingSetGroup.getWorkingSet();
if (workingSetGroup.isFiltered(getVisibleParent(element), element)) {
String message= PackagesMessages.getFormattedString("PackageExplorer.notFound", workingSet.getName()); //$NON-NLS-1$
if (MessageDialog.openQuestion(getSite().getShell(), PackagesMessages.getString("PackageExplorer.filteredDialog.title"), message)) { //$NON-NLS-1$
workingSetGroup.setWorkingSet(null, true);
if (revealElementOrParent(element))
return true;
}
}
// try to remove filters
CustomFiltersActionGroup filterGroup = fActionSet.getCustomFilterActionGroup();
String[] filters= filterGroup.removeFiltersFor(getVisibleParent(element), element, getTreeViewer().getContentProvider());
if (filters.length > 0) {
String message= PackagesMessages.getString("PackageExplorer.removeFilters"); //$NON-NLS-1$
if (MessageDialog.openQuestion(getSite().getShell(), PackagesMessages.getString("PackageExplorer.filteredDialog.title"), message)) { //$NON-NLS-1$
filterGroup.setFilters(filters);
if (revealElementOrParent(element))
return true;
}
}
FrameAction action = fActionSet.getUpAction();
while (action.getFrameList().getCurrentIndex() > 0) {
// only try to go up if there is a parent frame
// fix for bug# 63769 Endless loop after Show in Package Explorer
if (action.getFrameList().getSource().getFrame(IFrameSource.PARENT_FRAME, 0) == null)
break;
action.run();
if (revealElementOrParent(element))
return true;
}
return false;
}
private boolean revealElementOrParent(Object element) {
if (revealAndVerify(element))
return true;
element= getVisibleParent(element);
if (element != null) {
if (revealAndVerify(element))
return true;
if (element instanceof IJavaElement) {
IResource resource= ((IJavaElement)element).getResource();
if (resource != null) {
if (revealAndVerify(resource))
return true;
}
}
}
return false;
}
private Object getVisibleParent(Object object) {
// Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=19104
if (object == null)
return null;
if (!(object instanceof IJavaElement))
return object;
IJavaElement element2= (IJavaElement) object;
switch (element2.getElementType()) {
case IJavaElement.IMPORT_DECLARATION:
case IJavaElement.PACKAGE_DECLARATION:
case IJavaElement.IMPORT_CONTAINER:
case IJavaElement.TYPE:
case IJavaElement.METHOD:
case IJavaElement.FIELD:
case IJavaElement.INITIALIZER:
// select parent cu/classfile
element2= (IJavaElement)element2.getOpenable();
break;
case IJavaElement.JAVA_MODEL:
element2= null;
break;
}
if (element2.getElementType() == IJavaElement.COMPILATION_UNIT) {
element2= JavaModelUtil.toOriginal((ICompilationUnit)element2);
}
return element2;
}
private boolean revealAndVerify(Object element) {
if (element == null)
return false;
selectReveal(new StructuredSelection(element));
IElementComparer comparer= getTreeViewer().getComparer();
Object selected= ((IStructuredSelection)getSite().getSelectionProvider().getSelection()).getFirstElement();
if (comparer != null ? comparer.equals(element, selected) : element.equals(selected))
return true;
return false;
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.