Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
10760: Adjust intellisense file size limit for Rust files r=vlad20012 a=vlad20012 I finally figured out how to increase the file limit for Rust files. Now the limit for Rust files is 8MB. Previous attempt was #8699. Fixes #10624 changelog: Adjust intellisense file size limit for Rust files Co-authored-by: vlad20012 <beskvlad@gmail.com>
- Loading branch information
Showing
4 changed files
with
51 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/kotlin/org/rust/lang/core/psi/RsFileViewProviderFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Use of this source code is governed by the MIT license that can be | ||
* found in the LICENSE file. | ||
*/ | ||
|
||
package org.rust.lang.core.psi | ||
|
||
import com.intellij.lang.Language | ||
import com.intellij.openapi.vfs.VirtualFile | ||
import com.intellij.psi.FileViewProvider | ||
import com.intellij.psi.FileViewProviderFactory | ||
import com.intellij.psi.PsiManager | ||
import com.intellij.psi.SingleRootFileViewProvider | ||
|
||
/** | ||
* Hacky adjust the file limit for Rust file. | ||
* Coupled with [org.rust.lang.core.resolve.indexes.RsAliasIndex.getFileTypesWithSizeLimitNotApplicable]. | ||
* | ||
* @see SingleRootFileViewProvider.isTooLargeForIntelligence | ||
*/ | ||
class RsFileViewProviderFactory : FileViewProviderFactory { | ||
override fun createFileViewProvider( | ||
file: VirtualFile, | ||
language: Language, | ||
manager: PsiManager, | ||
eventSystemEnabled: Boolean | ||
): FileViewProvider { | ||
val shouldAdjustFileLimit = SingleRootFileViewProvider.isTooLargeForIntelligence(file) | ||
&& file.length <= RUST_FILE_SIZE_LIMIT_FOR_INTELLISENSE | ||
|
||
if (shouldAdjustFileLimit) { | ||
SingleRootFileViewProvider.doNotCheckFileSizeLimit(file) | ||
} | ||
|
||
return SingleRootFileViewProvider(manager, file, eventSystemEnabled) | ||
} | ||
} | ||
|
||
// Experimentally verified that 8Mb works with the default IDEA -Xmx768M. Larger values may | ||
// lead to OOM, please verify before adjusting | ||
private const val RUST_FILE_SIZE_LIMIT_FOR_INTELLISENSE: Int = 8 * 1024 * 1024 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters