Class MSG_CONTENT_INVALIDCodeAction

java.lang.Object
org.eclipse.lemminx.extensions.contentmodel.participants.codeactions.MSG_CONTENT_INVALIDCodeAction
All Implemented Interfaces:
ICodeActionParticipant

public class MSG_CONTENT_INVALIDCodeAction extends Object implements ICodeActionParticipant
Code action for MSG_CONTENT_INVALID.

The error indicates that the children of an element don't match the expected content model. This code action proposes:

  • Removing child elements not allowed by the content model
  • Replacing child elements with similarly-named expected elements (typos like <headign> → <heading>)
  • Reordering child elements when all are valid but in wrong order
  • Inserting missing required child elements
 <!ELEMENT note (to,from,heading,body)>

 <!-- Remove undeclared element -->
 <note>
   <to>Tove</to>
   <XXX>undeclared</XXX>  ← "Remove element 'XXX'"
   <from>Jani</from>
 </note>

 <!-- Reorder elements -->
 <note>
   <from>Jani</from>     ← wrong order
   <to>Tove</to>         ← "Reorder child elements"
   <heading>...</heading>
   <body>...</body>
 </note>

 <!-- Insert missing element -->
 <note>
   <to>Tove</to>
   <heading>...</heading>  ← <from> missing → "Insert missing element 'from'"
   <body>...</body>
 </note>
 
  • Constructor Details

    • MSG_CONTENT_INVALIDCodeAction

      public MSG_CONTENT_INVALIDCodeAction()
  • Method Details

    • doCodeAction

      public void doCodeAction(ICodeActionRequest request, List<org.eclipse.lsp4j.CodeAction> codeActions, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker)
      Description copied from interface: ICodeActionParticipant
      Collect the code action in the given codeActions for the given code action request request.
      Specified by:
      doCodeAction in interface ICodeActionParticipant
      Parameters:
      request - the code action request.
      codeActions - list of code actions to fill.
      cancelChecker - the cancel checker.