mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 05:21:29 +07:00
[codeInspection] Fix devkit inspection descriptions
GitOrigin-RevId: d5f8323eb560b9f63c7fa6589bb4aa1bbc9ff93d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
143d5b2d92
commit
ecb429a9f1
@@ -8,17 +8,17 @@ Reports assignments of application services to static final fields/properties.
|
||||
The only exception is an explicit constructor call to store dummy/default instances.
|
||||
</p>
|
||||
<p><b>Example:</b></p>
|
||||
<pre><code>
|
||||
<pre><code lang="java">
|
||||
// Incorrect way
|
||||
private static final ManagingFS ourInstance = ApplicationManager.getApplication().getService(ManagingFS.class);
|
||||
</code></pre>
|
||||
<pre><code>
|
||||
<pre><code lang="java">
|
||||
// Correct way
|
||||
private static final Supplier<ManagingFS> ourInstance = CachedSingletonsRegistry.lazy(() -> {
|
||||
return ApplicationManager.getApplication().getService(ManagingFS.class);
|
||||
});
|
||||
</code></pre>
|
||||
<pre><code>
|
||||
<pre><code lang="java">
|
||||
// Exception
|
||||
private static final UniqueVFilePathBuilder DUMMY_BUILDER = new UniqueVFilePathBuilder()
|
||||
</code></pre>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Reports <code>forEach</code> loops with missing cancellation checks.
|
||||
<p>Runs only within the methods with <code>com.intellij.util.concurrency.annotations.RequiresReadLock</code> annotation.</p>
|
||||
<p><b>Example:</b></p>
|
||||
<pre><code>
|
||||
<pre><code lang="kotlin">
|
||||
for (item in items) {
|
||||
ProgressManager.checkCanceled() // should be present in the first line
|
||||
...
|
||||
@@ -12,7 +12,7 @@ Reports <code>forEach</code> loops with missing cancellation checks.
|
||||
<p>
|
||||
In case of nested loops with nothing in between:
|
||||
</p>
|
||||
<pre><code>
|
||||
<pre><code lang="kotlin">
|
||||
for (item in items) {
|
||||
// nothing in between
|
||||
for (inner in item.inners) {
|
||||
|
||||
@@ -5,12 +5,12 @@ Reports usages of <code>java.awt.Color</code> to create gray colors.
|
||||
The <b>Convert to 'Gray'</b> quick fix replaces it using <code>com.intellij.ui.Gray</code> constants instead.
|
||||
</p>
|
||||
<p>Examples:</p>
|
||||
<pre>
|
||||
<pre><code lang="java">
|
||||
// bad:
|
||||
Color gray = new Color(37, 37, 37);
|
||||
|
||||
// good:
|
||||
Color gray = Gray._37;
|
||||
</pre>
|
||||
</code></pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -4,13 +4,13 @@ Reports classes annotated with the <code>@com.intellij.openapi.components.Servic
|
||||
<p>
|
||||
Suggests making a class final if it is concrete.</p>
|
||||
<p><b>Example:</b></p>
|
||||
<pre><code>
|
||||
<pre><code lang="kotlin">
|
||||
// MyService.kt
|
||||
@Service(Service.Level.APP)
|
||||
open class MyService
|
||||
</code></pre>
|
||||
<p>After the quick-fix is applied:</p>
|
||||
<pre><code>
|
||||
<pre><code lang="kotlin">
|
||||
// MyService.kt
|
||||
@Service(Service.Level.APP)
|
||||
class MyService
|
||||
@@ -19,13 +19,13 @@ Reports classes annotated with the <code>@com.intellij.openapi.components.Servic
|
||||
Suggests removing the <code>@Service</code> annotation if it is an abstract class or interface.
|
||||
</p>
|
||||
<p><b>Example:</b></p>
|
||||
<pre><code>
|
||||
<pre><code lang="java">
|
||||
// MyService.java
|
||||
@Service(Service.Level.APP)
|
||||
abstract class MyService {}
|
||||
</code></pre>
|
||||
<p>After the quick-fix is applied:</p>
|
||||
<pre><code>
|
||||
<pre><code lang="java">
|
||||
// MyService.java
|
||||
abstract class MyService {}
|
||||
</code></pre>
|
||||
|
||||
@@ -6,7 +6,8 @@ Reports Swing components that do not provide accessibility context.
|
||||
visually impaired users.
|
||||
</p>
|
||||
<p><b>Example:</b></p>
|
||||
<pre><code> ListCellRenderer<String> renderer = (list, val, index, sel, cell) -> {
|
||||
<pre><code lang="java">
|
||||
ListCellRenderer<String> renderer = (list, val, index, sel, cell) -> {
|
||||
JPanel panel = new JPanel();
|
||||
return panel;
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ Reports <code>TokenSet</code> field declarations referencing non-platform elemen
|
||||
</p>
|
||||
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
<pre><code lang="java">
|
||||
// element types holder:
|
||||
public interface MyLangTokenTypes {
|
||||
IElementType COMMENT = new MyLangTokenType("COMMENT");
|
||||
@@ -77,7 +77,7 @@ public class MyLangParserDefinition implements ParserDefinition {
|
||||
...
|
||||
}
|
||||
|
||||
</pre>
|
||||
</code></pre>
|
||||
|
||||
<!-- tooltip end -->
|
||||
<p><small>New in 2023.2</small>
|
||||
|
||||
@@ -5,7 +5,7 @@ Reports usage of <code>VirtualFile.getChildren()</code> inside recursive methods
|
||||
This may cause endless loops when iterating over cyclic symlinks.
|
||||
Use <code>VfsUtilCore.visitChildrenRecursively()</code> instead.
|
||||
</p>
|
||||
<pre><code>
|
||||
<pre><code lang="java">
|
||||
void processDirectory(VirtualFile dir) {
|
||||
for (VirtualFile file : dir.getChildren()) { // bad
|
||||
if (!file.isDirectory()) {
|
||||
@@ -17,7 +17,7 @@ void processDirectory(VirtualFile dir) {
|
||||
}
|
||||
</code>
|
||||
</pre>
|
||||
<pre><code>
|
||||
<pre><code lang="java">
|
||||
void processDirectory(VirtualFile dir) {
|
||||
VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor<Void>() { // good
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,7 @@ Reports passing unspecified <code>place</code> parameter for <code>ActionManager
|
||||
</p>
|
||||
<p>
|
||||
Examples:
|
||||
<pre>
|
||||
<pre><code lang="java">
|
||||
// bad:
|
||||
actionManager.createActionToolbar("", group, false);
|
||||
actionManager.createActionToolbar("unknown", group, false);
|
||||
@@ -15,7 +15,7 @@ actionManager.createActionPopupMenu(ActionPlaces.UNKNOWN, group);
|
||||
// good:
|
||||
actionManager.createActionToolbar("MyPlace", group, false);
|
||||
actionManager.createActionPopupMenu(ActionPlaces.EDITOR_TOOLBAR, group);
|
||||
</pre>
|
||||
</code></pre>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -8,7 +8,7 @@ Reports usages of <code>javax.swing.border.EmptyBorder</code> and <code>JBUI.Bor
|
||||
Quick fix performs replacement with <code>JBUI.Borders.empty()</code> or simplifies the expression.
|
||||
</p>
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
<pre><code lang="java">
|
||||
// bad:
|
||||
Border border1 = new EmptyBorder(1, 2, 3, 4);
|
||||
Border border2 = new EmptyBorder(1, 2, 1, 2);
|
||||
@@ -18,6 +18,6 @@ Border border3 = new EmptyBorder(1, 0, 0, 0);
|
||||
Border border1 = JBUI.Borders.empty(1, 2, 3, 4);
|
||||
Border border2 = JBUI.Borders.empty(1, 2);
|
||||
Border border3 = JBUI.Borders.emptyTop(1);
|
||||
</pre>
|
||||
</code></pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -8,7 +8,7 @@ Reports usages of <code>java.awt.Insets</code> and <code>JBUI.insetsXyz()</code>
|
||||
Quick fix performs replacement with <code>JBUI.insets()</code> or simplifies the expression.
|
||||
</p>
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
<pre><code lang="java">
|
||||
// bad:
|
||||
Insets insets1 = new Insets(1, 2, 3, 4);
|
||||
Insets insets2 = new Insets(1, 2, 1, 2);
|
||||
@@ -18,6 +18,6 @@ Insets insets3 = new Insets(1, 0, 0, 0);
|
||||
Insets insets1 = JBUI.insets(1, 2, 3, 4);
|
||||
Insets insets2 = JBUI.insets(1, 2);
|
||||
Insets insets3 = JBUI.insetsTop(1);
|
||||
</pre>
|
||||
</code></pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -8,7 +8,7 @@ Reports usages of <code>java.awt.Color</code>.
|
||||
Quick-fix replaces usages with <code>JBColor</code>, which defines "dark" color variant.
|
||||
</p>
|
||||
<p>Examples:</p>
|
||||
<pre>
|
||||
<pre><code lang="java">
|
||||
// bad:
|
||||
Color darkGreen = new Color(12, 58, 27);
|
||||
Color blue = Color.BLUE;
|
||||
@@ -17,6 +17,6 @@ Color blue = Color.BLUE;
|
||||
Color darkGreen = new JBColor(12, 58, 27);
|
||||
Color blue = JBColor.BLUE;
|
||||
Color green = new JBColor(new Color(12, 58, 27), new Color(27, 112, 39));
|
||||
</pre>
|
||||
</code></pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -8,12 +8,12 @@ Reports extensions which are instantiated by the IntelliJ Platform, but are decl
|
||||
</p>
|
||||
<h2>Example</h2>
|
||||
<p>Extension registration:</p>
|
||||
<pre>
|
||||
<pre><code lang="xml">
|
||||
<annotator language="myLang" implementationClass="com.example.MyAnnotator"/>
|
||||
</pre>
|
||||
</code></pre>
|
||||
|
||||
<p>Extension implementation:</p>
|
||||
<pre>
|
||||
<pre><code lang="kotlin">
|
||||
// bad:
|
||||
object MyAnnotator : Annotator {
|
||||
...
|
||||
@@ -23,7 +23,7 @@ object MyAnnotator : Annotator {
|
||||
class MyAnnotator : Annotator {
|
||||
...
|
||||
}
|
||||
</pre>
|
||||
</code></pre>
|
||||
<!-- tooltip end -->
|
||||
<p><small>New in 2023.1</small>
|
||||
</body>
|
||||
|
||||
@@ -8,12 +8,12 @@ Reports Kotlin objects that are registered as plugin extensions.
|
||||
</p>
|
||||
<h2>Example</h2>
|
||||
<p>Extension registration:</p>
|
||||
<pre>
|
||||
<pre><code lang="xml">
|
||||
<annotator language="myLang" implementationClass="com.example.MyAnnotator"/>
|
||||
</pre>
|
||||
</code></pre>
|
||||
|
||||
<p>Extension implementation:</p>
|
||||
<pre>
|
||||
<pre><code lang="kotlin">
|
||||
// bad:
|
||||
object MyAnnotator : Annotator {
|
||||
...
|
||||
@@ -23,7 +23,7 @@ object MyAnnotator : Annotator {
|
||||
class MyAnnotator : Annotator {
|
||||
...
|
||||
}
|
||||
</pre>
|
||||
</code></pre>
|
||||
<!-- tooltip end -->
|
||||
<p><small>New in 2023.1</small>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user