Copilot commented on code in PR #3718:
URL: 
https://github.com/apache/incubator-kie-tools/pull/3718#discussion_r3811743159


##########
packages/drools-lsp/drools-lsp-server/src/main/java/org/drools/lsp/server/DroolsLspDocumentService.java:
##########
@@ -178,7 +179,14 @@ public void didChange(DidChangeTextDocumentParams params) {
 
     public String getRuleName(CompletionParams completionParams) {
         String text = 
sourcesMap.get(completionParams.getTextDocument().getUri());
-        return DRLParserHelper.getFirstRuleName(text);
+        DRL10Parser parser = DRL10ParserHelper.createDrlParser(text);
+        DRL10Parser.CompilationUnitContext compilationUnitContext = 
parser.compilationUnit();
+        return compilationUnitContext.drlStatementdef()
+                .stream()
+                .filter(def -> def.ruledef() != null)
+                .map(def -> def.ruledef().name.getText())
+                .findFirst()
+                .orElse("");

Review Comment:
   The first-rule-name extraction logic was previously centralized in 
`DRLParserHelper.getFirstRuleName(...)`, but is now inlined here. To avoid 
duplication (and make future parser migrations easier), consider reintroducing 
a small local utility method/class in this repo (or using an equivalent 
upstream helper if available) and call it from here.



##########
packages/drools-lsp/drools-completion/pom.xml:
##########
@@ -35,9 +35,8 @@
 
   <dependencies>
     <dependency>
-      <groupId>org.kie.tools</groupId>
-      <artifactId>drools-parser</artifactId>
-      <version>${project.version}</version>
+      <groupId>org.drools</groupId>
+      <artifactId>drools-drl-parser</artifactId>
     </dependency>

Review Comment:
   This dependency no longer declares a `<version>`. Maven builds will fail 
unless `org.drools:drools-drl-parser` is provided via `<dependencyManagement>` 
(e.g., a BOM imported by the parent). If it isn’t managed, add an explicit 
version property (ideally centralized in the parent) to make the build 
deterministic.



-- 
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