mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
[slow operations] precalculate trimmed text (IDEA-305058)
EA-681203 T: DirectoryIndexImpl.getInfoForFile GitOrigin-RevId: 46a39817e23a07d2f3992826082621b54c767441
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ab11d3866e
commit
c930f3c430
@@ -6,6 +6,7 @@ import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.application.impl.NonBlockingReadActionImpl;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.SelectionModel;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
|
||||
@@ -397,6 +398,7 @@ public class InplaceIntroduceVariableTest extends AbstractJavaInplaceIntroduceTe
|
||||
UiInterceptors.register(new ChooserInterceptor(expectedOptions, Pattern.quote(secondChoiceText)));
|
||||
}
|
||||
final AbstractInplaceIntroducer<?, ?> introducer = invokeRefactoring(handler);
|
||||
NonBlockingReadActionImpl.waitForAsyncTaskCompletion();
|
||||
if (pass != null) {
|
||||
pass.accept(introducer);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package com.intellij.java.refactoring;
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.openapi.application.impl.NonBlockingReadActionImpl;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -537,6 +538,7 @@ public class IntroduceVariableTest extends LightJavaCodeInsightTestCase {
|
||||
String baseName = "/refactoring/introduceVariable/" + getTestName(false);
|
||||
configureByFile(baseName + ".java");
|
||||
testMe.invoke(getProject(), getEditor(), getFile(), null);
|
||||
NonBlockingReadActionImpl.waitForAsyncTaskCompletion();
|
||||
TemplateState state = TemplateManagerImpl.getTemplateState(getEditor());
|
||||
if (state == null) return;
|
||||
state.gotoEnd(false);
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.intention.impl.preview.IntentionPreviewPopupUpdateProcessor;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.application.impl.NonBlockingReadActionImpl;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -110,6 +111,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
}
|
||||
}
|
||||
|
||||
NonBlockingReadActionImpl.waitForAsyncTaskCompletion();
|
||||
String expectedFilePath = ObjectUtils.notNull(quickFix.getBasePath(), "") + "/" + AFTER_PREFIX + testName;
|
||||
quickFix.checkResultByFile("In file :" + expectedFilePath, expectedFilePath, false);
|
||||
|
||||
@@ -302,6 +304,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
LightQuickFixTestCase.this.invoke(action);
|
||||
NonBlockingReadActionImpl.waitForAsyncTaskCompletion();
|
||||
Path path = Path.of(getTestDataPath(), previewFilePath);
|
||||
if (Files.exists(path)) {
|
||||
assertSameLinesWithFile(path.toString(), previewContent);
|
||||
|
||||
@@ -4,6 +4,8 @@ package com.intellij.refactoring;
|
||||
import com.intellij.codeInsight.navigation.NavigationUtil;
|
||||
import com.intellij.codeInsight.unwrap.ScopeHighlighter;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.*;
|
||||
@@ -17,6 +19,7 @@ import com.intellij.refactoring.introduce.PsiIntroduceTarget;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.concurrency.AppExecutorUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -63,8 +66,11 @@ public final class IntroduceTargetChooser {
|
||||
@NotNull @NlsContexts.PopupTitle String title,
|
||||
int selection,
|
||||
@NotNull NotNullFunction<? super PsiElement, ? extends TextRange> ranger) {
|
||||
List<MyIntroduceTarget<T>> targets = ContainerUtil.map(expressions, t -> new MyIntroduceTarget<>(t, ranger, renderer));
|
||||
showIntroduceTargetChooser(editor, targets, target -> callback.pass(target.getPlace()), title, selection);
|
||||
ReadAction.nonBlocking(() -> ContainerUtil.map(expressions, t -> new MyIntroduceTarget<>(t, ranger, renderer)))
|
||||
.finishOnUiThread(ModalityState.NON_MODAL, targets ->
|
||||
showIntroduceTargetChooser(editor, targets, target -> callback.pass(target.getPlace()), title, selection))
|
||||
.expireWhen(() -> editor.isDisposed())
|
||||
.submit(AppExecutorUtil.getAppExecutorService());
|
||||
}
|
||||
|
||||
public static <T extends IntroduceTarget> void showIntroduceTargetChooser(@NotNull Editor editor,
|
||||
@@ -148,32 +154,32 @@ public final class IntroduceTargetChooser {
|
||||
}
|
||||
|
||||
private static class MyIntroduceTarget<T extends PsiElement> extends PsiIntroduceTarget<T> {
|
||||
private final NotNullFunction<? super PsiElement, ? extends TextRange> myRanger;
|
||||
private final Function<? super T, String> myRenderer;
|
||||
private final TextRange myTextRange;
|
||||
private final String myText;
|
||||
|
||||
MyIntroduceTarget(@NotNull T psi,
|
||||
@NotNull NotNullFunction<? super PsiElement, ? extends TextRange> ranger,
|
||||
@NotNull Function<? super T, String> renderer) {
|
||||
@NotNull NotNullFunction<? super PsiElement, ? extends TextRange> ranger,
|
||||
@NotNull Function<? super T, String> renderer) {
|
||||
super(psi);
|
||||
myRanger = ranger;
|
||||
myRenderer = renderer;
|
||||
myTextRange = ranger.fun(psi);
|
||||
myText = renderer.fun(psi);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TextRange getTextRange() {
|
||||
return myRanger.fun(getPlace());
|
||||
return myTextRange;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String render() {
|
||||
return myRenderer.fun(getPlace());
|
||||
return myText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return isValid() ? render() : "invalid";
|
||||
return isValid() ? myText : "invalid";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user