use of com.intellij.psi.util.CachedValue in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoIdFilter method createIdFilter.
private static IdFilter createIdFilter(@NotNull Project project, @NotNull Key<CachedValue<IdFilter>> cacheKey, @NotNull Condition<VirtualFile> filterCondition) {
return CachedValuesManager.getManager(project).getCachedValue(project, cacheKey, () -> {
BitSet bitSet = new BitSet();
ContentIterator iterator = fileOrDir -> {
if (filterCondition.value(fileOrDir)) {
addToBitSet(bitSet, fileOrDir);
}
ProgressManager.checkCanceled();
return true;
};
FileBasedIndex.getInstance().iterateIndexableFiles(iterator, project, null);
return CachedValueProvider.Result.create(new GoIdFilter(bitSet), ProjectRootManager.getInstance(project), VirtualFileManager.VFS_STRUCTURE_MODIFICATIONS);
}, false);
}
use of com.intellij.psi.util.CachedValue in project intellij-community by JetBrains.
the class PsiJavaModuleReference method multiResolve.
@NotNull
public static Collection<PsiJavaModule> multiResolve(@NotNull final PsiElement refOwner, final String refText, final boolean incompleteCode) {
if (StringUtil.isEmpty(refText))
return Collections.emptyList();
CachedValuesManager manager = CachedValuesManager.getManager(refOwner.getProject());
Key<CachedValue<Collection<PsiJavaModule>>> key = incompleteCode ? K_INCOMPLETE : K_COMPLETE;
return manager.getCachedValue(refOwner, key, () -> {
Collection<PsiJavaModule> modules = Resolver.findModules(refOwner.getContainingFile(), refText, incompleteCode);
return CachedValueProvider.Result.create(modules, OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
}, false);
}
use of com.intellij.psi.util.CachedValue in project intellij-community by JetBrains.
the class GradleConsoleFilterProvider method getDefaultFilters.
@NotNull
@Override
public Filter[] getDefaultFilters(@NotNull Project project) {
return new Filter[] { new GradleConsoleFilter(project), new RegexpFilter(project, RegexpFilter.FILE_PATH_MACROS + ":" + RegexpFilter.LINE_MACROS) {
private CachedValue<Boolean> myIsGradleProject = new CachedValueImpl<>(() -> CachedValueProvider.Result.create(isGradleProject(), ProjectRootModificationTracker.getInstance(project)));
@Override
public Result applyFilter(String line, int entireLength) {
if (line == null || !FileUtil.isAbsolutePlatformIndependent(line))
return null;
if (Boolean.FALSE.equals(myIsGradleProject.getValue()))
return null;
Result result = super.applyFilter(line, entireLength);
if (result == null)
return null;
Pattern pattern = getPattern();
Matcher matcher = pattern.matcher(StringUtil.newBombedCharSequence(line, 100));
if (!matcher.lookingAt())
return result;
int lineStart = entireLength - line.length();
int start = lineStart + matcher.start();
int end = lineStart + matcher.end();
return new Result(start, end, result.getFirstHyperlinkInfo());
}
private boolean isGradleProject() {
return !GradleSettings.getInstance(project).getLinkedProjectsSettings().isEmpty();
}
} };
}
use of com.intellij.psi.util.CachedValue in project intellij-community by JetBrains.
the class XmlDocumentImpl method updateSelfDependentDtdDescriptors.
private void updateSelfDependentDtdDescriptors(XmlDocumentImpl copy, HashMap<String, CachedValue<XmlNSDescriptor>> cacheStrict, HashMap<String, CachedValue<XmlNSDescriptor>> cacheNotStrict) {
copy.myDefaultDescriptorsCacheNotStrict = ContainerUtil.newConcurrentMap();
copy.myDefaultDescriptorsCacheStrict = ContainerUtil.newConcurrentMap();
for (Map.Entry<String, CachedValue<XmlNSDescriptor>> e : cacheStrict.entrySet()) {
if (e.getValue().hasUpToDateValue()) {
final XmlNSDescriptor nsDescriptor = e.getValue().getValue();
if (!isGeneratedFromDtd(nsDescriptor))
copy.myDefaultDescriptorsCacheStrict.put(e.getKey(), e.getValue());
}
}
for (Map.Entry<String, CachedValue<XmlNSDescriptor>> e : cacheNotStrict.entrySet()) {
if (e.getValue().hasUpToDateValue()) {
final XmlNSDescriptor nsDescriptor = e.getValue().getValue();
if (!isGeneratedFromDtd(nsDescriptor))
copy.myDefaultDescriptorsCacheNotStrict.put(e.getKey(), e.getValue());
}
}
}
Aggregations