Commit Graph

4644 Commits

Author SHA1 Message Date
Anna Kozlova
c7328bb1a2 [java] [javadoc snippet] fix injection with unclear context
use existing JShell wrappers

GitOrigin-RevId: 2e0351145e1e3f750d781cd62bcda20cc49693c7
2022-02-15 13:14:40 +00:00
Artemiy Sartakov
6633bef908 BulkFileAttributesReadInspection: clustering attribute calls by loops before reporting (IJ-CR-20279)
GitOrigin-RevId: 70cebc3298eea9feb57f7b4f1f4ca7b8b0535c66
2022-02-14 10:31:26 +00:00
Anna Kozlova
0a3d001b76 [java] avoid reformat inside psi operation (IDEA-287332)
GitOrigin-RevId: 387a7fe6e41da1f967b05dfa7da246e70e02b30f
2022-02-11 09:33:24 +00:00
Nikolay Chashnikov
9c66641799 [java] remove redundant import when "Remove annotation" quick fix is applied (IDEA-288488)
GitOrigin-RevId: 562cf18eafa636a761c75ae3e9630bdab3eff760
2022-02-11 09:25:51 +00:00
Artemiy Sartakov
9dcbd71cc6 MultiplePathConstructionsInspection: added inspection (IDEA-288529)
Reports multiple Path.of() or Paths.get() calls in a row with same expression

GitOrigin-RevId: 654825f7946243d0fd58ed2d2d4d577305ad0da5
2022-02-11 09:14:01 +00:00
Tagir Valeev
32442ebe48 [java-inspections] IDEA-288528 Add a quick-fix to correct typeuse nullability annotation
GitOrigin-RevId: ac4d271bc6e43306532d201e74fcf6e9f7b2e6ae
2022-02-11 08:30:20 +00:00
Nikita Eshkeev
fd0a6dfb94 [javadoc] IDEA-285556 Support language injection into snippet
Usually leading asterisks of a javadoc are aligned so the common indent for the lines in a snippet's body is obvious,
but nevertheless javadoc can have multiple leading asterisks, and they don't have to be aligned.
This patch fixes the indent stripping: if the indent is too short, which will result in leaving some leading
asterisks after stripping the indent from the line, the indent gets increased, so it goes after the last leading asterisk in the line.

GitOrigin-RevId: c79bcb3e25b96b5b1ff52da350f926673d155199
2022-02-10 21:11:41 +00:00
Anna Kozlova
8bb3536c11 [java] effectively final: ensure checks are performed on the same variable
GitOrigin-RevId: 77dc60e5a5119eecdd73268e192bd52390dff342
2022-02-10 14:42:24 +00:00
Artemiy Sartakov
bcca6ef32f BulkFileAttributesReadInspection: cr fixes (IJ-CR-20279):
1. analyze all calls in method in one go
2. use UncheckedIOException instead of RuntimeException when wrapping into try catch
3. info level when try catch needed + no report in batch mode
4. updated description

GitOrigin-RevId: 0a2542b851fa32c5fde98725985f55079447b02b
2022-02-09 12:12:31 +00:00
Anna Kozlova
37419d54aa [java] fixed hiding of constants during overload resolution (IDEA-287953)
GitOrigin-RevId: 5de6c138d9ac051af5b41d50c88a9b8b508e86bf
2022-02-08 14:28:05 +00:00
Andrey.Cherkasov
7ce1003bd9 [java-highlighting] Provide fix for "The receiver name does not match the enclosing class type"
IDEA-273225

GitOrigin-RevId: aac09cbfcb60a1757c7b142ac888979148d4e7cc
2022-02-08 04:33:49 +00:00
Andrey.Cherkasov
475eaf4754 [java-highlighting] Use 'SetVariableTypeFix' for the "The receiver type does not match the enclosing class type" error
GitOrigin-RevId: f60f37d148c81dfe0fb86d56a385c2561ad9bb07
2022-02-08 01:01:43 +00:00
Alexandr Suhinin
dee2a83524 [javadoc inspection] test: fix old quickfix tests
GitOrigin-RevId: 97acecc139826abd3750cbe9c08d5c42878abf70
2022-02-07 09:48:57 +00:00
Alexandr Suhinin
4ded859fcc [javadoc inspection]: fix unrelated tests for "JavadocDeclaration"
GitOrigin-RevId: bcd2694ca67951f18f4b87bd2a34d6d2ae585281
2022-02-07 09:48:48 +00:00
Alexandr Suhinin
66dc4f4509 [javadoc inspection]: test "JavadocDeclaration" inspection (copy from JavadocDeclarationHighlightingTest)
GitOrigin-RevId: 19cf2b25316068a0f5036e9f422c9e8147084ce4
2022-02-07 09:48:45 +00:00
Alexandr Suhinin
15dfb6342e [javadoc inspection]: test "MissingJavadoc" inspection
GitOrigin-RevId: 1bf6991891b8fb26a67c3f9f94f2a230ce030735
2022-02-07 09:48:43 +00:00
Ilyas Selimov
f47870ae8a EA-447738 [patterns for switch] - handle the case when permits list contains unresolved reference type
GitOrigin-RevId: 5a0adb3d51d548f40771a336d3fcbe76305be524
2022-02-07 07:09:53 +00:00
Anna Kozlova
b25ec4fd45 [java] try-with-resources should be ready for inferred intersection types (IDEA-288011)
GitOrigin-RevId: db5f49774555673bad7715319cc7b02a92229943
2022-02-04 15:35:09 +00:00
Anna Kozlova
02c569b58d [java] keep existing type annotations when new param is added to the constructor (IDEA-287983)
GitOrigin-RevId: 9a22583cf9333be8855545c87443484bce62a19c
2022-02-04 10:41:45 +00:00
Artemiy Sartakov
dd2943e081 SourceToSinkFlowInspection: tests for adding checker-qual dependency (IJ-CR-17164)
GitOrigin-RevId: 64c606a55f93cfe5a1f780508fcc71db1552d045
2022-02-04 09:41:14 +00:00
Artemiy Sartakov
c699fe0e24 IOStreamConstructorInspection: cr fixes (IJ-CR-20017):
1. report for arbitrary expressions that expect OutputStream / InputStream
2. report for arbitrary file creation arguments
3. check recursively if file creation argument is effectively final
4. reuse effectively final path variables if possible
5. use Paths.get() instead of Path.of() since 'of' method appeared only in java 11
6. info level for java 10 and higher

GitOrigin-RevId: 0a778328fe938faa0fe7eb2f199064f90b7a6d1b
2022-02-02 08:24:36 +00:00
Bas Leijdekkers
d73341c619 show method calls with () in "Inline stream mapping method" intention messages
GitOrigin-RevId: 2602d4e06902450e197232450c86d79ebc5203f7
2022-01-31 10:13:18 +00:00
Bas Leijdekkers
ea834397dc show method calls with () in "Replace with bulk method call" inspection messages
GitOrigin-RevId: cc40c33ea4729b0faaecefe3e67287ece06090bd
2022-01-31 10:13:13 +00:00
Artemiy Sartakov
51b6c30a78 BulkFileAttributesReadInspection: added inspection
Inspection reports multiple java.io.File attribute calls in a row. Attribute calls:
- lastModified
- isFile
- isDirectory
- length
It suggests replacing them with a single attributes extraction using java.nio.file.Files.readAttributes method

GitOrigin-RevId: cd2f93645aab9a4cba2e1f87e05b431f0d21ee50
2022-01-31 06:31:09 +00:00
Tagir Valeev
453a00c310 [java-inspections] IDEA-287483 Suggest explicit type for uninitialized 'var', based on the first assignment
GitOrigin-RevId: 80fa9ecf09130d04c41d27ad40897ef24183e4e1
2022-01-28 10:05:00 +00:00
Tagir Valeev
c7ed6477fb [java-inspections] IDEA-287311 Bug: Inspection 'bring variable into scope' introduces Compilation error when used with 'var'
GitOrigin-RevId: 85f7f526ec1cee6533f441bf42bc43b1b0bb8be1
2022-01-28 10:04:59 +00:00
Anna Kozlova
4a300c672b [java] don't include fully qualified name in unresolved call messages (IDEA-282207)
GitOrigin-RevId: 3f22a64e3ab3173157368140af5d072e3cad2654
2022-01-28 07:21:30 +00:00
Bart van Helvert
4e322147be [java] Put class name in quotation marks in sealed hierarchy error message
GitOrigin-RevId: 611f8cf8b738ecd1e2b915fbebd3948eefbbe82d
2022-01-26 20:16:39 +00:00
Artemiy Sartakov
67e36d74a5 IOStreamConstructorInspection: added inspection (IDEA-171230)
Inspection suggests conversions:
1. FileInputStream -> Files.newInputStream
2. FileOutputStream -> Files.newOutputStream
in cases when FileInputStream can be replaced with InputStream.
Also, it reuses path variable after conversion when possible (path variable should be effectively final).

GitOrigin-RevId: 474dcaeeb5336fcc8330b4b3ed65d443042ecf2f
2022-01-25 07:01:39 +00:00
Andrey.Cherkasov
352e14cad0 [java-highlighting] Fixes after review (IJ-CR-19779)
GitOrigin-RevId: 052a555e3b2af3a687e37f7c912d79861673969c
2022-01-25 01:36:11 +00:00
Ilyas Selimov
3d5bbea95f IDEA-283367 - [Patterns for switch] - fixed completeness for parameterized sealed hierarchies
GitOrigin-RevId: 4f5c59fe1e38b08f86974682b8adf7d70f0274b5
2022-01-24 12:28:36 +00:00
Ilyas Selimov
4011c84778 IDEA-283367 - [Patterns for switch] - implemented "any pattern is dominated over const label element"
GitOrigin-RevId: f6e6c9214ad854fa0506e587f43075fabaf8e979
2022-01-24 12:28:33 +00:00
Andrey.Cherkasov
7f49cd79b1 [java-highlightings] Highlight cyclic inheritance of type annotation
IDEA-285204

GitOrigin-RevId: e0f27053d3443cfe47474afd96582e2168cdc973
2022-01-21 06:19:54 +00:00
Nikita Eshkeev
436eee6cf4 [javadoc] IDEA-285556 Support language injection into snippet
Implement updating the content of a snippet tag with the help from a method implementer. A snippet might invoke overriding a method though a completion and when a parent method is inserted it might contain javadoc. In this case it's impossible to recreate a snippet tag because the new text for the tag contains "/**" and "*/" that come from the parent method's javadoc. The implemented method implementer helps to strip a method's javadoc if it's present.

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

GitOrigin-RevId: 42b315ed2670701e50574a383f0442df69accd35
2022-01-20 02:16:47 +00:00
Nikita Eshkeev
715e914e30 [javadoc] IDEA-285556 Support language injection into snippet
Fix injection for empty snippets. The range to inject is now starts after the colon and ends when the body ends. If no colon exist, then use the whole body as an injection point.

GitOrigin-RevId: c7961f13c30212f52aad45a121bcf11b70ce8f2b
2022-01-20 02:16:46 +00:00
Andrey.Cherkasov
7524dc20ff [java-highlightings] Provide missed fix to fix containing method return type for conditional return
IDEA-256730

GitOrigin-RevId: 98a8befb15c2b571d1020d34018d88a60b952363
2022-01-19 04:16:49 +00:00
Andrey.Cherkasov
381684d2b2 [java-highlightings] Don't propose fix making return type void for method calls in conditional expressions branches
IDEA-256730

GitOrigin-RevId: 2953a47102a15fa572ac8271edb9bb0fe7c2f49e
2022-01-19 04:16:47 +00:00
Anna Kozlova
4972eabd8b [java] don't replace lambda with method reference when qualifier is nullable (IDEA-278691)
GitOrigin-RevId: f514b690e9e2d007c124ce2b7179af39b6131f3f
2022-01-17 18:21:47 +00:00
Anna Kozlova
e3c0d74cb6 [java] don't propagate ellipsis type as target type for non-vararg calls (IDEA-286407)
GitOrigin-RevId: 3693373240012db841bffaca1a5f8765200acbc8
2022-01-17 18:21:45 +00:00
Andrey.Cherkasov
1687e43a3f [java-highlighting] Fixes after review (IJ-CR-19483)
GitOrigin-RevId: 19cb1e1ef0b68a296085fcee6d452ec40c51baf9
2022-01-15 19:22:09 +00:00
Nikita Eshkeev
34ec0bb7c9 [javadoc] IDEA-285556 Support language injection into snippet
Add an enclosing class for snippets in order not to make users define a class in a snippet code to eliminate syntax errors when the code consists of a set of instructions

GitOrigin-RevId: c6f52f94d51fdc6393c8a9fdc0ddb615e8d37b17
2022-01-15 01:44:09 +00:00
Anna Kozlova
724ed16f6f [java] replace default catch block template (IDEA-161593)
`throw e` won't fix the compilation error, comment - is not really better than empty catch block.

GitOrigin-RevId: ea002c332900b032392e766f3dd13fe3258ad49c
2022-01-14 20:39:23 +00:00
Andrey.Cherkasov
eb254acc5c [java-inspections] Fixes after review (IJ-CR-18136)
GitOrigin-RevId: a0864bcf774d435dc54ab63de1966f1a7779236f
2022-01-12 15:15:03 +00:00
Tagir Valeev
2d08b71a4e [java-inspections] IDEA-285964 Replacement for 'Expression can be replaced with Double.compare()' sometimes breaks the code
Option is added to disable the inspection when semantics change is possible

GitOrigin-RevId: 97e5576582b65c3ba0cb3122d6274a37e271386d
2022-01-10 08:52:07 +00:00
Andrey.Cherkasov
214ee7b316 [java-highlighting] Bad type in switch expression: provide quickfix to change return type of a method
IDEA-257275

GitOrigin-RevId: 5032f269098c8d6aa16a2a9231fc9ac566b85487
2022-01-04 21:57:32 +00:00
Andrey.Cherkasov
cc1c1cc844 [java-inspections] RedundantCollectionOperation: warn 'collection.addAll(List.of("x"))'
'collection.addAll(Set.of("x"))'
'collection.addAll(Collections.singletonList("x"))'

GitOrigin-RevId: 4a9185f774f9368fdcb5377eaeddb108b521f174
2022-01-04 21:57:31 +00:00
Andrey.Cherkasov
8bd14ace33 [java-inspections] ExcessiveLambdaUsage: suggest replacing 'list.replaceAll(… -> …)' with 'Collections.fill(list, …)'
GitOrigin-RevId: 5a548eb7a9e9d78ca46188b29c3e69f2502b99d3
2021-12-31 16:26:05 +00:00
Nikita Eshkeev
6ffd9bc4b6 [javadoc] IDEA-285556 Support language injection into snippet
JEP-413 says that by default a snippet tag's body is in JAVA language, so JavadocInjector injects JAVA into a snippet tag automatically. The injector relies on the lang attribute to inject a language, if the attribute is not present, then JAVA is used.
In order to make a user's live easier the injector doesn't make user guess the correct language name, instead if the injector didn't find a language by the value from the `lang` attribute it traverses throughout all the registered languages and looks for the one the name of which matches the specified ignoring case. That is the case for java: in our code base the language goes by the `JAVA` id, but users tend to write the language name in lowercase ("java") or with only the first letter in the capital case ("Java")

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

GitOrigin-RevId: cca8c90bb5ad04485f1bf4119b9936114e5492e4
2021-12-28 19:34:50 +00:00
Roman Ivanov
c9ec981d20 [java] fix test data
GitOrigin-RevId: c574abaafb637d2f403ab9c209c62c70b8d46f66
2021-12-28 14:22:23 +00:00
Roman Ivanov
9a51f2b953 Revert "[java] fix language level required for @snippet"
This reverts commit 093605a5d64aba4de5c9331ad6fc604e9f014328.

GitOrigin-RevId: a7de981964bbe6f30876c6aad8e9179c391d6aa4
2021-12-28 14:22:17 +00:00