Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
5042b9f5
Commit
5042b9f5
authored
7 years ago
by
Anna.Kozlova
Browse files
Options
Download
Email Patches
Plain Diff
wrap return value: check accessibility & navigational elements
IDEA-189391
parent
ff83d64f
Branches unavailable
Tags unavailable
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueProcessor.java
+11
-7
...refactoring/wrapreturnvalue/WrapReturnValueProcessor.java
with
11 additions
and
7 deletions
+11
-7
java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueProcessor.java
+
11
-
7
View file @
5042b9f5
...
...
@@ -183,12 +183,16 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
@Override
protected
boolean
preprocessUsages
(
@NotNull
final
Ref
<
UsageInfo
[]>
refUsages
)
{
MultiMap
<
PsiElement
,
String
>
conflicts
=
new
MultiMap
<>();
final
PsiClass
existingClass
=
JavaPsiFacade
.
getInstance
(
myProject
).
findClass
(
myQualifiedName
,
GlobalSearchScope
.
allScope
(
myProject
));
PsiClass
existingClass
=
JavaPsiFacade
.
getInstance
(
myProject
).
findClass
(
myQualifiedName
,
GlobalSearchScope
.
allScope
(
myProject
));
if
(
myUseExistingClass
)
{
if
(
existingClass
==
null
)
{
conflicts
.
putValue
(
null
,
RefactorJBundle
.
message
(
"could.not.find.selected.wrapping.class"
));
}
else
{
PsiElement
navigationElement
=
existingClass
.
getNavigationElement
();
if
(
navigationElement
instanceof
PsiClass
)
{
existingClass
=
(
PsiClass
)
navigationElement
;
}
boolean
foundConstructor
=
false
;
final
Set
<
PsiType
>
returnTypes
=
new
HashSet
<>();
returnTypes
.
add
(
myMethod
.
getReturnType
());
...
...
@@ -222,19 +226,19 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
continue
constr
;
}
}
if
(!
PsiUtil
.
isAccessible
(
constructor
,
myMethod
,
null
))
{
continue
constr
;
}
final
PsiCodeBlock
body
=
constructor
.
getBody
();
LOG
.
assertTrue
(
body
!
=
null
);
if
(
body
=
=
null
)
continue
constr
;
final
boolean
[]
found
=
new
boolean
[
1
];
body
.
accept
(
new
JavaRecursiveElementWalkingVisitor
()
{
@Override
public
void
visitAssignmentExpression
(
final
PsiAssignmentExpression
expression
)
{
super
.
visitAssignmentExpression
(
expression
);
final
PsiExpression
lExpression
=
expression
.
getLExpression
();
if
(
lExpression
instanceof
PsiReferenceExpression
&&
((
PsiReferenceExpression
)
lExpression
).
resolve
()
==
myDelegateField
)
{
final
PsiExpression
rExpression
=
expression
.
getRExpression
();
if
(
rExpression
instanceof
PsiReferenceExpression
&&
((
PsiReferenceExpression
)
rExpression
).
resolve
()
==
parameter
)
{
found
[
0
]
=
true
;
}
if
(
lExpression
instanceof
PsiReferenceExpression
&&
myDelegateField
.
isEquivalentTo
(((
PsiReferenceExpression
)
lExpression
).
resolve
()))
{
found
[
0
]
=
true
;
}
}
});
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help