mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
PY-71854 Jupyter(feat): rename getLoadLimit() to getDefaultLoadLimit
GitOrigin-RevId: 87ae69b139e84aa6817b27123d3d3db79ac64344
This commit is contained in:
committed by
intellij-monorepo-bot
parent
31b379fb88
commit
487eb45975
@@ -31,7 +31,7 @@ public class FileBasedIndexTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
}
|
||||
|
||||
public void testLargeFile() {
|
||||
String largeFileText = "class Foo { String bar; }" + StringUtil.repeat(" ", FileSizeLimit.getContentLoadLimit() + 42);
|
||||
String largeFileText = "class Foo { String bar; }" + StringUtil.repeat(" ", FileSizeLimit.getDefaultContentLoadLimit() + 42);
|
||||
VirtualFile file = myFixture.addFileToProject("Foo.java", largeFileText).getVirtualFile();
|
||||
int fileId = ((VirtualFileWithId)file).getId();
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ import static com.jetbrains.jsonSchema.impl.light.SchemaKeywordsKt.*;
|
||||
*/
|
||||
@Deprecated
|
||||
public final class JsonSchemaReader {
|
||||
private static final int MAX_SCHEMA_LENGTH = FileSizeLimit.getContentLoadLimit();
|
||||
private static final int MAX_SCHEMA_LENGTH = FileSizeLimit.getDefaultContentLoadLimit();
|
||||
private static final ObjectMapper jsonObjectMapper = new ObjectMapper(new JsonFactory());
|
||||
|
||||
private final Map<String, JsonSchemaObjectImpl> myIds = new HashMap<>();
|
||||
|
||||
@@ -83,11 +83,11 @@ class ProjectStoreTest {
|
||||
|
||||
assertThat(testComponent.state).isEqualTo(TestState("newValue"))
|
||||
|
||||
testComponent.state!!.AAValue = "s".repeat(FileSizeLimit.getContentLoadLimit() + 1024)
|
||||
testComponent.state!!.AAValue = "s".repeat(FileSizeLimit.getDefaultContentLoadLimit() + 1024)
|
||||
project.stateStore.save()
|
||||
|
||||
// we should save twice (first call - virtual file size is not yet set)
|
||||
testComponent.state!!.AAValue = "b".repeat(FileSizeLimit.getContentLoadLimit() + 1024)
|
||||
testComponent.state!!.AAValue = "b".repeat(FileSizeLimit.getDefaultContentLoadLimit() + 1024)
|
||||
project.stateStore.save()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ interface FileSizeLimit {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isTooLarge(fileSize: Long, extension: String? = ""): Boolean {
|
||||
fun isTooLarge(fileSize: Long, extension: String?): Boolean {
|
||||
val fileContentLoadLimit = getContentLoadLimit(extension)
|
||||
return fileSize > fileContentLoadLimit
|
||||
}
|
||||
@@ -56,7 +56,7 @@ interface FileSizeLimit {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getContentLoadLimit(): Int = getContentLoadLimit(null)
|
||||
fun getDefaultContentLoadLimit(): Int = getContentLoadLimit(null)
|
||||
|
||||
@JvmStatic
|
||||
fun getIntellisenseLimit(): Int = getIntellisenseLimit(null)
|
||||
@@ -69,9 +69,9 @@ interface FileSizeLimit {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getPreviewLimit(extension: String? = ""): Int {
|
||||
fun getPreviewLimit(extension: String?): Int {
|
||||
@Suppress("DEPRECATION")
|
||||
val limit = findApplicable(extension?:"")?.preview ?: FileUtilRt.LARGE_FILE_PREVIEW_SIZE
|
||||
val limit = findApplicable(extension ?: "")?.preview ?: FileUtilRt.LARGE_FILE_PREVIEW_SIZE
|
||||
return limit
|
||||
}
|
||||
|
||||
@@ -79,10 +79,15 @@ interface FileSizeLimit {
|
||||
val extensions = EP.extensionsIfPointIsRegistered
|
||||
|
||||
val duplicates: Map<String, Int> = extensions.flatMap { it.acceptableExtensions }.groupingBy { it }.eachCount().filter { it.value > 1 }
|
||||
duplicates.forEach {(element, count) ->
|
||||
thisLogger().warn("For file type $element $count limits are registered. Extensions: ${extensions.joinToString {
|
||||
"${it.javaClass.name}: ${it.acceptableExtensions.joinToString()}" }}")
|
||||
}
|
||||
duplicates.forEach { (element, count) ->
|
||||
thisLogger().warn("For file type $element $count limits are registered. Extensions: ${
|
||||
extensions
|
||||
.filter { it.acceptableExtensions.contains(element) }
|
||||
.joinToString { extension ->
|
||||
"${extension.javaClass.name}: ${extension.acceptableExtensions.joinToString()}"
|
||||
}
|
||||
}")
|
||||
}
|
||||
|
||||
val newLimits = extensions.flatMap { extension -> extension.acceptableExtensions.map { it to extension.getLimits() } }.toMap()
|
||||
return newLimits
|
||||
|
||||
@@ -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 > FileSizeLimit.getContentLoadLimit() / 1024) {
|
||||
if (value > FileSizeLimit.getDefaultContentLoadLimit() / 1024) {
|
||||
myConsoleBufferSizeWarningLabel.setText(ApplicationBundle.message("checkbox.override.console.cycle.buffer.size.warning.too.large"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ data class JsonRuntimeInfo(
|
||||
runtime.availableProcessors(),
|
||||
UnindexedFilesUpdater.getMaxNumberOfIndexingThreads(),
|
||||
FileSizeLimit.getIntellisenseLimit(),
|
||||
FileSizeLimit.getContentLoadLimit()
|
||||
FileSizeLimit.getDefaultContentLoadLimit()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,13 +64,13 @@ public class BasePasteHandler extends EditorWriteActionHandler {
|
||||
}
|
||||
|
||||
public static boolean isContentTooLarge(int contentLength) {
|
||||
return contentLength > FileSizeLimit.getContentLoadLimit();
|
||||
return contentLength > FileSizeLimit.getDefaultContentLoadLimit();
|
||||
}
|
||||
|
||||
public static void contentLengthLimitExceededMessage(int contentLength) {
|
||||
Messages.showErrorDialog(EditorBundle.message("content.to.paste.too.large.message",
|
||||
StringUtil.formatFileSize(contentLength),
|
||||
StringUtil.formatFileSize(FileSizeLimit.getContentLoadLimit())),
|
||||
StringUtil.formatFileSize(FileSizeLimit.getDefaultContentLoadLimit())),
|
||||
EditorBundle.message("content.to.paste.too.large.title"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ public class FileDocumentManagerImpl extends FileDocumentManagerBase implements
|
||||
int totalSize = 0;
|
||||
for (Document document : documents) {
|
||||
totalSize += document.getTextLength();
|
||||
if (totalSize > FileSizeLimit.getContentLoadLimit()) return true;
|
||||
if (totalSize > FileSizeLimit.getDefaultContentLoadLimit()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class LoadTextUtilTest extends LightPlatformTestCase {
|
||||
}
|
||||
|
||||
public void testVfsUtilLoadBytesMustIncludeBOMForBigRegularVirtualFile() throws IOException {
|
||||
String text = "A".repeat(FileSizeLimit.getContentLoadLimit() + 1);
|
||||
String text = "A".repeat(FileSizeLimit.getDefaultContentLoadLimit() + 1);
|
||||
byte[] stringBytes = text.getBytes(StandardCharsets.UTF_16BE);
|
||||
byte[] expectedAllBytes = ArrayUtil.mergeArrays(CharsetToolkit.UTF16BE_BOM, stringBytes);
|
||||
|
||||
@@ -82,7 +82,7 @@ public class LoadTextUtilTest extends LightPlatformTestCase {
|
||||
assertVfsUtilVariousGettersAreConsistent(vFile, text, stringBytes, expectedAllBytes);
|
||||
}
|
||||
public void testVfsUtilLoadBytesMustIncludeBOMForBigLightVirtualFile() throws IOException {
|
||||
String text = "A".repeat(FileSizeLimit.getContentLoadLimit() + 1);
|
||||
String text = "A".repeat(FileSizeLimit.getDefaultContentLoadLimit() + 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);
|
||||
|
||||
@@ -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", FileSizeLimit.getContentLoadLimit() + 1);
|
||||
String bigText = StringUtil.repeat("u", FileSizeLimit.getDefaultContentLoadLimit() + 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)));
|
||||
|
||||
@@ -255,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, FileSizeLimit.getContentLoadLimit() * 2, os);
|
||||
FileUtil.copy(is, FileSizeLimit.getDefaultContentLoadLimit() * 2, os);
|
||||
}
|
||||
File jar = IoTestUtil.createTestJar(tempDir.newFile("test.jar"), root);
|
||||
|
||||
|
||||
@@ -1010,7 +1010,7 @@ public class LocalFileSystemTest extends BareTestFixtureTestCase {
|
||||
|
||||
@Test
|
||||
public void testFileContentWithAlmostTooLargeLength() throws IOException {
|
||||
byte[] expectedContent = new byte[FileSizeLimit.getContentLoadLimit()];
|
||||
byte[] expectedContent = new byte[FileSizeLimit.getDefaultContentLoadLimit()];
|
||||
Arrays.fill(expectedContent, (byte) 'a');
|
||||
File file = tempDir.newFile("test.txt");
|
||||
FileUtil.writeToFile(file, expectedContent);
|
||||
|
||||
@@ -771,7 +771,7 @@ public class PsiDocumentManagerImplTest extends HeavyPlatformTestCase {
|
||||
|
||||
@NotNull
|
||||
private static String getTooLargeContent() {
|
||||
return StringUtil.repeat("a", FileSizeLimit.getContentLoadLimit() + 1);
|
||||
return StringUtil.repeat("a", FileSizeLimit.getDefaultContentLoadLimit() + 1);
|
||||
}
|
||||
|
||||
public void testDefaultProjectDocumentsAreAutoCommitted() throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user