JeremyYao opened a new issue, #1318:
URL: https://github.com/apache/daffodil-vscode/issues/1318

   ### Description
   In `testDfdlMixedLineFormats.dfdl.xsd`, there seems to be inconsistent 
attribute suggestions
   
   
![Image](https://github.com/user-attachments/assets/b4d6201b-4de6-4566-9781-91a8536b6356)
   
   
![Image](https://github.com/user-attachments/assets/5ea6b245-5eba-4e0b-a347-21a244a35d54)
   
   From the second screenshot, when I accept 
   
   
![Image](https://github.com/user-attachments/assets/84654892-590a-4b77-a356-c2d03802502b)
   
   it seems to insert a new element
   
   
![Image](https://github.com/user-attachments/assets/4f117906-b710-4a4a-a090-404f6a9eb0f1)
   
   ### Code behavior
   
   For the 4 element insertion suggestions, it doesn't seem to hit 
   
   ``` Typescript
   export function getAttributeCompletionProvider() {
     return vscode.languages.registerCompletionItemProvider(
       { language: 'dfdl' },
       {
         provideCompletionItems(
           document: vscode.TextDocument,
           position: vscode.Position
         ) {
           const triggerText = document
             .lineAt(position)
             .text.substring(0, position.character)
           const charBeforeTrigger = triggerText.charAt(position.character - 1)
           const charAfterTrigger = triggerText.charAt(position.character)
           let xmlItem = new XmlItem()
           xmlItem = nearestOpen(document, position)
           let nearestOpenItem = xmlItem.itemName
           let itemsOnLine = getItemsOnLineCount(triggerText)
           const nsPrefix = xmlItem.itemNS
           let additionalItems = getDefinedTypes(
             document,
             getSchemaNsPrefix(document)
           )
   
           if (isInXPath(document, position)) return undefined
   
           if (
             checkBraceOpen(document, position) ||
             cursorWithinBraces(document, position) ||
             cursorWithinQuotes(document, position) ||
             cursorAfterEquals(document, position) ||
             nearestOpenItem.includes('none')
           ) {
             return undefined
           }
           let preVal =
             !triggerText.includes('<' + nsPrefix + nearestOpenItem) &&
             lineCount(document, position, nearestOpenItem) === 1 &&
             itemsOnLine < 2
               ? '\t'
               : ''
   
           return checkNearestOpenItem(
             nearestOpenItem,
             triggerText,
             nsPrefix,
             preVal,
             additionalItems,
             charBeforeTrigger,
             charAfterTrigger
           )
         },
       },
       ' ',
       '\n' // triggered whenever a newline is typed
     )
   }
   ``` 
   
   in attributeCompletion.ts which handles attribute completion.
   
   It appears that there's no code logic to read the entire XML element and 
that it suggests the attribute suggestions if the line contains an XML opening 
(note triggerText)
   
   
![Image](https://github.com/user-attachments/assets/1c634eed-060e-4d1e-99b7-e9f1d0e4ad08)
   
   
![Image](https://github.com/user-attachments/assets/0f000b63-6753-4948-8bcb-0ccce905aacc)
   
   ### Fix Criteria
   
   Attributes for suggestions should work uniformly for mult-line XML elements 
and single-line ones. 


-- 
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: commits-unsubscr...@daffodil.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to