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 2cc23169f950b925ea31a1267af61b432f8d616f Author: Josh Tynjala <joshtynj...@apache.org> AuthorDate: Mon Sep 26 09:02:22 2022 -0700 linter: fix linting not working in MXML scripts --- .../main/java/org/apache/royale/linter/ASLinter.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/linter/src/main/java/org/apache/royale/linter/ASLinter.java b/linter/src/main/java/org/apache/royale/linter/ASLinter.java index 17f403c38..2f1761658 100644 --- a/linter/src/main/java/org/apache/royale/linter/ASLinter.java +++ b/linter/src/main/java/org/apache/royale/linter/ASLinter.java @@ -180,6 +180,7 @@ public class ASLinter extends BaseLinter { private void visitNode(IASNode node, TokenQuery tokenQuery, Collection<ICompilerProblem> problems) { ASTNodeID nodeID = node.getNodeID(); IASToken prevComment = tokenQuery.getPreviousComment(node); + boolean linterOn = true; while (prevComment != null) { String commentText = null; if (prevComment.getType() == ASTokenTypes.HIDDEN_TOKEN_SINGLE_LINE_COMMENT) { @@ -193,22 +194,23 @@ public class ASLinter extends BaseLinter { continue; } if (LINTER_TAG_ON.equals(commentText)) { - // linter is on + linterOn = true; break; } if (LINTER_TAG_OFF.equals(commentText)) { - // linter is off - return; + linterOn = false; + break; } prevComment = tokenQuery.getPreviousComment(prevComment); } - for (LinterRule rule : settings.rules) { - Map<ASTNodeID, NodeVisitor> nodeHandlers = rule.getNodeVisitors(); - if (nodeHandlers != null && nodeHandlers.containsKey(nodeID)) { - nodeHandlers.get(nodeID).visit(node, tokenQuery, problems); + if (linterOn) { + for (LinterRule rule : settings.rules) { + Map<ASTNodeID, NodeVisitor> nodeHandlers = rule.getNodeVisitors(); + if (nodeHandlers != null && nodeHandlers.containsKey(nodeID)) { + nodeHandlers.get(nodeID).visit(node, tokenQuery, problems); + } } } - for (int i = 0; i < node.getChildCount(); i++) { IASNode child = node.getChild(i); visitNode(child, tokenQuery, problems);