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

thiagoelg pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new 8ff7759a76d kie-issues#2218: DMN Editor: The autocomplete dialog 
suggests the function "years and month duration" if cursor is after word 
"years" (#3399)
8ff7759a76d is described below

commit 8ff7759a76d130206b2bea7767159bf4bae1f2f5
Author: Daniel José dos Santos <[email protected]>
AuthorDate: Fri Jan 23 14:03:19 2026 -0300

    kie-issues#2218: DMN Editor: The autocomplete dialog suggests the function 
"years and month duration" if cursor is after word "years" (#3399)
    
    Co-authored-by: Copilot <[email protected]>
---
 .../src/parser/grammar/ParserHelper.ts             |  8 +++
 packages/feel-input-component/src/FeelInput.tsx    | 69 +++++++++++-----------
 2 files changed, 43 insertions(+), 34 deletions(-)

diff --git a/packages/dmn-feel-antlr4-parser/src/parser/grammar/ParserHelper.ts 
b/packages/dmn-feel-antlr4-parser/src/parser/grammar/ParserHelper.ts
index 09bc25acf03..ae914115bea 100644
--- a/packages/dmn-feel-antlr4-parser/src/parser/grammar/ParserHelper.ts
+++ b/packages/dmn-feel-antlr4-parser/src/parser/grammar/ParserHelper.ts
@@ -247,6 +247,14 @@ export class ParserHelper {
               variableName
             )
           );
+        } else if (qn.length > 1) {
+          // This is a special case, when we have something.ReservedWord.
+          // For example, a.time, being 'time' a reserved word for the 
function 'time()'.
+          // So, if it is a part of a qualified name, it must be a 
FeelSyntacticSymbolNature.Unknown.
+          // If it is not, then we just ignore because it must be a function 
call (time()).
+          this.variables.push(
+            new FeelIdentifiedSymbol(start, length, startLine, endLine, 
FeelSyntacticSymbolNature.Unknown, variableName)
+          );
         }
       } else {
         if (!ReservedWords.FeelFunctions.has(variableName) && 
!ReservedWords.FeelKeywords.has(variableName)) {
diff --git a/packages/feel-input-component/src/FeelInput.tsx 
b/packages/feel-input-component/src/FeelInput.tsx
index 10ca344a039..a1d7244cb69 100644
--- a/packages/feel-input-component/src/FeelInput.tsx
+++ b/packages/feel-input-component/src/FeelInput.tsx
@@ -29,7 +29,7 @@ import {
   MONACO_FEEL_THEME,
 } from "./FeelConfigs";
 
-import { FeelSyntacticSymbolNature, FeelIdentifiers, ParsedExpression } from 
"@kie-tools/dmn-feel-antlr4-parser";
+import { FeelIdentifiers, FeelSyntacticSymbolNature, ParsedExpression } from 
"@kie-tools/dmn-feel-antlr4-parser";
 import { SemanticTokensProvider } from "./semanticTokensProvider";
 
 export const EXPRESSION_PROPERTIES_SEPARATOR = ".";
@@ -209,41 +209,42 @@ export const FeelInput = React.forwardRef<FeelInputRef, 
FeelInputProps>(
               }
             } else {
               const currentSymbol = 
getSymbolAtPosition(currentParsedExpression, pos);
-              for (const scopeSymbol of 
currentParsedExpression.availableSymbols) {
-                // Consider this scenario:
-                // 1. User typed: Tax In
-                // 2. Available symbols: [Tax Incoming, Tax Input, Tax 
InSomethingElse, Tax Out, Tax Output]
-                // 3. "Tax In" is an invalid symbol (unrecognized symbol)
-                // In this case, we want to show all symbols that starts with 
"Tax In"
-                if (currentSymbol && 
scopeSymbol.name.startsWith(currentSymbol.text)) {
-                  variablesSuggestions.push({
-                    kind: Monaco.languages.CompletionItemKind.Variable,
-                    label: scopeSymbol.name,
-                    insertText: scopeSymbol.name,
-                    detail: scopeSymbol.type,
-                    sortText: "1", // We want the variables to be at top of 
autocomplete
-                    // We want to replace the current symbol with the 
available scopeSymbol (Tax Incoming, for example)
-                    // Note: Monaco is NOT zero-indexed. It starts with 1 but 
FEEL parser is zero indexed,
-                    // that's why were incrementing 1 at each position.
-                    range: {
-                      startLineNumber: currentSymbol.startLine + 1,
-                      endLineNumber: currentSymbol.endLine + 1,
-                      startColumn: currentSymbol.startIndex + 1,
-                      endColumn: currentSymbol.startIndex + 1 + 
scopeSymbol.name.length,
-                    },
-                  } as Monaco.languages.CompletionItem);
-                } else {
-                  variablesSuggestions.push({
-                    kind: Monaco.languages.CompletionItemKind.Variable,
-                    label: scopeSymbol.name,
-                    insertText: scopeSymbol.name,
-                    detail: scopeSymbol.type,
-                    sortText: "2", // The others variables at second level
-                  } as Monaco.languages.CompletionItem);
+              if (!currentSymbol || currentSymbol?.feelSymbolNature === 
FeelSyntacticSymbolNature.Unknown) {
+                for (const scopeSymbol of 
currentParsedExpression.availableSymbols) {
+                  // Consider this scenario:
+                  // 1. User typed: Tax In
+                  // 2. Available symbols: [Tax Incoming, Tax Input, Tax 
InSomethingElse, Tax Out, Tax Output]
+                  // 3. "Tax In" is an invalid symbol (unrecognized symbol)
+                  // In this case, we want to show all symbols that starts 
with "Tax In"
+                  if (currentSymbol && 
scopeSymbol.name.startsWith(currentSymbol.text)) {
+                    variablesSuggestions.push({
+                      kind: Monaco.languages.CompletionItemKind.Variable,
+                      label: scopeSymbol.name,
+                      insertText: scopeSymbol.name,
+                      detail: scopeSymbol.type,
+                      sortText: "1", // We want the variables to be at top of 
autocomplete
+                      // We want to replace the current symbol with the 
available scopeSymbol (Tax Incoming, for example)
+                      // Note: Monaco is NOT zero-indexed. It starts with 1 
but FEEL parser is zero indexed,
+                      // that's why were incrementing 1 at each position.
+                      range: {
+                        startLineNumber: currentSymbol.startLine + 1,
+                        endLineNumber: currentSymbol.endLine + 1,
+                        startColumn: currentSymbol.startIndex + 1,
+                        endColumn: currentSymbol.startIndex + 1 + 
scopeSymbol.name.length,
+                      },
+                    } as Monaco.languages.CompletionItem);
+                  } else {
+                    variablesSuggestions.push({
+                      kind: Monaco.languages.CompletionItemKind.Variable,
+                      label: scopeSymbol.name,
+                      insertText: scopeSymbol.name,
+                      detail: scopeSymbol.type,
+                      sortText: "2", // The others variables at second level
+                    } as Monaco.languages.CompletionItem);
+                  }
                 }
+                variablesSuggestions.push(...completionItems);
               }
-
-              variablesSuggestions.push(...completionItems);
             }
             return {
               suggestions: variablesSuggestions,


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

Reply via email to