X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java index 81a3928..4f92951 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java @@ -12,15 +12,18 @@ import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Set; import java.util.SortedMap; import java.util.StringTokenizer; import java.util.TreeMap; + import net.sourceforge.phpdt.core.compiler.ITerminalSymbols; import net.sourceforge.phpdt.core.compiler.InvalidInputException; import net.sourceforge.phpdt.internal.compiler.parser.Scanner; import net.sourceforge.phpdt.internal.compiler.parser.SyntaxError; import net.sourceforge.phpdt.internal.compiler.util.Util; import net.sourceforge.phpeclipse.obfuscator.PHPIdentifier; + import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; /** @@ -191,7 +194,7 @@ public class IdentifierIndexManager { e.printStackTrace(); } } - public void parseIdentifiers(char[] charArray, StringBuffer buf) { + synchronized public void parseIdentifiers(char[] charArray, StringBuffer buf) { char[] ident; String identifier; int counter = 0; @@ -319,18 +322,6 @@ public class IdentifierIndexManager { // InputStream iStream; LineCreator lineCreator = createLineCreator(); try { - // iStream = fileToParse.getContents(); - // - // StringBuffer buf = new StringBuffer(); - // int c0; - // try { - // while ((c0 = iStream.read()) != (-1)) { - // buf.append((char) c0); - // } - // } catch (IOException e) { - // return; - // } - addInputStream(new BufferedInputStream(fileToParse.getContents()), fileToParse.getFullPath().toString(), lineCreator); } catch (CoreException e1) { // TODO Auto-generated catch block @@ -343,21 +334,18 @@ public class IdentifierIndexManager { * @throws CoreException */ public void addInputStream(InputStream stream, String filePath, LineCreator lineCreator) throws CoreException { -// InputStream stream; try { - // stream = new BufferedInputStream(fileToParse.getContents()); StringBuffer lineBuffer = new StringBuffer(); lineBuffer.append(filePath); int lineLength = lineBuffer.length(); - // lineCreator.parseIdentifiers(buf.toString().toCharArray(), - // lineBuffer); lineCreator.parseIdentifiers(Util.getInputStreamAsCharArray(stream, -1, null), lineBuffer); - if (lineLength != lineBuffer.length()) { - addLine(lineBuffer.toString()); - } - } catch (IOException e) { - e.printStackTrace(); +// if (lineLength != lineBuffer.length()) { + // always add the file for Open Include Action + addLine(lineBuffer.toString()); +// } + } catch (IOException e) { + e.printStackTrace(); } finally { try { if (stream != null) { @@ -482,9 +470,9 @@ public class IdentifierIndexManager { } } } - if (tokenExists) { +// if (tokenExists) { fFileMap.put(phpFileName, line); - } +// } } /** * Change the information for a given IFile resource @@ -663,4 +651,22 @@ public class IdentifierIndexManager { public SortedMap getIdentifierMap() { return fIndentifierMap; } + + synchronized public List getFileList(String filePattern) { + Set set = fFileMap.keySet(); + if (set.isEmpty()) { + return null; + } + Iterator iter = set.iterator(); + ArrayList list = new ArrayList(); + String fileName; + int index; + while(iter.hasNext()) { + fileName = (String) iter.next(); + if ((index=fileName.indexOf(filePattern))!=-1 && fileName.length()==(index+filePattern.length())) { + list.add(fileName); + } + } + return list; + } } \ No newline at end of file