mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
unguarded field access: support sync expressions (IDEA-153399)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import javax.annotation.concurrent.GuardedBy;
|
||||
|
||||
class Example
|
||||
{
|
||||
private final Distribution distribution = new Distribution();
|
||||
|
||||
public void add(long value)
|
||||
{
|
||||
synchronized (distribution) {
|
||||
distribution.total += value;
|
||||
<error descr="Cannot resolve symbol 'total'">total</error> += value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected static class Distribution
|
||||
{
|
||||
@GuardedBy("this")
|
||||
private long total = 0;
|
||||
}
|
||||
}
|
||||
+10
-1
@@ -24,11 +24,20 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class FieldAccessedNotGuardedInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testItself() throws Exception {
|
||||
myFixture.addClass("package net.jcip.annotations;\n" + getGuardedByAnnotationText());
|
||||
myFixture.testHighlighting(true, false, false, getTestName(true) + ".java");
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testJavax_itself() throws Exception {
|
||||
myFixture.addClass("package javax.annotation.concurrent;\n" + getGuardedByAnnotationText());
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSyncOnFieldQualifier() throws Exception {
|
||||
myFixture.addClass("package javax.annotation.concurrent;\n" + getGuardedByAnnotationText());
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.testHighlighting(true, false, false, getTestName(true) + ".java");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user