Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
82fa8efa
Commit
82fa8efa
authored
7 years ago
by
Anna.Kozlova
Browse files
Options
Download
Email Patches
Plain Diff
unused assignment: respect report initialization setting in fields (IDEA-183162)
parent
32736f15
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
java/java-analysis-impl/src/com/intellij/codeInspection/defUse/DefUseInspectionBase.java
+3
-1
.../intellij/codeInspection/defUse/DefUseInspectionBase.java
java/java-tests/testData/inspection/defUse/FieldIgnoringRedundantInitializer.java
+3
-0
.../inspection/defUse/FieldIgnoringRedundantInitializer.java
java/java-tests/testSrc/com/intellij/java/codeInspection/DefUseTest.java
+6
-0
.../testSrc/com/intellij/java/codeInspection/DefUseTest.java
with
12 additions
and
1 deletion
+12
-1
java/java-analysis-impl/src/com/intellij/codeInspection/defUse/DefUseInspectionBase.java
+
3
-
1
View file @
82fa8efa
...
...
@@ -158,7 +158,9 @@ public class DefUseInspectionBase extends AbstractBaseJavaLocalInspectionTool {
for
(
final
FieldWrite
fieldWrite
:
fieldWrites
)
{
if
(
wasDefinitelyAssigned
)
{
if
(
fieldWrite
.
isInitializer
())
{
reportInitializerProblem
(
field
,
holder
,
isOnTheFly
);
if
(
REPORT_REDUNDANT_INITIALIZER
)
{
reportInitializerProblem
(
field
,
holder
,
isOnTheFly
);
}
}
else
{
for
(
PsiAssignmentExpression
assignment
:
fieldWrite
.
getAssignments
())
{
...
...
This diff is collapsed.
Click to expand it.
java/java-tests/testData/inspection/defUse/FieldIgnoringRedundantInitializer.java
0 → 100644
+
3
-
0
View file @
82fa8efa
class
C
{
private
String
str
=
null
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
java/java-tests/testSrc/com/intellij/java/codeInspection/DefUseTest.java
+
6
-
0
View file @
82fa8efa
...
...
@@ -57,6 +57,12 @@ public class DefUseTest extends LightCodeInsightFixtureTestCase {
public
void
testNestedTryFinallyInEndlessLoop
()
{
doTest
();
}
public
void
testNestedTryFinallyInForLoop
()
{
doTest
();
}
public
void
testFieldInitializer
()
{
doTest
();
}
public
void
testFieldIgnoringRedundantInitializer
()
{
DefUseInspection
inspection
=
new
DefUseInspection
();
inspection
.
REPORT_REDUNDANT_INITIALIZER
=
false
;
myFixture
.
enableInspections
(
inspection
);
myFixture
.
testHighlighting
(
getTestName
(
false
)
+
".java"
);
}
private
void
doTest
()
{
myFixture
.
enableInspections
(
new
DefUseInspection
());
...
...
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