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

27 lines
828 B
HTML

<html>
<body>
Suggests replacing initialization of fields using assignment with initialization in the field declaration.
<p>Only reports if the field assignment is located in an instance or static initializer, and
joining it with the field declaration is likely to be safe.
In other cases, like assignment inside a constructor, the quick-fix is provided without highlighting,
as the fix may change the semantics.</p>
<p>Example:</p>
<pre><code>
class MyClass {
static final int intConstant;
static {
intConstant = 10;
}
}
</code></pre>
The quick fix moves the assigned value to the field initializer removing the class initializer if possible:
<pre><code>
class MyClass {
static final int intConstant = 10;
}
</code></pre>
<!-- tooltip end -->
<small>Since 2017.2</small>
</body>
</html>