mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
53 lines
1.2 KiB
HTML
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> |