in convert/src/convert/CategorizeLicenses.java [188:223]
public static Description snipLicenseBundle(String code, String firstLinePattern, String commentMarker, CommentType commentType) {
StringBuilder res = new StringBuilder();
boolean firstLine = true;
int start = -1;
int pos;
int next = 0;
int end = 0;
String[] lines = code.split("\n");
for (int i = 0; i < lines.length; i++) {
String line = lines[i];
pos = next;
next += line.length() + ((i + 1) < lines.length ? 1 : 0);
line = line.trim();
if (firstLine && firstLinePattern != null && Pattern.compile(firstLinePattern).matcher(line).matches())
continue;
if (firstLine && line.trim().isEmpty())
continue;
if (line.startsWith(commentMarker)) {
String part = line.substring(commentMarker.length()).trim();
if (firstLine && part.isEmpty())
continue;
if (firstLine) {
start = pos;
}
firstLine = false;
res.append(part);
res.append("\n");
if (!part.isEmpty()) {
end = next;
}
} else {
return createUnifiedDescriptionOrNull(start, end, res.toString(), commentType);
}
}
return createUnifiedDescriptionOrNull(start, end, res.toString(), commentType);
}