|
From: Markus B. <mba...@us...> - 2005-10-23 19:44:54
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/symbols In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2741/src/org/rubypeople/rdt/internal/core/symbols Modified Files: SymbolIndex.java Log Message: added logging, more selective flushing, find with regular expression Index: SymbolIndex.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/symbols/SymbolIndex.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SymbolIndex.java 19 Oct 2005 00:33:11 -0000 1.6 --- SymbolIndex.java 23 Oct 2005 19:44:46 -0000 1.7 *************** *** 18,21 **** --- 18,23 ---- import java.util.Map; import java.util.Set; + import java.util.regex.Pattern; + import java.util.regex.PatternSyntaxException; import org.eclipse.core.resources.IFile; *************** *** 38,41 **** --- 40,44 ---- public void add(ClassSymbol symbol, IFile file, ISourcePosition position) { + SymbolIndex.log("Adding Symbol: " + symbol) ; add(symbol, new Location(file.getFullPath(), position)); } *************** *** 47,53 **** return Collections.unmodifiableSet(locations); } public void flush(IPath foo_path) { ! // flush only relevant bits synchronized (index) { for (Iterator indexIter = index.entrySet().iterator(); indexIter.hasNext();) { --- 50,79 ---- return Collections.unmodifiableSet(locations); } + + /* + * returns a set of SearchResult instances as opposed to find(symbol), which returns locations + */ + public Set find(String regExp) throws PatternSyntaxException { + Pattern pattern = Pattern.compile(regExp); + Set searchResults = new HashSet() ; + + for (Iterator indexIter = index.entrySet().iterator(); indexIter.hasNext();) { + Map.Entry entry = (Map.Entry) indexIter.next(); + ClassSymbol symbol = (ClassSymbol) entry.getKey() ; + if (pattern.matcher(symbol.getName()).find()) { + Set foundLocations = (Set)entry.getValue() ; + for (Iterator locationIter = foundLocations.iterator(); locationIter.hasNext(); ) { + Location location = (Location) locationIter.next() ; + searchResults.add(new SearchResult(symbol, location)) ; + } + } + } + + return searchResults ; + } public void flush(IPath foo_path) { ! SymbolIndex.log("Flushing all Symbols with path: " + foo_path) ; ! synchronized (index) { for (Iterator indexIter = index.entrySet().iterator(); indexIter.hasNext();) { *************** *** 57,61 **** for (Iterator locationIter = locations.iterator(); locationIter.hasNext();) { Location location = (Location) locationIter.next(); ! locationIter.remove(); } --- 83,89 ---- for (Iterator locationIter = locations.iterator(); locationIter.hasNext();) { Location location = (Location) locationIter.next(); ! if (location.getSourcePath() == foo_path) { ! locationIter.remove(); ! } } *************** *** 73,76 **** --- 101,111 ---- return verbose; } + + public static void log(String message) { + if (!SymbolIndex.isVerbose()) { + return ; + } + System.out.println(message) ; + } |