diff options
Diffstat (limited to 'platform/core-api/src')
8 files changed, 36 insertions, 11 deletions
diff --git a/platform/core-api/src/com/intellij/ide/caches/FileContent.java b/platform/core-api/src/com/intellij/ide/caches/FileContent.java index 0933b7f19005..c4c6d61c4513 100644 --- a/platform/core-api/src/com/intellij/ide/caches/FileContent.java +++ b/platform/core-api/src/com/intellij/ide/caches/FileContent.java @@ -47,7 +47,7 @@ public class FileContent extends UserDataHolderBase { @NotNull public byte[] getBytes() throws IOException { if (myCachedBytes == null) { - myCachedBytes = myVirtualFile.contentsToByteArray(false); + myCachedBytes = myVirtualFile.isValid() ? myVirtualFile.contentsToByteArray(false) : ArrayUtil.EMPTY_BYTE_ARRAY; } return myCachedBytes; diff --git a/platform/core-api/src/com/intellij/ide/util/PropertiesComponent.java b/platform/core-api/src/com/intellij/ide/util/PropertiesComponent.java index f3b883d0b60f..f733cd04f4a6 100644 --- a/platform/core-api/src/com/intellij/ide/util/PropertiesComponent.java +++ b/platform/core-api/src/com/intellij/ide/util/PropertiesComponent.java @@ -17,8 +17,10 @@ package com.intellij.ide.util; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.project.Project; +import com.intellij.util.ObjectUtils; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.lang.reflect.Field; @@ -31,6 +33,7 @@ public abstract class PropertiesComponent { public abstract boolean isValueSet(String name); + @Nullable public abstract String getValue(@NonNls String name); public abstract void setValue(@NonNls String name, String value); @@ -62,7 +65,10 @@ public abstract class PropertiesComponent { @NotNull public String getValue(@NonNls String name, @NotNull String defaultValue) { - return isValueSet(name) ? getValue(name) : defaultValue; + if (!isValueSet(name)) { + return defaultValue; + } + return ObjectUtils.notNull(getValue(name), defaultValue); } public final int getOrInitInt(@NonNls String name, int defaultValue) { diff --git a/platform/core-api/src/com/intellij/lexer/DelegateLexer.java b/platform/core-api/src/com/intellij/lexer/DelegateLexer.java index ce8bbbc18748..102256b60160 100644 --- a/platform/core-api/src/com/intellij/lexer/DelegateLexer.java +++ b/platform/core-api/src/com/intellij/lexer/DelegateLexer.java @@ -26,7 +26,7 @@ import org.jetbrains.annotations.Nullable; public class DelegateLexer extends LexerBase { protected final Lexer myDelegate; - public DelegateLexer(Lexer delegate) { + public DelegateLexer(@NotNull Lexer delegate) { myDelegate = delegate; } 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 a319700b4be2..e99b8e6bebf0 100644 --- a/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java +++ b/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java @@ -79,7 +79,7 @@ public abstract class ProgressManager { } } - public static void progress(final String text) throws ProcessCanceledException { + public static void progress(@NotNull String text) throws ProcessCanceledException { progress(text, ""); } @@ -91,7 +91,7 @@ public abstract class ProgressManager { } } - public static void progress(final String text, @Nullable String text2) throws ProcessCanceledException { + public static void progress(@NotNull String text, @Nullable String text2) throws ProcessCanceledException { final ProgressIndicator pi = getInstance().getProgressIndicator(); if (pi != null) { pi.checkCanceled(); @@ -103,6 +103,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); @@ -135,9 +136,9 @@ public abstract class ProgressManager { * @throws E exception thrown by process */ public abstract <T, E extends Exception> T runProcessWithProgressSynchronously(@NotNull ThrowableComputable<T, E> process, - @NotNull @Nls String progressTitle, - boolean canBeCanceled, - @Nullable Project project) throws E; + @NotNull @Nls String progressTitle, + boolean canBeCanceled, + @Nullable Project project) throws E; /** * Runs the specified operation in a background thread and shows a modal progress dialog in the @@ -206,7 +207,10 @@ public abstract class ProgressManager { public abstract void runProcessWithProgressAsynchronously(@NotNull Task.Backgroundable task, @NotNull ProgressIndicator progressIndicator); protected static final ThreadLocal<ProgressIndicator> myThreadIndicator = new ThreadLocal<ProgressIndicator>(); - public void executeProcessUnderProgress(@NotNull Runnable process, ProgressIndicator progress) throws ProcessCanceledException { + + public void executeProcessUnderProgress(@NotNull Runnable process, + @Nullable("null means reuse current progress") ProgressIndicator progress) + throws ProcessCanceledException { ProgressIndicator oldIndicator = null; boolean set = progress != null && progress != (oldIndicator = myThreadIndicator.get()); diff --git a/platform/core-api/src/com/intellij/openapi/roots/FileIndexFacade.java b/platform/core-api/src/com/intellij/openapi/roots/FileIndexFacade.java index cc7dddd3c848..96dde81c6a80 100644 --- a/platform/core-api/src/com/intellij/openapi/roots/FileIndexFacade.java +++ b/platform/core-api/src/com/intellij/openapi/roots/FileIndexFacade.java @@ -45,6 +45,7 @@ public abstract class FileIndexFacade { public abstract boolean isInLibrarySource(@NotNull VirtualFile file); public abstract boolean isExcludedFile(@NotNull VirtualFile file); + public abstract boolean isUnderIgnored(@NotNull VirtualFile file); @Nullable public abstract Module getModuleForFile(@NotNull VirtualFile file); diff --git a/platform/core-api/src/com/intellij/openapi/vfs/JarFile.java b/platform/core-api/src/com/intellij/openapi/vfs/JarFile.java index c363a815577a..f8ddc7630e23 100644 --- a/platform/core-api/src/com/intellij/openapi/vfs/JarFile.java +++ b/platform/core-api/src/com/intellij/openapi/vfs/JarFile.java @@ -22,7 +22,7 @@ import java.io.InputStream; import java.util.Enumeration; import java.util.zip.ZipFile; -/** @deprecated causes ZipFile leaks, do not use (to be removed in IDEA 15) */ +/** @deprecated causes ZipFile leaks, do not use (to be removed in IDEA 15) + can lead to crashes (IDEA-126550) */ public interface JarFile { interface JarEntry { String getName(); 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 cd0f15f3796c..9e8c37880589 100644 --- a/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java +++ b/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java @@ -84,6 +84,20 @@ public class VfsUtilCore { return false; } + /** + * @return {@code true} if {@code url} is located under one of {@code rootUrls} or equal to one of them + */ + public static boolean isUnder(@NotNull String url, @Nullable Collection<String> rootUrls) { + if (rootUrls == null || rootUrls.isEmpty()) return false; + + for (String excludesUrl : rootUrls) { + if (isEqualOrAncestor(excludesUrl, url)) { + return true; + } + } + return false; + } + public static boolean isEqualOrAncestor(@NotNull String ancestorUrl, @NotNull String fileUrl) { if (ancestorUrl.equals(fileUrl)) return true; if (StringUtil.endsWithChar(ancestorUrl, '/')) { diff --git a/platform/core-api/src/com/intellij/psi/PsiInvalidElementAccessException.java b/platform/core-api/src/com/intellij/psi/PsiInvalidElementAccessException.java index fb2ae2ce4d21..f24556fe5c25 100644 --- a/platform/core-api/src/com/intellij/psi/PsiInvalidElementAccessException.java +++ b/platform/core-api/src/com/intellij/psi/PsiInvalidElementAccessException.java @@ -164,7 +164,7 @@ public class PsiInvalidElementAccessException extends RuntimeException implement } public static boolean isTrackingInvalidation() { - return Registry.is("psi.track.invalidation", true); + return Registry.is("psi.track.invalidation"); } @Nullable |