org.eclipse.search.ui.text.AbstractTextSearchResult Java Examples
The following examples show how to use
org.eclipse.search.ui.text.AbstractTextSearchResult.
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: FileTreeContentProvider.java From Pydev with Eclipse Public License 1.0 | 6 votes |
private synchronized void initialize(AbstractTextSearchResult result) { fResult = result; fChildrenMap = new HashMap<Object, Set>(); boolean showLineMatches = !((AbstractPythonSearchQuery) fResult.getQuery()).isFileNameSearch(); if (result != null) { Object[] elements = result.getElements(); for (int i = 0; i < elements.length; i++) { if (showLineMatches) { Match[] matches = result.getMatches(elements[i]); for (int j = 0; j < matches.length; j++) { insert(((FileMatch) matches[j]).getLineElement(), false); } } else { insert(elements[i], false); } } } }
Example #2
Source File: OccurrencesSearchResult.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) { //TODO same code in JavaSearchResult IEditorInput editorInput= editor.getEditorInput(); if (editorInput instanceof IFileEditorInput) { IFileEditorInput fileEditorInput= (IFileEditorInput) editorInput; return computeContainedMatches(result, fileEditorInput.getFile()); } else if (editorInput instanceof IClassFileEditorInput) { IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) editorInput; IClassFile classFile= classFileEditorInput.getClassFile(); Object[] elements= getElements(); if (elements.length == 0) return NO_MATCHES; //all matches from same file: JavaElementLine jel= (JavaElementLine) elements[0]; if (jel.getJavaElement().equals(classFile)) return collectMatches(elements); } return NO_MATCHES; }
Example #3
Source File: ModulaSearchResult.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
public Match[] computeContainedMatches( AbstractTextSearchResult result , IEditorPart editor ) { ArrayList<Match> list = new ArrayList<Match>(); Object[] objects = result.getElements(); for (int i = 0; i < objects.length; i++) { if (objects[i] instanceof IFile) { IFile f = (IFile) objects[i]; if (isMatchContained(editor, f)) { Match[] matches = getMatches(f); for (int j = 0; j < matches.length; j++) { list.add(matches[j]); } } } } return (Match[]) list.toArray(new Match[list.size()]); }
Example #4
Source File: ModulaSearchQuery.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
public IStatus run(IProgressMonitor monitor) { final AbstractTextSearchResult result = (AbstractTextSearchResult) getSearchResult(); result.removeAll(); ISearchResultCollector collector = new ISearchResultCollector() { public void accept(Object match) { if (match instanceof Match) { result.addMatch((Match)match); // match.getElement() is IFile } } }; ModulaSearchOperation op = new ModulaSearchOperation(fSearchInput, collector); MultiStatus status = new MultiStatus(XdsPlugin.PLUGIN_ID, IStatus.OK, Messages.M2SearchQuery_SearchProblems, null); op.execute(monitor, status); monitor.done(); return status; }
Example #5
Source File: JavaSearchTableContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public Object[] getElements(Object inputElement) { if (inputElement instanceof AbstractTextSearchResult) { Set<Object> filteredElements= new HashSet<Object>(); Object[] rawElements= ((AbstractTextSearchResult)inputElement).getElements(); int limit= getPage().getElementLimit().intValue(); for (int i= 0; i < rawElements.length; i++) { if (getPage().getDisplayedMatchCount(rawElements[i]) > 0) { filteredElements.add(rawElements[i]); if (limit != -1 && limit < filteredElements.size()) { break; } } } return filteredElements.toArray(); } return EMPTY_ARR; }
Example #6
Source File: PySearchIndexQuery.java From Pydev with Eclipse Public License 1.0 | 6 votes |
public void createMatches(IDocument doc, String text, StringMatcherWithIndexSemantics stringMatcher, IFile workspaceFile, AbstractTextSearchResult searchResult, ModulesKey modulesKey) { StringMatcherWithIndexSemantics.Position find = stringMatcher.find(text, 0); while (find != null) { int offset = find.getStart(); int end = find.getEnd(); int length = end - offset; PySelection ps = new PySelection(doc, offset); int lineNumber = ps.getLineOfOffset(); String lineContents = ps.getLine(lineNumber); int lineStartOffset = ps.getLineOffset(lineNumber); PyModuleLineElement element = new PyModuleLineElement(workspaceFile, lineNumber, lineStartOffset, lineContents, modulesKey); searchResult.addMatch(new PyModuleMatch(workspaceFile, offset, length, element, modulesKey)); find = stringMatcher.find(text, end); } }
Example #7
Source File: SearchLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private ILabelProvider getLabelProvider(Object element) { AbstractTextSearchResult input= fPage.getInput(); if (!(input instanceof JavaSearchResult)) return null; IMatchPresentation participant= ((JavaSearchResult) input).getSearchParticpant(element); if (participant == null) return null; ILabelProvider lp= fLabelProviderMap.get(participant); if (lp == null) { lp= participant.createLabelProvider(); fLabelProviderMap.put(participant, lp); Object[] listeners= fListeners.getListeners(); for (int i= 0; i < listeners.length; i++) { lp.addListener((ILabelProviderListener) listeners[i]); } } return lp; }
Example #8
Source File: FileLabelProvider.java From Pydev with Eclipse Public License 1.0 | 6 votes |
private String getColoredLabelWithCounts(Object element, String coloredName) { AbstractTextSearchResult result = fPage.getInput(); if (result == null) { return coloredName; } int matchCount = result.getMatchCount(element); if (matchCount <= 1) { return coloredName; } String countInfo = MessageFormat.format(SearchMessages.FileLabelProvider_count_format, matchCount); coloredName += " "; coloredName += countInfo; return coloredName; }
Example #9
Source File: TypeScriptSearchResultPage.java From typescript.java with MIT License | 6 votes |
public String getLabel() { String label= super.getLabel(); StructuredViewer viewer= getViewer(); if (viewer instanceof TableViewer) { TableViewer tv= (TableViewer) viewer; AbstractTextSearchResult result= getInput(); if (result != null) { int itemCount= ((IStructuredContentProvider) tv.getContentProvider()).getElements(getInput()).length; if (showLineMatches()) { int matchCount= getInput().getMatchCount(); if (itemCount < matchCount) { return Messages.format(SearchMessages.FileSearchPage_limited_format_matches, new Object[]{label, new Integer(itemCount), new Integer(matchCount)}); } } else { int fileCount= getInput().getElements().length; if (itemCount < fileCount) { return Messages.format(SearchMessages.FileSearchPage_limited_format_files, new Object[]{label, new Integer(itemCount), new Integer(fileCount)}); } } } } return label; }
Example #10
Source File: TypeScriptSearchTreeContentProvider.java From typescript.java with MIT License | 6 votes |
private synchronized void initialize(AbstractTextSearchResult result) { fResult= result; fChildrenMap= new HashMap(); boolean showLineMatches= true; //!((TypeScriptSearchQuery) fResult.getQuery()).isFileNameSearch(); if (result != null) { Object[] elements= result.getElements(); for (int i= 0; i < elements.length; i++) { if (showLineMatches) { Match[] matches= result.getMatches(elements[i]); for (int j= 0; j < matches.length; j++) { insert(((TypeScriptMatch) matches[j]).getLineElement(), false); } } else { insert(elements[i], false); } } } }
Example #11
Source File: SearchIndexLabelProvider.java From Pydev with Eclipse Public License 1.0 | 5 votes |
private StyledString getColoredLabelWithCounts(Object element, StyledString coloredName) { AbstractTextSearchResult result = fPage.getInput(); if (result == null) { return coloredName; } int matchCount = result.getMatchCount(element); if (matchCount <= 1) { return coloredName; } String countInfo = MessageFormat.format("({0} matches)", matchCount); coloredName.append(' ').append(countInfo, StyledString.COUNTER_STYLER); return coloredName; }
Example #12
Source File: ReplaceRefactoring.java From Pydev with Eclipse Public License 1.0 | 5 votes |
public ReplaceRefactoring(AbstractTextSearchResult result, Object[] selection, boolean skipFiltered, ICallback<Boolean, Match> skipMatch) { Assert.isNotNull(result); fResult = result; fSelection = selection; fSkipFiltered = skipFiltered; fSkipMatch = skipMatch; fMatches = new HashMap<>(); fReplaceString = null; }
Example #13
Source File: ReplaceAction.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Creates the replace action to be * @param shell the parent shell * @param result the file search page to * @param selection the selected entries or <code>null</code> to replace all * @param skipFiltered if set to <code>true</code>, filtered matches will not be replaced */ public ReplaceAction(Shell shell, AbstractTextSearchResult result, Object[] selection, boolean skipFiltered, ICallback<Boolean, Match> skipMatch) { fShell = shell; fResult = result; fSelection = selection; fSkipFiltered = skipFiltered; fSkipMatch = skipMatch; }
Example #14
Source File: AbstractSearchIndexTreeContentProvider.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { elementToTreeNode.clear(); if (newInput instanceof AbstractTextSearchResult) { AbstractTextSearchResult abstractTextSearchResult = (AbstractTextSearchResult) newInput; this.fResult = abstractTextSearchResult; root = new TreeNode<>(null, newInput); Object[] elements = abstractTextSearchResult.getElements(); int elementsLen = elements.length; for (int i = 0; i < elementsLen; i++) { Object object = elements[i]; Match[] matches = abstractTextSearchResult.getMatches(object); int matchesLen = matches.length; for (int j = 0; j < matchesLen; j++) { Match match = matches[j]; if (match instanceof ICustomMatch) { ICustomMatch moduleMatch = (ICustomMatch) match; obtainTeeNodeElement(moduleMatch.getLineElement()); } else { Log.log("Expecting ICustomMatch. Found:" + match.getClass() + " - " + match); } } } } else { this.clear(); } }
Example #15
Source File: LineElement.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public int getNumberOfMatches(AbstractTextSearchResult result) { int count = 0; Match[] matches = result.getMatches(fParent); for (int i = 0; i < matches.length; i++) { FileMatch curr = (FileMatch) matches[i]; if (curr.getLineElement() == this) { count++; } } return count; }
Example #16
Source File: JavaSearchResultPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private boolean isQueryRunning() { AbstractTextSearchResult result= getInput(); if (result != null) { return NewSearchUI.isQueryRunning(result.getQuery()); } return false; }
Example #17
Source File: OccurrencesSearchResult.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public Match[] computeContainedMatches(AbstractTextSearchResult result, IFile file) { Object[] elements= getElements(); if (elements.length == 0) return NO_MATCHES; //all matches from same file: JavaElementLine jel= (JavaElementLine) elements[0]; if (file.equals(jel.getJavaElement().getResource())) return collectMatches(elements); return NO_MATCHES; }
Example #18
Source File: OccurrencesSearchResultPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void preformEditorSelectionChanged(ITextSelection selection, CompilationUnit astRoot) { if (!isLinkingEnabled()) { return; } IOccurrencesFinder finder; AbstractTextSearchResult input= getInput(); if (input == null) { finder= new OccurrencesFinder(); } else { String id= ((OccurrencesSearchQuery) input.getQuery()).getFinderId(); if (id == OccurrencesFinder.ID) { finder= new OccurrencesFinder(); } else if (id == ExceptionOccurrencesFinder.ID) { finder= new ExceptionOccurrencesFinder(); } else { finder= new ImplementOccurrencesFinder(); } } int offset= selection.getOffset(); int length= selection.getLength(); if (finder.initialize(astRoot, offset, length) == null) { final OccurrencesSearchQuery query= new OccurrencesSearchQuery(finder, astRoot.getTypeRoot()); query.run(null); OccurrencesSearchResult result= (OccurrencesSearchResult) query.getSearchResult(); final JavaElementLine line= getMatchingLine(result, offset, length); getSite().getShell().getDisplay().asyncExec(new Runnable() { public void run() { setInput(query.getSearchResult(), line == null ? null : new StructuredSelection(line)); } }); } }
Example #19
Source File: SearchIndexResult.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) { IEditorInput ei = editor.getEditorInput(); if (ei instanceof IFileEditorInput) { IFileEditorInput fi = (IFileEditorInput) ei; return getMatches(fi.getFile()); } return EMPTY_ARR; }
Example #20
Source File: LineElement.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public FileMatch[] getMatches(AbstractTextSearchResult result) { ArrayList<FileMatch> res = new ArrayList<FileMatch>(); Match[] matches = result.getMatches(fParent); for (int i = 0; i < matches.length; i++) { FileMatch curr = (FileMatch) matches[i]; if (curr.getLineElement() == this) { res.add(curr); } } return res.toArray(new FileMatch[res.size()]); }
Example #21
Source File: SearchIndexQueryTest.java From Pydev with Eclipse Public License 1.0 | 5 votes |
public void testSearchQuery3() throws Exception { PySearchIndexQuery query = new PySearchIndexQuery("*my*"); String text = "rara\nmy\nnomyno\nmy"; IDocument doc = new Document(text); IFile f = new AdditionalInfoFileStub("stub") { @Override public long getModificationStamp() { return 0; } }; AbstractTextSearchResult searchResult = new PySearchResult(null); query.createMatches(doc, text, query.createStringMatcher(), f, searchResult, new ModulesKey("my", null)); assertEquals(3, searchResult.getMatchCount()); }
Example #22
Source File: FileSearchPage.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public String getLabel() { String label = super.getLabel(); StructuredViewer viewer = getViewer(); if (viewer instanceof TableViewer) { TableViewer tv = (TableViewer) viewer; AbstractTextSearchResult result = getInput(); if (result != null) { int itemCount = ((IStructuredContentProvider) tv.getContentProvider()).getElements(getInput()).length; if (showLineMatches()) { int matchCount = getInput().getMatchCount(); if (itemCount < matchCount) { return MessageFormat.format(SearchMessages.FileSearchPage_limited_format_matches, new Object[] { label, itemCount, matchCount }); } } else { int fileCount = getInput().getElements().length; if (itemCount < fileCount) { return MessageFormat.format(SearchMessages.FileSearchPage_limited_format_files, new Object[] { label, itemCount, fileCount }); } } } } return label; }
Example #23
Source File: PythonFileSearchResult.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) { IEditorInput ei = editor.getEditorInput(); if (ei instanceof IFileEditorInput) { IFileEditorInput fi = (IFileEditorInput) ei; return getMatches(fi.getFile()); } return EMPTY_ARR; }
Example #24
Source File: PyModuleLineElement.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public PyModuleMatch[] getMatches(AbstractTextSearchResult result) { ArrayList<PyModuleMatch> res = new ArrayList<PyModuleMatch>(); Match[] matches = result.getMatches(fParent); for (int i = 0; i < matches.length; i++) { PyModuleMatch curr = (PyModuleMatch) matches[i]; if (curr.getLineElement() == this) { res.add(curr); } } return res.toArray(new PyModuleMatch[res.size()]); }
Example #25
Source File: PyModuleLineElement.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public int getNumberOfMatches(AbstractTextSearchResult result) { int count = 0; Match[] matches = result.getMatches(fParent); for (int i = 0; i < matches.length; i++) { PyModuleMatch curr = (PyModuleMatch) matches[i]; if (curr.getLineElement() == this) { count++; } } return count; }
Example #26
Source File: SearchIndexQueryTest.java From Pydev with Eclipse Public License 1.0 | 5 votes |
public void testSearchQuery() throws Exception { PySearchIndexQuery query = new PySearchIndexQuery("my"); String text = "rara\nmy\nnomyno\nmy"; IDocument doc = new Document(text); IFile f = new AdditionalInfoFileStub("stub") { @Override public long getModificationStamp() { return 0; } }; AbstractTextSearchResult searchResult = new PySearchResult(null); query.createMatches(doc, text, query.createStringMatcher(), f, searchResult, new ModulesKey("my", null)); assertEquals(2, searchResult.getMatchCount()); }
Example #27
Source File: SearchIndexQueryTest.java From Pydev with Eclipse Public License 1.0 | 5 votes |
public void testSearchQuery2() throws Exception { PySearchIndexQuery query = new PySearchIndexQuery("*my"); String text = "rara\nmy\nnomyno\nmy"; IDocument doc = new Document(text); IFile f = new AdditionalInfoFileStub("stub") { @Override public long getModificationStamp() { return 0; } }; AbstractTextSearchResult searchResult = new PySearchResult(null); query.createMatches(doc, text, query.createStringMatcher(), f, searchResult, new ModulesKey("my", null)); assertEquals(2, searchResult.getMatchCount()); }
Example #28
Source File: ImplementationsSearchQuery.java From corrosion with Eclipse Public License 2.0 | 5 votes |
@Override public IStatus run(IProgressMonitor monitor) { startTime = System.currentTimeMillis(); // Cancel last references future if needed. if (references != null) { references.cancel(true); } AbstractTextSearchResult textResult = (AbstractTextSearchResult) getSearchResult(); textResult.removeAll(); try { // Execute LSP "references" service ReferenceParams params = new ReferenceParams(); params.setContext(new ReferenceContext(true)); params.setTextDocument(new TextDocumentIdentifier(info.getFileUri().toString())); params.setPosition(position); info.getInitializedLanguageClient().thenCompose(languageServer -> ((RLSServerInterface) languageServer).implementations(params)).thenAccept(locs -> { // Loop for each LSP Location and convert it to Match search. for (Location loc : locs) { Match match = toMatch(loc); result.addMatch(match); } }); return Status.OK_STATUS; } catch (Exception ex) { return new Status(IStatus.ERROR, LanguageServerPlugin.getDefault().getBundle().getSymbolicName(), ex.getMessage(), ex); } }
Example #29
Source File: CompositeSearchResult.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public int getMatchCount(Object element) { int count = 0; for(ISearchQuery child: query.getChildren()) { ISearchResult childResult = child.getSearchResult(); if(childResult instanceof AbstractTextSearchResult) count += ((AbstractTextSearchResult) childResult).getMatchCount(element); } return count; }
Example #30
Source File: NLSSearchResult.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) { //TODO: copied from JavaSearchResult: IEditorInput editorInput= editor.getEditorInput(); if (editorInput instanceof IFileEditorInput) { IFileEditorInput fileEditorInput= (IFileEditorInput) editorInput; return computeContainedMatches(result, fileEditorInput.getFile()); } else if (editorInput instanceof IClassFileEditorInput) { IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) editorInput; Set<Match> matches= new HashSet<Match>(); collectMatches(matches, classFileEditorInput.getClassFile()); return matches.toArray(new Match[matches.size()]); } return NO_MATCHES; }