mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
increase daemon reactivity when highlighting large java files
This commit is contained in:
+20
-1
@@ -1688,6 +1688,8 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
long e = System.currentTimeMillis();
|
||||
//System.out.println("Hi elapsed: "+(e-s));
|
||||
|
||||
//List<String> dumps = new ArrayList<>();
|
||||
|
||||
final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject());
|
||||
int N = Math.max(5, Timings.adjustAccordingToMySpeed(80, false));
|
||||
System.out.println("N = " + N);
|
||||
@@ -1702,12 +1704,21 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
// wait to engage all highlighting threads
|
||||
return;
|
||||
}
|
||||
// uncomment to debug what's causing pauses
|
||||
/*
|
||||
AtomicBoolean finished = new AtomicBoolean();
|
||||
AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> {
|
||||
if (!finished.get()) {
|
||||
dumps.add(ThreadDumper.dumpThreadsToString());
|
||||
}
|
||||
}, 10, TimeUnit.MILLISECONDS);
|
||||
*/
|
||||
type(' ');
|
||||
long end = System.currentTimeMillis();
|
||||
//finished.set(true);
|
||||
long interruptTime = end - now;
|
||||
interruptTimes[finalI] = interruptTime;
|
||||
assertTrue(codeAnalyzer.getUpdateProgress().isCanceled());
|
||||
System.out.println(interruptTime);
|
||||
throw new ProcessCanceledException();
|
||||
};
|
||||
try {
|
||||
@@ -1727,6 +1738,14 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
//highlightErrors();
|
||||
}
|
||||
|
||||
System.out.println("Interrupt times: " + Arrays.toString(interruptTimes));
|
||||
|
||||
/*
|
||||
for (String dump : dumps) {
|
||||
System.out.println("\n\n-----------------------------\n\n" + dump);
|
||||
}
|
||||
*/
|
||||
|
||||
long mean = ArrayUtil.averageAmongMedians(interruptTimes, 3);
|
||||
long avg = Arrays.stream(interruptTimes).sum() / interruptTimes.length;
|
||||
long max = Arrays.stream(interruptTimes).max().getAsLong();
|
||||
|
||||
+2
-1
@@ -21,9 +21,9 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.ex.MarkupModelEx;
|
||||
import com.intellij.openapi.editor.ex.RangeHighlighterEx;
|
||||
import com.intellij.openapi.editor.impl.DocumentMarkupModel;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
@@ -51,6 +51,7 @@ public abstract class DaemonCodeAnalyzerEx extends DaemonCodeAnalyzer {
|
||||
final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project);
|
||||
MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true);
|
||||
return model.processRangeHighlightersOverlappingWith(startOffset, endOffset, marker -> {
|
||||
ProgressManager.checkCanceled();
|
||||
Object tt = marker.getErrorStripeTooltip();
|
||||
if (!(tt instanceof HighlightInfo)) return true;
|
||||
HighlightInfo info = (HighlightInfo)tt;
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.LogUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.StubBuilder;
|
||||
import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
@@ -92,6 +93,8 @@ public class LightStubBuilder implements StubBuilder {
|
||||
|
||||
nextElement:
|
||||
while (element != null) {
|
||||
ProgressManager.checkCanceled();
|
||||
|
||||
final StubElement stub = createStub(tree, element, parentStub);
|
||||
boolean hasStub = stub != parentStub || parent == null;
|
||||
if (hasStub && !immediateParentStubbed) {
|
||||
|
||||
Reference in New Issue
Block a user