PY-71854 Platform(refactor): Replace all usage of old non file type specific File limits to the new FileSizeLimit

GitOrigin-RevId: c65b945a34e24ab79b06f2039361fd6dcc1048e7
This commit is contained in:
Nikita.Ashihmin
2024-10-04 10:16:12 +04:00
committed by intellij-monorepo-bot
parent 123fe277d6
commit a82c5d2f20
38 changed files with 123 additions and 87 deletions

View File

@@ -15,17 +15,19 @@ import com.intellij.openapi.fileEditor.FileEditorState
import com.intellij.openapi.fileEditor.FileEditorStateLevel
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.UserDataHolderBase
import com.intellij.openapi.util.io.FileUtilRt
import com.intellij.openapi.util.registry.RegistryManager
import com.intellij.openapi.util.text.StringUtil
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.isTooLarge
import com.intellij.ui.jcef.*
import com.intellij.util.IncorrectOperationException
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import org.cef.browser.CefBrowser
import org.cef.browser.CefFrame
import org.cef.handler.*
import org.cef.handler.CefLoadHandler
import org.cef.handler.CefLoadHandlerAdapter
import org.cef.handler.CefRequestHandler
import org.intellij.images.ImagesBundle
import org.intellij.images.editor.ImageZoomModel
import org.intellij.images.editor.impl.ImageFileEditorState
@@ -209,7 +211,7 @@ class JCefImageViewer(private val myFile: VirtualFile,
myRequestHandler.addResource(IMAGE_PATH) {
var stream: InputStream? = null
try {
stream = if (FileUtilRt.isTooLarge(myFile.length)) myFile.inputStream
stream = if (myFile.isTooLarge()) myFile.inputStream
else ByteArrayInputStream(myDocument.text.toByteArray(StandardCharsets.UTF_8))
}
catch (e: IOException) {

View File

@@ -6,10 +6,10 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileWithId;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.psi.stubs.StubUpdatingIndex;
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
@@ -31,7 +31,7 @@ public class FileBasedIndexTest extends LightJavaCodeInsightFixtureTestCase {
}
public void testLargeFile() {
String largeFileText = "class Foo { String bar; }" + StringUtil.repeat(" ", FileUtilRt.LARGE_FOR_CONTENT_LOADING + 42);
String largeFileText = "class Foo { String bar; }" + StringUtil.repeat(" ", FileSizeLimit.getContentLoadLimit() + 42);
VirtualFile file = myFixture.addFileToProject("Foo.java", largeFileText).getVirtualFile();
int fileId = ((VirtualFileWithId)file).getId();

View File

@@ -9,10 +9,10 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NlsContexts.DialogMessage;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
@@ -45,7 +45,7 @@ import static com.jetbrains.jsonSchema.impl.light.SchemaKeywordsKt.*;
*/
@Deprecated
public final class JsonSchemaReader {
private static final int MAX_SCHEMA_LENGTH = FileUtilRt.LARGE_FOR_CONTENT_LOADING;
private static final int MAX_SCHEMA_LENGTH = FileSizeLimit.getContentLoadLimit();
private static final ObjectMapper jsonObjectMapper = new ObjectMapper(new JsonFactory());
private final Map<String, JsonSchemaObjectImpl> myIds = new HashMap<>();

View File

@@ -14,10 +14,10 @@ import com.intellij.openapi.fileEditor.impl.LoadTextUtil
import com.intellij.openapi.util.buildNsUnawareJdom
import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream
import com.intellij.openapi.util.io.FileAttributes
import com.intellij.openapi.util.io.FileUtilRt
import com.intellij.openapi.util.io.NioFiles
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.isTooLarge
import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent
import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent
import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent
@@ -253,7 +253,7 @@ internal fun writeFile(
): VirtualFile {
val file = if (cachedFile == null || virtualFile?.isValid == true) virtualFile!! else getOrCreateVirtualFile(cachedFile, requestor)
if ((LOG.isDebugEnabled || ApplicationManager.getApplication().isUnitTestMode) && !FileUtilRt.isTooLarge(file.length)) {
if ((LOG.isDebugEnabled || ApplicationManager.getApplication().isUnitTestMode) && !file.isTooLarge()) {
fun isEqualContent(file: VirtualFile,
lineSeparator: LineSeparator,
content: BufferExposingByteArrayOutputStream,

View File

@@ -12,9 +12,9 @@ import com.intellij.openapi.components.impl.stores.stateStore
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ex.ProjectEx
import com.intellij.openapi.project.ex.ProjectManagerEx
import com.intellij.openapi.util.io.FileUtilRt
import com.intellij.openapi.vcs.readOnlyHandler.ReadonlyStatusHandlerImpl
import com.intellij.openapi.vfs.ReadonlyStatusHandler
import com.intellij.openapi.vfs.limits.FileSizeLimit
import com.intellij.project.stateStore
import com.intellij.testFramework.*
import com.intellij.testFramework.assertions.Assertions.assertThat
@@ -83,11 +83,11 @@ class ProjectStoreTest {
assertThat(testComponent.state).isEqualTo(TestState("newValue"))
testComponent.state!!.AAValue = "s".repeat(FileUtilRt.LARGE_FOR_CONTENT_LOADING + 1024)
testComponent.state!!.AAValue = "s".repeat(FileSizeLimit.getContentLoadLimit() + 1024)
project.stateStore.save()
// we should save twice (first call - virtual file size is not yet set)
testComponent.state!!.AAValue = "b".repeat(FileUtilRt.LARGE_FOR_CONTENT_LOADING + 1024)
testComponent.state!!.AAValue = "b".repeat(FileSizeLimit.getContentLoadLimit() + 1024)
project.stateStore.save()
}
}

View File

@@ -2968,6 +2968,8 @@ f:com.intellij.openapi.vfs.VirtualFileUtil
- sf:findOrCreateFile(com.intellij.openapi.vfs.VirtualFile,java.lang.String):com.intellij.openapi.vfs.VirtualFile
- sf:findPsiFile(com.intellij.openapi.vfs.VirtualFile,com.intellij.openapi.project.Project):com.intellij.psi.PsiFile
- sf:isFile(com.intellij.openapi.vfs.VirtualFile):Z
- sf:isTooLarge(com.intellij.openapi.vfs.VirtualFile):Z
- sf:isTooLargeForIntellijSense(com.intellij.openapi.vfs.VirtualFile):Z
- sf:originalFile(com.intellij.openapi.vfs.VirtualFile):com.intellij.openapi.vfs.VirtualFile
- sf:originalFileOrSelf(com.intellij.openapi.vfs.VirtualFile):com.intellij.openapi.vfs.VirtualFile
- sf:readBytes(com.intellij.openapi.vfs.VirtualFile):B[]

View File

@@ -2,15 +2,24 @@
package com.intellij.openapi.vfs;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
public final class PersistentFSConstants {
public static final long FILE_LENGTH_TO_CACHE_THRESHOLD = FileUtilRt.LARGE_FOR_CONTENT_LOADING;
@SuppressWarnings("deprecation")
public static final long FILE_LENGTH_TO_CACHE_THRESHOLD = FileSizeLimit.getFileLengthToCacheThreshold();
/**
* always in range [0, {@link #FILE_LENGTH_TO_CACHE_THRESHOLD}]
*/
private static int ourMaxIntellisenseFileSize = Math.min(FileUtilRt.getUserFileSizeLimit(), (int)FILE_LENGTH_TO_CACHE_THRESHOLD);
/**
* @deprecated Prefer using {@link com.intellij.openapi.vfs.limits.FileSizeLimit#getIntellisenseLimit(FileType)}
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated()
public static int getMaxIntellisenseFileSize() {
return ourMaxIntellisenseFileSize;
}

View File

@@ -12,6 +12,7 @@ import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.io.OSAgnosticPathUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.util.text.StringUtilRt;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.util.PathUtil;
import com.intellij.util.Processor;
import com.intellij.util.containers.ContainerUtil;
@@ -410,8 +411,8 @@ public class VfsUtilCore {
* please prefer {@link VirtualFile#contentsToByteArray()} as more efficient.
*/
public static byte @NotNull [] loadBytes(@NotNull VirtualFile file) throws IOException {
return FileUtilRt.isTooLarge(file.getLength()) ?
loadNBytes(file, FileUtilRt.LARGE_FILE_PREVIEW_SIZE) :
return VirtualFileUtil.isTooLarge(file) ?
loadNBytes(file, FileSizeLimit.getPreviewLimit(file.getExtension())) :
file.contentsToByteArray();
}

View File

@@ -12,6 +12,7 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.io.CanonicalPathPrefixTreeFactory
import com.intellij.openapi.util.io.relativizeToClosestAncestor
import com.intellij.openapi.vfs.limits.FileSizeLimit
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiManager
import com.intellij.testFramework.LightVirtualFileBase
@@ -52,6 +53,15 @@ fun VirtualFile.writeBytes(content: ByteArray) {
setBinaryContent(content)
}
fun VirtualFile.isTooLarge(): Boolean {
return FileSizeLimit.isTooLarge(length, extension)
}
fun VirtualFile.isTooLargeForIntellijSense(): Boolean {
val maxFileSize = FileSizeLimit.getIntellisenseLimit(extension)
return length > maxFileSize
}
fun VirtualFile.toNioPathOrNull(): Path? {
return runCatching { toNioPath() }.getOrNull()
}

View File

@@ -10,6 +10,7 @@ import com.intellij.openapi.util.io.FileTooBigException;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.util.ArrayUtil;
import com.intellij.util.LocalTimeCounter;
import com.intellij.util.ThreeState;
@@ -126,7 +127,7 @@ public class LightVirtualFile extends LightVirtualFileBase {
@Override
public byte @NotNull [] contentsToByteArray() throws IOException {
long cachedLength = myCachedLength;
if (cachedLength > FileUtilRt.LARGE_FOR_CONTENT_LOADING) {
if (FileSizeLimit.isTooLarge(cachedLength, FileUtilRt.getExtension(getNameSequence()).toString())) {
throw new FileTooBigException("file too big, length = "+cachedLength);
}
return doGetContent();

View File

@@ -14,8 +14,8 @@ import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.TextRangeScalarUtil;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileUtil;
import com.intellij.util.DocumentUtil;
import com.intellij.util.ObjectUtils;
import com.intellij.util.ThrowableRunnable;
@@ -395,7 +395,7 @@ public class RangeMarkerImpl extends UserDataHolderBase implements RangeMarkerEx
if (document != null) return true;
if (!file.isValid() || file.isDirectory() || isBinaryWithoutDecompiler(file)) return false;
return !file.getFileType().isBinary() || !FileUtilRt.isTooLarge(file.getLength());
return !file.getFileType().isBinary() || !VirtualFileUtil.isTooLarge(file);
}
private static boolean isBinaryWithoutDecompiler(@NotNull VirtualFile file) {

View File

@@ -10,10 +10,10 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.NonPhysicalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.encoding.EncodingManager;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.psi.FileViewProvider;
import com.intellij.testFramework.LightVirtualFile;
import com.intellij.util.FileContentUtilCore;
@@ -56,7 +56,7 @@ public abstract class FileDocumentManagerBase extends FileDocumentManager {
return null;
}
boolean tooLarge = FileUtilRt.isTooLarge(file.getLength());
boolean tooLarge = FileSizeLimit.isTooLarge(file.getLength(), file.getExtension());
if (file.getFileType().isBinary() && tooLarge) {
return null;
}
@@ -203,7 +203,9 @@ public abstract class FileDocumentManagerBase extends FileDocumentManager {
protected static int getPreviewCharCount(@NotNull VirtualFile file) {
Charset charset = EncodingManager.getInstance().getEncoding(file, false);
float bytesPerChar = charset == null ? 2 : charset.newEncoder().averageBytesPerChar();
return (int)(FileUtilRt.LARGE_FILE_PREVIEW_SIZE / bytesPerChar);
int largeFilePreviewSize = FileSizeLimit.getPreviewLimit(file.getExtension());
return (int)(largeFilePreviewSize / bytesPerChar);
}
private void cacheDocument(@NotNull VirtualFile file, @NotNull Document document) {

View File

@@ -6,11 +6,11 @@ import com.intellij.openapi.util.io.BufferExposingByteArrayInputStream;
import com.intellij.openapi.util.io.FileTooBigException;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.util.io.ResourceHandle;
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.VisibleForTesting;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -87,7 +87,7 @@ public abstract class ZipHandlerBase extends ArchiveHandler {
ZipEntry entry = zip.getEntry(relativePath);
if (entry != null) {
long length = entry.getSize();
if (FileUtilRt.isTooLarge(length)) {
if (FileSizeLimit.isTooLarge(length, FileUtilRt.getExtension(entry.getName()))) {
throw new FileTooBigException(getFile() + "!/" + relativePath);
}
try (InputStream stream = zip.getInputStream(entry)) {
@@ -113,7 +113,7 @@ public abstract class ZipHandlerBase extends ArchiveHandler {
InputStream stream = zip.getInputStream(entry);
if (stream != null) {
long length = entry.getSize();
if (!FileUtilRt.isTooLarge(length)) {
if (!FileSizeLimit.isTooLarge(length, FileUtilRt.getExtension(entry.getName()))) {
try {
return new BufferExposingByteArrayInputStream(FileUtil.loadBytes(stream, (int)length));
}

View File

@@ -10,9 +10,9 @@ import com.intellij.openapi.fileTypes.PlainTextLanguage;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vfs.PersistentFSConstants;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileUtil;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.psi.impl.DebugUtil;
import com.intellij.psi.impl.PsiDocumentManagerBase;
import com.intellij.psi.impl.PsiFileEx;
@@ -166,19 +166,20 @@ public class SingleRootFileViewProvider extends AbstractFileViewProvider impleme
if (file instanceof LightVirtualFile && ((LightVirtualFile)file).isTooLargeForIntelligence() == ThreeState.YES) {
return false;
}
int maxSize = PersistentFSConstants.getMaxIntellisenseFileSize();
int maxSize = FileSizeLimit.getIntellisenseLimit(file.getExtension());
return contentSize == null
? fileSizeIsGreaterThan(file, maxSize)
: contentSize > maxSize;
}
public static boolean isTooLargeForContentLoading(@NotNull VirtualFile vFile) {
return fileSizeIsGreaterThan(vFile, PersistentFSConstants.FILE_LENGTH_TO_CACHE_THRESHOLD);
int contentLoadLimit = FileSizeLimit.getContentLoadLimit(vFile.getExtension());
return fileSizeIsGreaterThan(vFile, contentLoadLimit);
}
public static boolean isTooLargeForContentLoading(@NotNull VirtualFile vFile,
@Nullable("if content size should be retrieved from a file") Long contentSize) {
long maxLength = PersistentFSConstants.FILE_LENGTH_TO_CACHE_THRESHOLD;
long maxLength = FileSizeLimit.getContentLoadLimit(vFile.getExtension());
return contentSize == null
? fileSizeIsGreaterThan(vFile, maxLength)
: contentSize > maxLength;

View File

@@ -25,8 +25,8 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.NullableComputable;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileUtil;
import com.intellij.util.ThreeState;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nls;
@@ -124,7 +124,7 @@ public class TwosideBinaryDiffViewer extends TwosideDiffViewer<BinaryEditorHolde
// Can't trust 0 length, at it might be a lie (and loading empty content into memory shouldn't hurt much).
contentsEquals = false;
}
else if (FileUtilRt.isTooLarge(length1) || FileUtilRt.isTooLarge(length2)) {
else if (VirtualFileUtil.isTooLarge(file1) || VirtualFileUtil.isTooLarge(file2)) {
return new ComparisonData(ThreeState.UNSURE, () -> DiffBundle.message("error.files.too.large.to.compare.text"));
}
else {

View File

@@ -5,7 +5,7 @@ package com.intellij.openapi.vfs;
* A marker interface for {@link VirtualFile#getOutputStream(Object)} to not assert file content size
* and use an {@link com.intellij.util.io.PreemptiveSafeFileOutputStream alternative implementation} of safe file output stream.
*
* @see com.intellij.openapi.util.io.FileUtilRt#isTooLarge
* @see VirtualFileUtil#isTooLarge
* @see com.intellij.util.io.PreemptiveSafeFileOutputStream
*/
public interface LargeFileWriteRequestor { }

View File

@@ -4,7 +4,6 @@ package com.intellij.util.indexing;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.PersistentFSConstants;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Processor;
import org.jetbrains.annotations.ApiStatus;
@@ -84,7 +83,7 @@ public abstract class FileBasedIndexExtension<K, V> extends IndexExtension<K, V,
* For most indices the method should return an empty collection.
*
* @return collection of file types to which file size limit will not be applied when indexing.
* This allows indexing of files whose limit exceeds {@link PersistentFSConstants#getMaxIntellisenseFileSize()}.
* This allows indexing of files whose limit exceeds {@link com.intellij.openapi.vfs.limits.FileSizeLimit#getIntellisenseLimit(FileType)}}.
* <p>
* Use carefully, because indexing large files may influence index update speed dramatically.
*/

View File

@@ -6,8 +6,8 @@ import com.intellij.lang.annotation.AnnotationHolder;
import com.intellij.lang.annotation.Annotator;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.PersistentFSConstants;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.SingleRootFileViewProvider;
@@ -21,7 +21,8 @@ final class LargeFilesAnnotator implements Annotator {
if (SingleRootFileViewProvider.isTooLargeForIntelligence(file)) {
holder.newAnnotation(HighlightSeverity.WARNING, CodeInsightBundle.message("message.file.size.0.exceeds.code.insight.limit.1",
StringUtil.formatFileSize(file.getLength()),
StringUtil.formatFileSize(PersistentFSConstants.getMaxIntellisenseFileSize())))
StringUtil.formatFileSize(
FileSizeLimit.getIntellisenseLimit(file.getExtension()))))
.fileLevel()
.create();
}

View File

@@ -16,11 +16,11 @@ import com.intellij.openapi.ui.InputValidatorEx;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.NlsContexts;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.encoding.EncodingManager;
import com.intellij.openapi.vfs.encoding.EncodingManagerImpl;
import com.intellij.openapi.vfs.encoding.EncodingReference;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.ui.AddEditDeleteListPanel;
import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.JBColor;
@@ -124,7 +124,7 @@ public class ConsoleConfigurable implements SearchableConfigurable, Configurable
myConsoleBufferSizeWarningLabel.setText(ApplicationBundle.message("checkbox.override.console.cycle.buffer.size.warning.unlimited"));
return;
}
if (value > FileUtilRt.LARGE_FOR_CONTENT_LOADING / 1024) {
if (value > FileSizeLimit.getContentLoadLimit() / 1024) {
myConsoleBufferSizeWarningLabel.setText(ApplicationBundle.message("checkbox.override.console.cycle.buffer.size.warning.too.large"));
return;
}

View File

@@ -32,7 +32,6 @@ import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.roots.impl.FilesScanExecutor;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.*;
@@ -225,7 +224,7 @@ final class FindInProjectTask {
boolean skipProjectFile = ProjectUtil.isProjectOrWorkspaceFile(virtualFile) && !myFindModel.isSearchInProjectFiles();
if (skipProjectFile && !Registry.is("find.search.in.project.files")) return true;
if (fileLength > FileUtilRt.LARGE_FOR_CONTENT_LOADING) {
if (VirtualFileUtil.isTooLarge(virtualFile)) {
myLargeFiles.add(virtualFile);
return true;
}

View File

@@ -9,7 +9,6 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.util.text.Strings;
import com.intellij.openapi.vfs.*;
@@ -237,7 +236,7 @@ public final class ExtensionsRootType extends RootType {
}
if (file.isDirectory()) return CONTINUE;
if (file.getFileType().isBinary()) return CONTINUE;
if (file.getLength() > FileUtilRt.LARGE_FOR_CONTENT_LOADING) return CONTINUE;
if (VirtualFileUtil.isTooLarge(file)) return CONTINUE;
String newText = FileUtil.loadTextAndClose(file.getInputStream());
String oldText = child.exists() ? FileUtil.loadFile(child) : "";

View File

@@ -33,8 +33,8 @@ import com.intellij.openapi.ui.popup.JBPopupFactory
import com.intellij.openapi.util.Comparing
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.vfs.NonPhysicalFileSystem
import com.intellij.openapi.vfs.PersistentFSConstants
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.isTooLargeForIntellijSense
import com.intellij.openapi.wm.IdeFocusManager
import com.intellij.openapi.wm.ToolWindow
import com.intellij.openapi.wm.ToolWindowId
@@ -63,7 +63,6 @@ import java.awt.Color
import java.awt.Container
import java.awt.KeyboardFocusManager
import java.awt.event.HierarchyEvent
import java.lang.Runnable
import java.util.*
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicReference
@@ -485,7 +484,7 @@ class StructureViewWrapperImpl(private val project: Project,
}
private suspend fun createStructureViewBuilder(file: VirtualFile): StructureViewBuilder? {
if (file.length > PersistentFSConstants.getMaxIntellisenseFileSize()) return null
if (file.isTooLargeForIntellijSense()) return null
val providers = getInstance().getProvidersAsync(project, file)
val provider = (if (providers.isEmpty()) null else providers[0]) ?: return null
if (provider is StructureViewFileEditorProvider) {

View File

@@ -24,10 +24,10 @@ import com.intellij.openapi.roots.*
import com.intellij.openapi.roots.impl.PushedFilePropertiesUpdater
import com.intellij.openapi.roots.impl.PushedFilePropertiesUpdaterImpl
import com.intellij.openapi.startup.InitProjectActivity
import com.intellij.openapi.util.io.FileUtilRt
import com.intellij.openapi.util.registry.Registry
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.openapi.vfs.isTooLarge
import com.intellij.openapi.vfs.newvfs.BulkFileListener
import com.intellij.openapi.vfs.newvfs.events.*
import com.intellij.project.stateStore
@@ -652,7 +652,7 @@ private class MyFileDocumentManagerListener(private val project: Project) : File
override fun fileContentReloaded(file: VirtualFile, document: Document) {
val psiFile = fileManager.findCachedViewProvider(file)
if (file.isValid && psiFile != null && FileUtilRt.isTooLarge(file.length) && psiFile !is PsiLargeFile) {
if (file.isValid && psiFile != null && file.isTooLarge() && psiFile !is PsiLargeFile) {
ApplicationManager.getApplication().runWriteAction(ExternalChangeAction { fileManager.reloadPsiAfterTextChange(psiFile, file) })
}
}

View File

@@ -2,8 +2,7 @@
package com.intellij.util.indexing.diagnostic.dto
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.intellij.openapi.util.io.FileUtilRt
import com.intellij.openapi.vfs.PersistentFSConstants
import com.intellij.openapi.vfs.limits.FileSizeLimit
import com.intellij.util.indexing.UnindexedFilesUpdater
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -21,8 +20,8 @@ data class JsonRuntimeInfo(
runtime.maxMemory(),
runtime.availableProcessors(),
UnindexedFilesUpdater.getMaxNumberOfIndexingThreads(),
PersistentFSConstants.getMaxIntellisenseFileSize(),
FileUtilRt.LARGE_FOR_CONTENT_LOADING
FileSizeLimit.getIntellisenseLimit(),
FileSizeLimit.getContentLoadLimit()
)
}
}

View File

@@ -12,8 +12,8 @@ import com.intellij.openapi.fileTypes.INativeFileType
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.util.NlsActions
import com.intellij.openapi.util.registry.Registry
import com.intellij.openapi.vfs.PersistentFSConstants
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.isTooLargeForIntellijSense
import com.intellij.util.Alarm
import com.intellij.util.SingleAlarm
import com.intellij.util.concurrency.annotations.RequiresEdt
@@ -175,7 +175,7 @@ abstract class AutoScrollToSourceHandler {
}
//IDEA-84881 Don't autoscroll to very large files
return file.length <= PersistentFSConstants.getMaxIntellisenseFileSize()
return !file.isTooLargeForIntellijSense()
}
@RequiresEdt

View File

@@ -19,8 +19,8 @@ import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.util.Producer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -64,13 +64,13 @@ public class BasePasteHandler extends EditorWriteActionHandler {
}
public static boolean isContentTooLarge(int contentLength) {
return contentLength > FileUtilRt.LARGE_FOR_CONTENT_LOADING;
return contentLength > FileSizeLimit.getContentLoadLimit();
}
public static void contentLengthLimitExceededMessage(int contentLength) {
Messages.showErrorDialog(EditorBundle.message("content.to.paste.too.large.message",
StringUtil.formatFileSize(contentLength),
StringUtil.formatFileSize(FileUtilRt.LARGE_FOR_CONTENT_LOADING)),
StringUtil.formatFileSize(FileSizeLimit.getContentLoadLimit())),
EditorBundle.message("content.to.paste.too.large.title"));
}
}

View File

@@ -3,7 +3,6 @@ package com.intellij.openapi.fileEditor.impl;
import com.intellij.CommonBundle;
import com.intellij.application.options.CodeStyle;
import com.intellij.codeWithMe.ClientId;
import com.intellij.concurrency.ConcurrentCollectionFactory;
import com.intellij.concurrency.ThreadContext;
import com.intellij.ide.plugins.DynamicPluginListener;
@@ -23,7 +22,6 @@ import com.intellij.openapi.editor.impl.DocumentImpl;
import com.intellij.openapi.editor.impl.EditorFactoryImpl;
import com.intellij.openapi.editor.impl.TrailingSpacesStripper;
import com.intellij.openapi.fileEditor.*;
import com.intellij.openapi.fileEditor.impl.converter.FileTextConverter;
import com.intellij.openapi.fileEditor.impl.text.TextEditorImpl;
import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers;
import com.intellij.openapi.fileTypes.FileType;
@@ -39,6 +37,7 @@ import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.*;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem;
import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent;
import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent;
@@ -204,7 +203,7 @@ public class FileDocumentManagerImpl extends FileDocumentManagerBase implements
int totalSize = 0;
for (Document document : documents) {
totalSize += document.getTextLength();
if (totalSize > FileUtilRt.LARGE_FOR_CONTENT_LOADING) return true;
if (totalSize > FileSizeLimit.getContentLoadLimit()) return true;
}
return false;
}
@@ -433,9 +432,6 @@ public class FileDocumentManagerImpl extends FileDocumentManagerBase implements
String text = document.getText();
String lineSeparator = getLineSeparator(document, file);
//Some files have document.text different from file representation
text = FileTextConverter.convertToSaveDocumentTextToFile(text, file);
if (!lineSeparator.equals("\n")) {
text = StringUtil.convertLineSeparators(text, lineSeparator);
}

View File

@@ -4,9 +4,9 @@ package com.intellij.openapi.fileEditor.impl;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.FileDocumentSynchronizationVetoer;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.ApiStatus;
import com.intellij.openapi.vfs.VirtualFileUtil;
import org.jetbrains.annotations.NotNull;
@ApiStatus.Internal
@@ -14,6 +14,6 @@ public final class LargeFileSavingVetoer extends FileDocumentSynchronizationVeto
@Override
public boolean maySaveDocument(@NotNull Document document, boolean isSaveExplicit) {
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
return file == null || !file.isValid() || !FileUtilRt.isTooLarge(file.getLength());
return file == null || !file.isValid() || !VirtualFileUtil.isTooLarge(file);
}
}

View File

@@ -8,9 +8,9 @@ import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.ui.EditorNotificationPanel;
import com.intellij.ui.EditorNotificationProvider;
import com.intellij.ui.EditorNotifications;
@@ -51,7 +51,7 @@ public final class LargeFileNotificationProvider implements EditorNotificationPr
return panel.text(IdeBundle.message(
"large.file.preview.notification",
StringUtil.formatFileSize(file.getLength()),
StringUtil.formatFileSize(FileUtilRt.LARGE_FILE_PREVIEW_SIZE)
StringUtil.formatFileSize(FileSizeLimit.getPreviewLimit(file.getExtension()))
));
};
}

View File

@@ -8,8 +8,8 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -109,7 +109,7 @@ public final class IncompatibleEncodingDialog extends DialogWrapper {
@Override
public boolean isEnabled() {
return !FileUtilRt.isTooLarge(virtualFile.getLength());
return !VirtualFileUtil.isTooLarge(virtualFile);
}
};
if (!SystemInfo.isMac && safeToConvert == EncodingUtil.Magic8.NO_WAY) {

View File

@@ -10,6 +10,7 @@ import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.SystemInfoRt;
import com.intellij.openapi.util.io.*;
import com.intellij.openapi.vfs.*;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.openapi.vfs.newvfs.ManagingFS;
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
import com.intellij.openapi.vfs.newvfs.VfsImplUtil;
@@ -359,7 +360,8 @@ public abstract class LocalFileSystemBase extends LocalFileSystem {
// as a first file.size() request alone. So that optimization needs to be carefully benchmarked to prove it
// does provide anything -- and my guess: it probably doesn't
var length = Files.size(nioFile);
if (FileUtilRt.isTooLarge(length)) {
if (FileSizeLimit.isTooLarge(length, FileUtilRt.getExtension(nioFile.getFileName().toString()))) {
throw new FileTooBigException("File " + nioFile.toAbsolutePath() + " is too large (=" + length + " b)");
}
return Files.readAllBytes(nioFile);

View File

@@ -10,10 +10,10 @@ import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.io.FileTooBigException;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.LargeFileWriteRequestor;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileUtil;
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
import com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem;
import com.intellij.util.LineSeparator;
@@ -197,7 +197,7 @@ public final class VirtualFileImpl extends VirtualFileSystemEntry {
}
private void checkNotTooLarge(@Nullable Object requestor) throws FileTooBigException {
if (!(requestor instanceof LargeFileWriteRequestor) && FileUtilRt.isTooLarge(getLength())) throw new FileTooBigException(getPath());
if (!(requestor instanceof LargeFileWriteRequestor) && VirtualFileUtil.isTooLarge(this)) throw new FileTooBigException(getPath());
}
@Override

View File

@@ -5,10 +5,8 @@ import com.intellij.openapi.fileTypes.PlainTextFileType;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.io.FileTooBigException;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.*;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.testFramework.LightPlatformTestCase;
import com.intellij.testFramework.LightVirtualFile;
import com.intellij.testFramework.VfsTestUtil;
@@ -63,7 +61,7 @@ public class LoadTextUtilTest extends LightPlatformTestCase {
}
public void testVfsUtilLoadBytesMustIncludeBOMForBigRegularVirtualFile() throws IOException {
String text = "A".repeat(FileUtilRt.LARGE_FOR_CONTENT_LOADING+1);
String text = "A".repeat(FileSizeLimit.getContentLoadLimit() + 1);
byte[] stringBytes = text.getBytes(StandardCharsets.UTF_16BE);
byte[] expectedAllBytes = ArrayUtil.mergeArrays(CharsetToolkit.UTF16BE_BOM, stringBytes);
@@ -84,7 +82,7 @@ public class LoadTextUtilTest extends LightPlatformTestCase {
assertVfsUtilVariousGettersAreConsistent(vFile, text, stringBytes, expectedAllBytes);
}
public void testVfsUtilLoadBytesMustIncludeBOMForBigLightVirtualFile() throws IOException {
String text = "A".repeat(FileUtilRt.LARGE_FOR_CONTENT_LOADING+1);
String text = "A".repeat(FileSizeLimit.getContentLoadLimit() + 1);
byte[] stringBytes = text.getBytes(StandardCharsets.UTF_16BE);
byte[] expectedAllBytes = ArrayUtil.mergeArrays(CharsetToolkit.UTF16BE_BOM, stringBytes);
LightVirtualFile vFile = new LightVirtualFile("test.txt", PlainTextFileType.INSTANCE, text, StandardCharsets.UTF_16BE, 2);
@@ -97,7 +95,7 @@ public class LoadTextUtilTest extends LightPlatformTestCase {
assertEquals(StandardCharsets.UTF_16BE, vFile.getCharset());
assertEquals(text, VfsUtilCore.loadText(vFile));
assertOrderedEquals(vFile.getInputStream().readAllBytes(), stringBytes);
if (FileUtilRt.isTooLarge(vFile.getLength())) {
if (VirtualFileUtil.isTooLarge(vFile)) {
assertThrows(FileTooBigException.class, () -> vFile.contentsToByteArray());
}
else {

View File

@@ -34,10 +34,10 @@ import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.ThrowableComputable;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.io.IoTestUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.*;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.openapi.wm.impl.status.EncodingPanel;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiFile;
@@ -919,7 +919,7 @@ public class FileEncodingTest extends HeavyPlatformTestCase implements TestDialo
public void testBigFileInsideJarCorrectlyHandlesBOM() throws IOException {
File tmpDir = createTempDirectory();
File jar = new File(tmpDir, "x.jar");
String bigText = StringUtil.repeat("u", FileUtilRt.LARGE_FOR_CONTENT_LOADING+1);
String bigText = StringUtil.repeat("u", FileSizeLimit.getContentLoadLimit() + 1);
byte[] utf16beBytes = ArrayUtil.mergeArrays(CharsetToolkit.UTF16BE_BOM, bigText.getBytes(StandardCharsets.UTF_16BE));
String name = "some_random_name";
IoTestUtil.createTestJar(jar, Collections.singletonList(Pair.create(name, utf16beBytes)));

View File

@@ -10,14 +10,13 @@ import com.intellij.openapi.project.DefaultProjectFactory;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.io.IoTestUtil;
import com.intellij.openapi.vfs.*;
import com.intellij.openapi.vfs.impl.ArchiveHandler;
import com.intellij.openapi.vfs.impl.ZipHandler;
import com.intellij.openapi.vfs.impl.ZipHandlerBase;
import com.intellij.openapi.vfs.impl.jar.JarFileSystemImpl;
import com.intellij.openapi.vfs.impl.jar.TimedZipHandler;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.openapi.vfs.newvfs.ArchiveFileSystem;
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
import com.intellij.openapi.vfs.newvfs.VfsImplUtil;
@@ -256,7 +255,7 @@ public class JarFileSystemTest extends BareTestFixtureTestCase {
FileUtil.writeToFile(new File(root, "small1"), "some text");
FileUtil.writeToFile(new File(root, "small2"), "another text");
try (InputStream is = new ZeroInputStream(); OutputStream os = new FileOutputStream(new File(root, "large"))) {
FileUtil.copy(is, FileUtilRt.LARGE_FOR_CONTENT_LOADING * 2, os);
FileUtil.copy(is, FileSizeLimit.getContentLoadLimit() * 2, os);
}
File jar = IoTestUtil.createTestJar(tempDir.newFile("test.jar"), root);

View File

@@ -12,11 +12,11 @@ import com.intellij.openapi.util.io.FileAttributes;
import com.intellij.openapi.util.io.FileAttributes.CaseSensitivity;
import com.intellij.openapi.util.io.FileSystemUtil;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.*;
import com.intellij.openapi.vfs.ex.temp.TempFileSystemMarker;
import com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.openapi.vfs.newvfs.*;
import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent;
import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent;
@@ -1010,7 +1010,7 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
@Test
public void testFileContentWithAlmostTooLargeLength() throws IOException {
byte[] expectedContent = new byte[FileUtilRt.LARGE_FOR_CONTENT_LOADING];
byte[] expectedContent = new byte[FileSizeLimit.getContentLoadLimit()];
Arrays.fill(expectedContent, (byte) 'a');
File file = tempDir.newFile("test.txt");
FileUtil.writeToFile(file, expectedContent);

View File

@@ -34,11 +34,11 @@ import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.ThrowableComputable;
import com.intellij.openapi.util.io.FileTooBigException;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
import com.intellij.openapi.vfs.limits.FileSizeLimit;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.PsiFileImpl;
import com.intellij.testFramework.HeavyPlatformTestCase;
@@ -764,14 +764,14 @@ public class PsiDocumentManagerImplTest extends HeavyPlatformTestCase {
private void assertLargeFileContentLimited(@NotNull String content, @NotNull VirtualFile vFile, @NotNull Document document) {
Charset charset = EncodingProjectManager.getInstance(getProject()).getEncoding(vFile, false);
float bytesPerChar = charset == null ? 2 : charset.newEncoder().averageBytesPerChar();
int contentSize = (int)(FileUtilRt.LARGE_FILE_PREVIEW_SIZE / bytesPerChar);
int contentSize = (int)(FileSizeLimit.getPreviewLimit(vFile.getExtension()) / bytesPerChar);
String substring = content.substring(0, contentSize);
assertEquals(substring, document.getText());
}
@NotNull
private static String getTooLargeContent() {
return StringUtil.repeat("a", FileUtilRt.LARGE_FOR_CONTENT_LOADING + 1);
return StringUtil.repeat("a", FileSizeLimit.getContentLoadLimit() + 1);
}
public void testDefaultProjectDocumentsAreAutoCommitted() throws IOException {

View File

@@ -28,7 +28,19 @@ public final class FileUtilRt {
private static final int DEFAULT_INTELLISENSE_LIMIT = 2500 * KILOBYTE;
public static final int MEGABYTE = KILOBYTE * KILOBYTE;
/**
* @deprecated Prefer using @link {@link com.intellij.openapi.vfs.limits.FileSizeLimit#getContentLoadLimit}
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated
public static final int LARGE_FOR_CONTENT_LOADING = Math.max(20 * MEGABYTE, Math.max(getUserFileSizeLimit(), getUserContentLoadLimit()));
/**
* @deprecated Prefer using @link {@link com.intellij.openapi.vfs.limits.FileSizeLimit#getPreviewLimit}
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated
public static final int LARGE_FILE_PREVIEW_SIZE = Math.min(getLargeFilePreviewSize(), LARGE_FOR_CONTENT_LOADING);
private static final int MAX_FILE_IO_ATTEMPTS = 10;
@@ -706,6 +718,11 @@ public final class FileUtilRt {
return buffer.toByteArray();
}
/**
* @deprecated Prefer using @link {@link com.intellij.openapi.vfs.limits.FileSizeLimit#isTooLarge}
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated
public static boolean isTooLarge(long len) {
return len > LARGE_FOR_CONTENT_LOADING;
}