Java Code Examples for com.intellij.util.containers.ContainerUtil#newHashSet()
The following examples show how to use
com.intellij.util.containers.ContainerUtil#newHashSet() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NewEditChangelistPanel.java From consulo with Apache License 2.0 | 6 votes |
private static EditorTextField createEditorField(final Project project, final int defaultLines) { final EditorTextFieldProvider service = ServiceManager.getService(project, EditorTextFieldProvider.class); final EditorTextField editorField; final Set<EditorCustomization> editorFeatures = ContainerUtil.newHashSet(); final SpellCheckerCustomization spellChecker = SpellCheckerCustomization.getInstance(); if(spellChecker.isEnabled()) { editorFeatures.add(spellChecker.getCustomization(true)); } if (defaultLines == 1) { editorFeatures.add(HorizontalScrollBarEditorCustomization.DISABLED); editorFeatures.add(OneLineEditorCustomization.ENABLED); } else { editorFeatures.add(SoftWrapsEditorCustomization.ENABLED); } editorField = service.getEditorField(PlainTextLanguage.INSTANCE, project, editorFeatures); final int height = editorField.getFontMetrics(editorField.getFont()).getHeight(); editorField.getComponent().setMinimumSize(new Dimension(100, (int)(height * 1.3))); return editorField; }
Example 2
Source File: ChangeListManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private Set<VirtualFile> getUnversionedDescendantsRecursively(@Nonnull List<VirtualFile> items, @Nonnull final Condition<FileStatus> condition) { final Set<VirtualFile> result = ContainerUtil.newHashSet(); Processor<VirtualFile> addToResultProcessor = file -> { if (condition.value(getStatus(file))) { result.add(file); } return true; }; for (VirtualFile item : items) { VcsRootIterator.iterateVfUnderVcsRoot(myProject, item, addToResultProcessor); } return result; }
Example 3
Source File: VcsLogUserFilterTest.java From consulo with Apache License 2.0 | 6 votes |
private void checkTurkishAndEnglishLocales(@Nonnull VcsUser user, @Nonnull Collection<VcsUser> synonymUsers, @Nonnull MultiMap<VcsUser, String> commits, @Nonnull List<VcsCommitMetadata> metadata, @Nonnull StringBuilder builder) throws VcsException { Set<String> expectedCommits = ContainerUtil.newHashSet(commits.get(user)); for (VcsUser synonym : synonymUsers) { expectedCommits.addAll(commits.get(synonym)); } Locale oldLocale = Locale.getDefault(); Locale.setDefault(new Locale("tr")); StringBuilder turkishBuilder = new StringBuilder(); checkFilterForUser(user, commits.keySet(), expectedCommits, metadata, turkishBuilder); Locale.setDefault(Locale.ENGLISH); StringBuilder defaultBuilder = new StringBuilder(); checkFilterForUser(user, commits.keySet(), expectedCommits, metadata, defaultBuilder); Locale.setDefault(oldLocale); if (!turkishBuilder.toString().isEmpty()) builder.append("Turkish Locale:\n").append(turkishBuilder); if (!defaultBuilder.toString().isEmpty()) builder.append("English Locale:\n").append(defaultBuilder); }
Example 4
Source File: TroveUtil.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public static Set<Integer> intersect(@Nonnull TIntHashSet... sets) { TIntHashSet result = null; Arrays.sort(sets, (set1, set2) -> { if (set1 == null) return -1; if (set2 == null) return 1; return set1.size() - set2.size(); }); for (TIntHashSet set : sets) { result = intersect(result, set); } if (result == null) return ContainerUtil.newHashSet(); return createJavaSet(result); }
Example 5
Source File: AbstractTreeClassChooserDialog.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override public Object[] getElementsByName(String name, FindSymbolParameters parameters, @Nonnull ProgressIndicator canceled) { String patternName = parameters.getLocalPatternName(); List<T> classes = myTreeClassChooserDialog.getClassesByName(name, parameters.isSearchInLibraries(), patternName, myTreeClassChooserDialog.getScope()); if (classes.size() == 0) return ArrayUtil.EMPTY_OBJECT_ARRAY; if (classes.size() == 1) { return isAccepted(classes.get(0)) ? ArrayUtil.toObjectArray(classes) : ArrayUtil.EMPTY_OBJECT_ARRAY; } Set<String> qNames = ContainerUtil.newHashSet(); List<T> list = new ArrayList<T>(classes.size()); for (T aClass : classes) { if (qNames.add(getFullName(aClass)) && isAccepted(aClass)) { list.add(aClass); } } return ArrayUtil.toObjectArray(list); }
Example 6
Source File: DataPack.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull static DataPack build(@Nonnull List<? extends GraphCommit<Integer>> commits, @Nonnull Map<VirtualFile, CompressedRefs> refs, @Nonnull Map<VirtualFile, VcsLogProvider> providers, @Nonnull final VcsLogStorage hashMap, boolean full) { RefsModel refsModel; PermanentGraph<Integer> permanentGraph; if (commits.isEmpty()) { refsModel = new RefsModel(refs, ContainerUtil.<Integer>newHashSet(), hashMap, providers); permanentGraph = EmptyPermanentGraph.getInstance(); } else { refsModel = new RefsModel(refs, getHeads(commits), hashMap, providers); Function<Integer, Hash> hashGetter = createHashGetter(hashMap); GraphColorManagerImpl colorManager = new GraphColorManagerImpl(refsModel, hashGetter, getRefManagerMap(providers)); Set<Integer> branches = getBranchCommitHashIndexes(refsModel.getBranches(), hashMap); StopWatch sw = StopWatch.start("building graph"); permanentGraph = PermanentGraphImpl.newInstance(commits, colorManager, branches); sw.report(); } return new DataPack(refsModel, permanentGraph, providers, full); }
Example 7
Source File: VcsLogUtil.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static String getSingleFilteredBranch(@Nonnull VcsLogBranchFilter filter, @Nonnull VcsLogRefs refs) { String branchName = null; Set<VirtualFile> checkedRoots = ContainerUtil.newHashSet(); for (VcsRef branch : refs.getBranches()) { if (!filter.matches(branch.getName())) continue; if (branchName == null) { branchName = branch.getName(); } else if (!branch.getName().equals(branchName)) { return null; } if (checkedRoots.contains(branch.getRoot())) return null; checkedRoots.add(branch.getRoot()); } return branchName; }
Example 8
Source File: VcsLogUserFilterImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public Collection<VcsUser> getUsers(@Nonnull VirtualFile root) { Set<VcsUser> result = ContainerUtil.newHashSet(); for (String user : myUsers) { result.addAll(getUsers(root, user)); } return result; }
Example 9
Source File: LinearBekGraphBuilder.java From consulo with Apache License 2.0 | 5 votes |
public Set<Integer> getAllNodes() { Set<Integer> nodes = ContainerUtil.newHashSet(); nodes.add(myParent); nodes.add(myLeftChild); nodes.add(myRightChild); nodes.addAll(getTailsAndBody()); return nodes; }
Example 10
Source File: TokenSetTest.java From consulo with Apache License 2.0 | 5 votes |
private static void check(@Nonnull TokenSet set, @Nonnull IElementType... elements) { final Set<IElementType> expected = ContainerUtil.newHashSet(elements); for (IElementType t : Arrays.asList(T1, T2, T3, T4, T5, T6)) { if (expected.contains(t)) { assertTrue("missed: " + t, set.contains(t)); } else { assertFalse("unexpected: " + t, set.contains(t)); } } }
Example 11
Source File: PushController.java From consulo with Apache License 2.0 | 5 votes |
public PushController(@Nonnull Project project, @Nonnull VcsPushDialog dialog, @Nonnull List<? extends Repository> preselectedRepositories, @javax.annotation.Nullable Repository currentRepo) { myProject = project; myPushSettings = ServiceManager.getService(project, PushSettings.class); myGlobalRepositoryManager = VcsRepositoryManager.getInstance(project); myExcludedRepositoryRoots = ContainerUtil.newHashSet(myPushSettings.getExcludedRepoRoots()); myPreselectedRepositories = preselectedRepositories; myCurrentlyOpenedRepository = currentRepo; myPushSupports = getAffectedSupports(); mySingleRepoProject = isSingleRepoProject(); myDialog = dialog; CheckedTreeNode rootNode = new CheckedTreeNode(null); createTreeModel(rootNode); myPushLog = new PushLog(myProject, rootNode, isSyncStrategiesAllowed()); myPushLog.getTree().addPropertyChangeListener(PushLogTreeUtil.EDIT_MODE_PROP, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { // when user starts edit we need to force disable ok actions, because tree.isEditing() still false; // after editing completed okActions will be enabled automatically by dialog validation Boolean isEditMode = (Boolean)evt.getNewValue(); if (isEditMode) { myDialog.disableOkActions(); } } }); startLoadingCommits(); Disposer.register(dialog.getDisposable(), this); }
Example 12
Source File: ChangeListManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private Set<VirtualFile> getUnversionedParents(@Nonnull Collection<VirtualFile> items, @Nonnull Condition<FileStatus> condition) { HashSet<VirtualFile> result = ContainerUtil.newHashSet(); for (VirtualFile item : items) { VirtualFile parent = item.getParent(); while (parent != null && condition.value(getStatus(parent))) { result.add(parent); parent = parent.getParent(); } } return result; }
Example 13
Source File: VcsLogPathsIndex.java From consulo with Apache License 2.0 | 5 votes |
public TIntHashSet getCommitsForPaths(@Nonnull Collection<FilePath> paths) throws IOException, StorageException { Set<Integer> allPathIds = ContainerUtil.newHashSet(); for (FilePath path : paths) { allPathIds.add(myPathsIndexer.myPathsEnumerator.enumerate(path.getPath())); } TIntHashSet result = new TIntHashSet(); Set<Integer> renames = allPathIds; while (!renames.isEmpty()) { renames = addCommitsAndGetRenames(renames, allPathIds, result); allPathIds.addAll(renames); } return result; }
Example 14
Source File: Properties.java From idea-gitignore with MIT License | 5 votes |
/** * Stores information about dismissed notification about editing ignored file. * * @param project current project * @param file current file */ public static void setDismissedIgnoredEditingNotification(@NotNull Project project, @NotNull VirtualFile file) { final PropertiesComponent props = properties(project); String[] values = props.getValues(DISMISSED_IGNORED_EDITING_NOTIFICATION); final HashSet<String> set = ContainerUtil.newHashSet(values != null ? values : new String[0]); set.add(file.getCanonicalPath()); props.setValues(DISMISSED_IGNORED_EDITING_NOTIFICATION, set.toArray(new String[0])); }
Example 15
Source File: LinearBekGraph.java From consulo with Apache License 2.0 | 5 votes |
public Collection<GraphEdge> getRemovedEdges() { Set<GraphEdge> result = ContainerUtil.newHashSet(); Set<GraphEdge> hidden = myHiddenEdges.getEdges(); result.addAll(ContainerUtil.filter(hidden, new Condition<GraphEdge>() { @Override public boolean value(GraphEdge graphEdge) { return graphEdge.getType() != GraphEdgeType.DOTTED; } })); result.addAll(ContainerUtil.intersection(hidden, myLinearGraph.myDottedEdges.getEdges())); result.removeAll(myLinearGraph.myHiddenEdges.getEdges()); return result; }
Example 16
Source File: RollbackAction.java From consulo with Apache License 2.0 | 5 votes |
private static boolean hasReversibleFiles(@Nonnull AnActionEvent e) { ChangeListManager manager = ChangeListManager.getInstance(e.getRequiredData(CommonDataKeys.PROJECT)); Set<VirtualFile> modifiedWithoutEditing = ContainerUtil.newHashSet(manager.getModifiedWithoutEditing()); return notNullize(e.getData(VcsDataKeys.VIRTUAL_FILE_STREAM)).anyMatch( file -> manager.haveChangesUnder(file) != ThreeState.NO || manager.isFileAffected(file) || modifiedWithoutEditing.contains(file)); }
Example 17
Source File: ScopesChooser.java From consulo with Apache License 2.0 | 5 votes |
public ScopesChooser(final List<Descriptor> defaultDescriptors, final InspectionProfileImpl inspectionProfile, final Project project, final String[] excludedScopeNames) { myDefaultDescriptors = defaultDescriptors; myInspectionProfile = inspectionProfile; myProject = project; myExcludedScopeNames = excludedScopeNames == null ? Collections.<String>emptySet() : ContainerUtil.newHashSet(excludedScopeNames); setPopupTitle(TITLE); getTemplatePresentation().setText("In All Scopes"); }
Example 18
Source File: ListTemplatesHandler.java From consulo with Apache License 2.0 | 5 votes |
private static LiveTemplateLookupElement createTemplateElement(final TemplateImpl template) { return new LiveTemplateLookupElementImpl(template, false) { @Override public Set<String> getAllLookupStrings() { String description = template.getDescription(); if (description == null) { return super.getAllLookupStrings(); } return ContainerUtil.newHashSet(getLookupString(), description); } }; }
Example 19
Source File: RefreshVFsSynchronously.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static Collection<VirtualFile> refreshFiles(@Nonnull Collection<File> files) { Collection<VirtualFile> filesToRefresh = ContainerUtil.newHashSet(); for (File file : files) { VirtualFile vf = findFirstValidVirtualParent(file); if (vf != null) { filesToRefresh.add(vf); } } VfsUtil.markDirtyAndRefresh(false, false, false, ArrayUtil.toObjectArray(filesToRefresh, VirtualFile.class)); return filesToRefresh; }
Example 20
Source File: NonClasspathDirectoriesScope.java From consulo with Apache License 2.0 | 4 votes |
public NonClasspathDirectoriesScope(@Nonnull Collection<VirtualFile> roots) { myRoots = ContainerUtil.newHashSet(roots); }