-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add code action to generate RelaxNG grammar
Signed-off-by: Jessica He <jhe@redhat.com>
- Loading branch information
1 parent
5db338d
commit 92a0eec
Showing
7 changed files
with
1,126 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...articipants/codeactions/nogrammarconstraints/GenerateRelaxNGSchemaCodeActionResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.lemminx.extensions.contentmodel.participants.codeactions.nogrammarconstraints; | ||
|
||
import static org.eclipse.lemminx.extensions.contentmodel.participants.codeactions.nogrammarconstraints.NoGrammarConstraintsCodeAction.createXmlModelEdit; | ||
|
||
import org.eclipse.lemminx.commons.BadLocationException; | ||
import org.eclipse.lemminx.dom.DOMDocument; | ||
import org.eclipse.lemminx.extensions.generators.FileContentGeneratorSettings; | ||
import org.eclipse.lemminx.extensions.generators.xml2relaxng.RelaxNGGeneratorSettings; | ||
import org.eclipse.lemminx.settings.SharedSettings; | ||
import org.eclipse.lsp4j.TextDocumentEdit; | ||
|
||
/** | ||
* Code action resolver participant used to: | ||
* | ||
* <ul> | ||
* <li>generate the RelaxNG file for the given DOM document</li> | ||
* <li>generate the association relaxng in the XML to bind it with the | ||
* generated RelaxNG schema</li> | ||
* | ||
* </ul> | ||
* | ||
*/ | ||
public class GenerateRelaxNGSchemaCodeActionResolver extends AbstractGenerateGrammarAndAssociationResolveCodeActionParticipant { | ||
|
||
public static final String PARTICIPANT_ID = GenerateRelaxNGSchemaCodeActionResolver.class.getName(); | ||
|
||
@Override | ||
protected TextDocumentEdit createFileEdit(String grammarFileName, DOMDocument document, | ||
SharedSettings sharedSettings) throws BadLocationException { | ||
return createXmlModelEdit(grammarFileName, null, document, sharedSettings); | ||
} | ||
|
||
@Override | ||
protected FileContentGeneratorSettings getFileContentGeneratorSettings() { | ||
return new RelaxNGGeneratorSettings(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
.../java/org/eclipse/lemminx/extensions/generators/xml2relaxng/RelaxNGGeneratorSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.lemminx.extensions.generators.xml2relaxng; | ||
|
||
import org.eclipse.lemminx.extensions.generators.FileContentGeneratorSettings; | ||
|
||
/** | ||
* RelaxNG generator settings | ||
* | ||
*/ | ||
public class RelaxNGGeneratorSettings extends FileContentGeneratorSettings { | ||
|
||
} |
Oops, something went wrong.