Skip to content

Commit

Permalink
Rename "processing instruction" snippet to "xml declaration"
Browse files Browse the repository at this point in the history
Fixes eclipse-lemminx#727

Signed-off-by: azerr <azerr@redhat.com>
  • Loading branch information
angelozerr authored and fbricon committed May 29, 2020
1 parent f2a90dd commit 3342ed0
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
import org.eclipse.lsp4j.Position;

/**
* Prolog snippet context used to filter the xml processing instructions
* snippets.
* Snippet context used to filter the XML declaration snippets.
*
*/
public class PrologSnippetContext implements IXMLSnippetContext {
public class XMLDeclarationSnippetContext implements IXMLSnippetContext {

public static IXMLSnippetContext DEFAULT_CONTEXT = new PrologSnippetContext();
public static IXMLSnippetContext DEFAULT_CONTEXT = new XMLDeclarationSnippetContext();

@Override
public boolean isMatch(ICompletionRequest request, Map<String, String> model) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public void load(SnippetRegistry registry) throws Exception {
CommentSnippetContext.DEFAULT_CONTEXT);
registry.registerSnippets(XMLSnippetRegistryLoader.class.getResourceAsStream("doctype-snippets.json"),
DocTypeSnippetContext.DEFAULT_CONTEXT);
registry.registerSnippets(XMLSnippetRegistryLoader.class.getResourceAsStream("prolog-snippets.json"),
PrologSnippetContext.DEFAULT_CONTEXT);
registry.registerSnippets(XMLSnippetRegistryLoader.class.getResourceAsStream("xml-declaration-snippets.json"),
XMLDeclarationSnippetContext.DEFAULT_CONTEXT);
registry.registerSnippets(XMLSnippetRegistryLoader.class.getResourceAsStream("dtdnode-snippets.json"),
DTDNodeSnippetContext.DEFAULT_CONTEXT);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Insert xml Processing Instruction": {
"Insert XML Declaration": {
"prefix": [
"<?xml"
],
Expand All @@ -8,9 +8,9 @@
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}"
],
"label": "$description",
"description": "Insert XML Processing Instruction"
"description": "Insert XML Declaration"
},
"Insert xml Processing Instruction with standalone": {
"Insert XML Declaration with standalone": {
"prefix": [
"<?xml"
],
Expand All @@ -19,6 +19,6 @@
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\" standalone=\"${3|yes,no|}\"?>${0}"
],
"label": "$description",
"description": "Insert XML Processing Instruction with standalone"
"description": "Insert XML Declaration with standalone"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public class XMLAssert {

public static final int NEW_XSD_SNIPPETS = 1;

public static final int PROLOG_SNIPPETS = 2;
public static final int XML_DECLARATION_SNIPPETS = 2;

public static final int REGION_SNIPPETS = 2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,17 @@ public void completionEncodingSingleQuotes() throws BadLocationException {
public void testAutoCompletionPrologWithXML() throws BadLocationException {
// With 'xml' label
testCompletionFor("<?xml|", true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 5), //
"<?xml"));
testCompletionFor("<?xml|>", true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 6), //
"<?xml"));
testCompletionFor("<?xml|?>", true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 7), //
"<?xml"));
Expand All @@ -202,22 +202,22 @@ public void testAutoCompletionPrologWithXML() throws BadLocationException {
public void testAutoCompletionPrologWithoutXML() throws BadLocationException {
// No 'xml' label
testCompletionFor("<?|", true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 2), //
"<?xml"));
testCompletionFor("<?|", false, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>", //
r(0, 0, 0, 2), //
"<?xml"));
testCompletionFor("<?|>", true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 3), //
"<?xml"));
testCompletionFor("<?|?>", true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 4), //
"<?xml"));
Expand All @@ -226,27 +226,27 @@ public void testAutoCompletionPrologWithoutXML() throws BadLocationException {
@Test
public void testAutoCompletionPrologWithPartialXML() throws BadLocationException {
testCompletionFor("<?x|", true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 3), //
"<?xml"));
testCompletionFor("<?xm|", true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 4), //
"<?xml"));
testCompletionFor("<?xml|", true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 5), //
"<?xml"));
testCompletionFor("<?xml|?", true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 6), //
"<?xml"));
testCompletionFor("<?xml|?>", true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 7), //
"<?xml"));
Expand All @@ -257,17 +257,17 @@ public void testAutoCompletionPrologDTDFileWithXML() throws BadLocationException
// With 'xml' label
String dtdFileURI = "test://test/test.dtd";
testCompletionFor("<?xml|", dtdFileURI, true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 5), //
"<?xml"));
testCompletionFor("<?xml|>", dtdFileURI, true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 6), //
"<?xml"));
testCompletionFor("<?xml|?>", dtdFileURI, true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 7), //
"<?xml"));
Expand All @@ -278,22 +278,22 @@ public void testAutoCompletionPrologDTDFileWithoutXML() throws BadLocationExcept
// No 'xml' label
String dtdFileURI = "test://test/test.dtd";
testCompletionFor("<?|", dtdFileURI, true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 2), //
"<?xml"));
testCompletionFor("<?|", dtdFileURI, false, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>", //
r(0, 0, 0, 2), //
"<?xml"));
testCompletionFor("<?|>", dtdFileURI, true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 3), //
"<?xml"));
testCompletionFor("<?|?>", dtdFileURI, true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 4), //
"<?xml"));
Expand All @@ -303,27 +303,27 @@ public void testAutoCompletionPrologDTDFileWithoutXML() throws BadLocationExcept
public void testAutoCompletionPrologDTFFileWithPartialXML() throws BadLocationException {
String dtdFileURI = "test://test/test.dtd";
testCompletionFor("<?x|", dtdFileURI, true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 3), //
"<?xml"));
testCompletionFor("<?xm|", dtdFileURI, true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 4), //
"<?xml"));
testCompletionFor("<?xml|", dtdFileURI, true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 5), //
"<?xml"));
testCompletionFor("<?xml|?", dtdFileURI, true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 6), //
"<?xml"));
testCompletionFor("<?xml|?>", dtdFileURI, true, //
c("Insert XML Processing Instruction", //
c("Insert XML Declaration", //
"<?xml version=\"${1|1.0,1.1|}\" encoding=\"${2|UTF-8,ISO-8859-1,Windows-1251,Windows-1252,Shift JIS,GB2312,EUC-KR|}\"?>${0}", //
r(0, 0, 0, 7), //
"<?xml"));
Expand Down
Loading

0 comments on commit 3342ed0

Please sign in to comment.