@NotNull private Pair<TIntHashSet, Integer> findRowsToSelectAndScroll( @NotNull GraphTableModel model, @NotNull VisibleGraph<Integer> visibleGraph) { TIntHashSet rowsToSelect = new TIntHashSet(); if (model.getRowCount() == 0) { // this should have been covered by facade.getVisibleCommitCount, // but if the table is empty (no commits match the filter), the GraphFacade is not updated, // because it can't handle it // => it has previous values set. return Pair.create(rowsToSelect, null); } Integer rowToScroll = null; for (int row = 0; row < visibleGraph.getVisibleCommitCount() && (rowsToSelect.size() < mySelectedCommits.size() || rowToScroll == null); row++) { // stop iterating if found all hashes int commit = visibleGraph.getRowInfo(row).getCommit(); if (mySelectedCommits.contains(commit)) { rowsToSelect.add(row); } if (myVisibleSelectedCommit != null && myVisibleSelectedCommit == commit) { rowToScroll = row; } } return Pair.create(rowsToSelect, rowToScroll); }
public TIntObjectHashMap<TIntHashSet> resolve( DirectedGraph<Integer, RDFEdge> graph, Set<Set<Integer>> literalSubjectPairs, Document document, KnowledgeBase kb) { TIntObjectHashMap<TIntHashSet> resolvedSubjects = new TIntObjectHashMap<TIntHashSet>(); TIntHashSet ham = new TIntHashSet(); TIntHashSet spam = new TIntHashSet(); resolvedSubjects.put(0, spam); resolvedSubjects.put(1, ham); for (Set<Integer> c : literalSubjectPairs) { TIntHashSet subjects = getAmbiguousURIRefs(c); if (subjects.size() > 1) { ham.add(subjects.toArray()[new Random().nextInt(subjects.size())]); if (resolvedSubjects.size() < subjects.size()) { for (int s : subjects.toArray()) { if (!ham.contains(s)) { spam.add(s); } } } } } return resolvedSubjects; }
@NotNull private static FontInfo doGetFontAbleToDisplay( int codePoint, int size, @JdkConstants.FontStyle int style) { synchronized (lock) { if (ourUndisplayableChars.contains(codePoint)) return ourSharedDefaultFont; final Collection<FontInfo> descriptors = ourUsedFonts.values(); for (FontInfo font : descriptors) { if (font.getSize() == size && font.getStyle() == style && font.canDisplay(codePoint)) { return font; } } for (int i = 0; i < ourFontNames.size(); i++) { String name = ourFontNames.get(i); FontInfo font = new FontInfo(name, size, style); if (font.canDisplay(codePoint)) { ourUsedFonts.put(new FontKey(name, size, style), font); ourFontNames.remove(i); return font; } } ourUndisplayableChars.add(codePoint); return ourSharedDefaultFont; } }
public boolean canDisplay(char c) { try { if (c < 128) return true; if (mySafeCharacters.contains(c)) return true; if (canDisplayImpl(c)) { mySafeCharacters.add(c); return true; } return false; } catch (Exception e) { // JRE has problems working with the font. Just skip. return false; } }
@NotNull private static List<VFileEvent> validateEvents(@NotNull List<VFileEvent> events) { final List<EventWrapper> deletionEvents = ContainerUtil.newArrayList(); for (int i = 0, size = events.size(); i < size; i++) { final VFileEvent event = events.get(i); if (event instanceof VFileDeleteEvent && event.isValid()) { deletionEvents.add(new EventWrapper((VFileDeleteEvent) event, i)); } } final TIntHashSet invalidIDs; if (deletionEvents.isEmpty()) { invalidIDs = EmptyIntHashSet.INSTANCE; } else { ContainerUtil.quickSort(deletionEvents, DEPTH_COMPARATOR); invalidIDs = new TIntHashSet(deletionEvents.size()); final Set<VirtualFile> dirsToBeDeleted = new THashSet<VirtualFile>(deletionEvents.size()); nextEvent: for (EventWrapper wrapper : deletionEvents) { final VirtualFile candidate = wrapper.event.getFile(); VirtualFile parent = candidate; while (parent != null) { if (dirsToBeDeleted.contains(parent)) { invalidIDs.add(wrapper.id); continue nextEvent; } parent = parent.getParent(); } if (candidate.isDirectory()) { dirsToBeDeleted.add(candidate); } } } final List<VFileEvent> filtered = new ArrayList<VFileEvent>(events.size() - invalidIDs.size()); for (int i = 0, size = events.size(); i < size; i++) { final VFileEvent event = events.get(i); if (event.isValid() && !(event instanceof VFileDeleteEvent && invalidIDs.contains(i))) { filtered.add(event); } } return filtered; }
public void testTrailingSoftWrapOffsetShiftOnTyping() throws IOException { // The main idea is to type on a logical line before soft wrap in order to ensure that its // offset is correctly shifted back. String text = "line1<caret>\n" + "second line that is long enough to be soft wrapped"; init(15, text); TIntHashSet offsetsBefore = collectSoftWrapStartOffsets(1); assertTrue(!offsetsBefore.isEmpty()); type('2'); final TIntHashSet offsetsAfter = collectSoftWrapStartOffsets(1); assertSame(offsetsBefore.size(), offsetsAfter.size()); offsetsBefore.forEach( value -> { assertTrue(offsetsAfter.contains(value + 1)); return true; }); }
private void update(@NotNull List<BreakpointWithHighlighter> breakpoints) { final TIntHashSet intHash = new TIntHashSet(); for (BreakpointWithHighlighter breakpoint : breakpoints) { SourcePosition sourcePosition = breakpoint.getSourcePosition(); breakpoint.reload(); if (breakpoint.isValid()) { if (sourcePosition == null || breakpoint.getSourcePosition().getLine() != sourcePosition.getLine()) { fireBreakpointChanged(breakpoint); } if (intHash.contains(breakpoint.getLineIndex())) { remove(breakpoint); } else { intHash.add(breakpoint.getLineIndex()); } } else { remove(breakpoint); } } }
@Override public boolean isGenerated(VirtualFile file) { if (myGeneratedSources.contains(FileBasedIndex.getFileId(file))) { return true; } if (isUnderRoots(myRootToModuleMap.keySet(), file)) { return true; } final Module module = getModuleByFile(file); if (module != null) { for (AdditionalOutputDirectoriesProvider provider : AdditionalOutputDirectoriesProvider.EP_NAME.getExtensions()) { for (String path : provider.getOutputDirectories(getProject(), module)) { if (path != null && VfsUtilCore.isAncestor(new File(path), new File(file.getPath()), true)) { return true; } } } } return false; }
private static void findReadsBeforeWrites( Instruction[] flow, TIntHashSet[] definitelyAssigned, List<ReadWriteVariableInstruction> result, TObjectIntHashMap<String> namesIndex, int[] postorder, int[] invpostorder, boolean onlyFirstRead) { // skip instructions that are not reachable from the start int start = ArrayUtil.find(invpostorder, 0); for (int i = start; i < flow.length; i++) { int j = invpostorder[i]; Instruction curr = flow[j]; if (curr instanceof ReadWriteVariableInstruction) { ReadWriteVariableInstruction rw = (ReadWriteVariableInstruction) curr; int name = namesIndex.get(rw.getVariableName()); TIntHashSet vars = definitelyAssigned[j]; if (rw.isWrite()) { if (vars == null) { vars = new TIntHashSet(); definitelyAssigned[j] = vars; } vars.add(name); } else { if (vars == null || !vars.contains(name)) { result.add(rw); if (onlyFirstRead) { if (vars == null) { vars = new TIntHashSet(); definitelyAssigned[j] = vars; } vars.add(name); } } } } for (Instruction succ : curr.allSuccessors()) { if (postorder[succ.num()] > postorder[curr.num()]) { TIntHashSet currDefinitelyAssigned = definitelyAssigned[curr.num()]; TIntHashSet succDefinitelyAssigned = definitelyAssigned[succ.num()]; if (currDefinitelyAssigned != null) { int[] currArray = currDefinitelyAssigned.toArray(); if (succDefinitelyAssigned == null) { succDefinitelyAssigned = new TIntHashSet(); succDefinitelyAssigned.addAll(currArray); definitelyAssigned[succ.num()] = succDefinitelyAssigned; } else { succDefinitelyAssigned.retainAll(currArray); } } else { if (succDefinitelyAssigned != null) { succDefinitelyAssigned.clear(); } else { succDefinitelyAssigned = new TIntHashSet(); definitelyAssigned[succ.num()] = succDefinitelyAssigned; } } } } } }