From c4288bb3bca4b5e5871a0243a19b8df9d9fd6124 Mon Sep 17 00:00:00 2001 From: Oleg Sukhodolsky Date: Mon, 1 Mar 2004 06:27:28 +0000 Subject: [PATCH] Moving intersects() method to TextComment interface.Minor javadoc changes in Comment.src/checkstyle/com/puppycrawl/tools/checkstyle/api/Comment.java --- .../tools/checkstyle/api/FileContents.java | 6 +++--- .../puppycrawl/tools/checkstyle/api/TextBlock.java | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/api/FileContents.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/api/FileContents.java index ac80bad1a..e6f0aecf6 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/api/FileContents.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/api/FileContents.java @@ -262,7 +262,7 @@ public final class FileContents implements CommentListener List row = (List) it.next(); Iterator rowIterator = row.iterator(); while (rowIterator.hasNext()) { - Comment comment = (Comment) rowIterator.next(); + TextBlock comment = (TextBlock) rowIterator.next(); if (comment.intersects( aStartLineNo, aStartColNo, aEndLineNo, aEndColNo)) { @@ -275,8 +275,8 @@ public final class FileContents implements CommentListener for (int lineNumber = aStartLineNo; lineNumber <= aEndLineNo; lineNumber++) { - Comment comment = (Comment) mCPlusPlusComments.get( - new Integer(lineNumber)); + TextBlock comment = + (TextBlock) mCPlusPlusComments.get(new Integer(lineNumber)); if (comment != null && comment.intersects(aStartLineNo, aStartColNo, aEndLineNo, aEndColNo)) { diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/api/TextBlock.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/api/TextBlock.java index 5b7e8fa92..39dc2cca7 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/api/TextBlock.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/api/TextBlock.java @@ -63,4 +63,16 @@ public interface TextBlock */ int getEndColNo(); + /** + * Checks if this comment intersects with a specified + * part of the file. + * + * @param aStartLineNo the starting line number in the file + * @param aStartColNo the starting column number in the file + * @param aEndLineNo the ending line number in the file + * @param aEndColNo the ending column number in the file + * @return true if the positions intersects with this comment. + */ + boolean intersects(int aStartLineNo, int aStartColNo, + int aEndLineNo, int aEndColNo); }