use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class ProjectRootManagerComponent method getAllRoots.
@Nullable
private Pair<Set<String>, Set<String>> getAllRoots(boolean includeSourceRoots) {
if (myProject.isDefault())
return null;
final Set<String> recursive = new THashSet<>(FileUtil.PATH_HASHING_STRATEGY);
final Set<String> flat = new THashSet<>(FileUtil.PATH_HASHING_STRATEGY);
final String projectFilePath = myProject.getProjectFilePath();
final File projectDirFile = projectFilePath == null ? null : new File(projectFilePath).getParentFile();
if (projectDirFile != null && projectDirFile.getName().equals(Project.DIRECTORY_STORE_FOLDER)) {
recursive.add(projectDirFile.getAbsolutePath());
} else {
flat.add(projectFilePath);
// may be not existing yet
ContainerUtil.addIfNotNull(flat, ProjectKt.getStateStore(myProject).getWorkspaceFilePath());
}
for (WatchedRootsProvider extension : Extensions.getExtensions(WatchedRootsProvider.EP_NAME, myProject)) {
recursive.addAll(extension.getRootsToWatch());
}
final Module[] modules = ModuleManager.getInstance(myProject).getModules();
for (Module module : modules) {
flat.add(module.getModuleFilePath());
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
addRootsToTrack(moduleRootManager.getContentRootUrls(), recursive, flat);
if (includeSourceRoots) {
addRootsToTrack(moduleRootManager.getSourceRootUrls(), recursive, flat);
}
final OrderEntry[] orderEntries = moduleRootManager.getOrderEntries();
for (OrderEntry entry : orderEntries) {
if (entry instanceof LibraryOrSdkOrderEntry) {
final LibraryOrSdkOrderEntry libSdkEntry = (LibraryOrSdkOrderEntry) entry;
for (OrderRootType orderRootType : OrderRootType.getAllTypes()) {
addRootsToTrack(libSdkEntry.getRootUrls(orderRootType), recursive, flat);
}
}
}
}
return Pair.create(recursive, flat);
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class ColorAndFontOptions method initScopesDescriptors.
private static void initScopesDescriptors(@NotNull List<EditorSchemeAttributeDescriptor> descriptions, @NotNull MyColorScheme scheme) {
Set<Pair<NamedScope, NamedScopesHolder>> namedScopes = new THashSet<>(new TObjectHashingStrategy<Pair<NamedScope, NamedScopesHolder>>() {
@Override
public int computeHashCode(@NotNull final Pair<NamedScope, NamedScopesHolder> object) {
return object.getFirst().getName().hashCode();
}
@Override
public boolean equals(@NotNull final Pair<NamedScope, NamedScopesHolder> o1, @NotNull final Pair<NamedScope, NamedScopesHolder> o2) {
return o1.getFirst().getName().equals(o2.getFirst().getName());
}
});
Project[] projects = ProjectManager.getInstance().getOpenProjects();
for (Project project : projects) {
DependencyValidationManagerImpl validationManager = (DependencyValidationManagerImpl) DependencyValidationManager.getInstance(project);
List<Pair<NamedScope, NamedScopesHolder>> cachedScopes = validationManager.getScopeBasedHighlightingCachedScopes();
namedScopes.addAll(cachedScopes);
}
List<Pair<NamedScope, NamedScopesHolder>> list = new ArrayList<>(namedScopes);
Collections.sort(list, (o1, o2) -> o1.getFirst().getName().compareToIgnoreCase(o2.getFirst().getName()));
for (Pair<NamedScope, NamedScopesHolder> pair : list) {
NamedScope namedScope = pair.getFirst();
String name = namedScope.getName();
TextAttributesKey textAttributesKey = ScopeAttributesUtil.getScopeTextAttributeKey(name);
if (scheme.getAttributes(textAttributesKey) == null) {
scheme.setAttributes(textAttributesKey, new TextAttributes());
}
NamedScopesHolder holder = pair.getSecond();
PackageSet value = namedScope.getValue();
String toolTip = holder.getDisplayName() + (value == null ? "" : ": " + value.getText());
addSchemedDescription(descriptions, name, SCOPES_GROUP, textAttributesKey, scheme, holder.getIcon(), toolTip);
}
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class TodoCommentInspection method checkFile.
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
final TodoItem[] todoItems = PsiTodoSearchHelper.SERVICE.getInstance(file.getProject()).findTodoItems(file);
final List<ProblemDescriptor> result = new ArrayList<>();
final THashSet<PsiComment> comments = new THashSet<>();
for (TodoItem todoItem : todoItems) {
final PsiComment comment = PsiTreeUtil.getParentOfType(file.findElementAt(todoItem.getTextRange().getStartOffset()), PsiComment.class, false);
if (comment != null && comments.add(comment)) {
result.add(manager.createProblemDescriptor(comment, InspectionsBundle.message("todo.comment.problem.descriptor"), isOnTheFly, null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
}
}
return result.toArray(new ProblemDescriptor[result.size()]);
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class QuickFixAction method getReadOnlyFiles.
private static Set<VirtualFile> getReadOnlyFiles(@NotNull RefEntity[] refElements) {
Set<VirtualFile> readOnlyFiles = new THashSet<>();
for (RefEntity refElement : refElements) {
PsiElement psiElement = refElement instanceof RefElement ? ((RefElement) refElement).getElement() : null;
if (psiElement == null || psiElement.getContainingFile() == null)
continue;
readOnlyFiles.add(psiElement.getContainingFile().getVirtualFile());
}
return readOnlyFiles;
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class QuickFixAction method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent e) {
final InspectionResultsView view = getInvoker(e);
final InspectionTree tree = view.getTree();
try {
Ref<CommonProblemDescriptor[]> descriptors = Ref.create();
Set<VirtualFile> readOnlyFiles = new THashSet<>();
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> ReadAction.run(() -> {
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
indicator.setText("Checking problem descriptors...");
descriptors.set(tree.getSelectedDescriptors(true, readOnlyFiles, false, false));
}), InspectionsBundle.message("preparing.for.apply.fix"), true, e.getProject())) {
return;
}
if (isProblemDescriptorsAcceptable() && descriptors.get().length > 0) {
doApplyFix(view.getProject(), descriptors.get(), readOnlyFiles, tree.getContext());
} else {
doApplyFix(getSelectedElements(view), view);
}
} finally {
view.setApplyingFix(false);
}
}
Aggregations