mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
+11
@@ -194,6 +194,7 @@ public abstract class AbstractLayoutCodeProcessor {
|
||||
|
||||
final Runnable[] resultRunnable = new Runnable[1];
|
||||
Runnable readAction = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!checkFileWritable(file)) return;
|
||||
try{
|
||||
@@ -205,6 +206,7 @@ public abstract class AbstractLayoutCodeProcessor {
|
||||
}
|
||||
};
|
||||
Runnable writeAction = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (resultRunnable[0] != null) {
|
||||
resultRunnable[0].run();
|
||||
@@ -261,6 +263,7 @@ public abstract class AbstractLayoutCodeProcessor {
|
||||
}
|
||||
|
||||
return new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SequentialModalProgressTask progressTask = new SequentialModalProgressTask(myProject, myCommandName);
|
||||
ReformatFilesTask reformatFilesTask = new ReformatFilesTask(tasks);
|
||||
@@ -277,11 +280,13 @@ public abstract class AbstractLayoutCodeProcessor {
|
||||
final Runnable[] resultRunnable = new Runnable[1];
|
||||
runLayoutCodeProcess(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
resultRunnable[0] = preprocessFiles(new ArrayList<PsiFile>(Arrays.asList(files)));
|
||||
}
|
||||
},
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (resultRunnable[0] != null){
|
||||
resultRunnable[0].run();
|
||||
@@ -352,10 +357,12 @@ public abstract class AbstractLayoutCodeProcessor {
|
||||
|
||||
final Runnable[] resultRunnable = new Runnable[1];
|
||||
runLayoutCodeProcess(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
resultRunnable[0] = preprocessFiles(array);
|
||||
}
|
||||
}, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (resultRunnable[0] != null) {
|
||||
resultRunnable[0].run();
|
||||
@@ -450,12 +457,14 @@ public abstract class AbstractLayoutCodeProcessor {
|
||||
final ModalityState modalityState = ModalityState.current();
|
||||
|
||||
final Runnable process = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runReadAction(readAction);
|
||||
}
|
||||
};
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
//DaemonCodeAnalyzer.getInstance(myProject).setUpdateByTimerEnabled(false);
|
||||
@@ -474,8 +483,10 @@ public abstract class AbstractLayoutCodeProcessor {
|
||||
*/
|
||||
|
||||
final Runnable writeRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (globalAction) CommandProcessor.getInstance().markCurrentCommandAsGlobal(myProject);
|
||||
try {
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class RefreshQueue {
|
||||
@@ -34,22 +35,23 @@ public abstract class RefreshQueue {
|
||||
return createSession(async, recursive, finishRunnable, getDefaultModalityState());
|
||||
}
|
||||
|
||||
public abstract RefreshSession createSession(boolean async, boolean recursive, @Nullable Runnable finishRunnable, ModalityState state);
|
||||
public abstract RefreshSession createSession(boolean async, boolean recursive, @Nullable Runnable finishRunnable, @NotNull ModalityState state);
|
||||
|
||||
public final void refresh(boolean async, boolean recursive, @Nullable Runnable finishRunnable, ModalityState state, VirtualFile... files) {
|
||||
public final void refresh(boolean async, boolean recursive, @Nullable Runnable finishRunnable, @NotNull ModalityState state, @NotNull VirtualFile... files) {
|
||||
RefreshSession session = createSession(async, recursive, finishRunnable, state);
|
||||
session.addAllFiles(files);
|
||||
session.launch();
|
||||
}
|
||||
|
||||
public abstract void refreshLocalRoots(boolean async, @Nullable Runnable postAction, ModalityState modalityState);
|
||||
public abstract void refreshLocalRoots(boolean async, @Nullable Runnable postAction, @NotNull ModalityState modalityState);
|
||||
|
||||
public final void refresh(boolean async, boolean recursive, @Nullable Runnable finishRunnable, VirtualFile... files) {
|
||||
public final void refresh(boolean async, boolean recursive, @Nullable Runnable finishRunnable, @NotNull VirtualFile... files) {
|
||||
refresh(async, recursive, finishRunnable, getDefaultModalityState(), files);
|
||||
}
|
||||
|
||||
public abstract void processSingleEvent(VFileEvent event);
|
||||
|
||||
@NotNull
|
||||
protected ModalityState getDefaultModalityState() {
|
||||
return ModalityState.NON_MODAL;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public abstract class RefreshSession {
|
||||
public abstract void addFile(@NotNull VirtualFile file);
|
||||
public abstract void addAllFiles(Collection<VirtualFile> files);
|
||||
|
||||
public void addAllFiles(VirtualFile[] files) {
|
||||
public void addAllFiles(@NotNull VirtualFile[] files) {
|
||||
addAllFiles(Arrays.asList(files));
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -32,7 +32,7 @@ public class ModalityStateEx extends ModalityState {
|
||||
this(EMPTY_REFS_ARRAY);
|
||||
}
|
||||
|
||||
public ModalityStateEx(Object[] modalEntities) {
|
||||
public ModalityStateEx(@NotNull Object[] modalEntities) {
|
||||
if (modalEntities.length > 0) {
|
||||
myModalEntities = new WeakReference[modalEntities.length];
|
||||
for (int i = 0; i < modalEntities.length; i++) {
|
||||
@@ -71,6 +71,7 @@ public class ModalityStateEx extends ModalityState {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dominates(@NotNull ModalityState anotherState){
|
||||
if (anotherState == ModalityState.any()) return false;
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.openapi.vfs.VfsBundle;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.io.storage.HeavyProcessLatch;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -41,22 +42,22 @@ public class RefreshQueueImpl extends RefreshQueue {
|
||||
private final ExecutorService myQueue = ConcurrencyUtil.newSingleThreadExecutor("FS Synchronizer");
|
||||
private final ProgressIndicator myRefreshIndicator = new RefreshProgress(VfsBundle.message("file.synchronize.progress"));
|
||||
|
||||
public void execute(final RefreshSessionImpl session) {
|
||||
public void execute(@NotNull RefreshSessionImpl session) {
|
||||
if (session.isAsynchronous()) {
|
||||
ModalityState state = session.getModalityState();
|
||||
queueSession(session, state != null ? state : ModalityState.NON_MODAL);
|
||||
queueSession(session, state);
|
||||
}
|
||||
else {
|
||||
final Application app = ApplicationManager.getApplication();
|
||||
boolean isEDT = app.isDispatchThread();
|
||||
final boolean hasWriteAction = app.isWriteAccessAllowed();
|
||||
if (isEDT || hasWriteAction) {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
boolean isEDT = application.isDispatchThread();
|
||||
if (isEDT) {
|
||||
session.scan();
|
||||
final boolean hasWriteAction = application.isWriteAccessAllowed();
|
||||
session.fireEvents(hasWriteAction);
|
||||
}
|
||||
else {
|
||||
if (((ApplicationEx)app).holdsReadLock()) {
|
||||
LOG.error("Do not call synchronous refresh from inside read action except for event dispatch thread. This will eventually cause deadlock if there are events to fire");
|
||||
if (((ApplicationEx)application).holdsReadLock()) {
|
||||
LOG.error( "Do not call synchronous refresh from inside read action except for event dispatch thread. This will eventually cause deadlock if there are events to fire");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,7 +67,7 @@ public class RefreshQueueImpl extends RefreshQueue {
|
||||
}
|
||||
}
|
||||
|
||||
private void queueSession(final RefreshSessionImpl session, final ModalityState modality) {
|
||||
private void queueSession(@NotNull final RefreshSessionImpl session, @NotNull final ModalityState modality) {
|
||||
myQueue.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -96,12 +97,12 @@ public class RefreshQueueImpl extends RefreshQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefreshSession createSession(final boolean async, boolean recursively, @Nullable final Runnable finishRunnable, ModalityState state) {
|
||||
public RefreshSession createSession(final boolean async, boolean recursively, @Nullable final Runnable finishRunnable, @NotNull ModalityState state) {
|
||||
return new RefreshSessionImpl(async, recursively, finishRunnable, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshLocalRoots(boolean async, Runnable postAction, ModalityState modalityState) {
|
||||
public void refreshLocalRoots(boolean async, @Nullable Runnable postAction, @NotNull ModalityState modalityState) {
|
||||
RefreshQueue.getInstance().refresh(async, true, postAction, modalityState, ManagingFS.getInstance().getLocalRoots());
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class RefreshSessionImpl extends RefreshSession {
|
||||
private final Semaphore mySemaphore = new Semaphore();
|
||||
private volatile boolean iHaveEventsToFire;
|
||||
|
||||
private ModalityState myModalityState;
|
||||
private final ModalityState myModalityState;
|
||||
|
||||
public RefreshSessionImpl(final boolean isAsync, final boolean recursively, final Runnable finishRunnable) {
|
||||
this(isAsync, recursively, finishRunnable, ModalityState.NON_MODAL);
|
||||
@@ -65,6 +65,7 @@ public class RefreshSessionImpl extends RefreshSession {
|
||||
myIsRecursive = false;
|
||||
myFinishRunnable = null;
|
||||
myEvents = new ArrayList<VFileEvent>(events);
|
||||
myModalityState = ModalityState.NON_MODAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,6 +168,7 @@ public class RefreshSessionImpl extends RefreshSession {
|
||||
return events;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ModalityState getModalityState() {
|
||||
return myModalityState;
|
||||
}
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ public class ExternalChangesAndRefreshingTest extends IntegrationTestCase {
|
||||
@Override
|
||||
protected void runBareRunnable(Runnable r) throws Throwable {
|
||||
if (getName().equals("testRefreshingAsynchronously")) {
|
||||
// this methods waits for another thread to finish, that leds
|
||||
// this method waits for another thread to finish, that leads
|
||||
// to deadlock in swing-thread. Therefore we have to run this test
|
||||
// outside of swing-thread
|
||||
r.run();
|
||||
|
||||
Reference in New Issue
Block a user