this
限定符。
使用 this
来消除代码引用的歧义在许多编码样式中都不受鼓励,并且很容易通过自动重构变得不必要。
示例:
class Foo {
int x;
void foo() {
this.x = 2;
}
}
在应用快速修复后:
class Foo {
int x;
void foo() {
x = 2;
}
}
使用检查设置可以忽略对字段的赋值。
例如,this.x = 2;
不会被报告,但 int y = this.x;
会被报告。