mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-83955 Latest 11.1 build keeps displaying out of memory dialog no matter how much max heap size is allowed
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.lang.properties.xml;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
* Date: 5/25/12
|
||||
*/
|
||||
public abstract class SoftLazyValue<T> {
|
||||
|
||||
private SoftReference<T> myReference;
|
||||
|
||||
public T getValue() {
|
||||
T t;
|
||||
if (myReference == null || (t = myReference.get()) == null) {
|
||||
t = compute();
|
||||
myReference = new SoftReference<T>(t);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected abstract T compute();
|
||||
}
|
||||
@@ -33,8 +33,25 @@ public class XmlPropertiesFile implements PropertiesFile {
|
||||
|
||||
private static final Key<CachedValue<PropertiesFile>> KEY = Key.create("xml properties file");
|
||||
private final XmlFile myFile;
|
||||
private final List<IProperty> myProperties = new ArrayList<IProperty>();
|
||||
private final MultiMap<String, IProperty> myPropertiesMap = new MultiMap<String, IProperty>();
|
||||
private final SoftLazyValue<MultiMap<String, IProperty>> myPropertiesMap = new SoftLazyValue<MultiMap<String, IProperty>>() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected MultiMap<String, IProperty> compute() {
|
||||
XmlTag rootTag = myFile.getRootTag();
|
||||
if (rootTag == null) {
|
||||
return MultiMap.emptyInstance();
|
||||
}
|
||||
|
||||
XmlTag[] entries = rootTag.findSubTags("entry");
|
||||
MultiMap<String, IProperty> map = new MultiMap<String, IProperty>();
|
||||
|
||||
for (XmlTag entry : entries) {
|
||||
XmlProperty property = new XmlProperty(entry, XmlPropertiesFile.this);
|
||||
map.putValue(property.getKey(), property);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
public static PropertiesFile getPropertiesFile(final PsiFile file) {
|
||||
@@ -55,15 +72,6 @@ public class XmlPropertiesFile implements PropertiesFile {
|
||||
|
||||
private XmlPropertiesFile(XmlFile file) {
|
||||
myFile = file;
|
||||
XmlTag rootTag = file.getRootTag();
|
||||
if (rootTag != null) {
|
||||
XmlTag[] entries = rootTag.findSubTags("entry");
|
||||
for (XmlTag entry : entries) {
|
||||
XmlProperty property = new XmlProperty(entry, this);
|
||||
myProperties.add(property);
|
||||
myPropertiesMap.putValue(property.getKey(), property);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -75,19 +83,19 @@ public class XmlPropertiesFile implements PropertiesFile {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<IProperty> getProperties() {
|
||||
return myProperties;
|
||||
return new ArrayList<IProperty>(myPropertiesMap.getValue().values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProperty findPropertyByKey(@NotNull @NonNls String key) {
|
||||
Collection<IProperty> properties = myPropertiesMap.get(key);
|
||||
Collection<IProperty> properties = myPropertiesMap.getValue().get(key);
|
||||
return properties.isEmpty() ? null : properties.iterator().next();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<IProperty> findPropertiesByKey(@NotNull @NonNls String key) {
|
||||
return new ArrayList<IProperty>(myPropertiesMap.get(key));
|
||||
return new ArrayList<IProperty>(myPropertiesMap.getValue().get(key));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user