-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Contribute to completion, hover .. with external JAR
Fixes #190 Signed-off-by: azerr <[email protected]>
- Loading branch information
1 parent
cf8674b
commit 06fa6f0
Showing
8 changed files
with
934 additions
and
1,187 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"title": "XML Language server contributions to package.json", | ||
"type": "object", | ||
"properties": { | ||
"contributes": { | ||
"type": "object", | ||
"properties": { | ||
"xml.javaExtensions": { | ||
"type": "array", | ||
"markdownDescription": "XML language server extensions", | ||
"items": { | ||
"type": "string", | ||
"description": "Relative path to a XML language server extension JAR file" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
'use strict'; | ||
|
||
import * as vscode from 'vscode'; | ||
import * as path from 'path'; | ||
import { Commands } from './commands'; | ||
|
||
let existingExtensions: Array<string>; | ||
|
||
export function collectXmlJavaExtensions(extensions: readonly vscode.Extension<any>[]): string[] { | ||
const result = []; | ||
if (extensions && extensions.length) { | ||
for (const extension of extensions) { | ||
const contributesSection = extension.packageJSON['contributes']; | ||
if (contributesSection) { | ||
const xmlJavaExtensions = contributesSection['xml.javaExtensions']; | ||
if (Array.isArray(xmlJavaExtensions) && xmlJavaExtensions.length) { | ||
for (const xmLJavaExtensionPath of xmlJavaExtensions) { | ||
result.push(path.resolve(extension.extensionPath, xmLJavaExtensionPath)); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
// Make a copy of extensions: | ||
existingExtensions = result.slice(); | ||
return result; | ||
} | ||
|
||
export function onExtensionChange(extensions: readonly vscode.Extension<any>[]) { | ||
if (!existingExtensions) { | ||
return; | ||
} | ||
const oldExtensions = new Set(existingExtensions.slice()); | ||
const newExtensions = collectXmlJavaExtensions(extensions); | ||
let hasChanged = ( oldExtensions.size !== newExtensions.length); | ||
if (!hasChanged) { | ||
for (const newExtension of newExtensions) { | ||
if (!oldExtensions.has(newExtension)) { | ||
hasChanged = true; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
if (hasChanged) { | ||
const msg = `Extensions to the XML Language Server changed, reloading ${vscode.env.appName} is required for the changes to take effect.`; | ||
const action = 'Reload'; | ||
const restartId = Commands.RELOAD_WINDOW; | ||
vscode.window.showWarningMessage(msg, action).then((selection) => { | ||
if (action === selection) { | ||
vscode.commands.executeCommand(restartId); | ||
} | ||
}); | ||
} | ||
} |
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