mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[performance] IJPL-148944 Test access to PSI from icon providers for JSON and YAML
GitOrigin-RevId: 627766e1bdc5e53ae9df368298ccaf7753422752
This commit is contained in:
committed by
intellij-monorepo-bot
parent
94da61a580
commit
66bdcd58fe
@@ -0,0 +1,37 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.json
|
||||
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.testFramework.fixtures.BasePlatformTestCase
|
||||
import com.intellij.util.AstLoadingFilter
|
||||
import com.intellij.util.PsiIconUtil
|
||||
import com.intellij.util.ThrowableRunnable
|
||||
import java.util.function.Supplier
|
||||
|
||||
class JsonIconsAstLoadingTest : BasePlatformTestCase() {
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
|
||||
Registry.get("ast.loading.filter").setValue(true, testRootDisposable);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this test fails for your [com.intellij.ide.IconProvider] you MUST avoid loading PSI by either:
|
||||
* - indexing and accessing index instead from [com.intellij.ide.IconProvider];
|
||||
* - cached computation on AST, e.g., using [com.intellij.util.gist.GistAstMarker].
|
||||
*/
|
||||
fun testNoAstLoadedFromIconProviders() {
|
||||
val file = myFixture.addFileToProject("package.json", """
|
||||
{
|
||||
"name": "my-awesome-package",
|
||||
"version": "1.0.0",
|
||||
"author": "Your Name <email@example.com>"
|
||||
}
|
||||
""".trimIndent())
|
||||
|
||||
AstLoadingFilter.disallowTreeLoading(ThrowableRunnable {
|
||||
PsiIconUtil.getIconFromProviders(file, 0)
|
||||
}, Supplier { "IconProvider must not access PSI of files directly! Use either indexes or GistManager to cache computation" })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.yaml
|
||||
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.testFramework.fixtures.BasePlatformTestCase
|
||||
import com.intellij.util.AstLoadingFilter
|
||||
import com.intellij.util.PsiIconUtil
|
||||
import com.intellij.util.ThrowableRunnable
|
||||
import java.util.function.Supplier
|
||||
|
||||
class YamlIconsAstLoadingTest : BasePlatformTestCase() {
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
|
||||
Registry.get("ast.loading.filter").setValue(true, testRootDisposable);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this test fails for your [com.intellij.ide.IconProvider] you MUST avoid loading PSI by either:
|
||||
* - indexing and accessing index instead from [com.intellij.ide.IconProvider];
|
||||
* - cached computation on AST, e.g., using [com.intellij.util.gist.GistAstMarker].
|
||||
*/
|
||||
fun testNoAstLoadedFromIconProviders() {
|
||||
val file = myFixture.addFileToProject("deployment.yaml", """
|
||||
apiVersion: apps/v1
|
||||
kind: Pod
|
||||
""".trimIndent())
|
||||
|
||||
AstLoadingFilter.disallowTreeLoading(ThrowableRunnable {
|
||||
PsiIconUtil.getIconFromProviders(file, 0)
|
||||
}, Supplier { "IconProvider must not access PSI of files directly! Use either indexes or GistManager to cache computation" })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user