Commit Graph

4636 Commits

Author SHA1 Message Date
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
Ilyas Selimov
9909791f3f IDEA-270438 - fixed completeness for enums
GitOrigin-RevId: 74b104129dea327095c7dfbbb44e2ad11eeb6d98
2021-06-28 06:43:26 +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
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
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
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
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
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
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
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
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
Artemiy Sartakov
33492f3827 OptionalToIfInspection: preserve code blocks with user code when they contain more than one instruction (IDEA-267045)
GitOrigin-RevId: 2abb37a3ce54c4ca126d55b52b68fe44cbc9ccfc
2021-06-07 06:15:29 +00:00
Artemiy Sartakov
88b4660169 MemberModel: fixed case when there is more than one member out of class (IJ-CR-6471)
GitOrigin-RevId: f84b1e8acee891a84ab637ad7fc48492674e5468
2021-06-07 06:15:27 +00:00
Bas Leijdekkers
bf0b3d08fb IG: generate correct replacement for Objects.equals() on nullable BigDecimal (IDEA-267972)
for "equals() called on BigDecimal" Inspection

GitOrigin-RevId: 3571d64777fdf551466d4bf5dd20cd316c619029
2021-05-31 16:46:40 +00:00
Andrey.Cherkasov
f68f593aa4 [java-inspections] UseBulkOperationInspection: support Maps (IDEA-262786)
GitOrigin-RevId: 9aae98c287f6e2057b09bfda78fb007ba45eeee6
2021-05-28 23:55:59 +00:00
Anna Kozlova
e287fd7576 [java] [inference]: avoid recursion guards in clients as they may prevent engine code to complete normally (IDEA-268120)
here highlighting got guarded and inference was unable to walk up to the containing call and failed because of that. Guard is needed for the case when the same code may be invoked *during* inference itself, corresponding guard exists already and mentioned in javadoc

GitOrigin-RevId: bdb8ba5056884d1b6869bd0d31c8482f77adb3a7
2021-05-27 23:14:57 +00:00
Anna Kozlova
1705f01347 [java] lambda context: allow conditional with lambda branches in switch cases (IDEA-269928)
extract cast processing to the upper level as it's not allowed in conditions (^Tagir)

GitOrigin-RevId: 3e608c133d2b44d67f9b57721fbf62c04c2c4147
2021-05-26 19:26:22 +00:00
Alexandr Suhinin
caab01294c IDEA-249164 IJ-CR-9284 fix comment tracking & ignore qualifiers to outer classes
GitOrigin-RevId: f5d07de538463dc6e2cca8d58ffd3c10e7d59d6d
2021-05-25 10:23:59 +00:00
Anna Kozlova
890efeaded [java]: redundant cast: treat switch expression branches separately (IDEA-269929)
GitOrigin-RevId: 4eecfab7aff32bc69164b740d1bd36f9a29b6cda
2021-05-25 06:42:14 +00:00
Anna Kozlova
5a42eae302 [java]: surround with: prefer same simple names for catch parameters (IDEA-269830)
GitOrigin-RevId: 9f8b5ced2ec29cbf0f23ccfdf18d4888a55e440d
2021-05-25 06:42:12 +00:00
Anna Kozlova
5ab478e48e [java] lambda context: allow conditional with lambda branches in switch cases (IDEA-269928)
GitOrigin-RevId: 5bdcade69a621a83cc88074dd566e401852d0fd0
2021-05-25 06:42:11 +00:00
Anna Kozlova
358f9086ce java inference: allow unresolved type parameters during potential compatibility check (IDEA-268866)
GitOrigin-RevId: f38e13385d534b025f8072e29a3558b0f2ecf4e7
2021-05-24 17:22:45 +00:00
Tagir Valeev
d70063b9f2 [java-dfa] Avoid marking annotation method results as non-null
While annotation implementations created by reflection never return nulls, it's possible to create a custom annotation interface implementation and nothing stops from returning null in this case. This leads to false-positives.
Fixes IDEA-269686 Wrong inspection message for nullable return value of annotation
Rollback IDEA-151174 Annotation method return values are non-nullable

GitOrigin-RevId: 88301bd8f5fb69e1e78efc23ecc1416c7c441473
2021-05-21 11:42:30 +00:00
Bas Leijdekkers
223eeb0b0f WrapWithAdapterMethodCallFix: wrap with List.of() instead of Arrays.asList() on Java 9 and higher (IDEA-269380)
GitOrigin-RevId: f39f5c58348afb6b3c57dbc059860f940c6ec363
2021-05-19 10:44:07 +00:00
Alexandr Suhinin
d419b7b165 IDEA-249164 unnecessary this inspection: highlight calls to constructor
GitOrigin-RevId: 35c56a70e381163d147f5ac87037291049a78c9b
2021-05-18 10:28:06 +00:00
Ilyas Selimov
3642a47796 DFA - moved the tests associated with "Simplify" quick-fix to a dedicated place
GitOrigin-RevId: 8bd67d61335fc77c2f8e115bfda45ade06041283
2021-05-18 10:27:41 +00:00
Andrey.Cherkasov
50f8045484 [java-inspections] Redundant char[] wrapping at String constructor could be replaced with String.valueOf() IDEA-262555
GitOrigin-RevId: cae0690cf100730f6a8502b17b57d7bb913a0cf0
2021-05-17 14:25:52 +00:00
Ilyas Selimov
d82ff9650f DFA - excluded boolean fix suggestion in conditional expressions which contain null expression types to prevent compilation error
GitOrigin-RevId: b0b956ad677ce1ecdc80070e25877aef8dc65100
2021-05-14 17:22:38 +00:00
Ilyas Selimov
85fd5fb24f DFA - removed smart pointers in the fix, changed naming and tests
GitOrigin-RevId: d136a7fee6bb26e8676d31d57a98f945959b3605
2021-05-14 09:49:42 +00:00
Ilyas Selimov
a117b21680 DFA - added Boolean.TRUE/FALSE.equals() quick fix to unbox boolean nullable variable
GitOrigin-RevId: 45952b11139cf435e218ddd9c3ba57e237230eed
2021-05-13 04:38:40 +00:00
Andrey.Cherkasov
c7ee606c95 [java-highlighting] fixes after review IDEA-216258
GitOrigin-RevId: 52b88a888751bb74e37b332c69d4ee0878ea26da
2021-05-12 23:25:01 +00:00
Andrey.Cherkasov
02e34802cf [java-highlighting] Don't suggest moving 'this' to the beginning of the list if there is already a receiver there
GitOrigin-RevId: d474d72a0fa00912a65f7ed32a85f2c2deec5e44
2021-05-12 23:24:58 +00:00
Ilyas Selimov
3a85b4d139 java - fixed insert return fix test
GitOrigin-RevId: 68248321a00c35871abb11b854b6d7368a7ce65e
2021-05-11 17:25:36 +00:00
Tagir Valeev
b6d4607a9d [java-intentions] Support type inference when suggesting to insert return (IJ-CR-8575)
GitOrigin-RevId: 0203d3a738d59d12c711ff8589f4293ec2bbf89f
2021-05-11 12:00:19 +00:00
Tagir Valeev
a9069f60e8 [java-intentions] IterateOverIterable: disable for empty lists and newly-created arrays (IJ-CR-8575)
GitOrigin-RevId: 78ef76ab85b1e051d0bb887801379136be041c5b
2021-05-11 12:00:19 +00:00
Anna Kozlova
a5fd904157 java: accept module/record component targets by default (IDEA-262023)
GitOrigin-RevId: e64346f24ac26ee5878ace72dd939afc9d5c3b24
2021-05-10 11:02:38 +00:00
Anna Kozlova
66873cdedb visibility based highlighting (IDEA-80384; IDEA-228556)
GitOrigin-RevId: 1c8c903d4bdc7be5459987cc5c081f302e4e2d16
2021-05-10 11:02:33 +00:00