Skip to content

Commit

Permalink
Move the version regex to VersionHoverProvider
Browse files Browse the repository at this point in the history
as it makes more sense to exist there
  • Loading branch information
Shresht7 committed Jan 1, 2024
1 parent c0e9487 commit 9dca9ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 0 additions & 3 deletions src/library/bg3/Version.ts
Expand Up @@ -18,9 +18,6 @@ export class Version {
/** Build Number */
private build: number = 0;

/** Regular expression to match the version line in `meta.lsx` */
public static readonly lsxRegex = /<attribute\s+id="Version64"\s+type="int64"\s+value="(\d+)"\/>/;

/** Parse the Version number */
constructor(x: bigint);
constructor(x: string);
Expand Down
7 changes: 5 additions & 2 deletions src/providers/hover/version.ts
Expand Up @@ -13,6 +13,9 @@ import { HoverProvider } from './_base';
*/
export class VersionHoverProvider extends HoverProvider {

/** Regular expression to match the version line in `meta.lsx` */
public static readonly versionRegex = /<attribute\s+id="Version64"\s+type="int64"\s+value="(\d+)"\/>/;

/** A selector that defines the documents this provider is applicable to */
private static readonly documentSelector = ['xml'];

Expand All @@ -26,10 +29,10 @@ export class VersionHoverProvider extends HoverProvider {
// Get the line that is currently being hovered over
const line = document.lineAt(position.line);
// Check if the line matches the version number regex
if (!bg3.Version.lsxRegex.test(line.text)) { return; };
if (!VersionHoverProvider.versionRegex.test(line.text)) { return; };

// Capture the int64 version number from the line and parse as BigInt
const capture = bg3.Version.lsxRegex.exec(line.text)?.at(1) || '0';
const capture = VersionHoverProvider.versionRegex.exec(line.text)?.at(1) || '0';
const bigIntVersion = BigInt(capture);

// Get the word that is being currently hovered over
Expand Down

0 comments on commit 9dca9ac

Please sign in to comment.