List Info

Thread: Simple search utility




Simple search utility
user name
2007-02-25 11:18:04

Searching for a pattern in a specified project or file is now available, with the TextSearcher utility.

 

For example - searching for variables pattern in the current file or project:

final TextSearcher searcher = TextSearcherFactory.createSearcher(project or file, "\$[a-zA-Z_]*");

searcher.search(new NullProgressMonitor() / null);

final List results = searcher.getResults();

 

1)     The result list elements are of type FileMatch (holds IFile, offset and length).

2)     There are many factories that construct the search utility – available through TextSearcherFactory

3)     The search pattern should follow the pattern class rules: http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html so never let the user search directly with the utility.

4)     The implementation is based on org.eclipse.search plug-in.

 

Bests,

____________

Roy Ganor

Software Engineer, R&D

tel.   ;+972-3-7539637

mob. +972-52-3290-754

ZEND

www.zend.com

 

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )