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;
/**
private Scanner fScanner;
private int fToken;
public LineCreator() {
- fScanner = new Scanner(true, false, false, false, true);
+ fScanner = new Scanner(true, false, false, false, true, null, null);
}
/**
* Add the information of the current identifier to the line
return;
} catch (InvalidInputException e) {
// ignore errors
- e.printStackTrace();
+// e.printStackTrace();
}
fToken = TokenNameERROR;
}
e.printStackTrace();
}
}
- public void parseIdentifiers(char[] charArray, StringBuffer buf) {
+ synchronized public void parseIdentifiers(char[] charArray, StringBuffer buf) {
char[] ident;
String identifier;
int counter = 0;
// 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
* @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) {
}
}
}
- if (tokenExists) {
+// if (tokenExists) {
fFileMap.put(phpFileName, line);
- }
+// }
}
/**
* Change the information for a given IFile resource
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