cleanup: introduce LanguageRefactoringSupport#getInstance

GitOrigin-RevId: 832c2688ee1976e8e353291c645b676c77ecd2ce
This commit is contained in:
Max Medvedev
2024-09-04 19:37:00 +00:00
committed by intellij-monorepo-bot
parent 72fdcc80d1
commit 3f27a3edf1
20 changed files with 46 additions and 40 deletions
@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight.intention.impl;
import com.intellij.codeInsight.completion.CompletionMemory;
@@ -71,7 +71,7 @@ public final class IntroduceVariableIntentionAction extends BaseRefactoringInten
if (type != null) return new IntroduceEmptyVariableHandlerImpl().generatePreview(editor, element.getContainingFile(), type);
final PsiExpression expression = detectExpressionStatement(element);
if (expression == null) return IntentionPreviewInfo.EMPTY;
RefactoringSupportProvider supportProvider = LanguageRefactoringSupport.INSTANCE.forLanguage(JavaLanguage.INSTANCE);
RefactoringSupportProvider supportProvider = LanguageRefactoringSupport.getInstance().forLanguage(JavaLanguage.INSTANCE);
JavaIntroduceVariableHandlerBase handler = (JavaIntroduceVariableHandlerBase)supportProvider.getIntroduceVariableHandler();
if (handler instanceof PreviewableRefactoringActionHandler previewableRefactoringActionHandler) {
return previewableRefactoringActionHandler.generatePreview(project, expression);
@@ -89,7 +89,7 @@ public final class IntroduceVariableIntentionAction extends BaseRefactoringInten
final PsiExpression expression = detectExpressionStatement(element);
if (expression == null) return;
RefactoringSupportProvider supportProvider = LanguageRefactoringSupport.INSTANCE.forLanguage(JavaLanguage.INSTANCE);
RefactoringSupportProvider supportProvider = LanguageRefactoringSupport.getInstance().forLanguage(JavaLanguage.INSTANCE);
JavaIntroduceVariableHandlerBase handler = (JavaIntroduceVariableHandlerBase)supportProvider.getIntroduceVariableHandler();
assert handler != null;
handler.invoke(project, editor, expression);
@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.refactoring.changeSignature;
import com.intellij.lang.LanguageRefactoringSupport;
@@ -7,12 +7,10 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.JavaTokenType;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiType;
import com.intellij.psi.impl.source.tree.Factory;
import com.intellij.psi.impl.source.tree.SharedImplUtil;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.CharTable;
import com.intellij.util.CommonJavaRefactoringUtil;
import com.intellij.util.IncorrectOperationException;
import java.util.ArrayList;
@@ -94,7 +92,7 @@ public final class ChangeSignatureUtil {
}
public static void invokeChangeSignatureOn(PsiMethod method, Project project) {
RefactoringSupportProvider provider = LanguageRefactoringSupport.INSTANCE.forContext(method);
RefactoringSupportProvider provider = LanguageRefactoringSupport.getInstance().forContext(method);
ChangeSignatureHandler handler = provider != null ? provider.getChangeSignatureHandler() : null;
if (handler != null) {
handler.invoke(project, new PsiElement[]{method}, null);
@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.refactoring.introduceVariable;
import com.intellij.codeInsight.CodeInsightUtil;
@@ -368,7 +368,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
final PsiFile file = anchorStatement.getContainingFile();
IntroduceVariableUtil.LOG.assertTrue(file != null, "expr.getContainingFile() == null");
final PsiElement nameSuggestionContext = editor == null ? null : file.findElementAt(editor.getCaretModel().getOffset());
final RefactoringSupportProvider supportProvider = LanguageRefactoringSupport.INSTANCE.forContext(expr);
final RefactoringSupportProvider supportProvider = LanguageRefactoringSupport.getInstance().forContext(expr);
final boolean isInplaceAvailableOnDataContext =
supportProvider != null &&
editor.getSettings().isVariableInplaceRenameEnabled() &&