You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2022/10/27 22:48:54 UTC

[royale-compiler] 07/09: linter: LineCommentPositionRule fixes

This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 4dafdbcef3fec05a2000c564cf881ec20045e412
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Oct 27 15:08:03 2022 -0700

    linter: LineCommentPositionRule fixes
---
 .../royale/linter/rules/LineCommentPositionRule.java       | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/linter/src/main/java/org/apache/royale/linter/rules/LineCommentPositionRule.java b/linter/src/main/java/org/apache/royale/linter/rules/LineCommentPositionRule.java
index 28d5e193b..04b448f16 100644
--- a/linter/src/main/java/org/apache/royale/linter/rules/LineCommentPositionRule.java
+++ b/linter/src/main/java/org/apache/royale/linter/rules/LineCommentPositionRule.java
@@ -51,18 +51,20 @@ public class LineCommentPositionRule extends LinterRule {
 
 	private void checkSingleLineComment(IASToken comment, TokenQuery tokenQuery, Collection<ICompilerProblem> problems) {
 		IASToken prevToken = tokenQuery.getSignificantTokenBefore(comment);
-		if (prevToken == null) {
-			return;
-		}
 		if (LineCommentPosition.ABOVE.equals(position)) {
+			if (prevToken == null) {
+				return;
+			}
 			if (prevToken.getLine() == comment.getLine()) {
-				// is beside the comment
+				// the comment is on the same line as a significant token
+				// (the comment should be on its own line)
 				problems.add(new LineCommentPositionLinterProblem(comment, position));
 			}
 		}
 		else if (LineCommentPosition.BESIDE.equals(position)) {
-			if (prevToken.getLine() != comment.getLine()) {
-				// is not beside the comment
+			if (prevToken == null || prevToken.getLine() != comment.getLine()) {
+				// the comment is not on the same line as a significant token
+				// it should not be on its own line
 				problems.add(new LineCommentPositionLinterProblem(comment, position));
 			}
 		}