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
c48baf0d
Commit
c48baf0d
authored
6 years ago
by
Tagir Valeev
1
Browse files
Options
Download
Email Patches
Plain Diff
IDEA-208497 Magic constant inspection shows warning for xor
parent
d3e23bbb
Branches unavailable
Tags unavailable
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicConstantInspection.java
+2
-1
...codeInspection/magicConstant/MagicConstantInspection.java
java/java-tests/testData/inspection/magic/Simple.java
+1
-0
java/java-tests/testData/inspection/magic/Simple.java
with
3 additions
and
1 deletion
+3
-1
java/java-impl/src/com/intellij/codeInspection/magicConstant/MagicConstantInspection.java
+
2
-
1
View file @
c48baf0d
...
...
@@ -695,7 +695,8 @@ public class MagicConstantInspection extends AbstractBaseJavaLocalInspectionTool
if
(
same
(
expression
,
minusOne
,
manager
))
return
true
;
if
(
expression
instanceof
PsiPolyadicExpression
)
{
IElementType
tokenType
=
((
PsiPolyadicExpression
)
expression
).
getOperationTokenType
();
if
(
JavaTokenType
.
OR
.
equals
(
tokenType
)
||
JavaTokenType
.
AND
.
equals
(
tokenType
)
||
JavaTokenType
.
PLUS
.
equals
(
tokenType
))
{
if
(
JavaTokenType
.
OR
.
equals
(
tokenType
)
||
JavaTokenType
.
XOR
.
equals
(
tokenType
)
||
JavaTokenType
.
AND
.
equals
(
tokenType
)
||
JavaTokenType
.
PLUS
.
equals
(
tokenType
))
{
for
(
PsiExpression
operand
:
((
PsiPolyadicExpression
)
expression
).
getOperands
())
{
if
(!
isAllowed
(
operand
,
scope
,
allowedValues
,
manager
,
visited
))
return
false
;
}
...
...
This diff is collapsed.
Click to expand it.
java/java-tests/testData/inspection/magic/Simple.java
+
1
-
0
View file @
c48baf0d
...
...
@@ -266,5 +266,6 @@ public class X {
void
font
(
@MagicConstant
(
flags
=
{
FontType
.
PLAIN
,
FontType
.
BOLD
,
FontType
.
ITALIC
})
int
x
)
{
// 0 is not allowed despite the fact that it's flags parameter
font
(<
warning
descr
=
"Should be one of: FontType.PLAIN, FontType.BOLD, FontType.ITALIC or their combination"
>
0
</
warning
>);
font
(
x
^
FontType
.
BOLD
);
}
}
This diff is collapsed.
Click to expand it.
小 白蛋
@baidan
mentioned in commit
f37bbf96
·
2 years ago
mentioned in commit
f37bbf96
mentioned in commit f37bbf96a43d65bd0078967ad1bbe8a45a4d8586
Toggle commit list
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