jhaabhijeet864 commented on code in PR #4083:
URL: 
https://github.com/apache/incubator-kie-tools/pull/4083#discussion_r4619036253


##########
packages/drools-lsp/drools-completion/src/main/java/org/drools/completion/DRLLintSuppression.java:
##########
@@ -0,0 +1,391 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.drools.completion;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.lsp4j.Diagnostic;
+
+/**
+ * Parses in-source linter suppression directives under the {@code 
@drl-lsp-lint}
+ * namespace and filters out suppressed diagnostics.
+ *
+ * <p>Supported directives:
+ * <ul>
+ *   <li>{@code @drl-lsp-lint:disable-file [code, ...]} &mdash; suppresses 
matching codes (or all codes) for the entire file</li>
+ *   <li>{@code @drl-lsp-lint:disable-line [code, ...]} &mdash; suppresses 
matching codes on the current line</li>
+ *   <li>{@code @drl-lsp-lint:disable-next-line [code, ...]} &mdash; 
suppresses matching codes on the line immediately following</li>
+ *   <li>{@code @drl-lsp-lint:disable-rule [code, ...]} &mdash; suppresses 
matching codes for the entire enclosing or following rule</li>
+ *   <li>{@code @drl-lsp-lint:disable [code, ...]} &mdash; starts a 
suppression region from this line downwards</li>
+ *   <li>{@code @drl-lsp-lint:enable [code, ...]} &mdash; ends a suppression 
region from this line downwards</li>
+ * </ul>
+ *
+ * <p>Directives apply strictly to {@code drools-lint} and {@code drools-type}
+ * diagnostics. Parser/syntax errors ({@code drools-drl-parser}) and compiler
+ * diagnostics ({@code drools}) are never suppressed.
+ */
+public final class DRLLintSuppression {
+
+    private static final Pattern DIRECTIVE_PATTERN = Pattern.compile(
+            
"(?i)@drl-lsp-lint:(disable-file|disable-next-line|disable-line|disable-rule|disable|enable)\\b");

Review Comment:
   Great point about \b matching before -. I'll update the regex to enforce a 
non-hyphen boundary (e.g. (?<![\w-]) / looking ahead for whitespace, colon, or 
end) so typos like disable-lines aren't truncated into disable. I'll also add 
validation that reports diagnostics for unrecognized actions and unknown codes 
instead of failing silently.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to