mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-185506: merge XmlEntityCacheImplUtil back to XmlEntityCache
GitOrigin-RevId: d150195d4163991eba9dbf0b3618d5a1db335860
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e6b7e1bb7d
commit
08e15d61b3
+3
-3
@@ -9,7 +9,7 @@ import com.intellij.psi.FileViewProvider;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.source.xml.XmlEntityCacheImplUtil;
|
||||
import com.intellij.psi.impl.source.xml.XmlEntityCache;
|
||||
import com.intellij.psi.search.PsiElementProcessor;
|
||||
import com.intellij.psi.util.CachedValue;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
@@ -44,8 +44,8 @@ public final class XmlEntityRefUtil {
|
||||
|
||||
final PsiElement targetElement = targetFile != null ? targetFile : element;
|
||||
CachedValue<XmlEntityDecl> value;
|
||||
synchronized (XmlEntityCacheImplUtil.LOCK) {
|
||||
Map<String, CachedValue<XmlEntityDecl>> map = XmlEntityCacheImplUtil.getCachingMap(targetElement);
|
||||
synchronized (XmlEntityCache.LOCK) {
|
||||
Map<String, CachedValue<XmlEntityDecl>> map = XmlEntityCache.getCachingMap(targetElement);
|
||||
|
||||
value = map.get(entityName);
|
||||
final PsiFile containingFile = element.getContainingFile();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.psi.impl.source.xml;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -10,13 +11,19 @@ import com.intellij.psi.util.CachedValue;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.psi.xml.XmlEntityDecl;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class XmlEntityCache {
|
||||
@ApiStatus.Internal
|
||||
public static final Object LOCK = new Object();
|
||||
private static final Key<Map<String,CachedValue<XmlEntityDecl>>> XML_ENTITY_DECL_MAP = Key.create("XML_ENTITY_DECL_MAP");
|
||||
|
||||
public static void cacheParticularEntity(PsiFile file, XmlEntityDecl decl) {
|
||||
synchronized(XmlEntityCacheImplUtil.LOCK) {
|
||||
final Map<String, CachedValue<XmlEntityDecl>> cachingMap = XmlEntityCacheImplUtil.getCachingMap(file);
|
||||
synchronized(LOCK) {
|
||||
final Map<String, CachedValue<XmlEntityDecl>> cachingMap = getCachingMap(file);
|
||||
final String name = decl.getName();
|
||||
if (cachingMap.containsKey(name)) return;
|
||||
final SmartPsiElementPointer declPointer = SmartPointerManager.getInstance(file.getProject()).createSmartPsiElementPointer(decl);
|
||||
@@ -34,18 +41,28 @@ public final class XmlEntityCache {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static Map<String, CachedValue<XmlEntityDecl>> getCachingMap(final PsiElement targetElement) {
|
||||
Map<String, CachedValue<XmlEntityDecl>> map = targetElement.getUserData(XML_ENTITY_DECL_MAP);
|
||||
if (map == null){
|
||||
map = new HashMap<>();
|
||||
targetElement.putUserData(XML_ENTITY_DECL_MAP, map);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static void copyEntityCaches(final PsiFile file, final PsiFile context) {
|
||||
synchronized (XmlEntityCacheImplUtil.LOCK) {
|
||||
final Map<String, CachedValue<XmlEntityDecl>> cachingMap = XmlEntityCacheImplUtil.getCachingMap(file);
|
||||
cachingMap.putAll(XmlEntityCacheImplUtil.getCachingMap(context));
|
||||
synchronized (LOCK) {
|
||||
final Map<String, CachedValue<XmlEntityDecl>> cachingMap = getCachingMap(file);
|
||||
cachingMap.putAll(getCachingMap(context));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static XmlEntityDecl getCachedEntity(PsiFile file, String name) {
|
||||
CachedValue<XmlEntityDecl> cachedValue;
|
||||
synchronized(XmlEntityCacheImplUtil.LOCK) {
|
||||
final Map<String, CachedValue<XmlEntityDecl>> cachingMap = XmlEntityCacheImplUtil.getCachingMap(file);
|
||||
synchronized(LOCK) {
|
||||
final Map<String, CachedValue<XmlEntityDecl>> cachingMap = getCachingMap(file);
|
||||
cachedValue = cachingMap.get(name);
|
||||
}
|
||||
return cachedValue != null ? cachedValue.getValue():null;
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.psi.impl.source.xml;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.CachedValue;
|
||||
import com.intellij.psi.xml.XmlEntityDecl;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class XmlEntityCacheImplUtil {
|
||||
public static final Object LOCK = new Object();
|
||||
|
||||
private static final Key<Map<String,CachedValue<XmlEntityDecl>>> XML_ENTITY_DECL_MAP = Key.create("XML_ENTITY_DECL_MAP");
|
||||
|
||||
public static Map<String, CachedValue<XmlEntityDecl>> getCachingMap(final PsiElement targetElement) {
|
||||
Map<String, CachedValue<XmlEntityDecl>> map = targetElement.getUserData(XML_ENTITY_DECL_MAP);
|
||||
if (map == null){
|
||||
map = new HashMap<>();
|
||||
targetElement.putUserData(XML_ENTITY_DECL_MAP, map);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user