-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from Shresht7:hover
Create `LocalizationHoverProvider`
- Loading branch information
Showing
32 changed files
with
741 additions
and
315 deletions.
There are no files selected for viewing
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
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 was deleted.
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,53 @@ | ||
// Library | ||
import * as vscode from 'vscode'; | ||
import { XMLBuilder, XMLParser, X2jOptions, XmlBuilderOptions } from "fast-xml-parser"; | ||
|
||
// -------------------- | ||
// XML HELPER FUNCTIONS | ||
// -------------------- | ||
|
||
// DEFAULT OPTIONS | ||
// --------------- | ||
|
||
/** Default options for the XML parser */ | ||
const defaultParserOptions: Partial<X2jOptions> = { | ||
ignoreAttributes: false, | ||
attributeNamePrefix: "", | ||
}; | ||
|
||
/** Default options for the XML builder */ | ||
const defaultBuilderOptions: Partial<XmlBuilderOptions> = { | ||
ignoreAttributes: false, | ||
attributeNamePrefix: "", | ||
}; | ||
|
||
/** | ||
* Reads the xml file at the given path and parses it as an object | ||
* @param path The path (vscode.Uri) of the xml file to read | ||
* @param options {@link X2jOptions} - (Default: {@link defaultParserOptions}) | ||
* @returns The parsed XML object | ||
*/ | ||
export async function read<T extends Record<string, any>>( | ||
path: vscode.Uri, | ||
options: Partial<X2jOptions> = defaultParserOptions | ||
): Promise<T> { | ||
const buf = await vscode.workspace.fs.readFile(path); | ||
const contents = Buffer.from(buf).toString('utf8'); | ||
return new XMLParser(options).parse(contents) as T; | ||
} | ||
|
||
/** | ||
* Builds and writes the object as xml to the given path | ||
* @param path The path (vscode.Uri) of the xml file to write to | ||
* @param obj The object to convert to xml | ||
* @param options {@link XmlBuilderOptions} - (Default: {@link defaultBuilderOptions}) | ||
*/ | ||
export async function write<T extends Record<string, any>>( | ||
path: vscode.Uri, | ||
obj: T, | ||
options: Partial<XmlBuilderOptions> = defaultBuilderOptions | ||
) { | ||
const contents = new XMLBuilder(options).build(obj); | ||
const buf = Buffer.from(contents, 'utf8'); | ||
return vscode.workspace.fs.writeFile(path, buf); | ||
} |
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,10 @@ | ||
// Library | ||
import { initializeLocalization } from './localization'; | ||
|
||
// ============ | ||
// INITIALIZERS | ||
// ============ | ||
|
||
export const initialize = { | ||
localization: initializeLocalization | ||
}; |
Oops, something went wrong.