Files
openide/java/java-impl/resources/inspectionDescriptions/UnnecessarilyQualifiedStaticUsage.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

53 lines
1.2 KiB
HTML

<html>
<body>
Reports usages of static members unnecessarily qualified with the class name.
<p>
Qualification with the class is unnecessary when the static member is available in a surrounding class
or in a super class of a surrounding class. Such qualification may be safely removed.
<p><b>Example:</b></p>
<pre><code>
class Foo {
static void foo() {}
static int x;
void bar() {
Foo.foo();
System.out.println(Foo.x);
}
static void baz() { Foo.foo(); }
}
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
class Foo {
static void foo() {}
static int x;
void bar() {
foo();
System.out.println(x);
}
static void baz() { foo(); }
}
</code></pre>
<!-- tooltip end -->
<p>
Use the inspection options to toggle the reporting for:
</p>
<ul>
<li>
<p>Static fields access:<br><code>void bar() { System.out.println(Foo.x); }</code></p>
</li>
<li>
<p>Calls to static methods:<br><code>void bar() { Foo.foo(); }</code></p>
</li>
</ul>
<p>
Also, you can configure the inspection to only report static member usage
in a static context. In this case, only <code>static void baz() { Foo.foo(); }</code> will be reported.
</p>
</body>
</html>