private Scanner fScanner;
private int fToken;
public LineCreator() {
- fScanner = new Scanner(true, false);
+ 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();
}
fToken = TokenNameERROR;
}
}
}
}
- } else if ((fToken == TokenNameLBRACE)
- || (fToken == TokenNameDOLLAR_LBRACE)) {
+ } else if (fToken == TokenNameLBRACE) {
getNextToken();
counter++;
} else if (fToken == TokenNameRBRACE) {
fToken = TokenNameEOF;
getNextToken();
try {
- while (fToken != TokenNameEOF && fToken != TokenNameERROR) {
+ while (fToken != TokenNameEOF) { // && fToken != TokenNameERROR) {
phpdocOffset = -1;
if (fToken == TokenNameCOMMENT_PHPDOC) {
phpdocOffset = fScanner.getCurrentTokenStartPosition();
}
return true;
}
+ public LineCreator createLineCreator() {
+ return new LineCreator();
+ }
/**
* Add the information for a given IFile resource
*
*/
public void addFile(IFile fileToParse) {
// InputStream iStream;
- LineCreator lineCreator = new LineCreator();
+ LineCreator lineCreator = createLineCreator();
try {
// iStream = fileToParse.getContents();
//
// } catch (IOException e) {
// return;
// }
- InputStream stream = null;
+
+ addInputStream(new BufferedInputStream(fileToParse.getContents()), fileToParse.getFullPath().toString(), lineCreator);
+ } catch (CoreException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+ /**
+ * @param fileToParse
+ * @param lineCreator
+ * @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();
+ } finally {
try {
- stream = new BufferedInputStream(fileToParse.getContents());
- StringBuffer lineBuffer = new StringBuffer();
- lineBuffer.append(fileToParse.getFullPath().toString());
- 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());
+ if (stream != null) {
+ stream.close();
}
} catch (IOException e) {
- return;
- } finally {
- try {
- if (stream != null) {
- stream.close();
- }
- } catch (IOException e) {
- }
}
- } catch (CoreException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
}
}
/**