diff options
Diffstat (limited to 'platform/core-api/src/com/intellij/openapi')
6 files changed, 36 insertions, 52 deletions
diff --git a/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java b/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java index 4dda4a664174..4a72e09dcd8e 100644 --- a/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java +++ b/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,9 +31,11 @@ public interface ModalityInvokator { * * @param runnable the runnable to execute. */ - ActionCallback invokeLater(Runnable runnable); + @NotNull + ActionCallback invokeLater(@NotNull Runnable runnable); - ActionCallback invokeLater(Runnable runnable, @NotNull Condition expired); + @NotNull + ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull Condition expired); /** * Causes <i>runnable.run()</i> to be executed asynchronously on the @@ -43,7 +45,9 @@ public interface ModalityInvokator { * @param runnable the runnable to execute. * @param state the state in which the runnable will be executed. */ - ActionCallback invokeLater(Runnable runnable, @NotNull ModalityState state); + @NotNull + ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull ModalityState state); - ActionCallback invokeLater(Runnable runnable, @NotNull ModalityState state, @NotNull Condition expired); + @NotNull + ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull ModalityState state, @NotNull Condition expired); }
\ No newline at end of file diff --git a/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java b/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java index 0f50f8d05ecf..afe440b8588f 100644 --- a/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java +++ b/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ public abstract class ProgressIndicatorProvider { @Nullable public static ProgressIndicatorProvider ourInstance; - @Nullable public static ProgressIndicatorProvider getInstance() { return ourInstance; } @@ -39,6 +38,7 @@ public abstract class ProgressIndicatorProvider { return ourInstance != null ? ourInstance.getProgressIndicator() : null; } + @NotNull public abstract NonCancelableSection startNonCancelableSection(); @NotNull @@ -46,12 +46,12 @@ public abstract class ProgressIndicatorProvider { return ourInstance != null ? ourInstance.startNonCancelableSection() : NonCancelableSection.EMPTY; } - public static volatile boolean ourNeedToCheckCancel = false; + protected static volatile boolean ourNeedToCheckCancel = false; public static void checkCanceled() throws ProcessCanceledException { // smart optimization! There's a thread started in ProgressManagerImpl, that set's this flag up once in 10 milliseconds if (ourNeedToCheckCancel && ourInstance != null) { + ourNeedToCheckCancel = false; // doCheckCanceled() may flip it back to true ourInstance.doCheckCanceled(); - ourNeedToCheckCancel = false; } } } diff --git a/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java b/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java index e99b8e6bebf0..4b4ace28cd37 100644 --- a/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java +++ b/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java @@ -25,38 +25,17 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; -public abstract class ProgressManager { - static { - ProgressIndicatorProvider.ourInstance = new ProgressIndicatorProvider() { - @Override - public ProgressIndicator getProgressIndicator() { - ProgressManager manager = ProgressManager.getInstance(); - return manager != null ? manager.getProgressIndicator() : null; - } - - @Override - protected void doCheckCanceled() throws ProcessCanceledException { - ProgressManager manager = ProgressManager.getInstance(); - if (manager != null) { - manager.doCheckCanceled(); - } - } - - @Override - public NonCancelableSection startNonCancelableSection() { - ProgressManager manager = ProgressManager.getInstance(); - return manager != null ? manager.startNonCancelableSection() : NonCancelableSection.EMPTY; - } - }; +public abstract class ProgressManager extends ProgressIndicatorProvider { + public ProgressManager() { + ProgressIndicatorProvider.ourInstance = this; } - private static ProgressManager ourInstance; + private static class ProgressManagerHolder { + private static final ProgressManager ourInstance = ServiceManager.getService(ProgressManager.class); + } public static ProgressManager getInstance() { - if (ourInstance == null) { - ourInstance = ServiceManager.getService(ProgressManager.class); - } - return ourInstance; + return ProgressManagerHolder.ourInstance; } public abstract boolean hasProgressIndicator(); @@ -66,17 +45,13 @@ public abstract class ProgressManager { public abstract void runProcess(@NotNull Runnable process, ProgressIndicator progress) throws ProcessCanceledException; public abstract <T> T runProcess(@NotNull Computable<T> process, ProgressIndicator progress) throws ProcessCanceledException; + @Override public ProgressIndicator getProgressIndicator() { return myThreadIndicator.get(); } - protected static volatile boolean ourNeedToCheckCancel = false; public static void checkCanceled() throws ProcessCanceledException { - // smart optimization! There's a thread started in ProgressManagerImpl, that set's this flag up once in 10 milliseconds - if (ourNeedToCheckCancel) { - getInstance().doCheckCanceled(); - ourNeedToCheckCancel = false; - } + ProgressIndicatorProvider.checkCanceled(); } public static void progress(@NotNull String text) throws ProcessCanceledException { @@ -100,11 +75,7 @@ public abstract class ProgressManager { } } - protected abstract void doCheckCanceled() throws ProcessCanceledException; - public abstract void executeNonCancelableSection(@NotNull Runnable runnable); - @NotNull - public abstract NonCancelableSection startNonCancelableSection(); public abstract void setCancelButtonText(String cancelButtonText); diff --git a/platform/core-api/src/com/intellij/openapi/util/SimpleModificationTracker.java b/platform/core-api/src/com/intellij/openapi/util/SimpleModificationTracker.java index 5232dc439b90..9b74576176fb 100644 --- a/platform/core-api/src/com/intellij/openapi/util/SimpleModificationTracker.java +++ b/platform/core-api/src/com/intellij/openapi/util/SimpleModificationTracker.java @@ -16,6 +16,7 @@ package com.intellij.openapi.util; import com.intellij.Patches; +import com.intellij.util.xmlb.annotations.Transient; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; @@ -28,6 +29,8 @@ public class SimpleModificationTracker implements ModificationTracker { // fixed in JDK8 assert Patches.JDK_BUG_ID_7103570; } + + @Transient public volatile int myCounter; @Override diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java b/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java index 9e8c37880589..b3fc7550adfa 100644 --- a/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java +++ b/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java @@ -46,6 +46,8 @@ public class VfsUtilCore { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.VfsUtilCore"); public static final String LOCALHOST_URI_PATH_PREFIX = "localhost/"; + public static final char VFS_SEPARATOR_CHAR = '/'; + private static final String PROTOCOL_DELIMITER = ":"; /** @@ -118,6 +120,11 @@ public class VfsUtilCore { return false; } + @Nullable + public static String getRelativePath(@NotNull VirtualFile file, @NotNull VirtualFile ancestor) { + return getRelativePath(file, ancestor, VFS_SEPARATOR_CHAR); + } + /** * Gets the relative path of <code>file</code> to its <code>ancestor</code>. Uses <code>separator</code> for * separating files. @@ -129,12 +136,10 @@ public class VfsUtilCore { */ @Nullable public static String getRelativePath(@NotNull VirtualFile file, @NotNull VirtualFile ancestor, char separator) { - if (!file.getFileSystem().equals(ancestor.getFileSystem())) return null; - - return doGetRelative(file, ancestor, separator); - } + if (!file.getFileSystem().equals(ancestor.getFileSystem())) { + return null; + } - public static String doGetRelative(VirtualFile file, VirtualFile ancestor, char separator) { int length = 0; VirtualFile parent = file; while (true) { diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java index e4c3e5c502f5..d265d5a8cd2e 100644 --- a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java +++ b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java @@ -717,6 +717,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica putUserData(BOM_KEY, BOM); } + @Override @NonNls public String toString() { return "VirtualFile: " + getPresentableUrl(); |