mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Uast: CACHED_UELEMENT_KEY removed (IDEA-234777)
GitOrigin-RevId: 5087be2e5ea595801d664eb438c45e89603c4b6c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7f19039ea3
commit
3b774a8c82
@@ -40,7 +40,6 @@
|
||||
<highlightingPassFactory implementation="com.intellij.codeInsight.daemon.impl.JavaTextBlockIndentPassFactory"/>
|
||||
<highlightingPassFactory implementation="com.intellij.codeInsight.daemon.problems.pass.ProjectProblemPassFactory"/>
|
||||
<deadCode implementation="com.intellij.codeInspection.java19modules.Java9ModuleEntryPoint"/>
|
||||
<smartPointer.anchorProvider implementation="com.intellij.uast.UastElementAnchorProvider"/>
|
||||
<metaLanguage implementation="com.intellij.uast.UastMetaLanguage"/>
|
||||
<lang.inspectionSuppressor language="JAVA" implementationClass="com.intellij.codeInspection.SuppressManagerImpl"/>
|
||||
<projectService serviceImplementation="com.intellij.codeInspection.bytecodeAnalysis.ProjectBytecodeAnalysis"/>
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.uast;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.impl.smartPointers.SmartPointerAnchorProvider;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.uast.UElement;
|
||||
import org.jetbrains.uast.UastContextKt;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
* @deprecated relies on usage UElement as a PsiElement, which is considered as a bad practice (IDEA-182835),
|
||||
* and also leads to inappropriate caching of UElements
|
||||
*/
|
||||
@Deprecated
|
||||
public class UastElementAnchorProvider extends SmartPointerAnchorProvider {
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiElement getAnchor(@NotNull PsiElement element) {
|
||||
if (element instanceof UElement) {
|
||||
Logger.getInstance(UastElementAnchorProvider.class)
|
||||
.error("creating a SmartPointer on a UElement " + element +
|
||||
", please avoid doing that, using UElement as PsiElement is a bad practice," +
|
||||
" use UastSmartPointer instead");
|
||||
PsiElement psi = ((UElement)element).getPsi();
|
||||
if (psi != null) {
|
||||
psi.putUserData(UastContextKt.getCACHED_UELEMENT_KEY(), new SoftReference<>((UElement)element));
|
||||
}
|
||||
return psi;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiElement restoreElement(@NotNull PsiElement anchor) {
|
||||
return (PsiElement)UastContextKt.toUElement(anchor);
|
||||
}
|
||||
}
|
||||
@@ -17,13 +17,7 @@ package org.jetbrains.uast
|
||||
|
||||
import com.intellij.lang.Language
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.reference.SoftReference
|
||||
|
||||
@Deprecated("no proper caching for UAST is implemented, please avoid relying on this key")
|
||||
internal val CACHED_UELEMENT_KEY: Key<SoftReference<UElement>> = Key.create<SoftReference<UElement>>("org.jetbrains.uast.cachedElement")
|
||||
|
||||
|
||||
@Deprecated("use UastFacade or UastLanguagePlugin instead", ReplaceWith("UastFacade"))
|
||||
class UastContext(val project: Project) : UastLanguagePlugin by UastFacade {
|
||||
@@ -60,11 +54,6 @@ object UastFacade : UastLanguagePlugin {
|
||||
override fun isFileSupported(fileName: String): Boolean = languagePlugins.any { it.isFileSupported(fileName) }
|
||||
|
||||
override fun convertElement(element: PsiElement, parent: UElement?, requiredType: Class<out UElement>?): UElement? {
|
||||
val cachedElement = element.getUserData(CACHED_UELEMENT_KEY)?.get()
|
||||
if (cachedElement != null) {
|
||||
return if (requiredType == null || requiredType.isInstance(cachedElement)) cachedElement else null
|
||||
}
|
||||
|
||||
return findPlugin(element)?.convertElement(element, parent, requiredType)
|
||||
}
|
||||
|
||||
@@ -72,12 +61,6 @@ object UastFacade : UastLanguagePlugin {
|
||||
if (element is PsiWhiteSpace) {
|
||||
return null
|
||||
}
|
||||
|
||||
val cachedElement = element.getUserData(CACHED_UELEMENT_KEY)?.get()
|
||||
if (cachedElement != null) {
|
||||
return if (requiredType == null || requiredType.isInstance(cachedElement)) cachedElement else null
|
||||
}
|
||||
|
||||
return findPlugin(element)?.convertElementWithParent(element, requiredType)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user