use of com.intellij.util.containers.hash.HashSet in project intellij-community by JetBrains.
the class InspectionViewPsiTreeChangeAdapter method processEventFileOrDir.
private void processEventFileOrDir(@NotNull PsiTreeChangeEvent event, boolean eagerEvaluateFiles) {
final PsiFile file = event.getFile();
if (file != null) {
VirtualFile vFile = file.getVirtualFile();
if (vFile == null)
return;
invalidateFiles(vFile);
} else {
final PsiElement child = event.getChild();
if (child instanceof PsiFileSystemItem) {
final VirtualFile childFile = ((PsiFileSystemItem) child).getVirtualFile();
if (childFile != null) {
if (eagerEvaluateFiles) {
Set<VirtualFile> files = new HashSet<>();
VfsUtilCore.iterateChildrenRecursively(childFile, VirtualFileFilter.ALL, files::add);
invalidateFiles(files.toArray(new VirtualFile[files.size()]));
} else {
invalidateFiles(childFile);
}
}
}
}
}
use of com.intellij.util.containers.hash.HashSet in project intellij-community by JetBrains.
the class HighlightUtil method checkIntersectionInTypeCast.
/**
* 15.16 Cast Expressions
* ( ReferenceType {AdditionalBound} ) expression, where AdditionalBound: & InterfaceType then all must be true
* • ReferenceType must denote a class or interface type.
* • The erasures of all the listed types must be pairwise different.
* • No two listed types may be subtypes of different parameterization of the same generic interface.
*/
@Nullable
static HighlightInfo checkIntersectionInTypeCast(@NotNull PsiTypeCastExpression expression, @NotNull LanguageLevel languageLevel, @NotNull PsiFile file) {
PsiTypeElement castTypeElement = expression.getCastType();
if (castTypeElement != null && isIntersection(castTypeElement, castTypeElement.getType())) {
HighlightInfo info = checkFeature(expression, Feature.INTERSECTION_CASTS, languageLevel, file);
if (info != null)
return info;
final PsiTypeElement[] conjuncts = PsiTreeUtil.getChildrenOfType(castTypeElement, PsiTypeElement.class);
if (conjuncts != null) {
final Set<PsiType> erasures = new HashSet<>(conjuncts.length);
erasures.add(TypeConversionUtil.erasure(conjuncts[0].getType()));
final List<PsiTypeElement> conjList = new ArrayList<>(Arrays.asList(conjuncts));
for (int i = 1; i < conjuncts.length; i++) {
final PsiTypeElement conjunct = conjuncts[i];
final PsiType conjType = conjunct.getType();
if (conjType instanceof PsiClassType) {
final PsiClass aClass = ((PsiClassType) conjType).resolve();
if (aClass != null && !aClass.isInterface()) {
final HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(conjunct).descriptionAndTooltip(JavaErrorMessages.message("interface.expected")).create();
QuickFixAction.registerQuickFixAction(errorResult, new FlipIntersectionSidesFix(aClass.getName(), conjList, conjunct, castTypeElement), null);
return errorResult;
}
} else {
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(conjunct).descriptionAndTooltip("Unexpected type: class is expected").create();
}
if (!erasures.add(TypeConversionUtil.erasure(conjType))) {
final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(conjunct).descriptionAndTooltip("Repeated interface").create();
QuickFixAction.registerQuickFixAction(highlightInfo, new DeleteRepeatedInterfaceFix(conjunct, conjList), null);
return highlightInfo;
}
}
final List<PsiType> typeList = ContainerUtil.map(conjList, PsiTypeElement::getType);
final Ref<String> differentArgumentsMessage = new Ref<>();
final PsiClass sameGenericParameterization = InferenceSession.findParameterizationOfTheSameGenericClass(typeList, pair -> {
if (!TypesDistinctProver.provablyDistinct(pair.first, pair.second)) {
return true;
}
differentArgumentsMessage.set(pair.first.getPresentableText() + " and " + pair.second.getPresentableText());
return false;
});
if (sameGenericParameterization != null) {
final String message = formatClass(sameGenericParameterization) + " cannot be inherited with different arguments: " + differentArgumentsMessage.get();
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
}
}
return null;
}
use of com.intellij.util.containers.hash.HashSet in project intellij-community by JetBrains.
the class IdeSettingsStatisticsUtils method getUsages.
public static Set<UsageDescriptor> getUsages(@NotNull IdeSettingsDescriptor descriptor, @NotNull Object componentInstance) {
Set<UsageDescriptor> descriptors = new HashSet<>();
String providerName = descriptor.myProviderName;
List<String> propertyNames = descriptor.getPropertyNames();
if (providerName != null && propertyNames.size() > 0) {
for (String propertyName : propertyNames) {
Object propertyValue = getPropertyValue(componentInstance, propertyName);
if (propertyValue != null) {
descriptors.add(new UsageDescriptor(getUsageDescriptorKey(providerName, propertyName, propertyValue.toString()), 1));
}
}
}
return descriptors;
}
use of com.intellij.util.containers.hash.HashSet in project intellij-community by JetBrains.
the class InstalledPluginsTableModel method warnAboutMissedDependencies.
private void warnAboutMissedDependencies(final Boolean newVal, final IdeaPluginDescriptor... ideaPluginDescriptors) {
final Set<PluginId> deps = new HashSet<>();
final List<IdeaPluginDescriptor> descriptorsToCheckDependencies = new ArrayList<>();
if (newVal) {
Collections.addAll(descriptorsToCheckDependencies, ideaPluginDescriptors);
} else {
descriptorsToCheckDependencies.addAll(getAllPlugins());
descriptorsToCheckDependencies.removeAll(Arrays.asList(ideaPluginDescriptors));
for (Iterator<IdeaPluginDescriptor> iterator = descriptorsToCheckDependencies.iterator(); iterator.hasNext(); ) {
IdeaPluginDescriptor descriptor = iterator.next();
final Boolean enabled = myEnabled.get(descriptor.getPluginId());
if (enabled == null || !enabled.booleanValue()) {
iterator.remove();
}
}
}
for (final IdeaPluginDescriptor ideaPluginDescriptor : descriptorsToCheckDependencies) {
PluginManagerCore.checkDependants(ideaPluginDescriptor, pluginId -> PluginManager.getPlugin(pluginId), pluginId -> {
Boolean enabled = myEnabled.get(pluginId);
if (enabled == null) {
return false;
}
if (newVal && !enabled.booleanValue()) {
deps.add(pluginId);
}
if (!newVal) {
if (ideaPluginDescriptor instanceof IdeaPluginDescriptorImpl && ((IdeaPluginDescriptorImpl) ideaPluginDescriptor).isDeleted()) {
return true;
}
final PluginId pluginDescriptorId = ideaPluginDescriptor.getPluginId();
for (IdeaPluginDescriptor descriptor : ideaPluginDescriptors) {
if (pluginId.equals(descriptor.getPluginId())) {
deps.add(pluginDescriptorId);
break;
}
}
}
return true;
});
}
if (!deps.isEmpty()) {
final String listOfSelectedPlugins = StringUtil.join(ideaPluginDescriptors, pluginDescriptor -> pluginDescriptor.getName(), ", ");
final Set<IdeaPluginDescriptor> pluginDependencies = new HashSet<>();
final String listOfDependencies = StringUtil.join(deps, pluginId -> {
final IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(pluginId);
assert pluginDescriptor != null;
pluginDependencies.add(pluginDescriptor);
return pluginDescriptor.getName();
}, "<br>");
final String message = !newVal ? "<html>The following plugins <br>" + listOfDependencies + "<br>are enabled and depend" + (deps.size() == 1 ? "s" : "") + " on selected plugins. " + "<br>Would you like to disable them too?</html>" : "<html>The following plugins on which " + listOfSelectedPlugins + " depend" + (ideaPluginDescriptors.length == 1 ? "s" : "") + " are disabled:<br>" + listOfDependencies + "<br>Would you like to enable them?</html>";
if (Messages.showOkCancelDialog(message, newVal ? "Enable Dependant Plugins" : "Disable Plugins with Dependency on this", Messages.getQuestionIcon()) == Messages.OK) {
for (PluginId pluginId : deps) {
myEnabled.put(pluginId, newVal);
}
updatePluginDependencies();
hideNotApplicablePlugins(newVal, pluginDependencies.toArray(new IdeaPluginDescriptor[pluginDependencies.size()]));
}
}
}
use of com.intellij.util.containers.hash.HashSet in project intellij-community by JetBrains.
the class RemoteAgentReflectiveProxyFactory method createAgentClassLoader.
@Override
protected ClassLoader createAgentClassLoader(URL[] agentLibraryUrls) throws Exception {
Set<URL> urls = new HashSet<>();
urls.addAll(Arrays.asList(agentLibraryUrls));
return myClassLoaderCache == null ? new URLClassLoader(urls.toArray(new URL[urls.size()]), null) : myClassLoaderCache.getOrCreateClassLoader(urls);
}
Aggregations