*
* @return the comment string, or
* null if no comments were found
*/
private static String getCommentsBefore(Node node) {
Token token = getFirstToken(node);
ArrayList comments = new ArrayList();
StringBuffer buffer = new StringBuffer();
String res = "";
if (token != null) {
token = token.getPreviousToken();
}
while (token != null) {
if (token.getId() == Asn1Constants.WHITESPACE) {
comments.add(getLineBreaks(token.getImage()));
} else if (token.getId() == Asn1Constants.COMMENT &&
!commentTokens.containsKey(token)) {
commentTokens.put(token, null);
comments.add(token.getImage().substring(2).trim());
} else {
break;
}
token = token.getPreviousToken();
}
for (int i = comments.size() - 1; i >= 0; i--) {
buffer.append(comments.get(i));
}
res = buffer.toString().trim();