mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
Textual changes for "Bulk 'Files.readAttributes()' call can be used" inspection
GitOrigin-RevId: 8ca94e665d8345b4b299415fd3bf43cf22d28c68
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0cf44fb1ee
commit
7e9ee7537f
@@ -1,26 +1,26 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports multiple <code>java.io.File</code> attribute checks in a row, such as:
|
||||
Reports multiple sequential <code>java.io.File</code> attribute checks, such as:
|
||||
<ul>
|
||||
<li><code>isDirectory</code></li>
|
||||
<li><code>isFile</code></li>
|
||||
<li><code>lastModified</code></li>
|
||||
<li><code>length</code></li>
|
||||
<li><code>isDirectory()</code></li>
|
||||
<li><code>isFile()</code></li>
|
||||
<li><code>lastModified()</code></li>
|
||||
<li><code>length()</code></li>
|
||||
</ul>
|
||||
These calls can be replaced with a bulk <code>Files.readAttributes</code> call.
|
||||
Usually the bulk method is more performant then multiple attribute checks.
|
||||
Such calls can be replaced with a bulk <code>Files.readAttributes()</code> call.
|
||||
This is usually more performant then multiple separate attribute checks.
|
||||
<p>Example:</p>
|
||||
<pre><code>
|
||||
boolean isNewFile(File file, long lastModified) throws IOException {
|
||||
return file.isFile() && file.lastModified() > lastModified;
|
||||
}
|
||||
boolean isNewFile(File file, long lastModified) throws IOException {
|
||||
return file.isFile() && file.lastModified() > lastModified;
|
||||
}
|
||||
</code></pre>
|
||||
<p>After the quick-fix is applied:</p>
|
||||
<pre><code>
|
||||
boolean isNewFile(File file, long lastModified) throws IOException {
|
||||
BasicFileAttributes fileAttributes = Files.readAttributes(file.toPath(), BasicFileAttributes.class);
|
||||
return fileAttributes.isRegularFile() && fileAttributes.lastModifiedTime().toMillis() > lastModified;
|
||||
}
|
||||
boolean isNewFile(File file, long lastModified) throws IOException {
|
||||
BasicFileAttributes fileAttributes = Files.readAttributes(file.toPath(), BasicFileAttributes.class);
|
||||
return fileAttributes.isRegularFile() && fileAttributes.lastModifiedTime().toMillis() > lastModified;
|
||||
}
|
||||
</code></pre>
|
||||
<!-- tooltip end -->
|
||||
<p>This inspection does not show a warning if <code>IOException</code> is not handled in the current context, but the quick-fix is still available.</p>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Fix all 'Bulk 'Files.readAttributes' call can be used instead of multiple file attribute calls' problems in file" "true"
|
||||
// "Fix all 'Bulk 'Files.readAttributes()' call can be used' problems in file" "true"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "false"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "false"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Fix all 'Bulk 'Files.readAttributes' call can be used instead of multiple file attribute calls' problems in file" "true"
|
||||
// "Fix all 'Bulk 'Files.readAttributes()' call can be used' problems in file" "true"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "false"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "false"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "false"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "false"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with bulk 'Files.readAttributes' call" "true"
|
||||
// "Replace with bulk 'Files.readAttributes()' call" "true"
|
||||
import java.io.*;
|
||||
|
||||
class Foo {
|
||||
|
||||
@@ -1751,9 +1751,9 @@ popup.title.effective.visibility=Effective Visibility
|
||||
inspection.io.stream.constructor.description='InputStream' and 'OutputStream' can be constructed using 'Files' methods
|
||||
inspection.input.stream.constructor.message='InputStream' can be constructed using 'Files.newInputStream'
|
||||
inspection.output.stream.constructor.message='OutputStream' can be constructed using 'Files.newOutputStream'
|
||||
inspection.bulk.file.attributes.read.description=Bulk 'Files.readAttributes' call can be used instead of multiple file attribute calls
|
||||
inspection.replace.with.bulk.file.attributes.read.fix.family.name=Replace with bulk 'Files.readAttributes' call
|
||||
inspection.bulk.file.attributes.read.message=Multiple file attribute calls can be replaced with single 'Files.readAttributes' call
|
||||
inspection.bulk.file.attributes.read.description=Bulk 'Files.readAttributes()' call can be used
|
||||
inspection.replace.with.bulk.file.attributes.read.fix.family.name=Replace with bulk 'Files.readAttributes()' call
|
||||
inspection.bulk.file.attributes.read.message=Multiple file attribute calls can be replaced with single 'Files.readAttributes()' call
|
||||
external.annotations.problem.title=Unable to read external annotations
|
||||
external.annotations.problem.parse.error=File: {0}<br>Problem: {1}
|
||||
external.annotations.open.file=Open annotations file
|
||||
|
||||
Reference in New Issue
Block a user