From c028919af978e13b1f543ef5dd0c99cd1ec30722 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 21 Feb 2020 11:26:53 +0100 Subject: [PATCH] do not get PostprocessReformattingAspect as component GitOrigin-RevId: 0fa698b35192e54930e2a54e5f5975b67408f0b4 --- .../java/refactoring/CopyClassTest.java | 8 ++++---- .../psi/impl/file/impl/FileManagerTest.java | 4 ++-- .../codeInsight/JavaCodeInsightTestCase.java | 4 ++-- .../refactoring/MultiFileTestCase.java | 18 ++---------------- .../refactoring/TypeMigrationTestBase.java | 6 ++---- .../source/codeStyle/CodeFormatterFacade.java | 5 +++-- .../refactoring/move/GroovyMoveScriptTest.java | 18 ++---------------- 7 files changed, 17 insertions(+), 46 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/java/refactoring/CopyClassTest.java b/java/java-tests/testSrc/com/intellij/java/refactoring/CopyClassTest.java index c5bfabffd5b3..3f988de80c36 100644 --- a/java/java-tests/testSrc/com/intellij/java/refactoring/CopyClassTest.java +++ b/java/java-tests/testSrc/com/intellij/java/refactoring/CopyClassTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.java.refactoring; import com.intellij.JavaTestUtil; @@ -32,7 +32,7 @@ public class CopyClassTest extends LightMultiFileTestCase { public void testPrivateMethodsInInterfaces() throws Exception { doTest("Foo", "Bar"); } - + public void testReplaceAllOccurrences1() throws Exception { doTest("Foo", "Bar"); } @@ -50,7 +50,7 @@ public class CopyClassTest extends LightMultiFileTestCase { private void doTest(final String oldName, final String copyName) throws Exception { myFixture.copyDirectoryToProject(getTestName(true), ""); performAction(oldName, copyName); - + VirtualFile fileAfter = myFixture.findFileInTempDir(copyName + ".java"); VirtualFile fileExpected = myFixture.findFileInTempDir(copyName + ".expected.java"); @@ -68,7 +68,7 @@ public class CopyClassTest extends LightMultiFileTestCase { Collections.singletonMap(oldClass.getNavigationElement().getContainingFile(), new PsiClass[]{oldClass}); CopyClassesHandler.doCopyClasses(sourceClasses, copyName, targetDirectory, getProject()); - getProject().getComponent(PostprocessReformattingAspect.class).doPostponedFormatting(); + PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting(); }); } diff --git a/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/FileManagerTest.java b/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/FileManagerTest.java index eca530bce010..c028c8d2fe11 100644 --- a/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/FileManagerTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/impl/file/impl/FileManagerTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.psi.impl.file.impl; import com.intellij.openapi.application.ApplicationManager; @@ -371,7 +371,7 @@ public class FileManagerTest extends JavaPsiTestCase { try { ApplicationManager.getApplication().runWriteAction(() -> { CodeStyleManager.getInstance(myProject).reformat(psiFile); - getProject().getComponent(PostprocessReformattingAspect.class).doPostponedFormatting(); + PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting(); myPsiManager.reloadFromDisk(psiFile); }); } diff --git a/java/testFramework/src/com/intellij/codeInsight/JavaCodeInsightTestCase.java b/java/testFramework/src/com/intellij/codeInsight/JavaCodeInsightTestCase.java index 3ee1fc1932c8..731c08bc150a 100644 --- a/java/testFramework/src/com/intellij/codeInsight/JavaCodeInsightTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/JavaCodeInsightTestCase.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; @@ -416,7 +416,7 @@ public abstract class JavaCodeInsightTestCase extends JavaPsiTestCase { protected void checkResultByFile(@NotNull final String filePath, final boolean stripTrailingSpaces) throws Exception { WriteCommandAction.writeCommandAction(getProject()).run(() -> { - getProject().getComponent(PostprocessReformattingAspect.class).doPostponedFormatting(); + PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting(); if (stripTrailingSpaces) { ((DocumentImpl)myEditor.getDocument()).stripTrailingSpaces(getProject()); } diff --git a/java/testFramework/src/com/intellij/refactoring/MultiFileTestCase.java b/java/testFramework/src/com/intellij/refactoring/MultiFileTestCase.java index 0a54cf04b411..990527090b37 100644 --- a/java/testFramework/src/com/intellij/refactoring/MultiFileTestCase.java +++ b/java/testFramework/src/com/intellij/refactoring/MultiFileTestCase.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring; import com.intellij.codeInsight.JavaCodeInsightTestCase; @@ -56,7 +42,7 @@ public abstract class MultiFileTestCase extends JavaCodeInsightTestCase { final VirtualFile rootAfter = LocalFileSystem.getInstance().findFileByPath(pathAfter.replace(File.separatorChar, '/')); performAction.performAction(rootDir, rootAfter); - WriteCommandAction.runWriteCommandAction(getProject(), () -> myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting()); + WriteCommandAction.runWriteCommandAction(getProject(), () -> PostprocessReformattingAspect.getInstance(myProject).doPostponedFormatting()); FileDocumentManager.getInstance().saveAllDocuments(); diff --git a/java/typeMigration/test/com/intellij/refactoring/TypeMigrationTestBase.java b/java/typeMigration/test/com/intellij/refactoring/TypeMigrationTestBase.java index 93d49cfcd26c..fea19b432514 100644 --- a/java/typeMigration/test/com/intellij/refactoring/TypeMigrationTestBase.java +++ b/java/typeMigration/test/com/intellij/refactoring/TypeMigrationTestBase.java @@ -1,6 +1,4 @@ -// Copyright 2000-2017 JetBrains s.r.o. -// Use of this source code is governed by the Apache 2.0 license that can be -// found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring; import com.intellij.openapi.command.WriteCommandAction; @@ -151,7 +149,7 @@ public abstract class TypeMigrationTestBase extends LightMultiFileTestCase { WriteCommandAction.runWriteCommandAction(null, () -> pr.performRefactoring(usages)); - WriteCommandAction.runWriteCommandAction(getProject(), () -> getProject().getComponent(PostprocessReformattingAspect.class).doPostponedFormatting()); + WriteCommandAction.runWriteCommandAction(getProject(), () -> PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting()); myFixture.getTempDirFixture().createFile(className + ".items", report); } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java index e188282572e8..3bd04b45b5b1 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.psi.impl.source.codeStyle; @@ -230,7 +230,8 @@ public class CodeFormatterFacade { i++; } } - final PostprocessReformattingAspect component = file.getProject().getComponent(PostprocessReformattingAspect.class); + + PostprocessReformattingAspect component = PostprocessReformattingAspect.getInstance(file.getProject()); FormattingProgressTask.FORMATTING_CANCELLED_FLAG.set(false); component.doPostponedFormatting(file.getViewProvider()); i = 0; diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/move/GroovyMoveScriptTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/move/GroovyMoveScriptTest.java index be8d4b341f81..3056f66ac741 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/move/GroovyMoveScriptTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/move/GroovyMoveScriptTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.groovy.refactoring.move; @@ -105,7 +91,7 @@ public class GroovyMoveScriptTest extends LightJavaCodeInsightFixtureTestCase { final VirtualFile expectedRoot = LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + getTestName(true) + "/after"); //File expectedRoot = new File(getTestDataPath() + testName + "/after"); - getProject().getComponent(PostprocessReformattingAspect.class).doPostponedFormatting(); + PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting(); VirtualFileManager.getInstance().syncRefresh(); try {