use of com.intellij.reference.SoftReference in project intellij-community by JetBrains.
the class AssignableFromContextFilter method isAcceptable.
@Override
public boolean isAcceptable(Object element, PsiElement context) {
if (myCurrentContext.get() != context) {
myCurrentContext = new SoftReference(context);
PsiElement cachedClass = context;
while (cachedClass != null && !(cachedClass instanceof PsiClass)) cachedClass = cachedClass.getContext();
myCachedClass = new SoftReference(cachedClass);
}
if (myCachedClass.get() instanceof PsiClass && element instanceof PsiClass) {
final String qualifiedName = ((PsiClass) myCachedClass.get()).getQualifiedName();
return qualifiedName != null && (qualifiedName.equals(((PsiClass) element).getQualifiedName()) || ((PsiClass) element).isInheritor((PsiClass) myCachedClass.get(), true));
}
return false;
}
use of com.intellij.reference.SoftReference in project intellij-plugins by JetBrains.
the class FrameworkInfo method reloadFramework.
private Trinity<Framework, Set<String>, Set<String>> reloadFramework() {
VirtualFile file = LocalFileSystem.getInstance().findFileByPath(myBridgeSupportPath);
if (file == null)
return Trinity.create(null, null, null);
Set<String> idSelectorNames = null;
Set<String> selectorNames = null;
Framework framework = null;
try {
framework = BridgeSupportReader.read(myName, myVersion, file.getInputStream(), myOSX);
idSelectorNames = ContainerUtil.newHashSet();
selectorNames = ContainerUtil.newHashSet();
for (Class clazz : framework.getClasses()) {
for (Function function : clazz.getFunctions()) {
if (function.isId()) {
idSelectorNames.addAll(MotionSymbolUtil.getSelectorNames(function));
}
selectorNames.add(function.getName());
}
}
} catch (IOException e) {
LOG.error("Failed to load bridgesupport file", e);
}
myFramework = framework != null ? new SoftReference<>(framework) : null;
myIdSelectorNames = idSelectorNames != null ? new SoftReference<>(idSelectorNames) : null;
mySelectorNames = selectorNames != null ? new SoftReference<>(selectorNames) : null;
return Trinity.create(framework, idSelectorNames, selectorNames);
}
use of com.intellij.reference.SoftReference in project intellij-community by JetBrains.
the class SrcFileAnnotator method doGetLineMapping.
@Nullable
private SoftReference<TIntIntHashMap> doGetLineMapping(final long date, boolean oldToNew, MyEditorBean editorBean) {
VirtualFile virtualFile = editorBean.getVFile();
final byte[] oldContent;
synchronized (LOCK) {
if (myOldContent == null) {
if (ApplicationManager.getApplication().isDispatchThread())
return null;
final LocalHistory localHistory = LocalHistory.getInstance();
byte[] byteContent = localHistory.getByteContent(virtualFile, new FileRevisionTimestampComparator() {
public boolean isSuitable(long revisionTimestamp) {
return revisionTimestamp < date;
}
});
if (byteContent == null && virtualFile.getTimeStamp() > date) {
byteContent = loadFromVersionControl(date, virtualFile);
}
myOldContent = new SoftReference<>(byteContent);
}
oldContent = myOldContent.get();
}
if (oldContent == null)
return null;
String[] coveredLines = getCoveredLines(oldContent, virtualFile);
final Document document = editorBean.getDocument();
if (document == null)
return null;
String[] currentLines = getUpToDateLines(document);
String[] oldLines = oldToNew ? coveredLines : currentLines;
String[] newLines = oldToNew ? currentLines : coveredLines;
Diff.Change change;
try {
change = Diff.buildChanges(oldLines, newLines);
} catch (FilesTooBigForDiffException e) {
LOG.info(e);
return null;
}
return new SoftReference<>(getCoverageVersionToCurrentLineMapping(change, oldLines.length));
}
Aggregations