mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[editor] IJPL-165302 Use minimum safe auto reparse delay instead of 0
(cherry picked from commit b68b251f0df2a9dc8c4a6df654d0bf6f57016da2) IJ-CR-147882 GitOrigin-RevId: 06a2e91b278f1c6380892906dfd2b9283bf16e84
This commit is contained in:
committed by
intellij-monorepo-bot
parent
53af24ec04
commit
36e0f786c3
+18
@@ -4,15 +4,20 @@ package com.intellij.codeInsight.daemon;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.util.xmlb.annotations.OptionTag;
|
||||
import com.intellij.util.xmlb.annotations.Transient;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public class DaemonCodeAnalyzerSettings {
|
||||
private static final int SAFE_AUTO_REPARSE_DELAY_MS = 100;
|
||||
|
||||
private boolean myNextErrorActionGoesToErrorsFirst = true;
|
||||
private int myAutoReparseDelay = 300;
|
||||
private int myErrorStripeMarkMinHeight = 2;
|
||||
|
||||
private boolean mySuppressWarnings = true;
|
||||
|
||||
private boolean myUseZeroAutoReparseDelay = false;
|
||||
|
||||
public static DaemonCodeAnalyzerSettings getInstance() {
|
||||
return ApplicationManager.getApplication().getService(DaemonCodeAnalyzerSettings.class);
|
||||
}
|
||||
@@ -32,10 +37,23 @@ public class DaemonCodeAnalyzerSettings {
|
||||
return myAutoReparseDelay;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public int chooseSafeAutoReparseDelay() {
|
||||
if (myUseZeroAutoReparseDelay) return 0;
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) return myAutoReparseDelay;
|
||||
|
||||
return Math.max(myAutoReparseDelay, SAFE_AUTO_REPARSE_DELAY_MS);
|
||||
}
|
||||
|
||||
public void setAutoReparseDelay(int millis) {
|
||||
myAutoReparseDelay = millis;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public void forceUseZeroAutoReparseDelay(boolean useZeroAutoReparseDelay) {
|
||||
myUseZeroAutoReparseDelay = useZeroAutoReparseDelay;
|
||||
}
|
||||
|
||||
@OptionTag("ERROR_STRIPE_MARK_MIN_HEIGHT")
|
||||
public int getErrorStripeMarkMinHeight() {
|
||||
return myErrorStripeMarkMinHeight;
|
||||
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
// 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.daemon.impl;
|
||||
|
||||
import com.intellij.codeHighlighting.Pass;
|
||||
import com.intellij.codeHighlighting.*;
|
||||
import com.intellij.codeHighlighting.Pass;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettingsImpl;
|
||||
import com.intellij.codeInsight.daemon.LineMarkerInfo;
|
||||
@@ -88,8 +88,8 @@ import org.jetbrains.annotations.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@@ -914,9 +914,9 @@ public final class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx
|
||||
}
|
||||
|
||||
private void scheduleIfNotRunning() {
|
||||
long autoReparseDelayNanos = TimeUnit.MILLISECONDS.toNanos(mySettings.getAutoReparseDelay());
|
||||
long autoReparseDelayNanos = TimeUnit.MILLISECONDS.toNanos(mySettings.chooseSafeAutoReparseDelay());
|
||||
myScheduledUpdateTimestamp = System.nanoTime() + autoReparseDelayNanos;
|
||||
// optimisation: this check is to avoid too many re-schedules in case of thousands of event spikes
|
||||
// optimization: this check is to avoid too many re-schedules in case of thousands of event spikes
|
||||
boolean isDone = myUpdateRunnableFuture.isDone();
|
||||
LOG.debug("Rescheduling highlighting: isDone ", isDone);
|
||||
if (isDone) {
|
||||
|
||||
@@ -190,10 +190,9 @@ public final class MainPassesRunner {
|
||||
// repeat several times when accidental background activity cancels highlighting
|
||||
int retries = 100;
|
||||
for (int i = 0; i < retries; i++) {
|
||||
int oldDelay = settings.getAutoReparseDelay();
|
||||
try {
|
||||
InspectionProfile currentProfile = myInspectionProfile;
|
||||
settings.setAutoReparseDelay(0);
|
||||
settings.forceUseZeroAutoReparseDelay(true);
|
||||
Function<InspectionProfile, InspectionProfileWrapper> profileProvider =
|
||||
p -> currentProfile == null
|
||||
? new InspectionProfileWrapper((InspectionProfileImpl)p)
|
||||
@@ -214,7 +213,7 @@ public final class MainPassesRunner {
|
||||
exception = e;
|
||||
}
|
||||
finally {
|
||||
settings.setAutoReparseDelay(oldDelay);
|
||||
settings.forceUseZeroAutoReparseDelay(false);
|
||||
}
|
||||
}
|
||||
if (exception != null) {
|
||||
|
||||
+2
-3
@@ -286,9 +286,8 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
Throwable exception = null;
|
||||
int retries = 1000;
|
||||
for (int i = 0; i < retries; i++) {
|
||||
int oldDelay = settings.getAutoReparseDelay();
|
||||
try {
|
||||
settings.setAutoReparseDelay(0);
|
||||
settings.forceUseZeroAutoReparseDelay(true);
|
||||
List<HighlightInfo> infos = new ArrayList<>();
|
||||
EdtTestUtil.runInEdtAndWait(() -> {
|
||||
codeAnalyzer.runPasses(psiFile, editor.getDocument(), textEditor, toIgnore, canChangeDocument, null);
|
||||
@@ -328,7 +327,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
exception = e;
|
||||
}
|
||||
finally {
|
||||
settings.setAutoReparseDelay(oldDelay);
|
||||
settings.forceUseZeroAutoReparseDelay(false);
|
||||
}
|
||||
}
|
||||
ExceptionUtil.rethrow(exception);
|
||||
|
||||
Reference in New Issue
Block a user