Example #1
0
 public static void main(String[] arguments) {
   GuiUtilities.initLookAndFeel();
   for (String argument : arguments) {
     String text = StringUtilities.readFile(argument);
     new HtmlViewer(text).setVisible(true);
   }
 }
 // FIXME: assumes C-family multi-line comments.
 private boolean isUnclosedComment(
     CharSequence entireDocument, int insertionPosition, CharSequence lineToTheLeft) {
   if (Pattern.matches("[ \t]*/\\*{1,2}", lineToTheLeft)) {
     // We're on a line that starts a block comment, but is it unclosed?
     int nextOpenComment = StringUtilities.indexOf(entireDocument, "/*", insertionPosition);
     int nextCloseComment = StringUtilities.indexOf(entireDocument, "*/", insertionPosition);
     if (nextCloseComment == -1) {
       // If there are no close comments after this point, this one we're looking at must be
       // unclosed.
       return true;
     }
     if (nextOpenComment != -1 && nextOpenComment < nextCloseComment) {
       // If there's an open comment after this point, and no intervening close comment, the one
       // we're looking at must be unclosed.
       return true;
     }
   }
   return false;
 }