mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not restart daemon on saving settings
This commit is contained in:
@@ -39,7 +39,6 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.event.*;
|
||||
import com.intellij.openapi.editor.ex.EditorEventMulticasterEx;
|
||||
import com.intellij.openapi.editor.impl.softwrap.SoftWrapHelper;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
@@ -315,26 +314,27 @@ public class DaemonListeners implements Disposable {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("cancelling code highlighting by write action:" + action);
|
||||
}
|
||||
if (containsDocumentWorthBothering(action)) {
|
||||
stopDaemon(false);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean containsDocumentWorthBothering(Object action) {
|
||||
if (action instanceof DocumentRunnable) {
|
||||
if (action instanceof DocumentRunnable.IgnoreDocumentRunnable) return false;
|
||||
Document document = ((DocumentRunnable)action).getDocument();
|
||||
if (!worthBothering(document, ((DocumentRunnable)action).getProject())) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
stopDaemon(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void writeActionFinished(Object action) {
|
||||
if (myDaemonCodeAnalyzer.isRunning()) {
|
||||
return;
|
||||
if (myDaemonCodeAnalyzer.isRunning()) return;
|
||||
if (containsDocumentWorthBothering(action)) {
|
||||
stopDaemon(true);
|
||||
}
|
||||
if (action instanceof DocumentRunnable) {
|
||||
Document document = ((DocumentRunnable)action).getDocument();
|
||||
if (!worthBothering(document, ((DocumentRunnable)action).getProject())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
stopDaemon(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package com.intellij.openapi.editor;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
@@ -25,7 +25,7 @@ public abstract class DocumentRunnable implements Runnable {
|
||||
private final Document myDocument;
|
||||
private final Project myProject;
|
||||
|
||||
public DocumentRunnable(@NotNull Document document, Project project) {
|
||||
public DocumentRunnable(@Nullable Document document, Project project) {
|
||||
myDocument = document;
|
||||
myProject = project;
|
||||
}
|
||||
@@ -37,4 +37,10 @@ public abstract class DocumentRunnable implements Runnable {
|
||||
public Project getProject() {
|
||||
return myProject;
|
||||
}
|
||||
|
||||
public abstract static class IgnoreDocumentRunnable extends DocumentRunnable {
|
||||
public IgnoreDocumentRunnable() {
|
||||
super(null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ public class SaveAndSyncHandler implements ApplicationComponent {
|
||||
return !LaterInvocator.isInModalContext() && !ProgressManager.getInstance().hasModalProgressIndicator();
|
||||
}
|
||||
|
||||
|
||||
private static void saveProjectsAndDocuments() {
|
||||
// made public for tests
|
||||
public static void saveProjectsAndDocuments() {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("enter: save()");
|
||||
}
|
||||
|
||||
+1
-1
@@ -1018,7 +1018,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
myDispatcher.getMulticaster().writeActionFinished(action);
|
||||
}
|
||||
|
||||
public void _saveSettings() { // for testing purposes
|
||||
public void _saveSettings() { // public for testing purposes
|
||||
if (mySaveSettingsIsInProgress.compareAndSet(false, true)) {
|
||||
try {
|
||||
doSave();
|
||||
|
||||
+3
-1
@@ -25,6 +25,7 @@ import com.intellij.openapi.components.RoamingType;
|
||||
import com.intellij.openapi.components.StateStorage;
|
||||
import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.DocumentRunnable;
|
||||
import com.intellij.openapi.options.StreamProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
@@ -101,7 +102,8 @@ public class StorageUtil {
|
||||
file.renameTo(backupFile);
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
// mark this action as modifying the file which daemon analyzer should ignore
|
||||
ApplicationManager.getApplication().runWriteAction(new DocumentRunnable.IgnoreDocumentRunnable() {
|
||||
public void run() {
|
||||
if (!file.exists()) {
|
||||
file.createParentDirs();
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.impl.ApplicationImpl;
|
||||
import com.intellij.openapi.components.RoamingType;
|
||||
import com.intellij.openapi.components.impl.stores.StorageUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.DocumentRunnable;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
@@ -543,10 +544,7 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
|
||||
|
||||
@Nullable
|
||||
private Document writeSchemeToDocument(final E scheme) throws WriteExternalException {
|
||||
if (!isShared(scheme)) {
|
||||
return myProcessor.writeScheme(scheme);
|
||||
}
|
||||
else {
|
||||
if (isShared(scheme)) {
|
||||
String originalPath = scheme.getExternalInfo().getOriginalPath();
|
||||
if (originalPath != null) {
|
||||
Element root = new Element(SHARED_SCHEME);
|
||||
@@ -564,6 +562,9 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return myProcessor.writeScheme(scheme);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateConfigFilesFromStreamProviders() {
|
||||
@@ -721,19 +722,7 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
|
||||
}
|
||||
|
||||
if (myVFSBaseDir != null) {
|
||||
final WriteExternalException[] ex = new WriteExternalException[1];
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable(){
|
||||
public void run() {
|
||||
try {
|
||||
doSave();
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
ex[0] = e;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (ex[0] != null) throw ex[0];
|
||||
doSave();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -755,10 +744,9 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
|
||||
private boolean myInsideSave = false;
|
||||
|
||||
private void doSave() throws WriteExternalException {
|
||||
|
||||
myInsideSave = true;
|
||||
try {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
ApplicationManager.getApplication().runWriteAction(new DocumentRunnable.IgnoreDocumentRunnable() {
|
||||
public void run() {
|
||||
((NewVirtualFile)myVFSBaseDir).markDirtyRecursively();
|
||||
myVFSBaseDir.refresh(false, true);
|
||||
@@ -772,16 +760,18 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
|
||||
|
||||
reserveUsingFileNames(schemes, fileNameProvider);
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
ApplicationManager.getApplication().runWriteAction(new DocumentRunnable.IgnoreDocumentRunnable() {
|
||||
public void run() {
|
||||
deleteFilesFromDeletedSchemes();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
saveSchemes(schemes, fileNameProvider);
|
||||
|
||||
if (myDeletedNames.size() > 0) {
|
||||
if (myDeletedNames.isEmpty()) {
|
||||
deleteServerFiles(DELETED_XML);
|
||||
}
|
||||
else {
|
||||
for (StreamProvider provider : getEnabledProviders()) {
|
||||
try {
|
||||
StorageUtil.sendContent(provider, getFileFullPath(DELETED_XML), createDeletedDocument(), myRoamingType, true);
|
||||
@@ -791,10 +781,6 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
deleteServerFiles(DELETED_XML);
|
||||
|
||||
}
|
||||
}
|
||||
finally {
|
||||
myInsideSave = false;
|
||||
@@ -859,7 +845,6 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user