public FileMatch[] getMatches(AbstractTextSearchResult result) { ArrayList<FileMatch> res= new ArrayList<>(); Match[] matches= result.getMatches(fParent); for (Match match : matches) { FileMatch curr= (FileMatch) match; if (curr.getLineElement() == this) { res.add(curr); } } return res.toArray(new FileMatch[res.size()]); }
public int getNumberOfMatches(AbstractTextSearchResult result) { int count= 0; Match[] matches= result.getMatches(fParent); for (Match match : matches) { FileMatch curr= (FileMatch) match; if (curr.getLineElement() == this) { count++; } } return count; }
protected final int getNumberOfPotentialMatches(Object element) { int res= 0; AbstractTextSearchResult result= fPage.getInput(); if (result != null) { Match[] matches= result.getMatches(element); for (int i = 0; i < matches.length; i++) { if ((matches[i]) instanceof JavaElementMatch) { if (((JavaElementMatch)matches[i]).getAccuracy() == SearchMatch.A_INACCURATE) res++; } } } return res; }
protected final int getNumberOfPotentialMatches(Object element) { int res= 0; AbstractTextSearchResult result= fPage.getInput(); if (result != null) { Match[] matches= result.getMatches(element); for (int i = 0; i < matches.length; i++) { if ((matches[i]) instanceof JavaElementMatch) { if (((JavaElementMatch)matches[i]).getAccuracy() == SearchMatch.A_INACCURATE) res++; } } } return res; }
protected final int getNumberOfPotentialMatches(Object element) { int res= 0; AbstractTextSearchResult result= fPage.getInput(); if (result != null) { Match[] matches= result.getMatches(element); for (int i = 0; i < matches.length; i++) { if ((matches[i]) instanceof JavaElementMatch) { if (((JavaElementMatch)matches[i]).getAccuracy() == SearchMatch.A_INACCURATE) res++; } } } return res; }
private void updateFilterStateForAllMatches() { boolean disableFiltering= getActiveMatchFilters() == null; ArrayList changed= new ArrayList(); Object[] elements= getElements(); for (int i= 0; i < elements.length; i++) { Match[] matches= getMatches(elements[i]); for (int k= 0; k < matches.length; k++) { if (disableFiltering || updateFilterState(matches[k])) { changed.add(matches[k]); } } } Match[] allChanges= (Match[]) changed.toArray(new Match[changed.size()]); fireChange(new FilterUpdateEvent(this, allChanges, getActiveMatchFilters())); }
private void updateFilterStateForAllMatches() { boolean disableFiltering= getActiveMatchFilters() == null; ArrayList<Match> changed= new ArrayList<>(); Object[] elements= getElements(); for (Object element : elements) { Match[] matches= getMatches(element); for (Match match : matches) { if (disableFiltering || updateFilterState(match)) { changed.add(match); } } } Match[] allChanges= changed.toArray(new Match[changed.size()]); fireChange(new FilterUpdateEvent(this, allChanges, getActiveMatchFilters())); }
private void updateFilterStateForAllMatches() { boolean disableFiltering = getActiveMatchFilters() == null; ArrayList changed = new ArrayList(); Object[] elements = getElements(); for (int i = 0; i < elements.length; i++) { Match[] matches = getMatches(elements[i]); for (int k = 0; k < matches.length; k++) { if (disableFiltering || updateFilterState(matches[k])) { changed.add(matches[k]); } } } Match[] allChanges = (Match[]) changed.toArray(new Match[changed.size()]); fireChange(new FilterUpdateEvent(this, allChanges, getActiveMatchFilters())); }
public boolean visit(IResourceDelta delta) throws CoreException { switch (delta.getKind()) { case IResourceDelta.ADDED : return false; case IResourceDelta.REMOVED : IResource res= delta.getResource(); if (res instanceof IFile) { Match[] matches= fResult.getMatches(res); fResult.removeMatches(matches); } break; case IResourceDelta.CHANGED : // handle changed resource break; } return true; } });
if (result == null) return EMPTY_MATCH_ARRAY; Match[] matches= result.getMatches(element); if (result.getActiveMatchFilters() == null) // default behaviour: filter state not used, all matches shown return matches;
private synchronized void initialize(AbstractTextSearchResult result) { fResult= result; fChildrenMap= new HashMap<>(); boolean showLineMatches= !((FileSearchQuery) fResult.getQuery()).isFileNameSearch(); if (result != null) { Object[] elements= result.getElements(); for (Object element : elements) { if (showLineMatches) { Match[] matches= result.getMatches(element); for (Match match : matches) { insert(((FileMatch) match).getLineElement(), false); } } else { insert(element, false); } } } }
if (result == null) return EMPTY_MATCH_ARRAY; Match[] matches= result.getMatches(element); if (result.getActiveMatchFilters() == null) // default behaviour: filter state not used, all matches shown return matches;
/** * Returns the number of matches that are currently displayed for the given * element. If {@link AbstractTextSearchResult#getActiveMatchFilters()} is not null, only matches * are returned that are not filtered by the match filters. * Any action operating on the visible matches in the * search result page should use this method to get the match count for a * search result (instead of asking the search result directly). * * @param element * The element to get the matches for * @return The number of matches displayed for the given element. If the * current input of this page is <code>null</code>, 0 is * returned * @see AbstractTextSearchResult#getMatchCount(Object) */ public int getDisplayedMatchCount(Object element) { AbstractTextSearchResult result= getInput(); if (result == null) return 0; if (result.getActiveMatchFilters() == null) // default behaviour: filter state not used, all matches shown return result.getMatchCount(element); int count= 0; Match[] matches= result.getMatches(element); for (int i= 0; i < matches.length; i++) { if (!matches[i].isFiltered()) count++; } return count; }
/** * Returns the number of matches that are currently displayed for the given * element. If {@link AbstractTextSearchResult#getActiveMatchFilters()} is not null, only matches * are returned that are not filtered by the match filters. * Any action operating on the visible matches in the * search result page should use this method to get the match count for a * search result (instead of asking the search result directly). * * @param element * The element to get the matches for * @return The number of matches displayed for the given element. If the * current input of this page is <code>null</code>, 0 is * returned * @see AbstractTextSearchResult#getMatchCount(Object) */ public int getDisplayedMatchCount(Object element) { AbstractTextSearchResult result= getInput(); if (result == null) return 0; if (result.getActiveMatchFilters() == null) // default behaviour: filter state not used, all matches shown return result.getMatchCount(element); int count= 0; Match[] matches= result.getMatches(element); for (int i= 0; i < matches.length; i++) { if (!matches[i].isFiltered()) count++; } return count; }
private void handleDelta(IResourceDelta d) { try { d.accept(delta -> { switch (delta.getKind()) { case IResourceDelta.ADDED : return false; case IResourceDelta.REMOVED : IResource res= delta.getResource(); if (res instanceof IFile) { Match[] matches= fResult.getMatches(res); fResult.removeMatches(matches); } break; case IResourceDelta.CHANGED : // handle changed resource break; } return true; }); } catch (CoreException e) { SearchPlugin.log(e); } }
private StyledString internalGetRichText(Object element) { JavaElementLine jel= (JavaElementLine) element; String lineNumberString= getLineNumberLabel(jel); Styler highlightStyle= ColoringLabelProvider.HIGHLIGHT_STYLE; StyledString res= new StyledString(); res.append(lineNumberString, StyledString.QUALIFIER_STYLER); res.append(jel.getLineContents()); Match[] matches= getPage().getInput().getMatches(jel); for (int i= 0; i < matches.length; i++) { OccurrenceMatch curr= (OccurrenceMatch) matches[i]; int offset= curr.getOriginalOffset() - jel.getLineStartOffset() + lineNumberString.length(); int length= curr.getOriginalLength(); if (offset >= 0 && (offset + length <= res.length())) { if ((curr.getFlags() & IOccurrencesFinder.F_WRITE_OCCURRENCE) != 0) { res.setStyle(offset, length, ColoringLabelProvider.HIGHLIGHT_WRITE_STYLE); } else { res.setStyle(offset, length, highlightStyle); } } } return res; }
private StyledString internalGetRichText(Object element) { JavaElementLine jel= (JavaElementLine) element; String lineNumberString= getLineNumberLabel(jel); Styler highlightStyle= ColoringLabelProvider.HIGHLIGHT_STYLE; StyledString res= new StyledString(); res.append(lineNumberString, StyledString.QUALIFIER_STYLER); res.append(jel.getLineContents()); Match[] matches= getPage().getInput().getMatches(jel); for (int i= 0; i < matches.length; i++) { OccurrenceMatch curr= (OccurrenceMatch) matches[i]; int offset= curr.getOriginalOffset() - jel.getLineStartOffset() + lineNumberString.length(); int length= curr.getOriginalLength(); if (offset >= 0 && (offset + length <= res.length())) { if ((curr.getFlags() & IOccurrencesFinder.F_WRITE_OCCURRENCE) != 0) { res.setStyle(offset, length, ColoringLabelProvider.HIGHLIGHT_WRITE_STYLE); } else { res.setStyle(offset, length, highlightStyle); } } } return res; }