Package org.eclipse.lemminx.extensions.contentmodel.commands

## Class AssociateGrammarCommand

- java.lang.Object
- - org.eclipse.lemminx.services.extensions.commands.AbstractDOMDocumentCommandHandler
  - - org.eclipse.lemminx.extensions.contentmodel.commands.AssociateGrammarCommand

All Implemented Interfaces:
  `IXMLCommandService.IDelegateCommandHandler`

    public class AssociateGrammarCommand
    extends AbstractDOMDocumentCommandHandler

XML Command "xml.associate.grammar.insert" to associate a grammar to a given DOM document. The command parameters `ExecuteCommandParams` must be filled with 3 parameters:

- document URI (String) : the DOM document file URI to bind with a grammar.
- grammar URI (String) : the XSD, DTD file URI to bind with the DOM document.
- binding type (String) : which can takes values "standard", "xml-model" to know which binding type must be inserted in the DOM document.

Author:
  Angelo ZERR

### Nested Class Summary

Nested Classes
`static class` `AssociateGrammarCommand.GrammarBindingType`
`static class` `AssociateGrammarCommand.UnknownBindingTypeException`

### Field Summary

Fields
`static String` `COMMAND_ID`

### Constructor Summary

Constructors
`AssociateGrammarCommand​(IXMLDocumentProvider documentProvider)`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected Object` `executeCommand​(DOMDocument document, org.eclipse.lsp4j.ExecuteCommandParams params, SharedSettings sharedSettings, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker)` Executes a command

### Methods inherited from class org.eclipse.lemminx.services.extensions.commands.AbstractDOMDocumentCommandHandler

`executeCommand`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### COMMAND_ID

    public static final String COMMAND_ID

See Also:
  Constant Field Values

### Constructor Detail

#### AssociateGrammarCommand

    public AssociateGrammarCommand​(IXMLDocumentProvider documentProvider)

### Method Detail

#### executeCommand

    protected Object executeCommand​(DOMDocument document,
                                    org.eclipse.lsp4j.ExecuteCommandParams params,
                                    SharedSettings sharedSettings,
                                    org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker)
                             throws Exception

Description copied from class: `AbstractDOMDocumentCommandHandler`
Executes a command

Specified by:
  `executeCommand` in class `AbstractDOMDocumentCommandHandler`
Parameters:
  `document` - the DOM document retrieve by the `TextDocumentIdentifier` argument.
  `params` - command execution parameters
  `sharedSettings` - the shared settings
  `cancelChecker` - check if cancel has been requested
Returns:
  the result of the command
Throws:
  `Exception` - the unhandled exception will be wrapped in `org.eclipse.lsp4j.jsonrpc.ResponseErrorException` and be wired back to the JSON-RPC protocol caller