fix DaemonRespondToChangesTest.testDaemonIgnoresFrameDeactivation

This commit is contained in:
Vladimir Krivosheev
2016-09-25 18:39:40 +02:00
parent 3abae33444
commit 2fbe1f5fe7
3 changed files with 24 additions and 9 deletions
@@ -33,7 +33,6 @@ import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.codeInspection.accessStaticViaInstance.AccessStaticViaInstance;
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspectionBase;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.codeInspection.ex.InspectionToolRegistrar;
import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
@@ -107,7 +106,6 @@ import com.intellij.openapi.util.Segment;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.*;
import com.intellij.psi.impl.DebugUtil;
@@ -1293,8 +1291,8 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
}
public void testDaemonIgnoresFrameDeactivation() throws Throwable {
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true); // return default value to avoid unnecessary save
InspectionProfileManager.getInstance().setRootProfile(InspectionProfileImpl.getDefaultProfile().getName()); // reset to default profile from the custom one to avoid unnecessary save
// return default value to avoid unnecessary save
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);
String text = "class S { ArrayList<caret>XXX x;}";
configureByText(StdFileTypes.JAVA, text);
@@ -1318,7 +1316,6 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
}
}
public void testApplyLocalQuickFix() throws Throwable {
configureByText(StdFileTypes.JAVA, "class X { static int sss; public int f() { return this.<caret>sss; }}");
@@ -35,6 +35,7 @@ import com.intellij.openapi.util.JDOMUtil
import com.intellij.openapi.util.NamedJDOMExternalizable
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess
import com.intellij.project.isDirectoryBased
import com.intellij.ui.AppUIUtil
import com.intellij.util.ArrayUtilRt
import com.intellij.util.SmartList
@@ -115,6 +116,22 @@ abstract class ComponentStoreImpl : IComponentStore {
override fun save(readonlyFiles: MutableList<JBPair<StateStorage.SaveSession, VirtualFile>>) {
var errors: MutableList<Throwable>? = null
// component state uses scheme manager in an ipr project, so, we must save it before
val isIprProject = project?.let { !it.isDirectoryBased } ?: false
if (isIprProject) {
settingsSavingComponents.firstOrNull { it is SchemeManagerFactoryBase }?.let {
try {
it.save()
}
catch (e: Throwable) {
if (errors == null) {
errors = SmartList<Throwable>()
}
errors!!.add(e)
}
}
}
val externalizationSession = if (components.isEmpty()) null else storageManager.startExternalization()
if (externalizationSession != null) {
val names = ArrayUtilRt.toStringArray(components.keys)
@@ -131,7 +148,7 @@ abstract class ComponentStoreImpl : IComponentStore {
if (errors == null) {
errors = SmartList<Throwable>()
}
errors.add(Exception("Cannot get ${name} component state", e))
errors!!.add(Exception("Cannot get ${name} component state", e))
}
timeLog?.let {
@@ -149,13 +166,15 @@ abstract class ComponentStoreImpl : IComponentStore {
for (settingsSavingComponent in settingsSavingComponents) {
try {
settingsSavingComponent.save()
if (!isIprProject || settingsSavingComponent !is SchemeManagerFactoryBase) {
settingsSavingComponent.save()
}
}
catch (e: Throwable) {
if (errors == null) {
errors = SmartList<Throwable>()
}
errors.add(e)
errors!!.add(e)
}
}
@@ -119,7 +119,6 @@ open class FileBasedStorage(file: Path,
attributes = Files.readAttributes(file, BasicFileAttributes::class.java)
}
catch (e: NoSuchFileException) {
LOG.debug(e) { "Document was not loaded for $fileSpec, doesn't exists" }
return null
}
catch (e: IOException) {