in maven-jxr/src/main/java/org/apache/maven/jxr/pacman/JavaFileImpl.java [75:144]
private void parseRecursive(String nestedPrefix, StreamTokenizer stok) throws IOException {
int openBracesCount = 0;
char prevttype = Character.MIN_VALUE; // previous token type
boolean inTripleQuote = false; // used to toggle between inside/outside triple-quoted multi-line strings
while (stok.nextToken() != StreamTokenizer.TT_EOF) {
if (stok.sval == null) {
if (stok.ttype == '{') {
openBracesCount++;
} else if (stok.ttype == '}') {
if (--openBracesCount == 0) {
// break out of recursive
return;
}
}
continue;
} else {
if ('"' == stok.ttype && '"' == prevttype) {
inTripleQuote = !inTripleQuote;
}
prevttype = (char) stok.ttype;
if (inTripleQuote) {
// skip content found inside triple-quoted multi-line Java 15 String
continue;
}
}
// set the package
if ("package".equals(stok.sval) && stok.ttype != '\"') {
stok.nextToken();
if (stok.sval != null) {
this.setPackageType(new PackageType(stok.sval));
}
}
// set the imports
if ("import".equals(stok.sval) && stok.ttype != '\"') {
stok.nextToken();
String name = stok.sval;
/*
WARNING: this is a bug/non-feature in the current
StreamTokenizer. We needed to set the comment char as "*"
and packages that are imported with this (ex "test.*") will be
stripped( and become "test." ). Here we need to test for this
and if necessary re-add the char.
*/
if (name != null) {
if (name.charAt(name.length() - 1) == '.') {
name = name + '*';
}
this.addImportType(new ImportType(name));
}
}
// Add the class or classes. There can be several classes in one file so
// continue with the while loop to get them all.
if (classTypes.contains(stok.sval) && stok.ttype != '"') {
stok.nextToken();
if (stok.sval != null) {
this.addClassType(
new ClassType(nestedPrefix + stok.sval, getFilenameWithoutPathOrExtension(this.getPath())));
parseRecursive(nestedPrefix + stok.sval + ".", stok);
}
}
}
}