Skip to content

Commit

Permalink
Allow globs in xml.javaExtensions
Browse files Browse the repository at this point in the history
Paths supplied to `xml.javaExtensions` will be treated as globs.

Signed-off-by: David Thompson <[email protected]>
  • Loading branch information
datho7561 committed Sep 11, 2020
1 parent ee541b3 commit d4cd6e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,24 @@ To do that:

```json
"contributes": {
"xml.javaExtensions": [
"./jar/your-custom-xml-extension.jar"
]
"xml.javaExtensions": [
"./jar/your-custom-xml-extension.jar"
]
}
```

* You can also list multiple jars or use glob patterns to specify the jars:

```json
"contributes": {
"xml.javaExtensions": [
"./jar/dependencies/*.jar",
"./jar/my-xml-extension.jar"
]
}
```


You can see the [vscode-xml-maven](https://github.com/angelozerr/vscode-xml-maven) sample which registers custom maven completion [MavenCompletionParticipant](https://github.com/angelozerr/lsp4xml-extensions-maven/blob/master/org.eclipse.lsp4xml.extensions.maven/src/main/java/org/eclipse/lsp4xml/extensions/maven/MavenCompletionParticipant.java#L28) for scope:

![VScode XML Maven](images/vscode-xml-maven.gif)
Expand Down
3 changes: 2 additions & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as vscode from 'vscode';
import * as path from 'path';
import { Commands } from './commands';
const glob = require('glob');

let existingExtensions: Array<string>;

Expand All @@ -15,7 +16,7 @@ export function collectXmlJavaExtensions(extensions: readonly vscode.Extension<a
const xmlJavaExtensions = contributesSection['xml.javaExtensions'];
if (Array.isArray(xmlJavaExtensions) && xmlJavaExtensions.length) {
for (const xmLJavaExtensionPath of xmlJavaExtensions) {
result.push(path.resolve(extension.extensionPath, xmLJavaExtensionPath));
result.push(...glob.sync(path.resolve(extension.extensionPath, xmLJavaExtensionPath)));
}
}
}
Expand Down

0 comments on commit d4cd6e1

Please sign in to comment.