Commit Graph

2246 Commits

Author SHA1 Message Date
Nikita Eshkeev
68f1da981c [codeInsight] IDEA-113640 Provide intention to combine System.out.println(String.format(...)) into System.out.printf
This patch removes StringUtil.isEmpty("%n") from RedundantStringFormatCallInspection#joinWithNewlineToken as it is always true. In addition to that it also includes:
- inlining the getMethodNameRange method since the createProblemDescriptor method accepts a nullable parameter
- moving RedundantStringFormatCallInspection#joinWithNewlineToken inside of StringFormatToPrintfQuickFix to reduce its visibility scope

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

GitOrigin-RevId: e70f0b6be7eb158910016ac2bb31bb5667186c91
2020-05-04 23:13:31 +00:00
Nikita Eshkeev
fcd7fac054 [codeInsight] IDEA-113640 Provide intention to combine System.out.println(String.format(...)) into System.out.printf
This patch fixes the notes from the code review, it includes:

- Renaming the testData files so their titles are more informative
- Moving `PsiLiteralUtil#append` to `RedundantStringFormatCallInspection` and renaming it to `joinWithNewlineToken` so it does not have to deal with the escape characters' problems
- `RedundantStringFormatCallInspection` only highlights the "`format`" word in `String.format` in order to reduce the warnings area in code visually

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

GitOrigin-RevId: 07b3b3b2d24e500774928d406e274dd4cb20bd5d
2020-05-04 17:09:45 +00:00
Nikita Eshkeev
d605adb8d1 [codeInsight] IDEA-113640 Provide intention to combine System.out.println(String.format(...)) into System.out.printf
The RedundantStringFormatCallInspection inspection used to be able to
detect excessive String.format calls and get rid of them not changing
the callsite at all. This patch enhances the inspection's capabilities
with changing the callsite if it is either PrintStream#print or
PrintStream#println and converting it to PrintStream#printf adding "%n"
if necessary.

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

GitOrigin-RevId: 7edc5b0a84fb6c7b9caf504b1afb8905c5684985
2020-05-01 14:07:13 +00:00
Tagir Valeev
653d690ee2 NullableNotNullManager#findDefaultTypeUseNullability: fix local variables handling
We should not use container annotation for top-level local variable type, but may use it for nested ones.

GitOrigin-RevId: 507cfd221f073dffc78ccec3fd9ba6b79b888c76
2020-04-29 09:39:08 +00:00
Anna Kozlova
fc75a00a48 reorder properties
GitOrigin-RevId: eed5c309063e7661b2448effdd7bb1134239d985
2020-04-29 09:15:17 +00:00
Tagir Valeev
659710fb77 NullableNotNullManager#findNullabilityDefault: avoid propagating default nullability to local variable type
GitOrigin-RevId: c89c89138ae819767dfecfa2b2e47fc126ecc9f1
2020-04-29 07:15:24 +00:00
Anna Kozlova
09d57e4993 compound assignment: allow assignment to string super types (IDEA-238812)
GitOrigin-RevId: 56d7dd94bc8e1b728aef2c59a54bee76ad43df74
2020-04-29 06:28:48 +00:00
Tagir Valeev
5195a3cb84 Support default annotation for types
Fixes IDEA-236740 NonNullByDefault not working with Generic Types.

GitOrigin-RevId: 88bfc4b9dd87bd28f7a137bed4e3271485d89406
2020-04-28 10:51:57 +00:00
Nikita Bobko
b84bf7ab7f Fix compilation in Kotlin plugin
GitOrigin-RevId: 7e11af4acb717a25fc7c6830e1acefbc4c9795ab
2020-04-27 17:09:55 +00:00
Tagir Valeev
d48d0186f4 Move 'default' handling from PsiModifierListImpl to VisibilityUtil
Review ID: IDEA-CR-61867

GitOrigin-RevId: 29187429b1917860d8b45dc07bf7e094b0510365
2020-04-27 09:44:13 +00:00
Alexey Kudravtsev
6f7e72f06a cleanup
GitOrigin-RevId: f9766961fcad0760d25069ed952c032767f1354c
2020-04-24 12:16:59 +00:00
Vladimir Krivosheev
bec63807ce clear cache before notify listeners to ensure that listeners don't get outdated data
GitOrigin-RevId: c98fd042cfacf7ebfd0a438485eb5a3cc5a2d4d5
2020-04-24 09:33:17 +00:00
Tagir Valeev
3643ee6506 Fixes according to review IDEA-CR-61871
GitOrigin-RevId: 206247808adba050a5839ee8ac0be790bb53c8ac
2020-04-24 08:26:53 +00:00
Tagir Valeev
2d76fd9259 Constable and ConstantDesc as primitive wrapper supertypes
Fixes IDEA-237669 Spurious error "switch label is unreachable"

GitOrigin-RevId: 8fbea69ed90c8a1aca860a58cf5a70908a904c4c
2020-04-24 04:03:50 +00:00
Tagir Valeev
ec8510b0a6 PsiPolyExpressionUtil#isBooleanOrNumericType: do not check bounds
JLS 15.25 says: ...has return type boolean or Boolean. or ...is convertible to a numeric type.
JLS 5.1.8 says:
A type is said to be convertible to a numeric type if it is a numeric type (§4.2), or it is a reference type that may be converted to a numeric type by unboxing conversion.

Nothing about bounds
PolyConditionalExpressionWithTargetPrimitive test behavior matches Java 9+ now (with --release=8)

GitOrigin-RevId: fa14e909ad623a3ab6bb8355bbbe396003cd782c
2020-04-23 08:56:21 +00:00
Tagir Valeev
6ef313e638 PsiPolyExpressionUtil#isBooleanOrNumeric: substitute all type parameters except the method ones (see JLS 15.25)
Fixes IDEA-238074 NullPointerException in the Ternary Operator with autoboxing

GitOrigin-RevId: 2445b78d19fda16fd6c6f7e5d30f24dc0688fe26
2020-04-23 07:24:13 +00:00
Nikita Eshkeev
cb0ba6f429 [codeInsight] IDEA-219640 Inspection to detect some pointless String.substring
This patch fixes notes from the latest code review, the changes include:

- Moving RedundantStringOperationVisitor#getTargetString to SubstringEqualsToCharAtEqualsQuickFix#getTargetString
to reduce the complexity of the visitor
- Making `textExtactor` from SubstringEqualsToCharAtEqualsQuickFix#getTargetString
NotNull
- Adding the check that the length of the input string should be greater
than 1 in order to perform the transformation in PsiLiteralUtil#charLiteralForCharString

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

GitOrigin-RevId: 2a11f8691bab082da39d2763ab7d96a41b7ce09a
2020-04-21 10:53:34 +00:00
Anna Kozlova
0917e56f43 dynamic plugins: some java psi stuff
GitOrigin-RevId: 8cbda00cf3790de6da27c1e90deb5ee3990bea8b
2020-04-20 11:43:50 +00:00
Nikita Eshkeev
0aa2e160b0 [codeInsight] IDEA-219640 Inspection to detect some pointless String.substring
This patch fixes the notes from the review, it includes:

- restoring annotation.naming.convention.display.name
- using com.intellij.openapi.util.Pair instead of custom private objects
- using EquivalenceChecker.expressionsMatch in order to extract
difference between two PsiBinaryExpression
- using BoolUtils.findNegation to properly deduce the sign of the equals
clause
- restoring comments while replacing substring with charAt
- properly handling special characters (e.g. '\\', '\n', '\"', etc.) in
equals clause when it is converted to charAt + "=="
- eliminating the imperative form of a message for the inspection of
substring + equals

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

GitOrigin-RevId: be1dfd53a6af10979485cd172af39653faafb744
2020-04-17 22:57:24 +00:00
Anna Kozlova
411b07eb57 dynamic plugins: make main method provider dynamic
GitOrigin-RevId: 4ca9fdc602e47adc1ad08023df1db111faabab61
2020-04-17 11:43:56 +00:00
Anna Kozlova
022c5be762 java type system: use captured wildcard bounds in cast context (IDEA-233551)
starting with javac 1.9+ such code starting to compile, javac 8 rejects the code with the same language level used

GitOrigin-RevId: 87a1e4d475927af0ee71cd74f5a66e130908ed82
2020-04-16 19:41:33 +00:00
Bas Leijdekkers
43ff3e1187 text blocks: skip any trailing whitespace, not just spaces
GitOrigin-RevId: d768589bdc1db6c6357e8dd7fffcca334d83231a
2020-04-03 18:44:34 +00:00
Bas Leijdekkers
721d7b8364 add some documentation (IDEA-CR-60894)
GitOrigin-RevId: f84c9cd7765e2156247b2f8ad26539082084b51f
2020-04-03 18:44:34 +00:00
Bas Leijdekkers
6090e522fc rename method (IDEA-CR-60894)
GitOrigin-RevId: 60900578bd58c0f27c80a7eb1dc890f31ca5596b
2020-04-03 18:44:34 +00:00
Bas Leijdekkers
3cdf183fd1 minor optimization: stop calculating text block indent when it is 0 (IDEA-CR-60894)
GitOrigin-RevId: 1c8a6b6c5e150c186412246ace5c4b8f3b0950f6
2020-04-03 18:44:34 +00:00
Tagir Valeev
ad5b2797ee IDEA-236404 @NotNull PsiSubstitutor.EMPTY can be null
GitOrigin-RevId: 66c99774427a9455916424c94a6df014e9140d5a
2020-04-02 02:32:16 +00:00
Anna Kozlova
bd1a21a02a bump highest language level to 14, prepare to remove 13_preview
GitOrigin-RevId: ec42a9047ba63b0cbaddd8357d11ae2ed56ed6b6
2020-04-01 12:31:42 +00:00
Vladimir Krivosheev
d669742145 cleanup - use Objects.equals instead of Comparing.equal
GitOrigin-RevId: 37d620c12497b0add4fb7bbd9119d2b5ba79a457
2020-03-31 14:31:51 +00:00
Tagir Valeev
6c3e99c855 PsiCapturedWildcardType#captureUpperBound: check every substitutedBoundType (IDEA-CR-60194)
GitOrigin-RevId: c7a7683fa42d003df662586e355ee0feefefcb24
2020-03-31 07:37:00 +00:00
Bas Leijdekkers
c90d596d0d Introduce PsiLiteralExpression.isTextBlock()
GitOrigin-RevId: c7f05c887f6496d19900e831e5c5bad230e8636c
2020-03-30 18:46:03 +00:00
Tagir Valeev
aa876c39db Unreasonable contracts removed after contract issues inspection update
GitOrigin-RevId: c91a2615de3eb5a0a089d67ce6e25a3d5db093f6
2020-03-29 08:04:59 +00:00
Tagir Valeev
49b29d6bf7 @NotNull
GitOrigin-RevId: 1743116409561b113a8748f1345b9cef8435b1cc
2020-03-26 09:31:34 +00:00
Anna Kozlova
7f29fa37d0 fix properties
GitOrigin-RevId: 71ff9a73faf368c33211d69ee401051848ffc8af
2020-03-23 21:04:43 +00:00
Anna Kozlova
69801c215d i18n java error messages
GitOrigin-RevId: eb774594b0b17acd67b781b834e0b86e163064c1
2020-03-23 11:32:35 +00:00
Tagir Valeev
0b0e7ec8c8 Move recursion detection from PsiUtil#captureToplevelWildcards to PsiCapturedWildcardType#captureUpperBound
Review ID: IDEA-CR-60194

GitOrigin-RevId: 022c029950a1f7d1cb935ac95501e4c7ff2380e0
2020-03-23 10:02:55 +00:00
Tagir Valeev
161f6cf1a9 Prevent creation of recursive PsiCapturedWildcardType
Fixes IDEA-235214 Highlighting freezes when captured wildcard used on the type with cyclic dependency in type variable

GitOrigin-RevId: 16d114ccab944d55dfbbdc29c227d60756e2ba1a
2020-03-18 06:31:42 +00:00
Peter Gromov
81762901e8 java resolve: don't check for staticness in processors that don't care (IDEA-233325)
GitOrigin-RevId: f6122e80a30e7613eab234422982e3be4f8ac3cb
2020-03-13 22:02:41 +00:00
Anna.Kozlova
cee2594b56 nonnls for psi factories
GitOrigin-RevId: bbe77f0b110f380c88308d446bf189e3f3446e07
2020-03-13 14:10:13 +00:00
Nicolay Mitropolsky
082a2371bd I18nInspection: properly escape the ' (IDEA-CR-59632)
GitOrigin-RevId: fb054db7d8f133ce548d6fd3c9a9635c639a2000
2020-03-10 15:23:35 +00:00
Alexey Kudravtsev
295a9bc984 fix exception on unboxing captured wildcard of numeric type
GitOrigin-RevId: 6fb5c3ed9b1225d4224c8c543221d12412718114
2020-03-10 13:32:01 +00:00
Tagir Valeev
5c9020d62c Warnings fixed
GitOrigin-RevId: e1122f5298badfeb93f0ba6d68e597a6fd90150b
2020-03-04 10:15:36 +00:00
Dmitry.Krasilschikov
a47b8f5a72 Bundle API: rename lazyMessage() to messagePointer()
GitOrigin-RevId: 1b4a35db8900da03fe48d4638362e5ea36cf106b
2020-03-03 16:02:28 +00:00
Dmitry.Krasilschikov
c11f6c3ec4 IDEA-233188 don't localize language name
GitOrigin-RevId: ad243c4524ba88fe7c390fc1ca1b7a0639e3a8e2
2020-03-01 16:32:06 +00:00
Tagir Valeev
c6b380cf6d AnnotationTargetUtil#getTarget javadoc update
GitOrigin-RevId: 0b2d85a1e1bc871eb245fe8f784bb12f56710bd8
2020-02-28 05:07:09 +00:00
Dmitry.Krasilschikov
5799e62f56 a better key: error.message.wildcard.not.expected
GitOrigin-RevId: 81c0e2884f029782b12396599996aeeab00903d6
2020-02-26 12:32:36 +00:00
Bas Leijdekkers
29f6ad76a4 support ErrorProne Immutable and GuardedBy annotations
GitOrigin-RevId: 10f5298141586860fd180e029905b37566ad2bdf
2020-02-21 19:11:25 +00:00
Matthew Gharrity
541cc98b39 Support androidx.annotation.GuardedBy
...in FieldAccessNotGuardedInspection

This fixes https://issuetracker.google.com/149753966

GitOrigin-RevId: 74dc3eb66ad8fbd4afcb6e7d1d2f6d84e5b46e45
2020-02-21 19:11:25 +00:00
Vladimir Krivosheev
da19823987 cleanup (useless javadoc and unclear author)
GitOrigin-RevId: 674769829c2dfa05db6e0e2a6a7c1f9ac6e601ef
2020-02-21 17:31:28 +00:00
Tagir Valeev
5401038759 Typo fixed (IDEA-CR-58580)
GitOrigin-RevId: 2ee5496c808167d725d208f582dd26c35e25859d
2020-02-19 08:46:59 +00:00
Tagir Valeev
d47e93c5e2 findTypeAnnotationInHierarchy -> findAnnotationInTypeHierarchy; javadoc updated (IDEA-CR-58580)
GitOrigin-RevId: f1f50de2e4988c3bc5b3bd6debfcf5d8c84705e9
2020-02-19 08:46:59 +00:00