From 5e602d4693f6c1b615947a1314ef30effe3d1d59 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 8 Jun 2017 15:55:34 +0300 Subject: [PATCH] cleanup --- .../codeInspection/ex/QuickFixWrapper.java | 14 +++++----- .../openapi/components/BaseComponent.java | 2 +- .../openapi/vfs/newvfs/impl/VfsData.java | 2 +- .../com/intellij/ide/IdeEventQueueTest.java | 2 +- .../openapi/vfs/VfsUtilPerformanceTest.java | 26 +++++++++---------- 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/QuickFixWrapper.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/QuickFixWrapper.java index 15c78ec8a58d..29247b78128d 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/QuickFixWrapper.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/QuickFixWrapper.java @@ -40,8 +40,7 @@ public class QuickFixWrapper implements IntentionAction { private static final Logger LOG = Logger.getInstance("com.intellij.codeInspection.ex.QuickFixWrapper"); private final ProblemDescriptor myDescriptor; - private final int myFixNumber; - + private final LocalQuickFix myFix; @NotNull public static IntentionAction wrap(@NotNull ProblemDescriptor descriptor, int fixNumber) { @@ -50,12 +49,12 @@ public class QuickFixWrapper implements IntentionAction { LOG.assertTrue(fixes != null && fixes.length > fixNumber); final QuickFix fix = fixes[fixNumber]; - return fix instanceof IntentionAction ? (IntentionAction)fix : new QuickFixWrapper(descriptor, fixNumber); + return fix instanceof IntentionAction ? (IntentionAction)fix : new QuickFixWrapper(descriptor, (LocalQuickFix)fix); } - private QuickFixWrapper(@NotNull ProblemDescriptor descriptor, int fixNumber) { + private QuickFixWrapper(@NotNull ProblemDescriptor descriptor, @NotNull LocalQuickFix fix) { myDescriptor = descriptor; - myFixNumber = fixNumber; + myFix = fix; } @Override @@ -67,7 +66,7 @@ public class QuickFixWrapper implements IntentionAction { @Override @NotNull public String getFamilyName() { - return myDescriptor.getFixes()[myFixNumber].getName(); + return getFix().getName(); } @Override @@ -104,8 +103,9 @@ public class QuickFixWrapper implements IntentionAction { return getFix().getElementToMakeWritable(file); } + @NotNull public LocalQuickFix getFix() { - return (LocalQuickFix)myDescriptor.getFixes()[myFixNumber]; + return myFix; } @TestOnly diff --git a/platform/core-api/src/com/intellij/openapi/components/BaseComponent.java b/platform/core-api/src/com/intellij/openapi/components/BaseComponent.java index 557049e9b490..145341a0cdf2 100644 --- a/platform/core-api/src/com/intellij/openapi/components/BaseComponent.java +++ b/platform/core-api/src/com/intellij/openapi/components/BaseComponent.java @@ -30,7 +30,7 @@ public interface BaseComponent extends NamedComponent { } /** - * @see {@link com.intellij.openapi.Disposable} + * @see com.intellij.openapi.Disposable */ default void disposeComponent() { } diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VfsData.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VfsData.java index c74f3248aa7a..a20a4ca91365 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VfsData.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VfsData.java @@ -110,7 +110,7 @@ public class VfsData { } @Nullable - public static VirtualFileSystemEntry getFileById(int id, VirtualDirectoryImpl parent) { + static VirtualFileSystemEntry getFileById(int id, VirtualDirectoryImpl parent) { Segment segment = getSegment(id, false); if (segment == null) return null; diff --git a/platform/platform-tests/testSrc/com/intellij/ide/IdeEventQueueTest.java b/platform/platform-tests/testSrc/com/intellij/ide/IdeEventQueueTest.java index 7c8fb123c960..c6530b5b47b6 100644 --- a/platform/platform-tests/testSrc/com/intellij/ide/IdeEventQueueTest.java +++ b/platform/platform-tests/testSrc/com/intellij/ide/IdeEventQueueTest.java @@ -31,7 +31,7 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; public class IdeEventQueueTest extends PlatformTestCase { - public void testManyEvents() { + public void testManyEventsStress() { int N = 100000; PlatformTestUtil.startPerformanceTest("Event queue dispatch", 10000, () -> { UIUtil.dispatchAllInvocationEvents(); diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilPerformanceTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilPerformanceTest.java index 7ff17dc68b0d..54b034202f24 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilPerformanceTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilPerformanceTest.java @@ -287,7 +287,7 @@ public class VfsUtilPerformanceTest extends BareTestFixtureTestCase { } @Test - public void addingManyChildrenToTheSameDirectoryMustNotBeQuadratic() throws IOException { + public void addingManyChildrenToTheSameDirectoryMustNotBeQuadratic() throws Exception { int N = 1_000_000; // measures create N children inside one directory. // to avoid slow local file system try to use MyFakeVirtualFile which doesn't actually query disk @@ -296,21 +296,19 @@ public class VfsUtilPerformanceTest extends BareTestFixtureTestCase { Disposer.register(getTestRootDisposable(), ()-> ApplicationInfoImpl.setInStressTest(false)); List toDelete = new ArrayList<>(); try { - UIUtil.invokeLaterIfNeeded(()->{ - PlatformTestUtil.startPerformanceTest("adding many children", 15000, () -> { - VirtualFile validVTemp = new MyFakeDirectory("vtemp"); - toDelete.add(validVTemp); - List events = IntStream.range(0, N) - .mapToObj(i -> new VFileCreateEvent(this, validVTemp, i + ".txt", false, false)) - .collect(Collectors.toList()); + UIUtil.invokeLaterIfNeeded(()-> PlatformTestUtil.startPerformanceTest("adding many children", 15000, () -> { + VirtualFile validVTemp = new MyFakeDirectory("vtemp"); + toDelete.add(validVTemp); + List events = IntStream.range(0, N) + .mapToObj(i -> new VFileCreateEvent(this, validVTemp, i + ".txt", false, false)) + .collect(Collectors.toList()); - WriteCommandAction.runWriteCommandAction(null, () -> { - PersistentFS.getInstance().processEvents(events); - }); + WriteCommandAction.runWriteCommandAction(null, () -> { + PersistentFS.getInstance().processEvents(events); + }); - assertEquals(N, validVTemp.getChildren().length); - }).assertTiming(); - }); + assertEquals(N, validVTemp.getChildren().length); + }).assertTiming()); } finally { toDelete.forEach(VfsTestUtil::deleteFile);