mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[jeka] Do not try to build stubs for too large files
This commit is contained in:
@@ -257,6 +257,11 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
|
||||
return fileSizeIsGreaterThan(vFile, PersistentFS.MAX_INTELLISENSE_FILESIZE);
|
||||
}
|
||||
|
||||
public static boolean isTooLarge(final VirtualFile vFile, final long contentSize) {
|
||||
if (Boolean.TRUE.equals(vFile.getUserData(ourNoSizeLimitKey))) return false;
|
||||
return contentSize > PersistentFS.MAX_INTELLISENSE_FILESIZE;
|
||||
}
|
||||
|
||||
private static boolean fileSizeIsGreaterThan(final VirtualFile vFile, final long maxInBytes) {
|
||||
if (vFile instanceof LightVirtualFile) {
|
||||
// This is optimization in order to avoid conversion of [large] file contents to bytes
|
||||
|
||||
@@ -1163,7 +1163,12 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
ProgressManager.getInstance().executeNonCancelableSection(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
final FileContent newFc = new FileContent(vFile, content.getText(), vFile.getCharset());
|
||||
final String contentText = content.getText();
|
||||
if (isTooLarge(vFile, contentText.length())) {
|
||||
return;
|
||||
}
|
||||
|
||||
final FileContent newFc = new FileContent(vFile, contentText, vFile.getCharset());
|
||||
|
||||
if (dominantContentFile != null) {
|
||||
dominantContentFile.putUserData(PsiFileImpl.BUILDING_STUB, true);
|
||||
@@ -1820,6 +1825,14 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isTooLarge(VirtualFile file, long contentSize) {
|
||||
if (SingleRootFileViewProvider.isTooLarge(file, contentSize)) {
|
||||
final FileType type = FileTypeManager.getInstance().getFileTypeByFile(file);
|
||||
return !myNoLimitCheckTypes.contains(type);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public CollectingContentIterator createContentIterator() {
|
||||
return new UnindexedFilesFinder();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user