Commit 20be9891 authored by Daniil Ovchinnikov's avatar Daniil Ovchinnikov Committed by intellij-monorepo-bot
Browse files

IJP-961 allow slow operations in the common cases for the time being

GitOrigin-RevId: 34c4d3a16e01eb560fc9ae284a8e65cedfb9c54c
parent 4a3ef63f
Showing with 112 additions and 62 deletions
+112 -62
// 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.
// Copyright 2000-2021 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.debugger.impl;
import com.intellij.debugger.DebugEnvironment;
......@@ -23,6 +23,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.SlowOperations;
import com.intellij.xdebugger.XDebugProcess;
import com.intellij.xdebugger.XDebugProcessStarter;
import com.intellij.xdebugger.XDebugSession;
......@@ -66,9 +67,9 @@ public class GenericDebuggerRunner implements JvmPatchableProgramRunner<GenericD
});
}
else {
executionManager.startRunProfile(environment, state, state1 -> {
executionManager.startRunProfile(environment, state, state1 -> SlowOperations.allowSlowOperations(() -> {
return doExecute(state, environment);
});
}));
}
}
......
// 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.
// Copyright 2000-2021 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.execution.impl;
import com.intellij.debugger.engine.JavaDebugProcess;
......@@ -43,6 +43,7 @@ import com.intellij.unscramble.ThreadDumpConsoleFactory;
import com.intellij.unscramble.ThreadDumpParser;
import com.intellij.unscramble.ThreadState;
import com.intellij.util.ArrayUtil;
import com.intellij.util.SlowOperations;
import com.intellij.util.TimeoutUtil;
import com.intellij.util.concurrency.AppExecutorUtil;
import com.intellij.util.messages.MessageBusConnection;
......@@ -112,9 +113,9 @@ public class DefaultJavaProgramRunner implements JvmPatchableProgramRunner<Runne
});
}
else {
executionManager.startRunProfile(environment, currentState, (ignored) -> {
executionManager.startRunProfile(environment, currentState, (ignored) -> SlowOperations.allowSlowOperations(() -> {
return doExecute(currentState, environment);
});
}));
}
}
......
// 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.
// Copyright 2000-2021 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.completion;
import com.intellij.codeInsight.ExpectedTypeInfo;
......@@ -38,6 +38,7 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiTypesUtil;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.SlowOperations;
import com.intellij.util.ThreeState;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.Contract;
......@@ -316,7 +317,7 @@ public final class ConstructorInsertHandler implements InsertHandler<LookupEleme
final PsiAnonymousClass
aClass = PsiTreeUtil.findElementOfClassAtOffset(file, editor.getCaretModel().getOffset(), PsiAnonymousClass.class, false);
if (aClass == null) return;
CommandProcessor.getInstance().executeCommand(project, () -> {
CommandProcessor.getInstance().executeCommand(project, () -> SlowOperations.allowSlowOperations(() -> {
final Collection<CandidateInfo> candidatesToImplement = OverrideImplementExploreUtil.getMethodsToOverrideImplement(aClass, true);
for (Iterator<CandidateInfo> iterator = candidatesToImplement.iterator(); iterator.hasNext(); ) {
final CandidateInfo candidate = iterator.next();
......@@ -343,7 +344,7 @@ public final class ConstructorInsertHandler implements InsertHandler<LookupEleme
}
});
}
}, getCommandName(), getCommandName(), UndoConfirmationPolicy.DEFAULT, editor.getDocument());
}), getCommandName(), getCommandName(), UndoConfirmationPolicy.DEFAULT, editor.getDocument());
};
}
......
// 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.
// Copyright 2000-2021 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.ide.projectView.impl.nodes;
import com.intellij.ide.projectView.PresentationData;
......@@ -9,6 +9,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.impl.ElementPresentationUtil;
import com.intellij.psi.impl.source.jsp.jspJava.JspClass;
import com.intellij.util.SlowOperations;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -160,7 +161,7 @@ public class ClassTreeNode extends BasePsiMemberNode<PsiClass> {
public boolean canRepresent(final Object element) {
if (!isValid()) return false;
return super.canRepresent(element) || canRepresent(getValue(), element);
return super.canRepresent(element) || SlowOperations.allowSlowOperations(() -> canRepresent(getValue(), element));
}
private boolean canRepresent(final PsiClass psiClass, final Object element) {
......
// 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.
// Copyright 2000-2021 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.lang.java;
......@@ -15,6 +15,7 @@ import com.intellij.psi.*;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.templateLanguages.TemplateLanguageUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.SlowOperations;
import org.jetbrains.annotations.NotNull;
public class JavaImportOptimizer implements ImportOptimizer {
......@@ -36,6 +37,10 @@ public class JavaImportOptimizer implements ImportOptimizer {
@Override
public void run() {
SlowOperations.allowSlowOperations(() -> doRun());
}
private void doRun() {
try {
final PsiDocumentManager manager = PsiDocumentManager.getInstance(file.getProject());
final Document document = manager.getDocument(file);
......
// 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-2021 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.introduceVariable;
import com.intellij.codeInsight.CodeInsightUtil;
......@@ -60,6 +60,7 @@ import com.intellij.refactoring.util.occurrences.ExpressionOccurrenceManager;
import com.intellij.refactoring.util.occurrences.NotInSuperCallOccurrenceFilter;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.Processor;
import com.intellij.util.SlowOperations;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.siyeh.ig.psiutils.CommentTracker;
......@@ -692,7 +693,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
@Override
public void pass(final JavaReplaceChoice choice) {
if (choice == null || !tryIntroduceInplace(project, editor, choice, occurrenceManager, originalType)) {
if (choice == null || !SlowOperations.allowSlowOperations(() -> tryIntroduceInplace(project, editor, choice, occurrenceManager, originalType))) {
CommandProcessor.getInstance().executeCommand(project, () -> introduce(choice), getRefactoringName(), null);
}
}
......
// 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.
// Copyright 2000-2021 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.ide.structureView.impl.java;
import com.intellij.ide.structureView.StructureViewTreeElement;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.impl.light.LightElement;
import com.intellij.util.SlowOperations;
import org.jetbrains.annotations.NotNull;
import java.util.*;
......@@ -58,6 +59,10 @@ public class JavaClassTreeElement extends JavaClassTreeElementBase<PsiClass> {
}
static LinkedHashSet<PsiElement> getOwnChildren(@NotNull PsiClass aClass) {
return SlowOperations.allowSlowOperations(() -> doGetOwnChildren(aClass));
}
private static @NotNull LinkedHashSet<PsiElement> doGetOwnChildren(@NotNull PsiClass aClass) {
LinkedHashSet<PsiElement> members = new LinkedHashSet<>();
addPhysicalElements(aClass.getFields(), members, aClass);
addPhysicalElements(aClass.getMethods(), members, aClass);
......
// 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.
// Copyright 2000-2021 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.execution.filters;
import com.intellij.execution.filters.ExceptionAnalysisProvider.StackLine;
......@@ -28,6 +28,7 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.ui.HyperlinkAdapter;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.util.ObjectUtils;
import com.intellij.util.SlowOperations;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
......@@ -406,7 +407,8 @@ public class ExceptionWorker {
PsiElement element = file.findElementAt(startOffset);
List<PsiElement> candidates = new ArrayList<>();
while (element != null && element.getTextRange().getStartOffset() < endOffset) {
PsiElement matched = myElementMatcher.matchElement(element);
PsiElement finalElement = element;
PsiElement matched = SlowOperations.allowSlowOperations(() -> myElementMatcher.matchElement(finalElement));
if (matched != null) {
candidates.add(matched);
if (candidates.size() > 1) return;
......@@ -417,7 +419,7 @@ public class ExceptionWorker {
PsiElement foundElement = candidates.get(0);
TextRange range = foundElement.getTextRange();
targetEditor.getCaretModel().moveToOffset(range.getStartOffset());
displayAnalysisAction(file.getProject(), foundElement, targetEditor, originalEditor);
SlowOperations.allowSlowOperations(() -> displayAnalysisAction(file.getProject(), foundElement, targetEditor, originalEditor));
}
}
......
/*
* Copyright 2000-2010 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-2021 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.daemon;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.psi.PsiFile;
import com.intellij.util.SlowOperations;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -40,7 +27,7 @@ public abstract class ProblemHighlightFilter {
}
public static boolean shouldHighlightFile(@Nullable final PsiFile psiFile) {
return shouldProcess(psiFile, true);
return SlowOperations.allowSlowOperations(() -> shouldProcess(psiFile, true));
}
public static boolean shouldProcessFileInBatch(@Nullable final PsiFile psiFile) {
......
// 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.
// Copyright 2000-2021 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;
import com.intellij.application.options.CodeStyle;
......@@ -6,6 +6,7 @@ import com.intellij.formatting.FormatTextRanges;
import com.intellij.lang.ASTNode;
import com.intellij.lang.FileASTNode;
import com.intellij.lang.injection.InjectedLanguageManager;
import com.intellij.model.ModelBranch;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationListener;
......@@ -32,7 +33,6 @@ import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.ExternalFormatProcessor;
import com.intellij.model.ModelBranch;
import com.intellij.psi.impl.PsiDocumentManagerBase;
import com.intellij.psi.impl.PsiManagerEx;
import com.intellij.psi.impl.file.impl.FileManager;
......@@ -42,6 +42,7 @@ import com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl;
import com.intellij.psi.impl.source.codeStyle.IndentHelperImpl;
import com.intellij.psi.impl.source.tree.*;
import com.intellij.util.Function;
import com.intellij.util.SlowOperations;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.JBIterable;
import com.intellij.util.containers.MultiMap;
......@@ -790,7 +791,7 @@ public final class PostprocessReformattingAspect implements PomModelAspect {
}
else {
final CodeFormatterFacade codeFormatter = getFormatterFacade(viewProvider);
codeFormatter.processText(file, textRanges, false);
SlowOperations.allowSlowOperations(() -> codeFormatter.processText(file, textRanges, false));
}
}
......
......@@ -6,6 +6,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.ThrowableComputable;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
......@@ -15,23 +16,43 @@ public final class SlowOperations {
private static final Logger LOG = Logger.getInstance(SlowOperations.class);
private static final Set<String> ourReportedTraces = new HashSet<>();
private static final String[] misbehavingFrames = {
"org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable.KotlinIntroduceVariableHandler",
"org.jetbrains.kotlin.idea.actions.KotlinAddImportAction",
"org.jetbrains.kotlin.idea.codeInsight.KotlinCopyPasteReferenceProcessor",
"com.intellij.apiwatcher.plugin.presentation.bytecode.UsageHighlighter",
};
private static boolean ourAllowedFlag = false;
private SlowOperations() {}
/**
* If you get an exception from this method, then you need to move the computation to the background
* while also trying to avoid blocking the UI thread as well. It's okay if the API changes in the process,
* e.g. instead of wrapping implementation of some extension into {@link #allowSlowOperations},
* it's better to admit that the EP semantic as a whole requires index access,
* and then move the iteration over all extensions to the background on the platform-side.
* <p/>
* In cases when it's impossible to do so, the computation should be wrapped into {@code allowSlowOperations} explicitly.
* This way it's possible to find all such operations by searching usages of {@code allowSlowOperations}.
*
* @see com.intellij.openapi.application.NonBlockingReadAction
* @see com.intellij.openapi.application.CoroutinesKt#readAction
* @see com.intellij.openapi.actionSystem.ex.ActionUtil#underModalProgress
*/
public static void assertSlowOperationsAreAllowed() {
if (Registry.is("ide.enable.slow.operations.in.edt")) {
return;
}
Application application = ApplicationManager.getApplication();
if (
!application.isUnitTestMode() &&
application.isDispatchThread() &&
!ourAllowedFlag &&
ourReportedTraces.add(ExceptionUtil.currentStackTrace())
) {
LOG.error("Slow operations are prohibited in the EDT");
if (application.isUnitTestMode() || !application.isDispatchThread() || ourAllowedFlag) {
return;
}
String stackTrace = ExceptionUtil.currentStackTrace();
if (ContainerUtil.or(misbehavingFrames, stackTrace::contains) || !ourReportedTraces.add(stackTrace)) {
return;
}
LOG.error("Slow operations are prohibited in the EDT");
}
public static <T, E extends Throwable> T allowSlowOperations(@NotNull ThrowableComputable<T, E> computable) throws E {
......
// 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.
// Copyright 2000-2021 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.ide.util.treeView;
import com.intellij.ide.projectView.PresentationData;
......@@ -13,6 +13,7 @@ import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.FileStatusManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.tree.LeafState;
import com.intellij.util.SlowOperations;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -145,7 +146,7 @@ public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor<Abst
public final T getValue() {
Object value = getEqualityObject();
return value == null ? null : (T)TreeAnchorizer.getService().retrieveElement(value);
return value == null ? null : (T)SlowOperations.allowSlowOperations(() -> TreeAnchorizer.getService().retrieveElement(value));
}
public final void setValue(T value) {
......
// 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.
// Copyright 2000-2021 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.execution.impl.statistics;
import com.intellij.execution.RunManager;
......@@ -22,6 +22,7 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.SlowOperations;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
......@@ -87,7 +88,9 @@ public final class RunConfigurationTypeUsagesCollector extends ProjectUsagesColl
addOrIncrement(templates, template);
collectRunConfigurationFeatures(runConfiguration, templates);
if (runConfiguration instanceof FusAwareRunConfiguration) {
List<EventPair<?>> additionalData = ((FusAwareRunConfiguration)runConfiguration).getAdditionalUsageData();
List<EventPair<?>> additionalData = SlowOperations.allowSlowOperations(
() -> ((FusAwareRunConfiguration)runConfiguration).getAdditionalUsageData()
);
pairs.add(ADDITIONAL_FIELD.with(new ObjectEventData(additionalData)));
}
if (runConfiguration instanceof TargetEnvironmentAwareRunProfile) {
......
// 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.
// Copyright 2000-2021 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.actions;
......@@ -20,6 +20,7 @@ import com.intellij.psi.*;
import com.intellij.psi.codeStyle.ChangedRangesInfo;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.SlowOperations;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -105,7 +106,7 @@ public class ReformatCodeProcessor extends AbstractLayoutCodeProcessor {
: document.getImmutableCharSequence();
try {
EditorScrollingPositionKeeper.perform(document, true, () -> {
EditorScrollingPositionKeeper.perform(document, true, () -> SlowOperations.allowSlowOperations(() -> {
if (processChangedTextOnly) {
ChangedRangesInfo info = VcsFacade.getInstance().getChangedRangesInfo(fileToProcess);
if (info != null) {
......@@ -117,7 +118,7 @@ public class ReformatCodeProcessor extends AbstractLayoutCodeProcessor {
Collection<TextRange> ranges = getRangesToFormat(fileToProcess);
CodeStyleManager.getInstance(myProject).reformatText(fileToProcess, ranges);
}
});
}));
}
catch (ProcessCanceledException pce) {
if (before != null) {
......
// 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.
// Copyright 2000-2021 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.daemon.impl;
......@@ -36,6 +36,7 @@ import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.SlowOperations;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
......@@ -85,6 +86,10 @@ public class ShowAutoImportPass extends TextEditorHighlightingPass {
if (DumbService.isDumb(myProject) || !myFile.isValid()) return;
if (myEditor.isDisposed() || myEditor instanceof EditorWindow && !((EditorWindow)myEditor).isValid()) return;
SlowOperations.allowSlowOperations(() -> doShowImports());
}
private void doShowImports() {
int caretOffset = myEditor.getCaretModel().getOffset();
importUnambiguousImports(caretOffset);
if (isImportHintEnabled()) {
......
// 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-2021 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.editorActions;
......@@ -23,6 +23,7 @@ import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.util.SlowOperations;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -97,7 +98,7 @@ public class CopyHandler extends EditorActionHandler implements CopyAction.Trans
final List<TextBlockTransferableData> transferableDataList = new ArrayList<>();
DumbService.getInstance(project).withAlternativeResolveEnabled(() -> {
DumbService.getInstance(project).withAlternativeResolveEnabled(() -> SlowOperations.allowSlowOperations(() -> {
for (CopyPastePostProcessor<? extends TextBlockTransferableData> processor : CopyPastePostProcessor.EP_NAME.getExtensionList()) {
try {
transferableDataList.addAll(processor.collectTransferableData(file, editor, startOffsets, endOffsets));
......@@ -109,7 +110,7 @@ public class CopyHandler extends EditorActionHandler implements CopyAction.Trans
LOG.error(e);
}
}
});
}));
String text = editor.getCaretModel().supportsMultipleCarets()
? EditorCopyPasteHelperImpl.getSelectedTextForClipboard(editor, transferableDataList)
......
// 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.
// Copyright 2000-2021 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.editorActions;
import com.google.common.annotations.VisibleForTesting;
......@@ -32,6 +32,7 @@ import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.util.DocumentUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.Producer;
import com.intellij.util.SlowOperations;
import com.intellij.util.text.CharArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -208,7 +209,9 @@ public class PasteHandler extends EditorActionHandler implements EditorTextInser
final Ref<Boolean> indented = new Ref<>(Boolean.FALSE);
for (Map.Entry<CopyPastePostProcessor, List<? extends TextBlockTransferableData>> e : extraData.entrySet()) {
//noinspection unchecked
e.getKey().processTransferableData(project, editor, bounds, caretOffset, indented, e.getValue());
SlowOperations.allowSlowOperations(
() -> e.getKey().processTransferableData(project, editor, bounds, caretOffset, indented, e.getValue())
);
}
boolean pastedTextContainsWhiteSpacesOnly =
......
// 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.
// Copyright 2000-2021 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.editorActions;
import com.intellij.codeInsight.AutoPopupController;
......@@ -47,6 +47,7 @@ import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.SlowOperations;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.CharArrayUtil;
import org.jetbrains.annotations.ApiStatus;
......@@ -142,6 +143,10 @@ public final class TypedHandler extends TypedActionHandlerBase {
@Override
public void execute(@NotNull final Editor originalEditor, final char charTyped, @NotNull final DataContext dataContext) {
SlowOperations.allowSlowOperations(()-> doExecute(originalEditor, charTyped, dataContext));
}
private void doExecute(@NotNull Editor originalEditor, char charTyped, @NotNull DataContext dataContext) {
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final PsiFile originalFile;
......
// 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.
// Copyright 2000-2021 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.folding.impl;
import com.intellij.lang.folding.FoldingDescriptor;
......@@ -21,6 +21,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.SmartPointerManager;
import com.intellij.util.ObjectUtils;
import com.intellij.util.SlowOperations;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
......@@ -255,7 +256,7 @@ final class UpdateFoldRegionsOperation implements Runnable {
private boolean shouldRemoveRegion(@NotNull FoldRegion region, @NotNull EditorFoldingInfo info,
@NotNull Map<TextRange, Boolean> rangeToExpandStatusMap, @NotNull Ref<? super FoldingUpdate.RegionInfo> matchingInfo) {
matchingInfo.set(null);
PsiElement element = info.getPsiElement(region);
PsiElement element = SlowOperations.allowSlowOperations(() -> info.getPsiElement(region));
if (element != null) {
PsiFile containingFile = element.getContainingFile();
boolean isInjected = InjectedLanguageManager.getInstance(myProject).isInjectedFragment(containingFile);
......
// 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.
// Copyright 2000-2021 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.hint;
......@@ -24,8 +24,8 @@ import com.intellij.ui.ColorUtil;
import com.intellij.ui.JBColor;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.Function;
import com.intellij.util.SlowOperations;
import com.intellij.util.indexing.DumbModeAccessType;
import com.intellij.util.indexing.FileBasedIndex;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.accessibility.AccessibleContextUtil;
......@@ -319,6 +319,10 @@ public class ParameterInfoComponent extends JPanel {
}
ParameterInfoControllerBase.Model update(boolean singleParameterInfo) {
return SlowOperations.allowSlowOperations(() -> doUpdate(singleParameterInfo));
}
private ParameterInfoControllerBase.Model doUpdate(boolean singleParameterInfo) {
MyParameterContext context = new MyParameterContext(singleParameterInfo);
int highlightedComponentIdx = -1;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment