PCE in tests

This commit is contained in:
Alexey Kudravtsev
2010-04-28 16:57:36 +04:00
parent 100e6b296e
commit 646af555e0
8 changed files with 29 additions and 8 deletions
@@ -221,7 +221,9 @@ public class RefCountHolder {
public boolean analyze(Runnable analyze, final TextRange dirtyScope, final PsiFile file) {
myState.compareAndSet(State.READY, State.VIRGIN);
if (!myState.compareAndSet(State.VIRGIN, State.BEING_WRITTEN_BY_GHP)) return false;
if (!myState.compareAndSet(State.VIRGIN, State.BEING_WRITTEN_BY_GHP)) {
return false;
}
try {
if (dirtyScope != null) {
@@ -141,10 +141,12 @@ public abstract class DaemonAnalyzerTestCase extends CodeInsightTestCase {
if (toInitializeDaemon) {
daemonCodeAnalyzer.projectOpened();
}
daemonCodeAnalyzer.setUpdateByTimerEnabled(false);
((StartupManagerImpl)StartupManagerEx.getInstanceEx(getProject())).runStartupActivities();
((StartupManagerImpl)StartupManagerEx.getInstanceEx(getProject())).runPostStartupActivities();
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
myRunCommandForTest = wrapInCommand();
}
@@ -42,6 +42,7 @@ public abstract class LightDaemonAnalyzerTestCase extends LightCodeInsightTestCa
protected void setUp() throws Exception {
super.setUp();
DaemonCodeAnalyzer.getInstance(getProject()).projectOpened();
DaemonCodeAnalyzer.getInstance(getProject()).setUpdateByTimerEnabled(false);
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
}
@@ -220,6 +220,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
public void updateVisibleHighlighters(@NotNull Editor editor) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (!myUpdateByTimerEnabled) return;
//if (ApplicationManager.getApplication().isUnitTestMode()) return;
final TextEditor textEditor = TextEditorProvider.getInstance().getTextEditor(editor);
@@ -255,6 +256,10 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
stopProcess(true);
}
public boolean isUpdateByTimerEnabled() {
return myUpdateByTimerEnabled;
}
public void setImportHintsEnabled(PsiFile file, boolean value) {
VirtualFile vFile = file.getVirtualFile();
if (value) {
@@ -115,7 +115,7 @@ public abstract class PassExecutorService implements Disposable {
if (dumb && !(pass instanceof DumbAware)) {
continue;
}
TextEditorHighlightingPass textEditorHighlightingPass;
if (pass instanceof TextEditorHighlightingPass) {
textEditorHighlightingPass = (TextEditorHighlightingPass)pass;
@@ -147,7 +147,7 @@ public abstract class PassExecutorService implements Disposable {
List<FileEditor> editors = documentToEditors.get(document);
if (editors == null) {
editors= new SmartList<FileEditor>();
editors = new SmartList<FileEditor>();
documentToEditors.put(document, editors);
}
if (!editors.contains(fileEditor)) editors.add(fileEditor);
@@ -161,7 +161,7 @@ public abstract class PassExecutorService implements Disposable {
threadsToStartCountdown.addAndGet(passes.size());
// create one scheduled pass per unique id (possibly for multiple fileeditors. they all will be applied at the pass finish)
ContainerUtil.quickSort(passes, new Comparator<TextEditorHighlightingPass>(){
ContainerUtil.quickSort(passes, new Comparator<TextEditorHighlightingPass>() {
public int compare(final TextEditorHighlightingPass o1, final TextEditorHighlightingPass o2) {
return o1.getId() - o2.getId();
}
@@ -175,13 +175,14 @@ public abstract class PassExecutorService implements Disposable {
newId = currentPass.getId();
}
if (newId != passId) {
createScheduledPass(fileEditors, currentPass, toBeSubmitted, passes, freePasses, updateProgress, threadsToStartCountdown, jobPriority);
createScheduledPass(fileEditors, currentPass, toBeSubmitted, passes, freePasses, updateProgress, threadsToStartCountdown,
jobPriority);
passId = newId;
}
}
}
log(updateProgress, null, "---------------------starting------------------------ "+threadsToStartCountdown.get());
log(updateProgress, null, "---------------------starting------------------------ " + threadsToStartCountdown.get());
for (ScheduledPass freePass : freePasses) {
submit(freePass);
@@ -19,6 +19,7 @@ package com.intellij.codeInsight.lookup.impl;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl;
import com.intellij.codeInsight.documentation.DocumentationManager;
import com.intellij.codeInsight.hint.EditorHintListener;
import com.intellij.codeInsight.hint.HintManager;
@@ -140,9 +141,14 @@ public class LookupManagerImpl extends LookupManager implements ProjectComponent
}
final DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(myProject);
final boolean previousUpdate;
if (daemonCodeAnalyzer != null) {
previousUpdate = ((DaemonCodeAnalyzerImpl)daemonCodeAnalyzer).isUpdateByTimerEnabled();
daemonCodeAnalyzer.setUpdateByTimerEnabled(false);
}
else {
previousUpdate = false;
}
myActiveLookup = new LookupImpl(myProject, editor, arranger);
myActiveLookupEditor = editor;
myActiveLookup.addLookupListener(new LookupAdapter() {
@@ -164,7 +170,7 @@ public class LookupManagerImpl extends LookupManager implements ProjectComponent
private void dispose() {
alarm.cancelAllRequests();
if (daemonCodeAnalyzer != null) {
daemonCodeAnalyzer.setUpdateByTimerEnabled(true);
daemonCodeAnalyzer.setUpdateByTimerEnabled(previousUpdate);
}
if (myActiveLookup == null) return;
myActiveLookup.removeLookupListener(this);
@@ -80,7 +80,9 @@ public class LeafPsiElement extends LeafElement implements PsiElement, Navigatio
public PsiFile getContainingFile() {
PsiFile file = SharedImplUtil.getContainingFile(this);
if (file == null || !file.isValid()) throw new PsiInvalidElementAccessException(this);
if (file == null || !file.isValid()) {
throw new PsiInvalidElementAccessException(this);
}
return file;
}
@@ -819,6 +819,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
myPsiManager = (PsiManagerImpl)PsiManager.getInstance(getProject());
configureInspections(myInspections == null ? new LocalInspectionTool[0] : myInspections);
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
DaemonCodeAnalyzer.getInstance(getProject()).setUpdateByTimerEnabled(false);
}
private void enableInspectionTool(InspectionProfileEntry tool){
@@ -1131,6 +1132,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
Project project = file.getProject();
ensureIndexesUpToDate(project);
DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project);
codeAnalyzer.setUpdateByTimerEnabled(false);
FileStatusMap fileStatusMap = codeAnalyzer.getFileStatusMap();
for (int ignoreId : toIgnore) {
fileStatusMap.markFileUpToDate(editor.getDocument(), file, ignoreId);