use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class MavenArtifactDownloader method collectArtifactsToDownload.
private Map<MavenId, DownloadData> collectArtifactsToDownload(List<MavenExtraArtifactType> types) {
Map<MavenId, DownloadData> result = new THashMap<>();
THashSet<String> dependencyTypesFromSettings = new THashSet<>();
AccessToken accessToken = ReadAction.start();
try {
if (myProject.isDisposed())
return result;
dependencyTypesFromSettings.addAll(MavenProjectsManager.getInstance(myProject).getImportingSettings().getDependencyTypesAsSet());
} finally {
accessToken.finish();
}
for (MavenProject eachProject : myMavenProjects) {
List<MavenRemoteRepository> repositories = eachProject.getRemoteRepositories();
for (MavenArtifact eachDependency : eachProject.getDependencies()) {
if (myArtifacts != null && !myArtifacts.contains(eachDependency))
continue;
if (MavenConstants.SCOPE_SYSTEM.equalsIgnoreCase(eachDependency.getScope()))
continue;
if (myProjectsTree.findProject(eachDependency.getMavenId()) != null)
continue;
String dependencyType = eachDependency.getType();
if (!dependencyTypesFromSettings.contains(dependencyType) && !eachProject.getDependencyTypesFromImporters(SupportedRequestType.FOR_IMPORT).contains(dependencyType)) {
continue;
}
MavenId id = eachDependency.getMavenId();
DownloadData data = result.get(id);
if (data == null) {
data = new DownloadData();
result.put(id, data);
}
data.repositories.addAll(repositories);
for (MavenExtraArtifactType eachType : types) {
Pair<String, String> classifierAndExtension = eachProject.getClassifierAndExtension(eachDependency, eachType);
String classifier = eachDependency.getFullClassifier(classifierAndExtension.first);
String extension = classifierAndExtension.second;
data.classifiersWithExtensions.add(new DownloadElement(classifier, extension, eachType));
}
}
}
return result;
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class MavenProjectsTree method delete.
private void delete(MavenProjectReader projectReader, List<VirtualFile> files, MavenExplicitProfiles explicitProfiles, MavenGeneralSettings generalSettings, MavenProgressIndicator process) {
if (files.isEmpty())
return;
UpdateContext updateContext = new UpdateContext();
Stack<MavenProject> updateStack = new Stack<>();
Set<MavenProject> inheritorsToUpdate = new THashSet<>();
for (VirtualFile each : files) {
MavenProject mavenProject = findProject(each);
if (mavenProject == null)
return;
inheritorsToUpdate.addAll(findInheritors(mavenProject));
doDelete(findAggregator(mavenProject), mavenProject, updateContext);
}
inheritorsToUpdate.removeAll(updateContext.deletedProjects);
for (MavenProject each : inheritorsToUpdate) {
doUpdate(each, null, false, false, false, explicitProfiles, updateContext, updateStack, projectReader, generalSettings, process);
}
updateExplicitProfiles();
updateContext.fireUpdatedIfNecessary();
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class InconsistentResourceBundleInspection method checkFile.
@Override
public void checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, @NotNull ProblemsHolder problemsHolder, @NotNull GlobalInspectionContext globalContext, @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) {
Set<ResourceBundle> visitedBundles = globalContext.getUserData(VISITED_BUNDLES_KEY);
if (!(file instanceof PropertiesFile))
return;
final PropertiesFile propertiesFile = (PropertiesFile) file;
ResourceBundle resourceBundle = propertiesFile.getResourceBundle();
assert visitedBundles != null;
if (!visitedBundles.add(resourceBundle))
return;
List<PropertiesFile> files = resourceBundle.getPropertiesFiles();
if (files.size() < 2)
return;
BidirectionalMap<PropertiesFile, PropertiesFile> parents = new BidirectionalMap<>();
for (PropertiesFile f : files) {
PropertiesFile parent = PropertiesUtil.getParent(f, files);
if (parent != null) {
parents.put(f, parent);
}
}
final FactoryMap<PropertiesFile, Map<String, String>> propertiesFilesNamesMaps = new FactoryMap<PropertiesFile, Map<String, String>>() {
@Nullable
@Override
protected Map<String, String> create(PropertiesFile key) {
return key.getNamesMap();
}
};
Map<PropertiesFile, Set<String>> keysUpToParent = new THashMap<>();
for (PropertiesFile f : files) {
Set<String> keys = new THashSet<>(propertiesFilesNamesMaps.get(f).keySet());
PropertiesFile parent = parents.get(f);
while (parent != null) {
keys.addAll(propertiesFilesNamesMaps.get(parent).keySet());
parent = parents.get(parent);
}
keysUpToParent.put(f, keys);
}
for (final InconsistentResourceBundleInspectionProvider provider : myInspectionProviders.getValue()) {
if (isProviderEnabled(provider.getName())) {
provider.check(parents, files, keysUpToParent, propertiesFilesNamesMaps, manager, globalContext.getRefManager(), problemDescriptionsProcessor);
}
}
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class DuplicateStringLiteralInspection method getCandidateFiles.
@NotNull
private Set<PsiFile> getCandidateFiles(String stringToFind, Project project) {
final GlobalSearchScope scope = GlobalSearchScope.projectScope(project);
final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(project);
final List<String> words = StringUtil.getWordsInStringLongestFirst(stringToFind);
if (words.isEmpty())
return Collections.emptySet();
Set<PsiFile> resultFiles = null;
for (String word : words) {
if (word.length() < MIN_STRING_LENGTH) {
continue;
}
ProgressManager.checkCanceled();
final Set<PsiFile> files = new THashSet<>();
Processor<PsiFile> processor = Processors.cancelableCollectProcessor(files);
searchHelper.processAllFilesWithWordInLiterals(word, scope, processor);
if (resultFiles == null) {
resultFiles = files;
} else {
resultFiles.retainAll(files);
}
if (resultFiles.isEmpty())
return Collections.emptySet();
}
return resultFiles != null ? resultFiles : Collections.emptySet();
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class XmlNSDescriptorImpl method doBuildDeclarationMap.
// Read-only calculation
private CachedValue<Map<String, XmlElementDescriptor>> doBuildDeclarationMap() {
return CachedValuesManager.getManager(myElement.getProject()).createCachedValue(() -> {
final List<XmlElementDecl> result = new ArrayList<>();
myElement.processElements(new FilterElementProcessor(new ClassFilter(XmlElementDecl.class), result), getDeclaration());
final Map<String, XmlElementDescriptor> ret = new LinkedHashMap<>((int) (result.size() * 1.5));
Set<PsiFile> dependencies = new THashSet<>(1);
dependencies.add(myDescriptorFile);
for (final XmlElementDecl xmlElementDecl : result) {
final String name = xmlElementDecl.getName();
if (name != null) {
if (!ret.containsKey(name)) {
ret.put(name, new XmlElementDescriptorImpl(xmlElementDecl));
// if element descriptor was produced from entity reference use proper dependency
PsiElement dependingElement = xmlElementDecl.getUserData(XmlElement.DEPENDING_ELEMENT);
if (dependingElement != null) {
PsiFile dependingElementContainingFile = dependingElement.getContainingFile();
if (dependingElementContainingFile != null)
dependencies.add(dependingElementContainingFile);
}
}
}
}
return new CachedValueProvider.Result<>(ret, dependencies.toArray());
}, false);
}
Aggregations