summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorcremet <cremet@epfl.ch>2004-01-15 14:56:31 +0000
committercremet <cremet@epfl.ch>2004-01-15 14:56:31 +0000
commit08ab698c371a7cf5e0621c3c2d9c882721d79aa8 (patch)
treed2189af78e1e73e4a4e891a2a6e064c1d2b267c0 /sources
parent2d4a2223b17ae7140395939a78837f0d9bfe66de (diff)
downloadscala-08ab698c371a7cf5e0621c3c2d9c882721d79aa8.tar.gz
scala-08ab698c371a7cf5e0621c3c2d9c882721d79aa8.tar.bz2
scala-08ab698c371a7cf5e0621c3c2d9c882721d79aa8.zip
- Fixed the parsing of comments so that leading...
- Fixed the parsing of comments so that leading white spaces are not discarded (see bug 258).
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/tools/scaladoc/Comment.java46
1 files changed, 21 insertions, 25 deletions
diff --git a/sources/scala/tools/scaladoc/Comment.java b/sources/scala/tools/scaladoc/Comment.java
index 85eaf739ce..fc76d8438e 100644
--- a/sources/scala/tools/scaladoc/Comment.java
+++ b/sources/scala/tools/scaladoc/Comment.java
@@ -64,31 +64,26 @@ public class Comment {
*
* @param comment
*/
- protected String cleanComment(String comment) {
- if (comment == null)
+ public static String cleanComment(String s) {
+ if (s == null)
return "";
- else {
- comment = comment.substring(3, comment.length() - 2);
- StringBuffer buff = new StringBuffer();
- boolean startLine = true;
- int i = 0;
- while (i < comment.length()) {
- char ch = comment.charAt(i);
- if (startLine && ((ch == '\t') ||
- (ch == ' ') ||
- (ch == '*')))
- i++;
- else if (startLine)
- startLine = false;
- else {
- if ((ch == '\n') || (ch == '\r'))
- startLine = true;
- buff.append(ch);
- i++;
- }
- }
- return buff.toString();
- }
+ s = s.substring(3, s.length() - 2);
+ StringBuffer buf = new StringBuffer();
+ String regexp = "^([ \\t]*)([\\*]*)(.*)$";
+ Pattern p = Pattern.compile(regexp,
+ Pattern.MULTILINE);
+ Matcher m = p.matcher(s);
+
+ while (m.find()) {
+ if (m.group(2).length() == 0)
+ buf.append(m.group(1) +
+ m.group(2) +
+ m.group(3));
+ else
+ buf.append(m.group(3));
+ buf.append("\n");
+ }
+ return buf.toString();
}
/**
@@ -96,7 +91,8 @@ public class Comment {
* text from tags.
*/
protected void parseComment() {
- String[] parts = rawText.split("\n@|\\A@");
+ String regexp = "\n[ ]*@|\\A[ ]*@";
+ String[] parts = rawText.split(regexp);
if (parts.length == 0) {
text = "";
tags = new Tag[0];