use of com.intellij.openapi.util.UserDataHolder in project kotlin by JetBrains.
the class SlicedMapImpl method getSliceContents.
@NotNull
@Override
public <K, V> ImmutableMap<K, V> getSliceContents(@NotNull ReadOnlySlice<K, V> slice) {
ImmutableMap.Builder<K, V> builder = ImmutableMap.builder();
for (Map.Entry<Object, UserDataHolderImpl> entry : map.entrySet()) {
UserDataHolder holder = entry.getValue();
V value = holder.getUserData(slice.getKey());
if (value != null) {
//noinspection unchecked
builder.put((K) entry.getKey(), value);
}
}
return builder.build();
}
use of com.intellij.openapi.util.UserDataHolder in project intellij-community by JetBrains.
the class ProjectFacetsConfigurator method getSharedModuleData.
private UserDataHolder getSharedModuleData(final Module module) {
UserDataHolder dataHolder = mySharedModuleData.get(module);
if (dataHolder == null) {
dataHolder = new UserDataHolderBase();
mySharedModuleData.put(module, dataHolder);
}
return dataHolder;
}
use of com.intellij.openapi.util.UserDataHolder in project intellij-community by JetBrains.
the class TextFilePatchInProgress method getDiffRequestProducers.
@NotNull
@Override
public DiffRequestProducer getDiffRequestProducers(final Project project, final PatchReader patchReader) {
final PatchChange change = getChange();
final FilePatch patch = getPatch();
final String path = patch.getBeforeName() == null ? patch.getAfterName() : patch.getBeforeName();
final Getter<CharSequence> baseContentGetter = new Getter<CharSequence>() {
@Override
public CharSequence get() {
return patchReader.getBaseRevision(project, path);
}
};
return new DiffRequestProducer() {
@NotNull
@Override
public DiffRequest process(@NotNull UserDataHolder context, @NotNull ProgressIndicator indicator) throws DiffRequestProducerException, ProcessCanceledException {
if (myCurrentBase != null && myCurrentBase.getFileType() == UnknownFileType.INSTANCE) {
return new UnknownFileTypeDiffRequest(myCurrentBase, getName());
}
if (isConflictingChange()) {
final VirtualFile file = getCurrentBase();
Getter<ApplyPatchForBaseRevisionTexts> getter = new Getter<ApplyPatchForBaseRevisionTexts>() {
@Override
public ApplyPatchForBaseRevisionTexts get() {
return ApplyPatchForBaseRevisionTexts.create(project, file, VcsUtil.getFilePath(file), getPatch(), baseContentGetter);
}
};
String afterTitle = getPatch().getAfterVersionId();
if (afterTitle == null)
afterTitle = "Patched Version";
return PatchDiffRequestFactory.createConflictDiffRequest(project, file, getPatch(), afterTitle, getter, getName(), context, indicator);
} else {
return PatchDiffRequestFactory.createDiffRequest(project, change, getName(), context, indicator);
}
}
@NotNull
@Override
public String getName() {
final File ioCurrentBase = getIoCurrentBase();
return ioCurrentBase == null ? getCurrentPath() : ioCurrentBase.getPath();
}
};
}
use of com.intellij.openapi.util.UserDataHolder in project intellij-community by JetBrains.
the class FactorTree method cache.
public void cache(GroovyClassDescriptor descriptor, CustomMembersHolder holder) {
Map current = null;
for (Factor factor : descriptor.affectingFactors) {
Object key;
switch(factor) {
case placeElement:
key = descriptor.getPlace();
break;
case placeFile:
key = descriptor.getPlaceFile();
break;
case qualifierType:
key = descriptor.getPsiType().getCanonicalText(false);
break;
default:
throw new IllegalStateException("Unknown variant: " + factor);
}
if (current == null) {
if (key instanceof UserDataHolder) {
final Project project = descriptor.getProject();
current = CachedValuesManager.getManager(project).getCachedValue((UserDataHolder) key, GDSL_MEMBER_CACHE, myProvider, false);
continue;
}
current = myTopLevelCache.getValue();
}
Map next = (Map) current.get(key);
if (next == null) {
//noinspection unchecked
current.put(key, next = ContainerUtil.newConcurrentMap());
if (key instanceof String) {
// type
//noinspection unchecked
current.put(CONTAINS_TYPE, true);
}
}
current = next;
}
if (current == null)
current = myTopLevelCache.getValue();
//noinspection unchecked
current.put(myExecutor, holder);
}
use of com.intellij.openapi.util.UserDataHolder in project intellij-plugins by JetBrains.
the class DartResolveScopeProvider method getDartResolveScope.
@Nullable
private static GlobalSearchScope getDartResolveScope(@NotNull final Module module, @NotNull final VirtualFile pubspecFile, @Nullable final VirtualFile contextSubdir) {
final Project project = module.getProject();
final UserDataHolder dataHolder = contextSubdir != null ? PsiManager.getInstance(project).findDirectory(contextSubdir) : PsiManager.getInstance(project).findFile(pubspecFile);
if (dataHolder == null) {
// unlikely as contextSubdir and pubspecFile are checked to be in project
return null;
}
return CachedValuesManager.getManager(project).getCachedValue(dataHolder, () -> {
final Collection<VirtualFile> pathPackageRoots = getPathPackageRoots(module.getProject(), pubspecFile);
final VirtualFile dartRoot = pubspecFile.getParent();
final GlobalSearchScope scope;
if (contextSubdir == null || "test".equals(contextSubdir.getName())) {
// the biggest scope
scope = createDirectoriesScope(project, pathPackageRoots, dartRoot);
} else if ("lib".equals(contextSubdir.getName()) || PACKAGES_FOLDER_NAME.equals(contextSubdir.getName())) {
// the smallest scope
scope = createDirectoriesScope(project, pathPackageRoots, dartRoot.findChild("lib"), dartRoot.findChild(PACKAGES_FOLDER_NAME));
} else {
scope = createDirectoriesScope(project, pathPackageRoots, contextSubdir, dartRoot.findChild("lib"), dartRoot.findChild(PACKAGES_FOLDER_NAME));
}
final GlobalSearchScope scopeWithLibs = scope.intersectWith(GlobalSearchScope.projectScope(project)).union(getModuleLibrariesClassesScope(module));
return new CachedValueProvider.Result<>(scopeWithLibs, PsiModificationTracker.MODIFICATION_COUNT);
});
}
Aggregations