mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 22:09:38 +07:00
59 lines
1.2 KiB
HTML
59 lines
1.2 KiB
HTML
<html>
|
|
<body>
|
|
Reports usage of static members that is not qualified
|
|
with the class name.
|
|
<p>
|
|
This is legal if the static member is in
|
|
the same class, but may be confusing.
|
|
</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
class Foo {
|
|
static void foo() {}
|
|
static int x;
|
|
|
|
void bar() {
|
|
foo();
|
|
System.out.println(x);
|
|
}
|
|
|
|
static void baz() { foo(); }
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</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>
|
|
<!-- tooltip end -->
|
|
<p>Use the inspection settings to toggle the reporting for the following items:</p>
|
|
<ul>
|
|
<li>
|
|
<p>
|
|
static fields access<br>
|
|
<code>void bar() { System.out.println(x); }</code>
|
|
</p>
|
|
</li>
|
|
<li>
|
|
<p>
|
|
calls to static methods<br>
|
|
<code>void bar() { foo(); }</code><br>
|
|
<code>static void baz() { foo(); }</code>
|
|
</p>
|
|
</li>
|
|
</ul>
|
|
<p>
|
|
You can also configure the inspection to only report static member usage from a non-static context.
|
|
In the above example, <code>static void baz() { foo(); }</code> will not be reported.
|
|
</p>
|
|
</body>
|
|
</html> |