diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java index dd337716d1fc..2a99de2e749c 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java @@ -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) { diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java index 431801f908a5..e2bd7044f1f9 100644 --- a/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java @@ -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(); } diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/LightDaemonAnalyzerTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/LightDaemonAnalyzerTestCase.java index 40cf8c048143..53709d32d0c6 100644 --- a/java/testFramework/src/com/intellij/codeInsight/daemon/LightDaemonAnalyzerTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/daemon/LightDaemonAnalyzerTestCase.java @@ -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); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java index 57353aafea0c..6c14fadc30d7 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java @@ -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) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PassExecutorService.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PassExecutorService.java index 525c97024724..22938eab8868 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PassExecutorService.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PassExecutorService.java @@ -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 editors = documentToEditors.get(document); if (editors == null) { - editors= new SmartList(); + editors = new SmartList(); 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(){ + ContainerUtil.quickSort(passes, new Comparator() { 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); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupManagerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupManagerImpl.java index 8d3a9e0bfc54..a2c3d241b6a1 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupManagerImpl.java @@ -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); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LeafPsiElement.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LeafPsiElement.java index d17fd46337ed..83c1b9f2dd03 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LeafPsiElement.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LeafPsiElement.java @@ -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; } diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index 9d928258bc85..0146adc33f0d 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -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);