Commit Graph

10307 Commits

Author SHA1 Message Date
Anna Kozlova
4b7f896333 [java highlighting] skip anonymous class context for its expression list (IDEA-272378)
GitOrigin-RevId: 5d8e034a4c550aed057ad860bdbaf1645118e5b3
2021-06-30 14:01:18 +00:00
Anna Kozlova
9746172003 [java] support java 16+ external documentation format (IDEA-272488)
GitOrigin-RevId: 33b65d2f06e791b5c2be2735d738c0ba5c8e3972
2021-06-30 14:01:15 +00:00
Roman Ivanov
d16221be29 [java] guard pattern formatting : IDEA-272657
GitOrigin-RevId: 33ddf8ed8d257359edf40d12e950458504dc2eb1
2021-06-29 20:28:24 +00:00
Ilyas Selimov
dcae1753d1 IDEA-270438 - fixed selector type restrictions
GitOrigin-RevId: 826ebda6866b822783d1611b7f44116f5e3d5f8f
2021-06-29 12:34:22 +00:00
Ilyas Selimov
a508d00a25 IDEA-270438 - fixed totality for arrays
GitOrigin-RevId: 991b05698d1fe95155986e6669e60d46c713b588
2021-06-28 12:14:26 +00:00
Ilyas Selimov
85ec7337d1 IDEA-270438 - fixed assignability in switch, added check for selector types
GitOrigin-RevId: 810891b03c0f6274ddc60225ec9e6079405e639c
2021-06-28 12:14:22 +00:00
Alexandr Suhinin
871df6878a IDEA-271869 convert pattern switch to enhanced switch
GitOrigin-RevId: d7be3df6093a835e75491fb9eeafbdf7f9265b32
2021-06-28 07:06:00 +00:00
Ilyas Selimov
9909791f3f IDEA-270438 - fixed completeness for enums
GitOrigin-RevId: 74b104129dea327095c7dfbbb44e2ad11eeb6d98
2021-06-28 06:43:26 +00:00
Tagir Valeev
1c0decab4f [java-dfa] Fix TypeConstraints#superTypes() if superclass is type-parameter (compilation error)
Fixes EA-319642 - AE: TypeConstraints$ExactClass.<init>

GitOrigin-RevId: 311f8f508dec12cd20b836e9948328495aa21fec
2021-06-28 06:06:58 +00:00
Ilyas Selimov
7fa76d8c9c IDEA-270438 - fixed completeness and tests
GitOrigin-RevId: 6e920fc66d916e9bf9f7795eaf426c7ec3532b4d
2021-06-27 13:59:32 +00:00
Ilyas Selimov
5ad49432ce IDEA-270438 - removed duplicates, refactoring, misc fixes
GitOrigin-RevId: 0e6b3bf43f3caa3245c03db339700971534616b2
2021-06-27 13:46:02 +00:00
Anna Kozlova
28370b2513 [java] [introduce variable] fix for very broken code
GitOrigin-RevId: beec9f6d8024571c78b24fc93f05f70cf1f8a2db
2021-06-25 15:33:54 +00:00
Tagir Valeev
7427f881fd [java-analysis] NullableNotNullManager: prefer type annotation over inherited annotation
Fixes IDEA-272250 False-positive warning when overridden method has a nullability type annotation

GitOrigin-RevId: a05ae5bdad95e475ac8a2af7736bcafc0e008364
2021-06-25 11:42:21 +00:00
Tagir Valeev
3ca2ad32e0 [java-dfa] DfaBinOpValue: math during backpropagation should be done within the required type
Otherwise, we can get the wrong number due to non-processed overflow when negating (for x-Integer.MIN_VALUE) or when collapsing two bin-ops into one
Fixes EA-290247 - IAE: DfaBinOpValue.<init>

GitOrigin-RevId: 2390830de3b91fb0f6390b75558e565e4fc73a45
2021-06-25 11:42:16 +00:00
Tagir Valeev
61bf6f49a8 [java-analysis] Eclipse annotations: TYPE_BOUND/TYPE_ARGUMENT targets should not apply to mixed places like FIELD+TYPE_USE
Fixes IDEA-272286 org.eclipse.jdt.annotation.NonNullByDefault should not add @NonNull to Local variables

GitOrigin-RevId: a9c8f21ea5e50ef4696d2c98e5a0b01e40dd1797
2021-06-25 11:42:13 +00:00
Anna Kozlova
921d49d3e0 [java] ensure arg wrapper is not available for mutual use when it can't work for some argument
GitOrigin-RevId: 87bbf922fb4ea9a0127aa5d653b2d799f0056c09
2021-06-25 08:46:15 +00:00
Ilyas Selimov
b6c313031d IDEA-270438 - completeness for sealed types and plain classes
GitOrigin-RevId: 0aa0559c6186bac92cf36b20d896000a0a64964e
2021-06-24 14:39:32 +00:00
Ilyas Selimov
4ef6b0a83d IDEA-270438 - initial completeness for enums
GitOrigin-RevId: 0dc7e2291065f7048317ed827ad47b287fef6568
2021-06-23 18:00:53 +00:00
Anna Kozlova
4966aa2d3c [global inspections] accept top level functions
GitOrigin-RevId: 73b321f756acc62383b7bdd889db278a42ea13a1
2021-06-23 13:19:43 +00:00
Anna Kozlova
4ded64a93c [unused parameters] be prepared that overriding method may have more parameters
GitOrigin-RevId: d8a1ecd496df41749d859ba5fafdf33cb0786de5
2021-06-23 13:19:40 +00:00
Artemiy Sartakov
00d140041a MemberModel: remove test with slash in name
GitOrigin-RevId: f5d8b68d98a9f6b8728b5eb8cc85b7ac612f3ac6
2021-06-23 10:48:33 +00:00
Ilyas Selimov
6ac057e620 IDEA-270438 - initial highlighting for switch patterns
Includes dominance, fall-through rules, completeness doesn't work, new quick fixes doesn't exist

GitOrigin-RevId: dcdd00ee8204fac5d9d172f5e71281887645cccd
2021-06-23 10:21:25 +00:00
Artemiy Sartakov
0edb49570e MemberModel: do not report when filename is not a proper identifier
GitOrigin-RevId: 526379531fdf35391a01ae13b995c3b12e21cb6b
2021-06-23 10:07:16 +00:00
Roman Ivanov
895ba21929 [java] better parser recovery when param list ends with ;
IDEA-270332

GitOrigin-RevId: ffbb52c67373a7af7c63bdca568d0c2a5b5286f6
2021-06-23 09:20:30 +00:00
Tagir Valeev
8e242ccfca [java-dfa] Find the cause: cosmetic changes in messages
GitOrigin-RevId: 01b45074f9c8adc03bc788958ecba2fde134e55d
2021-06-23 04:51:46 +00:00
Tagir Valeev
e102808d58 [java-inspections] IDEA-272016 Find the cause cannot explain why 'environmentStr.equalsIgnoreCase("rpt")' is always 'false'
Also, improved explanations in other cases

GitOrigin-RevId: de42850d4fa2e17c2c2ee0c30bbf5df22c988fa6
2021-06-23 04:51:44 +00:00
Nikita Eshkeev
0e5e22a101 [java][resolve] IDEA-271676 Pattern matching for switch: fix resolve
Fix the resolution algorithm for both switch statements and switch expressions. The main obstacle is that the handler of a case expression is a child node of the labeled case rule and the handler of a case statement is the right sibling of the labeled case rule.

The fact that a case handler is the right sibling of a labeled case rule in switch statements complicates the resolving, because the scope of a pattern variable is bound only to the immediate case handler and cannot be accessible from different case handler, which might be invoked when there is no `break` statements between case rules. In order to restrict the scope of a pattern variable in a switch statement the following check is added: check if the analyzed PsiSwitchLabeledStatement is not followed by any other case rules and if so try to resolve an element using its pattern variables.

The scope of pattern variables for PsiSwitchLabeledRuleStatements is restricted only to their case handlers, so the resolve works there only if the lastParent is not null, which, according to the contract, contains the case's handler.

Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>

GitOrigin-RevId: 084b8b679b4070a67a996c3b50992622025d96ee
2021-06-23 00:33:25 +00:00
Andrey.Cherkasov
b2cbfec46a Add javadoc and support for long constant for JavaPsiMathUti.getRangeFromComparison
GitOrigin-RevId: 87d9703aa0c1c704d02c8590dadfb40354513706
2021-06-22 19:51:51 +00:00
Andrey.Cherkasov
16c77ee931 Add test case for the SimplifyStreamApiCallChainsInspectionFixTest
GitOrigin-RevId: aa076ded2e9a1506288e0798c2031e913819a927
2021-06-22 19:51:50 +00:00
Andrey.Cherkasov
cbe208fba4 [java-inspections] fixes after review IDEA-259667
GitOrigin-RevId: b5a4e5b12fa88af4c237d035713897eff7b8cf1e
2021-06-22 19:51:48 +00:00
Anna Kozlova
f803857dc1 [java] add cast fix when multiple arguments require fix simultaneously (IDEA-271993)
GitOrigin-RevId: 2f6dc7ed7341c851b56a80a9b6404678ac0da0b9
2021-06-22 19:26:14 +00:00
Roman Ivanov
4732cc18f6 [java] do not suggest to replace switch statement with label
IDEA-226169, IDEA-271705

GitOrigin-RevId: 194aa32a4d824970b8823b30c5f32a6c22b8f867
2021-06-22 17:11:09 +00:00
Anna Kozlova
c4d12028ea [java highlighting] check switch expressions assignability (IDEA-271947)
GitOrigin-RevId: 88f8323cf191138ca94420271be65539a94cfc7c
2021-06-22 09:39:13 +00:00
Nikita Eshkeev
e0970fca77 [java][resolve] IDEA-271676 Pattern matching for switch: fix resolve
Fix the resolve algorithm according to [JEP 406](https://openjdk.java.net/jeps/406). It includes:

- The correct resolution of variables in pattern matching guards in both if and switch
- Restricting the maximal scope of resolving by the PsiSwitchLabeledRuleStatement
- Various tests for resolving variable in pattern matching for switch

Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>

GitOrigin-RevId: 1efb10f50a458a382a71ffeaef5a0f540b4a8893
2021-06-19 21:31:03 +00:00
Artemiy Sartakov
3a1d5cbeb5 SourceToSinkFlowInspection: cr fixes(IJ-CR-10092):
1. moved SourceToSinkFlowInspection to jvm-analysis-impl
2. resused annos names from UntaintedAnnotationProvider
3. javadoc for public methods
4. renamed inspection to "Unsafe string is passed to safe method"
5. do not suggest to annotate element if it is already annotated with @PolyTainted

GitOrigin-RevId: 6121aa41cf72d1fe258a8ced0752d22370d18c54
2021-06-19 08:46:16 +00:00
Anna Kozlova
30d955f114 [global inspections] [kotlin] cope with primary constructors
GitOrigin-RevId: 23428b26b42c38c910bdddd8dc870501aed0e992
2021-06-18 20:10:43 +00:00
Anna Kozlova
5de14cb0ca [global inspections] [kotlin] cope with method/property inheritance
GitOrigin-RevId: c686738495b77d1d045f8932f7ce0c8d2462c9cb
2021-06-18 20:10:40 +00:00
Andrey.Cherkasov
fc8855795d IDEA-259667 draft of collect(toList()) -> toList() conversion (since Java 16)
GitOrigin-RevId: 3874dfbd658a574be68124b005472cfb0a2222f6
2021-06-18 05:15:26 +00:00
Nikita Eshkeev
aff8571fd9 [vcs][properties] IDEA-270602 Optimize precommit code analysis for property files
Enable the check if properties are used in a project only for changed or added properties by default

Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>

GitOrigin-RevId: 6d336d0bb803543c3627c23923605d0d6827dc86
2021-06-17 22:59:22 +00:00
Roman Ivanov
b12c4d4231 [java] fix test data
GitOrigin-RevId: 61472708704a021e22e06a5c46a9f37509d045ea
2021-06-15 17:46:11 +00:00
Roman Ivanov
8a9bebd7f8 [java] check if language level is enough to use null in switch
GitOrigin-RevId: 806af1f97f457bf77dd3f780e72578de5be4fb27
2021-06-15 17:46:06 +00:00
Roman Ivanov
3ff8c67c09 [java] split HighlightingFeature for patterns in switch into 2 parts
Otherwise, in the context for instanceof it looks weird

GitOrigin-RevId: 115b7552f7ad4050e7833dbb890ec3fb6048db64
2021-06-15 17:46:04 +00:00
Tagir Valeev
8824ba3b8a [java-dfa] Fix cast to intersection type in Java (IDEA-271523)
GitOrigin-RevId: 044e8db87d771242a898142df214b58092820a73
2021-06-15 09:24:59 +00:00
Artemiy Sartakov
403e0956f1 SourceToSinkFlowInspection: added inspection to detect unsafe flows from source to sink (IDEA-271540)
GitOrigin-RevId: af964bc79c2625794c4ad53159368bb0849d727e
2021-06-15 06:33:15 +00:00
Alexandr Suhinin
0d3a00a2bd [extract duplicates] map parameters in duplicates
GitOrigin-RevId: 0d840da8ab57cb6b583af91839750713f10c8a07
2021-06-14 23:01:52 +00:00
Alexandr Suhinin
5311e7a4da [extract duplicates] replace multiple duplicates
GitOrigin-RevId: 7729aa9f1d8c8d49539a7ebf9b8ea750a8a0a03a
2021-06-14 23:01:51 +00:00
Anna Kozlova
b28fd6a1a4 [global inspections] align uast sourcePsi/javaPsi usages
references by light elements are not available and sourcePsi should be used instead

GitOrigin-RevId: 63be95769d6736e622acb02c8e68057bb9d4c050
2021-06-14 10:58:11 +00:00
Roman Ivanov
6371cde54c [java] fix usages after changing PSI structure
earlier we had PsiExpressionList, now it is PsiCaseLabelElementList

GitOrigin-RevId: 14b06afe93d631d12048539704cd6e71efc5d4ef
2021-06-11 17:35:47 +00:00
Roman Ivanov
0f24b2a047 [java] highlight patterns in switch if level is low
GitOrigin-RevId: c22fba0aa5e31cebfd59bff164ab2df0a5d389e0
2021-06-11 17:35:43 +00:00
Roman Ivanov
e60c890f45 [java] PsiDefaultElement ->PsiDefaultCaseLabelElement
GitOrigin-RevId: 1ec42a39b2271a829d9dff6891a39f26e12aa4b7
2021-06-11 17:35:39 +00:00