Fix package manager issues causing builds not to succeed (#292)

* ci: try omitting yarn, vsce doesn't support yarnV2 (yet)

* ci: consolidate dependency updates

* lint: formatting
This commit is contained in:
Tyler Wilding 2023-07-12 22:03:50 -06:00 committed by GitHub
parent 73d7d111ba
commit fe1d7db6bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 519 additions and 511 deletions

View file

@ -8,3 +8,7 @@ updates:
directory: "/" directory: "/"
schedule: schedule:
interval: "weekly" interval: "weekly"
groups:
frontend-dependencies:
patterns:
- "*"

View file

@ -35,11 +35,12 @@ jobs:
- name: Bump Version - name: Bump Version
env: env:
VSCE_PAT: ${{ secrets.VSCE_PAT }} VSCE_PAT: ${{ secrets.VSCE_PAT }}
# TODO - https://github.com/microsoft/vscode-vsce/pull/876
run: | run: |
git config --global user.name "OpenGOALBot" git config --global user.name "OpenGOALBot"
git config --global user.email "OpenGOALBot@users.noreply.github.com" git config --global user.email "OpenGOALBot@users.noreply.github.com"
yarn vsce package yarn vsce package --no-yarn
yarn vsce publish ${{ github.event.inputs.bump }} yarn vsce publish ${{ github.event.inputs.bump }} --no-yarn
git push git push
git push origin $(git tag --points-at HEAD) git push origin $(git tag --points-at HEAD)

File diff suppressed because it is too large Load diff

View file

@ -75,7 +75,7 @@
mode + mode +
'" is invalid. ' + '" is invalid. ' +
"Must be one of: " + "Must be one of: " +
MODES.join(",") MODES.join(","),
); );
} }
} }
@ -85,7 +85,7 @@
if (!state) { if (!state) {
throw error( throw error(
"You must call parinferCodeMirror.init(cm) on a CodeMirror instance " + "You must call parinferCodeMirror.init(cm) on a CodeMirror instance " +
"before you can use the rest of the API." "before you can use the rest of the API.",
); );
} }
return state; return state;
@ -141,7 +141,7 @@
error.extra.lineNo, error.extra.lineNo,
error.extra.x, error.extra.x,
error.extra.x + 1, error.extra.x + 1,
CLASSNAME_ERROR CLASSNAME_ERROR,
); );
} }
} }
@ -158,7 +158,7 @@
trail.lineNo, trail.lineNo,
trail.startX, trail.startX,
trail.endX, trail.endX,
CLASSNAME_PARENTRAIL CLASSNAME_PARENTRAIL,
); );
} }
} }
@ -259,7 +259,7 @@
"", "",
{ line: lineNo, ch: x + delta }, { line: lineNo, ch: x + delta },
{ line: lineNo, ch: x }, { line: lineNo, ch: x },
"+indent" "+indent",
); );
} }
} }
@ -333,7 +333,7 @@
paren.closer.lineNo, paren.closer.lineNo,
paren.closer.x, paren.closer.x,
paren.closer.x + 1, paren.closer.x + 1,
CLASSNAME_LOCUS_PAREN CLASSNAME_LOCUS_PAREN,
); );
} }
hideParens(cm, paren.children); hideParens(cm, paren.children);
@ -389,7 +389,7 @@
switch (layer.type) { switch (layer.type) {
case "guides": case "guides":
paper.path( paper.path(
["M", open.midx, open.bottom, "V", close.bottom].join(" ") ["M", open.midx, open.bottom, "V", close.bottom].join(" "),
); );
break; break;
case "locus": case "locus":
@ -423,7 +423,7 @@
open.midx, open.midx,
"V", "V",
open.bottom, open.bottom,
].join(" ") ].join(" "),
); );
break; break;
} }

View file

@ -480,7 +480,7 @@
result.lineNo, result.lineNo,
result.x, result.x,
result.x + origCh.length, result.x + origCh.length,
ch ch,
); );
result.indentDelta -= origCh.length - ch.length; result.indentDelta -= origCh.length - ch.length;
} }
@ -849,7 +849,7 @@
cursorX, cursorX,
cursorLine, cursorLine,
result.parenTrail.startX, result.parenTrail.startX,
result.lineNo result.lineNo,
) && !isCursorInComment(result, cursorX, cursorLine) ) && !isCursorInComment(result, cursorX, cursorLine)
); );
} }
@ -862,7 +862,7 @@
var clamping = isCursorClampingParenTrail( var clamping = isCursorClampingParenTrail(
result, result,
result.cursorX, result.cursorX,
result.cursorLine result.cursorLine,
); );
if (clamping) { if (clamping) {
@ -1107,7 +1107,7 @@
opener, opener,
result.parenTrail.lineNo, result.parenTrail.lineNo,
result.parenTrail.startX + i, result.parenTrail.startX + i,
closeCh closeCh,
); );
} }
} }
@ -1118,7 +1118,7 @@
result.parenTrail.lineNo, result.parenTrail.lineNo,
result.parenTrail.startX, result.parenTrail.startX,
result.parenTrail.endX, result.parenTrail.endX,
parens parens,
); );
result.parenTrail.endX = result.parenTrail.startX + parens.length; result.parenTrail.endX = result.parenTrail.startX + parens.length;
rememberParenTrail(result); rememberParenTrail(result);
@ -1161,7 +1161,7 @@
opener, opener,
result.parenTrail.lineNo, result.parenTrail.lineNo,
result.parenTrail.endX, result.parenTrail.endX,
closeCh closeCh,
); );
} }
@ -1170,7 +1170,7 @@
result, result,
result.parenTrail.lineNo, result.parenTrail.lineNo,
result.parenTrail.endX, result.parenTrail.endX,
closeCh closeCh,
); );
result.parenTrail.endX++; result.parenTrail.endX++;
@ -1346,7 +1346,7 @@
result.cursorX, result.cursorX,
result.cursorLine, result.cursorLine,
result.x, result.x,
result.lineNo result.lineNo,
) )
) { ) {
resetParenTrail(result, result.lineNo, result.x); resetParenTrail(result, result.lineNo, result.x);

View file

@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
@ -24,7 +24,7 @@
<script src="./assets/parinfer-codemirror.js"></script> <script src="./assets/parinfer-codemirror.js"></script>
<script> <script>
var myCodeMirror = CodeMirror.fromTextArea( var myCodeMirror = CodeMirror.fromTextArea(
document.getElementById("code-indent") document.getElementById("code-indent"),
); );
parinferCodeMirror.init(myCodeMirror); parinferCodeMirror.init(myCodeMirror);
</script> </script>

View file

@ -13,7 +13,7 @@ export class RecentFiles {
if (editor?.document != undefined) { if (editor?.document != undefined) {
this.addFile(editor?.document.fileName); this.addFile(editor?.document.fileName);
} }
}) }),
); );
} }

View file

@ -19,15 +19,15 @@ export function getConfig() {
typeSearcherPath: configOptions.get<string>("typeSearcherPath"), typeSearcherPath: configOptions.get<string>("typeSearcherPath"),
jak1DecompConfigVersion: configOptions.get<string>( jak1DecompConfigVersion: configOptions.get<string>(
"decompilerJak1ConfigVersion", "decompilerJak1ConfigVersion",
"ntsc_v1" "ntsc_v1",
), ),
jak2DecompConfigVersion: configOptions.get<string>( jak2DecompConfigVersion: configOptions.get<string>(
"decompilerJak2ConfigVersion", "decompilerJak2ConfigVersion",
"ntsc_v1" "ntsc_v1",
), ),
colorsGoalGlobals: configOptions.get<string>("colors.goal.entity.global"), colorsGoalGlobals: configOptions.get<string>("colors.goal.entity.global"),
colorsGoalStorageControl: configOptions.get<string>( colorsGoalStorageControl: configOptions.get<string>(
"colors.goal.storage.control" "colors.goal.storage.control",
), ),
colorsGoalSymbols: configOptions.get<string>("colors.goal.symbol"), colorsGoalSymbols: configOptions.get<string>("colors.goal.symbol"),
colorsIRTypeAnalysis: configOptions.get<string>("colors.ir.typeanalysis"), colorsIRTypeAnalysis: configOptions.get<string>("colors.ir.typeanalysis"),
@ -56,7 +56,7 @@ export async function updateEeManPagePath(path: string) {
await userConfig.update( await userConfig.update(
"opengoal.eeManPagePath", "opengoal.eeManPagePath",
path, path,
vscode.ConfigurationTarget.Global vscode.ConfigurationTarget.Global,
); );
} }
@ -65,7 +65,7 @@ export async function updateVuManPagePath(path: string) {
await userConfig.update( await userConfig.update(
"opengoal.vuManPagePath", "opengoal.vuManPagePath",
path, path,
vscode.ConfigurationTarget.Global vscode.ConfigurationTarget.Global,
); );
} }
@ -74,7 +74,7 @@ export async function updateDecompilerPath(path: string) {
await userConfig.update( await userConfig.update(
"opengoal.decompilerPath", "opengoal.decompilerPath",
path, path,
vscode.ConfigurationTarget.Global vscode.ConfigurationTarget.Global,
); );
} }
@ -83,7 +83,7 @@ export async function updateTypeSearcherPath(path: string) {
await userConfig.update( await userConfig.update(
"opengoal.typeSearcherPath", "opengoal.typeSearcherPath",
path, path,
vscode.ConfigurationTarget.Global vscode.ConfigurationTarget.Global,
); );
} }
@ -92,6 +92,6 @@ export async function updateOpengoalParinferMode(mode: string) {
await userConfig.update( await userConfig.update(
"opengoal.parinferMode", "opengoal.parinferMode",
mode, mode,
vscode.ConfigurationTarget.Global vscode.ConfigurationTarget.Global,
); );
} }

View file

@ -35,7 +35,7 @@ export async function setVSIconAssociations() {
// - NOTE this may break situations where a file type is being handled by another extension // - NOTE this may break situations where a file type is being handled by another extension
let currentIconAssociations: any = userConfig.get( let currentIconAssociations: any = userConfig.get(
"vsicons.associations.files" "vsicons.associations.files",
); );
if (currentIconAssociations === undefined) { if (currentIconAssociations === undefined) {
currentIconAssociations = opengoalVSIconAssocs; currentIconAssociations = opengoalVSIconAssocs;
@ -64,11 +64,11 @@ export async function setVSIconAssociations() {
await userConfig.update( await userConfig.update(
"vsicons.associations.files", "vsicons.associations.files",
currentIconAssociations, currentIconAssociations,
vscode.ConfigurationTarget.Global vscode.ConfigurationTarget.Global,
); );
} catch (err) { } catch (err) {
getMainChannel().append( getMainChannel().append(
`Failed to write icon configuration override - ${err}` `Failed to write icon configuration override - ${err}`,
); );
} }
} }
@ -267,7 +267,7 @@ export async function setTextmateColors() {
const userConfig = vscode.workspace.getConfiguration(); const userConfig = vscode.workspace.getConfiguration();
const currentTokenColorCustomizations: any = userConfig.get( const currentTokenColorCustomizations: any = userConfig.get(
"editor.tokenColorCustomizations" "editor.tokenColorCustomizations",
); );
const opengoalTextMateRules = getTextMateRules(); const opengoalTextMateRules = getTextMateRules();
@ -302,7 +302,7 @@ export async function setTextmateColors() {
await userConfig.update( await userConfig.update(
"editor.tokenColorCustomizations", "editor.tokenColorCustomizations",
currentTokenColorCustomizations, currentTokenColorCustomizations,
vscode.ConfigurationTarget.Global vscode.ConfigurationTarget.Global,
); );
} catch (err) { } catch (err) {
getMainChannel().append(`Failed to write textmate rule override - ${err}`); getMainChannel().append(`Failed to write textmate rule override - ${err}`);

View file

@ -36,7 +36,7 @@ export function getProjectRoot(): vscode.Uri {
// if it's still undefined, throw an error // if it's still undefined, throw an error
if (projectRoot === undefined) { if (projectRoot === undefined) {
vscode.window.showErrorMessage( vscode.window.showErrorMessage(
"OpenGOAL - Unable to locate 'jak-project' workspace folder" "OpenGOAL - Unable to locate 'jak-project' workspace folder",
); );
throw new Error("unable to locate 'jak-project' workspace folder"); throw new Error("unable to locate 'jak-project' workspace folder");
} }

View file

@ -24,7 +24,7 @@ let fsWatcher: vscode.FileSystemWatcher | undefined;
const decompStatusItem = vscode.window.createStatusBarItem( const decompStatusItem = vscode.window.createStatusBarItem(
vscode.StatusBarAlignment.Left, vscode.StatusBarAlignment.Left,
0 0,
); );
enum DecompStatus { enum DecompStatus {
@ -85,12 +85,12 @@ function getDecompilerConfig(gameName: GameName): string | undefined {
if (gameName == GameName.Jak1) { if (gameName == GameName.Jak1) {
decompConfigPath = vscode.Uri.joinPath( decompConfigPath = vscode.Uri.joinPath(
getProjectRoot(), getProjectRoot(),
`decompiler/config/jak1/jak1_config.jsonc` `decompiler/config/jak1/jak1_config.jsonc`,
).fsPath; ).fsPath;
} else if (gameName == GameName.Jak2) { } else if (gameName == GameName.Jak2) {
decompConfigPath = vscode.Uri.joinPath( decompConfigPath = vscode.Uri.joinPath(
getProjectRoot(), getProjectRoot(),
`decompiler/config/jak2/jak2_config.jsonc` `decompiler/config/jak2/jak2_config.jsonc`,
).fsPath; ).fsPath;
} }
if (decompConfigPath === undefined || !existsSync(decompConfigPath)) { if (decompConfigPath === undefined || !existsSync(decompConfigPath)) {
@ -124,7 +124,7 @@ async function checkDecompilerPath(): Promise<string | undefined> {
const potentialPath = vscode.Uri.joinPath( const potentialPath = vscode.Uri.joinPath(
getProjectRoot(), getProjectRoot(),
defaultDecompPath() defaultDecompPath(),
); );
if (existsSync(potentialPath.fsPath)) { if (existsSync(potentialPath.fsPath)) {
decompilerPath = potentialPath.fsPath; decompilerPath = potentialPath.fsPath;
@ -137,7 +137,7 @@ async function checkDecompilerPath(): Promise<string | undefined> {
}); });
if (path === undefined || path.length == 0) { if (path === undefined || path.length == 0) {
vscode.window.showErrorMessage( vscode.window.showErrorMessage(
"OpenGOAL - Aborting decompilation, you didn't provide a path to the executable" "OpenGOAL - Aborting decompilation, you didn't provide a path to the executable",
); );
return undefined; return undefined;
} }
@ -150,7 +150,7 @@ async function checkDecompilerPath(): Promise<string | undefined> {
async function decompFiles( async function decompFiles(
decompConfig: string, decompConfig: string,
gameName: GameName, gameName: GameName,
fileNames: string[] fileNames: string[],
) { ) {
if (fileNames.length == 0) { if (fileNames.length == 0) {
return; return;
@ -186,7 +186,7 @@ async function decompFiles(
} catch (error: any) { } catch (error: any) {
updateStatus(DecompStatus.Errored); updateStatus(DecompStatus.Errored);
channel.append( channel.append(
`DECOMP ERROR:\nSTDOUT:\n${error.stdout}\nSTDERR:\n${error.stderr}` `DECOMP ERROR:\nSTDOUT:\n${error.stdout}\nSTDERR:\n${error.stderr}`,
); );
} }
} }
@ -198,7 +198,7 @@ async function getValidObjectNames(gameName: string) {
"goal_src", "goal_src",
gameName, gameName,
"build", "build",
"all_objs.json" "all_objs.json",
); );
if (!existsSync(objsPath)) { if (!existsSync(objsPath)) {
return undefined; return undefined;
@ -224,11 +224,11 @@ async function decompSpecificFile() {
["jak1", "jak2"], ["jak1", "jak2"],
{ {
title: "Game?", title: "Game?",
} },
); );
if (gameNameSelection === undefined) { if (gameNameSelection === undefined) {
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
"OpenGOAL - can't decompile, didn't provide a game name" "OpenGOAL - can't decompile, didn't provide a game name",
); );
return; return;
} else { } else {
@ -251,7 +251,7 @@ async function decompSpecificFile() {
if (fileName === undefined) { if (fileName === undefined) {
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
"OpenGOAL - can't decompile, didn't provide an object name" "OpenGOAL - can't decompile, didn't provide an object name",
); );
return; return;
} }
@ -260,7 +260,7 @@ async function decompSpecificFile() {
const decompConfig = getDecompilerConfig(gameName); const decompConfig = getDecompilerConfig(gameName);
if (decompConfig === undefined) { if (decompConfig === undefined) {
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
`OpenGOAL - Can't decompile no ${gameName.toString} config selected` `OpenGOAL - Can't decompile no ${gameName.toString} config selected`,
); );
return; return;
} }
@ -272,7 +272,7 @@ async function decompCurrentFile() {
const editor = vscode.window.activeTextEditor; const editor = vscode.window.activeTextEditor;
if (!editor || !editor.document === undefined) { if (!editor || !editor.document === undefined) {
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
"No active file open, can't decompile!" "No active file open, can't decompile!",
); );
return; return;
} }
@ -280,7 +280,7 @@ async function decompCurrentFile() {
let fileName = path.basename(editor.document.fileName); let fileName = path.basename(editor.document.fileName);
if (!fileName.match(/.*_ir2\.asm/)) { if (!fileName.match(/.*_ir2\.asm/)) {
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
"Current file is not a valid IR2 file, can't decompile!" "Current file is not a valid IR2 file, can't decompile!",
); );
return; return;
} else { } else {
@ -291,14 +291,14 @@ async function decompCurrentFile() {
const gameName = determineGameFromPath(editor.document.uri); const gameName = determineGameFromPath(editor.document.uri);
if (gameName === undefined) { if (gameName === undefined) {
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
"OpenGOAL - Can't decompile, couldn't determine game from file" "OpenGOAL - Can't decompile, couldn't determine game from file",
); );
return; return;
} }
const decompConfig = getDecompilerConfig(gameName); const decompConfig = getDecompilerConfig(gameName);
if (decompConfig === undefined) { if (decompConfig === undefined) {
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
`OpenGOAL - Can't decompile no ${gameName.toString} config selected` `OpenGOAL - Can't decompile no ${gameName.toString} config selected`,
); );
return; return;
} }
@ -309,24 +309,24 @@ async function decompCurrentFile() {
async function decompAllActiveFiles() { async function decompAllActiveFiles() {
let jak1ObjectNames = truncateFileNameEndings( let jak1ObjectNames = truncateFileNameEndings(
getFileNamesFromUris(getUrisFromTabs(/.*jak1\/.*_ir2\.asm/)), getFileNamesFromUris(getUrisFromTabs(/.*jak1\/.*_ir2\.asm/)),
"_ir2.asm" "_ir2.asm",
); );
jak1ObjectNames = jak1ObjectNames.concat( jak1ObjectNames = jak1ObjectNames.concat(
truncateFileNameEndings( truncateFileNameEndings(
getFileNamesFromUris(getUrisFromTabs(/.*jak1\/.*_disasm\.gc/)), getFileNamesFromUris(getUrisFromTabs(/.*jak1\/.*_disasm\.gc/)),
"_disasm.gc" "_disasm.gc",
) ),
); );
jak1ObjectNames = [...new Set(jak1ObjectNames)]; jak1ObjectNames = [...new Set(jak1ObjectNames)];
let jak2ObjectNames = truncateFileNameEndings( let jak2ObjectNames = truncateFileNameEndings(
getFileNamesFromUris(getUrisFromTabs(/.*jak2\/.*_ir2\.asm/)), getFileNamesFromUris(getUrisFromTabs(/.*jak2\/.*_ir2\.asm/)),
"_ir2.asm" "_ir2.asm",
); );
jak2ObjectNames = jak2ObjectNames.concat( jak2ObjectNames = jak2ObjectNames.concat(
truncateFileNameEndings( truncateFileNameEndings(
getFileNamesFromUris(getUrisFromTabs(/.*jak2\/.*_disasm\.gc/)), getFileNamesFromUris(getUrisFromTabs(/.*jak2\/.*_disasm\.gc/)),
"_disasm.gc" "_disasm.gc",
) ),
); );
jak2ObjectNames = [...new Set(jak2ObjectNames)]; jak2ObjectNames = [...new Set(jak2ObjectNames)];
@ -334,7 +334,7 @@ async function decompAllActiveFiles() {
const jak1Config = getDecompilerConfig(GameName.Jak1); const jak1Config = getDecompilerConfig(GameName.Jak1);
if (jak1Config === undefined) { if (jak1Config === undefined) {
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
"OpenGOAL - Can't decompile no Jak 1 config selected" "OpenGOAL - Can't decompile no Jak 1 config selected",
); );
return; return;
} }
@ -345,7 +345,7 @@ async function decompAllActiveFiles() {
const jak2Config = getDecompilerConfig(GameName.Jak2); const jak2Config = getDecompilerConfig(GameName.Jak2);
if (jak2Config === undefined) { if (jak2Config === undefined) {
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
"OpenGOAL - Can't decompile no Jak 2 config selected" "OpenGOAL - Can't decompile no Jak 2 config selected",
); );
return; return;
} }
@ -373,7 +373,7 @@ function openManPage() {
function toggleAutoDecompilation() { function toggleAutoDecompilation() {
if (fsWatcher === undefined) { if (fsWatcher === undefined) {
fsWatcher = vscode.workspace.createFileSystemWatcher( fsWatcher = vscode.workspace.createFileSystemWatcher(
"**/decompiler/config/**/*.{jsonc,json,gc}" "**/decompiler/config/**/*.{jsonc,json,gc}",
); );
fsWatcher.onDidChange((uri: vscode.Uri) => { fsWatcher.onDidChange((uri: vscode.Uri) => {
decompAllActiveFiles(); decompAllActiveFiles();
@ -396,7 +396,7 @@ async function updateSourceFile() {
const editor = vscode.window.activeTextEditor; const editor = vscode.window.activeTextEditor;
if (!editor || !editor.document === undefined) { if (!editor || !editor.document === undefined) {
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
"No active file open, can't decompile!" "No active file open, can't decompile!",
); );
return; return;
} }
@ -427,7 +427,7 @@ async function updateSourceFile() {
encoding: "utf8", encoding: "utf8",
cwd: getProjectRoot()?.fsPath, cwd: getProjectRoot()?.fsPath,
timeout: 20000, timeout: 20000,
} },
); );
updateStatus(DecompStatus.Idle); updateStatus(DecompStatus.Idle);
channel.append(stdout.toString()); channel.append(stdout.toString());
@ -438,7 +438,7 @@ async function updateReferenceTest() {
const editor = vscode.window.activeTextEditor; const editor = vscode.window.activeTextEditor;
if (!editor || !editor.document === undefined) { if (!editor || !editor.document === undefined) {
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
"No active file open, can't decompile!" "No active file open, can't decompile!",
); );
return; return;
} }
@ -466,7 +466,7 @@ async function updateReferenceTest() {
} }
const folderToSearch = vscode.Uri.joinPath( const folderToSearch = vscode.Uri.joinPath(
getProjectRoot(), getProjectRoot(),
`goal_src/${gameName}` `goal_src/${gameName}`,
); );
const files = await glob(`**/${fileName}.gc`, { const files = await glob(`**/${fileName}.gc`, {
cwd: folderToSearch.fsPath, cwd: folderToSearch.fsPath,
@ -480,8 +480,8 @@ async function updateReferenceTest() {
getProjectRoot(), getProjectRoot(),
`test/decompiler/reference/${gameName}/${files[0].replace( `test/decompiler/reference/${gameName}/${files[0].replace(
".gc", ".gc",
"_REF.gc" "_REF.gc",
)}` )}`,
).fsPath; ).fsPath;
const decompContents = await fs.readFile(disasmFilePath, { const decompContents = await fs.readFile(disasmFilePath, {
@ -499,7 +499,7 @@ export async function activateDecompTools() {
// no color support :( - https://github.com/microsoft/vscode/issues/571 // no color support :( - https://github.com/microsoft/vscode/issues/571
channel = vscode.window.createOutputChannel( channel = vscode.window.createOutputChannel(
"OpenGOAL Decompiler", "OpenGOAL Decompiler",
"opengoal-ir" "opengoal-ir",
); );
toggleAutoDecompilation(); toggleAutoDecompilation();
@ -509,37 +509,37 @@ export async function activateDecompTools() {
// Commands // Commands
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand("opengoal.decomp.openManPage", openManPage) vscode.commands.registerCommand("opengoal.decomp.openManPage", openManPage),
); );
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.decompileCurrentFile", "opengoal.decomp.decompileCurrentFile",
decompCurrentFile decompCurrentFile,
) ),
); );
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.decompileSpecificFile", "opengoal.decomp.decompileSpecificFile",
decompSpecificFile decompSpecificFile,
) ),
); );
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.toggleAutoDecompilation", "opengoal.decomp.toggleAutoDecompilation",
toggleAutoDecompilation toggleAutoDecompilation,
) ),
); );
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.updateSourceFile", "opengoal.decomp.updateSourceFile",
updateSourceFile updateSourceFile,
) ),
); );
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.updateReferenceTest", "opengoal.decomp.updateReferenceTest",
updateReferenceTest updateReferenceTest,
) ),
); );
activateDecompTypeSearcher(); activateDecompTypeSearcher();

View file

@ -85,21 +85,21 @@ export async function open_in_pdf(mnemonic: string) {
// Finally, open the PDF // Finally, open the PDF
if (selected_option.type == "ee") { if (selected_option.type == "ee") {
const path = vscode.Uri.parse( const path = vscode.Uri.parse(
`${config.eeManPagePath}#page=${selected_option.page}` `${config.eeManPagePath}#page=${selected_option.page}`,
); );
vscode.commands.executeCommand( vscode.commands.executeCommand(
"vscode.openWith", "vscode.openWith",
path, path,
"pdf.opengoal.manpage" "pdf.opengoal.manpage",
); );
} else if (selected_option.type == "vu") { } else if (selected_option.type == "vu") {
const path = vscode.Uri.parse( const path = vscode.Uri.parse(
`${config.vuManPagePath}#page=${selected_option.page}` `${config.vuManPagePath}#page=${selected_option.page}`,
); );
vscode.commands.executeCommand( vscode.commands.executeCommand(
"vscode.openWith", "vscode.openWith",
path, path,
"pdf.opengoal.manpage" "pdf.opengoal.manpage",
); );
} }
} }

View file

@ -37,7 +37,7 @@ async function addToOffsets() {
(match, key) => { (match, key) => {
console.log(`${match}-${key}`); console.log(`${match}-${key}`);
return `${parseInt(key) + incAmount}`; return `${parseInt(key) + incAmount}`;
} },
); );
selectedText.replace(editor.selection, result); selectedText.replace(editor.selection, result);
@ -86,7 +86,7 @@ async function preserveBlock() {
blockContent = content; blockContent = content;
selectedText.replace( selectedText.replace(
editor.selection, editor.selection,
`;; +++${fileName}:${blockName}\n${content}\n;; ---${fileName}:${blockName}` `;; +++${fileName}:${blockName}\n${content}\n;; ---${fileName}:${blockName}`,
); );
}); });
@ -95,7 +95,7 @@ async function preserveBlock() {
const projectRoot = getWorkspaceFolderByName("jak-project"); const projectRoot = getWorkspaceFolderByName("jak-project");
if (projectRoot === undefined) { if (projectRoot === undefined) {
vscode.window.showErrorMessage( vscode.window.showErrorMessage(
"OpenGOAL - Unable to locate 'jak-project' workspace folder" "OpenGOAL - Unable to locate 'jak-project' workspace folder",
); );
return undefined; return undefined;
} }
@ -112,7 +112,7 @@ async function preserveBlock() {
// Otherwise, let's update it... // Otherwise, let's update it...
await updateFileBeforeDecomp( await updateFileBeforeDecomp(
gsrcPath, gsrcPath,
`;; +++${blockName}\n${blockContent}\n;; ---${blockName}` `;; +++${blockName}\n${blockContent}\n;; ---${blockName}`,
); );
} }
@ -184,20 +184,20 @@ async function generateTypeFlags() {
// :flag-assert #xcb036003d4 / #x9 0000 0010 // :flag-assert #xcb036003d4 / #x9 0000 0010
let clipboardVal = ` :method-count-assert ${parseInt( let clipboardVal = ` :method-count-assert ${parseInt(
methodCount.replace("0x", ""), methodCount.replace("0x", ""),
16 16,
)}\n`; )}\n`;
clipboardVal += ` :size-assert #x${parseInt( clipboardVal += ` :size-assert #x${parseInt(
flags.slice(-4), flags.slice(-4),
16 16,
).toString(16)} ;; ${parseInt(flags.slice(-4), 16)}\n`; ).toString(16)} ;; ${parseInt(flags.slice(-4), 16)}\n`;
clipboardVal += ` :flag-assert #x${parseInt( clipboardVal += ` :flag-assert #x${parseInt(
methodCount.replace("0x", ""), methodCount.replace("0x", ""),
16 16,
).toString(16)}${flags}`; ).toString(16)}${flags}`;
vscode.env.clipboard.writeText(clipboardVal); vscode.env.clipboard.writeText(clipboardVal);
vscode.window.showInformationMessage( vscode.window.showInformationMessage(
"OpenGOAL - Type Flags Copied to Clipboard!" "OpenGOAL - Type Flags Copied to Clipboard!",
); );
return; return;
} }
@ -215,7 +215,7 @@ async function genTypeFields() {
["basic", "structure"], ["basic", "structure"],
{ {
title: "Structure Type?", title: "Structure Type?",
} },
); );
if (structureTypeSelection === undefined) { if (structureTypeSelection === undefined) {
return; return;
@ -421,7 +421,7 @@ async function genMethodStubs() {
} }
if (foundType && line.includes("method-count-assert")) { if (foundType && line.includes("method-count-assert")) {
parentTypeMethodCount = parseInt( parentTypeMethodCount = parseInt(
line.split("method-count-assert")[1].trim() line.split("method-count-assert")[1].trim(),
); );
break; break;
} }
@ -441,43 +441,43 @@ export async function activateMiscDecompTools() {
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.misc.addToOffsets", "opengoal.decomp.misc.addToOffsets",
addToOffsets addToOffsets,
) ),
); );
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.misc.preserveBlock", "opengoal.decomp.misc.preserveBlock",
preserveBlock preserveBlock,
) ),
); );
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.misc.convertHexToDec", "opengoal.decomp.misc.convertHexToDec",
convertHexToDec convertHexToDec,
) ),
); );
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.misc.convertDecToHex", "opengoal.decomp.misc.convertDecToHex",
convertDecToHex convertDecToHex,
) ),
); );
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.misc.generateTypeFlags", "opengoal.decomp.misc.generateTypeFlags",
generateTypeFlags generateTypeFlags,
) ),
); );
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.misc.genTypeFields", "opengoal.decomp.misc.genTypeFields",
genTypeFields genTypeFields,
) ),
); );
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.misc.genMethodStubs", "opengoal.decomp.misc.genMethodStubs",
genMethodStubs genMethodStubs,
) ),
); );
} }

View file

@ -63,7 +63,7 @@ async function checkTypeSearcherPath(): Promise<string | undefined> {
const potentialPath = vscode.Uri.joinPath( const potentialPath = vscode.Uri.joinPath(
getProjectRoot(), getProjectRoot(),
defaultTypeSearcherPath() defaultTypeSearcherPath(),
); );
if (existsSync(potentialPath.fsPath)) { if (existsSync(potentialPath.fsPath)) {
typeSearcherPath = potentialPath.fsPath; typeSearcherPath = potentialPath.fsPath;
@ -92,7 +92,7 @@ export async function updateTypeCastSuggestions(gameName: GameName) {
try { try {
const jsonPath = vscode.Uri.joinPath( const jsonPath = vscode.Uri.joinPath(
getExtensionContext().extensionUri, getExtensionContext().extensionUri,
`${gameName.toString()}-types.json` `${gameName.toString()}-types.json`,
).fsPath; ).fsPath;
await execFileAsync( await execFileAsync(
typeSearcherPath, typeSearcherPath,
@ -101,7 +101,7 @@ export async function updateTypeCastSuggestions(gameName: GameName) {
encoding: "utf8", encoding: "utf8",
cwd: getProjectRoot().fsPath, cwd: getProjectRoot().fsPath,
timeout: 500, timeout: 500,
} },
); );
if (existsSync(jsonPath)) { if (existsSync(jsonPath)) {
const result = readFileSync(jsonPath, { encoding: "utf-8" }); const result = readFileSync(jsonPath, { encoding: "utf-8" });
@ -135,7 +135,7 @@ async function applyLabelCast(
objectName: string, objectName: string,
labelRef: string, labelRef: string,
castToType: string, castToType: string,
pointerSize?: number pointerSize?: number,
) { ) {
const configDir = await getDecompilerConfigDirectory(editor.document.uri); const configDir = await getDecompilerConfigDirectory(editor.document.uri);
if (configDir === undefined) { if (configDir === undefined) {
@ -173,7 +173,7 @@ async function applyLabelCast(
async function validActiveFile(editor: vscode.TextEditor): Promise<boolean> { async function validActiveFile(editor: vscode.TextEditor): Promise<boolean> {
if (!editor.document === undefined) { if (!editor.document === undefined) {
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
"No active file open, can't decompile!" "No active file open, can't decompile!",
); );
return false; return false;
} }
@ -181,7 +181,7 @@ async function validActiveFile(editor: vscode.TextEditor): Promise<boolean> {
const fileName = basename(editor.document.fileName); const fileName = basename(editor.document.fileName);
if (!fileName.match(/.*_ir2\.asm/)) { if (!fileName.match(/.*_ir2\.asm/)) {
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
"Current file is not a valid IR2 file." "Current file is not a valid IR2 file.",
); );
return false; return false;
} }
@ -190,7 +190,7 @@ async function validActiveFile(editor: vscode.TextEditor): Promise<boolean> {
function generateCastSelectionItems( function generateCastSelectionItems(
fullList: string[] | undefined, fullList: string[] | undefined,
recentList: string[] | undefined recentList: string[] | undefined,
): vscode.QuickPickItem[] { ): vscode.QuickPickItem[] {
const items: vscode.QuickPickItem[] = []; const items: vscode.QuickPickItem[] = [];
if (recentList !== undefined && recentList.length > 0) { if (recentList !== undefined && recentList.length > 0) {
@ -222,7 +222,7 @@ function generateCastSelectionItems(
}, },
{ {
label: "__custom", label: "__custom",
} },
); );
return items; return items;
} }
@ -252,7 +252,7 @@ async function labelCastSelection() {
// Get the stack index // Get the stack index
const labelRef = await getLabelReference( const labelRef = await getLabelReference(
editor.document.lineAt(editor.selection.start.line).text editor.document.lineAt(editor.selection.start.line).text,
); );
if (labelRef === undefined) { if (labelRef === undefined) {
return; return;
@ -268,7 +268,7 @@ async function labelCastSelection() {
const items = generateCastSelectionItems( const items = generateCastSelectionItems(
typeCastSuggestions.get(gameName), typeCastSuggestions.get(gameName),
recentLabelCasts.get(gameName) recentLabelCasts.get(gameName),
); );
let castToType; let castToType;
if (items.length > 0) { if (items.length > 0) {
@ -311,7 +311,7 @@ async function labelCastSelection() {
objectName, objectName,
labelRef, labelRef,
castToType.trim(), castToType.trim(),
pointerSize pointerSize,
); );
lastCastKind = CastKind.Label; lastCastKind = CastKind.Label;
@ -333,7 +333,7 @@ async function applyStackCast(
editor: vscode.TextEditor, editor: vscode.TextEditor,
funcName: string, funcName: string,
stackOffset: number, stackOffset: number,
castToType: string castToType: string,
) { ) {
const configDir = await getDecompilerConfigDirectory(editor.document.uri); const configDir = await getDecompilerConfigDirectory(editor.document.uri);
if (configDir === undefined) { if (configDir === undefined) {
@ -361,7 +361,7 @@ async function stackCastSelection() {
// Get the relevant function/method name // Get the relevant function/method name
const funcName = await getFuncNameFromSelection( const funcName = await getFuncNameFromSelection(
editor.document, editor.document,
editor.selection editor.selection,
); );
if (funcName === undefined) { if (funcName === undefined) {
return; return;
@ -369,7 +369,7 @@ async function stackCastSelection() {
// Get the stack index // Get the stack index
const stackOffset = await getStackOffset( const stackOffset = await getStackOffset(
editor.document.lineAt(editor.selection.start.line).text editor.document.lineAt(editor.selection.start.line).text,
); );
if (stackOffset === undefined) { if (stackOffset === undefined) {
return; return;
@ -385,7 +385,7 @@ async function stackCastSelection() {
const items = generateCastSelectionItems( const items = generateCastSelectionItems(
typeCastSuggestions.get(gameName), typeCastSuggestions.get(gameName),
recentStackCasts.get(gameName) recentStackCasts.get(gameName),
); );
let castToType; let castToType;
if (items.length > 0) { if (items.length > 0) {
@ -420,7 +420,7 @@ async function stackCastSelection() {
function getRegisters( function getRegisters(
document: vscode.TextDocument, document: vscode.TextDocument,
selection: vscode.Selection selection: vscode.Selection,
): string[] { ): string[] {
const regSet = new Set<string>(); const regSet = new Set<string>();
for (let i = selection.start.line; i <= selection.end.line; i++) { for (let i = selection.start.line; i <= selection.end.line; i++) {
@ -436,7 +436,7 @@ async function applyTypeCast(
funcName: string, funcName: string,
castContext: CastContext, castContext: CastContext,
registerSelection: string, registerSelection: string,
castToType: string castToType: string,
) { ) {
const configDir = await getDecompilerConfigDirectory(editor.document.uri); const configDir = await getDecompilerConfigDirectory(editor.document.uri);
if (configDir === undefined) { if (configDir === undefined) {
@ -481,7 +481,7 @@ async function typeCastSelection() {
// Determine the range of the selection // Determine the range of the selection
const startOpNum = await getOpNumber( const startOpNum = await getOpNumber(
editor.document.lineAt(editor.selection.start.line).text editor.document.lineAt(editor.selection.start.line).text,
); );
if (startOpNum === undefined) { if (startOpNum === undefined) {
return; return;
@ -489,7 +489,7 @@ async function typeCastSelection() {
const castContext = new CastContext(startOpNum); const castContext = new CastContext(startOpNum);
if (!editor.selection.isSingleLine) { if (!editor.selection.isSingleLine) {
const endOpNum = await getOpNumber( const endOpNum = await getOpNumber(
editor.document.lineAt(editor.selection.end.line).text editor.document.lineAt(editor.selection.end.line).text,
); );
if (endOpNum === undefined) { if (endOpNum === undefined) {
return; return;
@ -500,7 +500,7 @@ async function typeCastSelection() {
// Get the relevant function/method name // Get the relevant function/method name
const funcName = await getFuncNameFromSelection( const funcName = await getFuncNameFromSelection(
editor.document, editor.document,
editor.selection editor.selection,
); );
if (funcName === undefined) { if (funcName === undefined) {
return; return;
@ -510,7 +510,7 @@ async function typeCastSelection() {
const registers = getRegisters(editor.document, editor.selection); const registers = getRegisters(editor.document, editor.selection);
if (registers.length == 0) { if (registers.length == 0) {
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
"Found no registers to cast in that selection" "Found no registers to cast in that selection",
); );
return; return;
} }
@ -521,7 +521,7 @@ async function typeCastSelection() {
}); });
if (registerSelection === undefined) { if (registerSelection === undefined) {
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
"Can't cast if no register is provided" "Can't cast if no register is provided",
); );
return; return;
} }
@ -536,7 +536,7 @@ async function typeCastSelection() {
const items = generateCastSelectionItems( const items = generateCastSelectionItems(
typeCastSuggestions.get(gameName), typeCastSuggestions.get(gameName),
recentTypeCasts.get(gameName) recentTypeCasts.get(gameName),
); );
let castToType; let castToType;
if (items.length > 0) { if (items.length > 0) {
@ -566,7 +566,7 @@ async function typeCastSelection() {
funcName, funcName,
castContext, castContext,
registerSelection, registerSelection,
castToType.trim() castToType.trim(),
); );
lastCastKind = CastKind.TypeCast; lastCastKind = CastKind.TypeCast;
@ -589,7 +589,7 @@ async function repeatLastCast() {
if (lastCastKind === CastKind.Label) { if (lastCastKind === CastKind.Label) {
const objectName = basename(editor.document.fileName).split("_ir2.asm")[0]; const objectName = basename(editor.document.fileName).split("_ir2.asm")[0];
const labelRef = await getLabelReference( const labelRef = await getLabelReference(
editor.document.lineAt(editor.selection.start.line).text editor.document.lineAt(editor.selection.start.line).text,
); );
if (labelRef === undefined || lastLabelCastType === undefined) { if (labelRef === undefined || lastLabelCastType === undefined) {
return; return;
@ -599,12 +599,12 @@ async function repeatLastCast() {
objectName, objectName,
labelRef, labelRef,
lastLabelCastType, lastLabelCastType,
lastLabelCastSize lastLabelCastSize,
); );
} else if (lastCastKind === CastKind.Stack) { } else if (lastCastKind === CastKind.Stack) {
const funcName = await getFuncNameFromSelection( const funcName = await getFuncNameFromSelection(
editor.document, editor.document,
editor.selection editor.selection,
); );
if (funcName === undefined) { if (funcName === undefined) {
return; return;
@ -612,7 +612,7 @@ async function repeatLastCast() {
// Get the stack index // Get the stack index
const stackOffset = await getStackOffset( const stackOffset = await getStackOffset(
editor.document.lineAt(editor.selection.start.line).text editor.document.lineAt(editor.selection.start.line).text,
); );
if (stackOffset === undefined || lastStackCastType === undefined) { if (stackOffset === undefined || lastStackCastType === undefined) {
return; return;
@ -621,13 +621,13 @@ async function repeatLastCast() {
} else if (lastCastKind === CastKind.TypeCast) { } else if (lastCastKind === CastKind.TypeCast) {
const funcName = await getFuncNameFromSelection( const funcName = await getFuncNameFromSelection(
editor.document, editor.document,
editor.selection editor.selection,
); );
if (funcName === undefined) { if (funcName === undefined) {
return; return;
} }
const startOpNum = await getOpNumber( const startOpNum = await getOpNumber(
editor.document.lineAt(editor.selection.start.line).text editor.document.lineAt(editor.selection.start.line).text,
); );
if (startOpNum === undefined) { if (startOpNum === undefined) {
return; return;
@ -635,7 +635,7 @@ async function repeatLastCast() {
const castContext = new CastContext(startOpNum); const castContext = new CastContext(startOpNum);
if (!editor.selection.isSingleLine) { if (!editor.selection.isSingleLine) {
const endOpNum = await getOpNumber( const endOpNum = await getOpNumber(
editor.document.lineAt(editor.selection.end.line).text editor.document.lineAt(editor.selection.end.line).text,
); );
if (endOpNum === undefined) { if (endOpNum === undefined) {
return; return;
@ -652,7 +652,7 @@ async function repeatLastCast() {
funcName, funcName,
castContext, castContext,
lastTypeCastRegister, lastTypeCastRegister,
lastTypeCastType lastTypeCastType,
); );
} }
} }
@ -661,25 +661,25 @@ export async function activateTypeCastTools() {
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.casts.labelCastSelection", "opengoal.decomp.casts.labelCastSelection",
labelCastSelection labelCastSelection,
) ),
); );
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.casts.stackCastSelection", "opengoal.decomp.casts.stackCastSelection",
stackCastSelection stackCastSelection,
) ),
); );
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.casts.typeCastSelection", "opengoal.decomp.casts.typeCastSelection",
typeCastSelection typeCastSelection,
) ),
); );
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.casts.repeatLast", "opengoal.decomp.casts.repeatLast",
repeatLastCast repeatLastCast,
) ),
); );
} }

View file

@ -237,24 +237,24 @@ async function searchForTypes(message: any): Promise<any> {
projectRoot = getWorkspaceFolderByName("jak-project"); projectRoot = getWorkspaceFolderByName("jak-project");
if (projectRoot === undefined) { if (projectRoot === undefined) {
vscode.window.showErrorMessage( vscode.window.showErrorMessage(
"OpenGOAL - Unable to locate 'jak-project' workspace folder" "OpenGOAL - Unable to locate 'jak-project' workspace folder",
); );
return []; return [];
} }
} }
const typeSearcherPath = vscode.Uri.joinPath( const typeSearcherPath = vscode.Uri.joinPath(
projectRoot, projectRoot,
defaultTypeSearcherPath() defaultTypeSearcherPath(),
); );
if (!existsSync(typeSearcherPath.fsPath)) { if (!existsSync(typeSearcherPath.fsPath)) {
vscode.window.showErrorMessage( vscode.window.showErrorMessage(
"OpenGOAL - Unable to locate 'type_searcher' binary" "OpenGOAL - Unable to locate 'type_searcher' binary",
); );
} }
const searchFile = vscode.Uri.joinPath( const searchFile = vscode.Uri.joinPath(
projectRoot, projectRoot,
"search-results.json" "search-results.json",
).fsPath; ).fsPath;
const args = [`--output-path`, searchFile, "--game", message.gameName]; const args = [`--output-path`, searchFile, "--game", message.gameName];
@ -298,7 +298,7 @@ async function searchForTypes(message: any): Promise<any> {
encoding: "utf8", encoding: "utf8",
cwd: projectRoot?.fsPath, cwd: projectRoot?.fsPath,
timeout: 20000, timeout: 20000,
} },
); );
// Parse the file // Parse the file
const result = readFileSync(searchFile, { encoding: "utf-8" }); const result = readFileSync(searchFile, { encoding: "utf-8" });
@ -324,7 +324,7 @@ async function openPanel() {
{ {
enableScripts: true, enableScripts: true,
retainContextWhenHidden: true, retainContextWhenHidden: true,
} },
); );
currentPanel.webview.html = getWebviewContent(); currentPanel.webview.html = getWebviewContent();
@ -342,7 +342,7 @@ async function openPanel() {
} }
}, },
undefined, undefined,
getExtensionContext().subscriptions getExtensionContext().subscriptions,
); );
} }
@ -351,7 +351,7 @@ export async function activateDecompTypeSearcher() {
getExtensionContext().subscriptions.push( getExtensionContext().subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.decomp.typeSearcher.open", "opengoal.decomp.typeSearcher.open",
openPanel openPanel,
) ),
); );
} }

View file

@ -14,7 +14,7 @@ import { getWorkspaceFolderByName } from "../utils/workspace";
export function getCastFileData( export function getCastFileData(
projectRoot: vscode.Uri, projectRoot: vscode.Uri,
document: vscode.TextDocument, document: vscode.TextDocument,
fileName: string fileName: string,
): any | undefined { ): any | undefined {
const gameName = determineGameFromPath(document.uri); const gameName = determineGameFromPath(document.uri);
if (gameName === undefined) { if (gameName === undefined) {
@ -25,12 +25,12 @@ export function getCastFileData(
if (gameName == GameName.Jak1) { if (gameName == GameName.Jak1) {
castFilePath = vscode.Uri.joinPath( castFilePath = vscode.Uri.joinPath(
projectRoot, projectRoot,
`decompiler/config/jak1/${config.jak2DecompConfigVersion}/${fileName}` `decompiler/config/jak1/${config.jak2DecompConfigVersion}/${fileName}`,
).fsPath; ).fsPath;
} else if (gameName == GameName.Jak2) { } else if (gameName == GameName.Jak2) {
castFilePath = vscode.Uri.joinPath( castFilePath = vscode.Uri.joinPath(
projectRoot, projectRoot,
`decompiler/config/jak2/${config.jak2DecompConfigVersion}/${fileName}` `decompiler/config/jak2/${config.jak2DecompConfigVersion}/${fileName}`,
).fsPath; ).fsPath;
} }
if (!existsSync(castFilePath)) { if (!existsSync(castFilePath)) {
@ -41,12 +41,12 @@ export function getCastFileData(
} }
export function getDecompilerConfigDirectory( export function getDecompilerConfigDirectory(
activeFile: vscode.Uri activeFile: vscode.Uri,
): string | undefined { ): string | undefined {
const projectRoot = getWorkspaceFolderByName("jak-project"); const projectRoot = getWorkspaceFolderByName("jak-project");
if (projectRoot === undefined) { if (projectRoot === undefined) {
vscode.window.showErrorMessage( vscode.window.showErrorMessage(
"OpenGOAL - Unable to locate 'jak-project' workspace folder" "OpenGOAL - Unable to locate 'jak-project' workspace folder",
); );
return undefined; return undefined;
} }
@ -57,13 +57,13 @@ export function getDecompilerConfigDirectory(
decompConfigPath = vscode.Uri.joinPath( decompConfigPath = vscode.Uri.joinPath(
projectRoot, projectRoot,
`decompiler/config/jak1/`, `decompiler/config/jak1/`,
getConfig().jak1DecompConfigVersion getConfig().jak1DecompConfigVersion,
).fsPath; ).fsPath;
} else if (gameName == GameName.Jak2) { } else if (gameName == GameName.Jak2) {
decompConfigPath = vscode.Uri.joinPath( decompConfigPath = vscode.Uri.joinPath(
projectRoot, projectRoot,
`decompiler/config/jak2/`, `decompiler/config/jak2/`,
getConfig().jak1DecompConfigVersion getConfig().jak1DecompConfigVersion,
).fsPath; ).fsPath;
} }
if (decompConfigPath === undefined || !existsSync(decompConfigPath)) { if (decompConfigPath === undefined || !existsSync(decompConfigPath)) {
@ -78,7 +78,7 @@ export async function updateVarCasts(
funcName: string, funcName: string,
argMeta: ArgumentMeta | undefined, argMeta: ArgumentMeta | undefined,
currSymbol: string, currSymbol: string,
newName: string newName: string,
) { ) {
// If the user provides a name with a space and an extra word, interpret that as the variable type // If the user provides a name with a space and an extra word, interpret that as the variable type
let varType = undefined; let varType = undefined;
@ -91,7 +91,7 @@ export async function updateVarCasts(
const projectRoot = getWorkspaceFolderByName("jak-project"); const projectRoot = getWorkspaceFolderByName("jak-project");
if (projectRoot === undefined) { if (projectRoot === undefined) {
vscode.window.showErrorMessage( vscode.window.showErrorMessage(
"OpenGOAL - Unable to locate 'jak-project' workspace folder" "OpenGOAL - Unable to locate 'jak-project' workspace folder",
); );
return; return;
} }
@ -113,7 +113,7 @@ export async function updateVarCasts(
for (const argName of varNameData[funcName].args) { for (const argName of varNameData[funcName].args) {
if (argName === newName) { if (argName === newName) {
vscode.window.showErrorMessage( vscode.window.showErrorMessage(
"OpenGOAL - Cannot cast different args to the same name, unsupported!" "OpenGOAL - Cannot cast different args to the same name, unsupported!",
); );
return; return;
} }
@ -155,7 +155,7 @@ export async function updateVarCasts(
value === newName) value === newName)
) { ) {
vscode.window.showErrorMessage( vscode.window.showErrorMessage(
"OpenGOAL - Cannot cast different variables to the same name, unsupported!" "OpenGOAL - Cannot cast different variables to the same name, unsupported!",
); );
return; return;
} }

View file

@ -39,7 +39,7 @@ export async function activate(context: vscode.ExtensionContext) {
}); });
context.subscriptions.push( context.subscriptions.push(
vscode.commands.registerCommand("opengoal.switchFile", switchFile) vscode.commands.registerCommand("opengoal.switchFile", switchFile),
); );
activateDecompTools(); activateDecompTools();
@ -48,7 +48,7 @@ export async function activate(context: vscode.ExtensionContext) {
// Customized PDF Viewer // Customized PDF Viewer
const provider = new PdfCustomProvider( const provider = new PdfCustomProvider(
vscode.Uri.file(context.extensionPath) vscode.Uri.file(context.extensionPath),
); );
context.subscriptions.push( context.subscriptions.push(
vscode.window.registerCustomEditorProvider( vscode.window.registerCustomEditorProvider(
@ -59,8 +59,8 @@ export async function activate(context: vscode.ExtensionContext) {
enableFindWidget: false, // default enableFindWidget: false, // default
retainContextWhenHidden: true, retainContextWhenHidden: true,
}, },
} },
) ),
); );
// TODO - disposable stuff? // TODO - disposable stuff?
@ -68,24 +68,24 @@ export async function activate(context: vscode.ExtensionContext) {
// Language Customizations // Language Customizations
vscode.languages.registerFoldingRangeProvider( vscode.languages.registerFoldingRangeProvider(
{ scheme: "file", language: "opengoal-ir" }, { scheme: "file", language: "opengoal-ir" },
new IRFoldingRangeProvider() new IRFoldingRangeProvider(),
); );
vscode.languages.registerInlayHintsProvider( vscode.languages.registerInlayHintsProvider(
{ scheme: "file", language: "opengoal-ir" }, { scheme: "file", language: "opengoal-ir" },
new IRInlayHintsProvider() new IRInlayHintsProvider(),
); );
vscode.languages.registerRenameProvider( vscode.languages.registerRenameProvider(
{ scheme: "file", language: "opengoal", pattern: "**/*_disasm.gc" }, { scheme: "file", language: "opengoal", pattern: "**/*_disasm.gc" },
new OpenGOALDisasmRenameProvider() new OpenGOALDisasmRenameProvider(),
); );
vscode.languages.registerRenameProvider( vscode.languages.registerRenameProvider(
{ scheme: "file", language: "opengoal-ir" }, { scheme: "file", language: "opengoal-ir" },
new IRRenameProvider() new IRRenameProvider(),
); );
vscode.languages.registerCompletionItemProvider( vscode.languages.registerCompletionItemProvider(
{ scheme: "file", language: "opengoal-ir" }, { scheme: "file", language: "opengoal-ir" },
new IRCompletionItemProvider(), new IRCompletionItemProvider(),
"@" // NOTE - can't use `"` without overriding a default setting https://github.com/microsoft/vscode/issues/131238#issuecomment-902519923 "@", // NOTE - can't use `"` without overriding a default setting https://github.com/microsoft/vscode/issues/131238#issuecomment-902519923
); );
// Start the LSP // Start the LSP
@ -101,7 +101,7 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.workspace.onDidSaveTextDocument(nreplOnFileSaveHandler); vscode.workspace.onDidSaveTextDocument(nreplOnFileSaveHandler);
} catch (err) { } catch (err) {
vscode.window.showErrorMessage( vscode.window.showErrorMessage(
"Failed to activate OpenGOAL extension, see logs for details" "Failed to activate OpenGOAL extension, see logs for details",
); );
getMainChannel().append(`Failed to activate extension - ${err}`); getMainChannel().append(`Failed to activate extension - ${err}`);
} }

View file

@ -19,7 +19,7 @@ function parinferRangeToVSCodeRange(parenTrail: any) {
parenTrail.lineNo, parenTrail.lineNo,
parenTrail.startX, parenTrail.startX,
parenTrail.lineNo, parenTrail.lineNo,
parenTrail.endX parenTrail.endX,
); );
} }
@ -74,7 +74,7 @@ let currentParinferMode = ParinferMode.DISABLED;
const parinferStatusItem = vscode.window.createStatusBarItem( const parinferStatusItem = vscode.window.createStatusBarItem(
vscode.StatusBarAlignment.Left, vscode.StatusBarAlignment.Left,
0 0,
); );
function updateStatus() { function updateStatus() {
@ -125,7 +125,7 @@ function applyParinfer(
editor: vscode.TextEditor, editor: vscode.TextEditor,
text: string, text: string,
options: ParinferOptions, options: ParinferOptions,
mode: ParinferMode mode: ParinferMode,
) { ) {
// console.log(`Options Before - ${JSON.stringify(options, null, 2)}`); // console.log(`Options Before - ${JSON.stringify(options, null, 2)}`);
let parinferResult: any; // TODO - make a type def for this let parinferResult: any; // TODO - make a type def for this
@ -154,18 +154,18 @@ function applyParinfer(
{ {
undoStopAfter: false, undoStopAfter: false,
undoStopBefore: false, undoStopBefore: false,
} },
) )
.then(function (editWasApplied) { .then(function (editWasApplied) {
if (editWasApplied) { if (editWasApplied) {
// set the new cursor position // set the new cursor position
const newCursorPosition = new vscode.Position( const newCursorPosition = new vscode.Position(
parinferResult.cursorLine, parinferResult.cursorLine,
parinferResult.cursorX parinferResult.cursorX,
); );
const nextCursor = new vscode.Selection( const nextCursor = new vscode.Selection(
newCursorPosition, newCursorPosition,
newCursorPosition newCursorPosition,
); );
editor.selection = nextCursor; editor.selection = nextCursor;
updateParenTrails(editor, parinferResult.parenTrails); updateParenTrails(editor, parinferResult.parenTrails);
@ -218,12 +218,12 @@ function processEventQueue() {
activeEditor, activeEditor,
selectionEvent.text, selectionEvent.text,
options, options,
currentParinferMode currentParinferMode,
); );
} }
export function onChangeSelection( export function onChangeSelection(
event: vscode.TextEditorSelectionChangeEvent event: vscode.TextEditorSelectionChangeEvent,
) { ) {
const editor = event.textEditor; const editor = event.textEditor;
@ -262,7 +262,7 @@ function getTextFromRange(txt: string, range: vscode.Range, length: integer) {
function convertChangeObjects( function convertChangeObjects(
oldText: string, oldText: string,
changeEvent: vscode.TextDocumentContentChangeEvent changeEvent: vscode.TextDocumentContentChangeEvent,
) { ) {
return { return {
lineNo: changeEvent.range.start.line, lineNo: changeEvent.range.start.line,
@ -270,7 +270,7 @@ function convertChangeObjects(
oldText: getTextFromRange( oldText: getTextFromRange(
oldText, oldText,
changeEvent.range, changeEvent.range,
changeEvent.rangeLength changeEvent.rangeLength,
), ),
x: changeEvent.range.start.character, x: changeEvent.range.start.character,
}; };
@ -338,17 +338,17 @@ function showChangeModeMenu() {
} }
export function registerParinferCommands( export function registerParinferCommands(
context: vscode.ExtensionContext context: vscode.ExtensionContext,
): void { ): void {
changeParinferMode( changeParinferMode(
(getConfig().opengoalParinferMode as ParinferMode) ?? ParinferMode.DISABLED (getConfig().opengoalParinferMode as ParinferMode) ?? ParinferMode.DISABLED,
); );
updateStatus(); updateStatus();
parinferStatusItem.hide(); // TODO - consolidate menu https://github.com/rust-lang/rust-analyzer/blob/9c03aa1ac2e67051db83a85baf3cfee902e4dd84/editors/code/src/ctx.ts#L406 parinferStatusItem.hide(); // TODO - consolidate menu https://github.com/rust-lang/rust-analyzer/blob/9c03aa1ac2e67051db83a85baf3cfee902e4dd84/editors/code/src/ctx.ts#L406
context.subscriptions.push( context.subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.parinfer.changeMode", "opengoal.parinfer.changeMode",
showChangeModeMenu showChangeModeMenu,
) ),
); );
} }

View file

@ -2,7 +2,7 @@ import * as vscode from "vscode";
export function getSymbolAtPosition( export function getSymbolAtPosition(
document: vscode.TextDocument, document: vscode.TextDocument,
position: vscode.Position position: vscode.Position,
) { ) {
const symbolRange = document.getWordRangeAtPosition(position, /[^\s()]+/g); const symbolRange = document.getWordRangeAtPosition(position, /[^\s()]+/g);
if (symbolRange === undefined) { if (symbolRange === undefined) {

View file

@ -6,7 +6,7 @@ export class IRCompletionItemProvider implements vscode.CompletionItemProvider {
document: vscode.TextDocument, document: vscode.TextDocument,
position: vscode.Position, position: vscode.Position,
token: vscode.CancellationToken, token: vscode.CancellationToken,
context: vscode.CompletionContext context: vscode.CompletionContext,
): vscode.ProviderResult< ): vscode.ProviderResult<
vscode.CompletionItem[] | vscode.CompletionList<vscode.CompletionItem> vscode.CompletionItem[] | vscode.CompletionList<vscode.CompletionItem>
> { > {
@ -29,7 +29,7 @@ export class IRCompletionItemProvider implements vscode.CompletionItemProvider {
position.line, position.line,
position.character - 1, position.character - 1,
position.line, position.line,
position.character position.character,
); );
let docstring = `"something\n`; let docstring = `"something\n`;
@ -51,7 +51,7 @@ export class IRCompletionItemProvider implements vscode.CompletionItemProvider {
resolveCompletionItem?( resolveCompletionItem?(
item: vscode.CompletionItem, item: vscode.CompletionItem,
token: vscode.CancellationToken token: vscode.CancellationToken,
): vscode.ProviderResult<vscode.CompletionItem> { ): vscode.ProviderResult<vscode.CompletionItem> {
throw new Error("Method not implemented."); throw new Error("Method not implemented.");
} }

View file

@ -29,8 +29,8 @@ export class IRFoldingRangeProvider implements vscode.FoldingRangeProvider {
new vscode.FoldingRange( new vscode.FoldingRange(
currFunctionStart, currFunctionStart,
i - 1, i - 1,
vscode.FoldingRangeKind.Region vscode.FoldingRangeKind.Region,
) ),
); );
} }
} }
@ -42,8 +42,8 @@ export class IRFoldingRangeProvider implements vscode.FoldingRangeProvider {
new vscode.FoldingRange( new vscode.FoldingRange(
currLabelStart, currLabelStart,
i - 1, i - 1,
vscode.FoldingRangeKind.Region vscode.FoldingRangeKind.Region,
) ),
); );
} }
currLabelStart = i; currLabelStart = i;
@ -56,8 +56,8 @@ export class IRFoldingRangeProvider implements vscode.FoldingRangeProvider {
new vscode.FoldingRange( new vscode.FoldingRange(
currLabelStart, currLabelStart,
i - 1, i - 1,
vscode.FoldingRangeKind.Region vscode.FoldingRangeKind.Region,
) ),
); );
currLabelStart = -1; currLabelStart = -1;
} }
@ -68,8 +68,8 @@ export class IRFoldingRangeProvider implements vscode.FoldingRangeProvider {
new vscode.FoldingRange( new vscode.FoldingRange(
currBranchStart, currBranchStart,
i - 1, i - 1,
vscode.FoldingRangeKind.Region vscode.FoldingRangeKind.Region,
) ),
); );
} }
currBranchStart = i; currBranchStart = i;
@ -82,8 +82,8 @@ export class IRFoldingRangeProvider implements vscode.FoldingRangeProvider {
new vscode.FoldingRange( new vscode.FoldingRange(
currBranchStart, currBranchStart,
i - 1, i - 1,
vscode.FoldingRangeKind.Region vscode.FoldingRangeKind.Region,
) ),
); );
currBranchStart = -1; currBranchStart = -1;
} }

View file

@ -62,7 +62,7 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
public async provideInlayHints( public async provideInlayHints(
document: vscode.TextDocument, document: vscode.TextDocument,
range: vscode.Range, range: vscode.Range,
token: vscode.CancellationToken token: vscode.CancellationToken,
): Promise<vscode.InlayHint[] | undefined> { ): Promise<vscode.InlayHint[] | undefined> {
// Check if the file has already been computed in the cache // Check if the file has already been computed in the cache
// We store the entire files hints in the cache and just return the ones that the range wants here // We store the entire files hints in the cache and just return the ones that the range wants here
@ -97,7 +97,7 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
private async getAllPotentialStackValues( private async getAllPotentialStackValues(
stackCastData: any, stackCastData: any,
stackOffset: number stackOffset: number,
): Promise<string[]> { ): Promise<string[]> {
// Consistently sort the values // Consistently sort the values
const values = []; const values = [];
@ -112,7 +112,7 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
private async generateStackCastHints( private async generateStackCastHints(
stackCastData: any, stackCastData: any,
lineNumber: number, lineNumber: number,
line: string line: string,
): Promise<vscode.InlayHint[]> { ): Promise<vscode.InlayHint[]> {
const hints = []; const hints = [];
// If the line has an op number, we will care about it // If the line has an op number, we will care about it
@ -133,7 +133,7 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
].map((a) => a.index); ].map((a) => a.index);
const hintLabel = await this.getAllPotentialStackValues( const hintLabel = await this.getAllPotentialStackValues(
stackCastData, stackCastData,
stackOffset stackOffset,
); );
for (const index of indexes) { for (const index of indexes) {
if (index === undefined) { if (index === undefined) {
@ -141,7 +141,7 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
} }
const newHint = new vscode.InlayHint( const newHint = new vscode.InlayHint(
new vscode.Position(lineNumber, index + `sp, ${stackOffset}`.length), new vscode.Position(lineNumber, index + `sp, ${stackOffset}`.length),
`: ${hintLabel.join(" | ")}` `: ${hintLabel.join(" | ")}`,
); );
newHint.paddingLeft = true; newHint.paddingLeft = true;
newHint.kind = vscode.InlayHintKind.Type; newHint.kind = vscode.InlayHintKind.Type;
@ -155,7 +155,7 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
private async getAllPotentialLabelValues( private async getAllPotentialLabelValues(
labelCastData: any, labelCastData: any,
labelRef: string labelRef: string,
): Promise<string[]> { ): Promise<string[]> {
// Consistently sort the values // Consistently sort the values
const values = []; const values = [];
@ -174,7 +174,7 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
private async generateLabelCastHints( private async generateLabelCastHints(
labelCastData: any, labelCastData: any,
lineNumber: number, lineNumber: number,
line: string line: string,
): Promise<vscode.InlayHint[]> { ): Promise<vscode.InlayHint[]> {
const hints = []; const hints = [];
// If the line has an op number, we will care about it // If the line has an op number, we will care about it
@ -191,11 +191,11 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
continue; continue;
} }
const indexes = [...line.matchAll(new RegExp(labelRef, "gi"))].map( const indexes = [...line.matchAll(new RegExp(labelRef, "gi"))].map(
(a) => a.index (a) => a.index,
); );
const hintLabel = await this.getAllPotentialLabelValues( const hintLabel = await this.getAllPotentialLabelValues(
labelCastData, labelCastData,
labelRef labelRef,
); );
for (const index of indexes) { for (const index of indexes) {
if (index === undefined) { if (index === undefined) {
@ -203,7 +203,7 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
} }
const newHint = new vscode.InlayHint( const newHint = new vscode.InlayHint(
new vscode.Position(lineNumber, index + `L${labelRef}`.length), new vscode.Position(lineNumber, index + `L${labelRef}`.length),
`: ${hintLabel.join(" | ")}` `: ${hintLabel.join(" | ")}`,
); );
newHint.paddingLeft = true; newHint.paddingLeft = true;
newHint.kind = vscode.InlayHintKind.Type; newHint.kind = vscode.InlayHintKind.Type;
@ -218,7 +218,7 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
private async getAllPotentialTypeValues( private async getAllPotentialTypeValues(
typeCastData: any, typeCastData: any,
opNumber: number, opNumber: number,
register: string register: string,
): Promise<string[]> { ): Promise<string[]> {
// Consistently sort the values // Consistently sort the values
const values = []; const values = [];
@ -241,7 +241,7 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
private async generateTypeCastHints( private async generateTypeCastHints(
typeCastData: any, typeCastData: any,
lineNumber: number, lineNumber: number,
line: string line: string,
): Promise<vscode.InlayHint[]> { ): Promise<vscode.InlayHint[]> {
const hints = []; const hints = [];
// If the line has an op number, we will care about it // If the line has an op number, we will care about it
@ -268,12 +268,12 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
continue; continue;
} }
const indexes = [...line.matchAll(new RegExp(register, "gi"))].map( const indexes = [...line.matchAll(new RegExp(register, "gi"))].map(
(a) => a.index (a) => a.index,
); );
const hintLabel = await this.getAllPotentialTypeValues( const hintLabel = await this.getAllPotentialTypeValues(
typeCastData, typeCastData,
opNumber, opNumber,
register register,
); );
for (const index of indexes) { for (const index of indexes) {
if (index === undefined) { if (index === undefined) {
@ -281,7 +281,7 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
} }
const newHint = new vscode.InlayHint( const newHint = new vscode.InlayHint(
new vscode.Position(lineNumber, index + register.length), new vscode.Position(lineNumber, index + register.length),
`: ${hintLabel.join(" | ")}` `: ${hintLabel.join(" | ")}`,
); );
newHint.paddingLeft = true; newHint.paddingLeft = true;
newHint.kind = vscode.InlayHintKind.Type; newHint.kind = vscode.InlayHintKind.Type;
@ -295,12 +295,12 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
} }
private async computeHintsForDocument( private async computeHintsForDocument(
document: vscode.TextDocument document: vscode.TextDocument,
): Promise<vscode.InlayHint[] | undefined> { ): Promise<vscode.InlayHint[] | undefined> {
const projectRoot = getWorkspaceFolderByName("jak-project"); const projectRoot = getWorkspaceFolderByName("jak-project");
if (projectRoot === undefined) { if (projectRoot === undefined) {
vscode.window.showErrorMessage( vscode.window.showErrorMessage(
"OpenGOAL - Unable to locate 'jak-project' workspace folder" "OpenGOAL - Unable to locate 'jak-project' workspace folder",
); );
return undefined; return undefined;
} }
@ -308,19 +308,19 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
const labelCastData = getCastFileData( const labelCastData = getCastFileData(
projectRoot, projectRoot,
document, document,
"label_types.jsonc" "label_types.jsonc",
); );
const stackCastData = getCastFileData( const stackCastData = getCastFileData(
projectRoot, projectRoot,
document, document,
"stack_structures.jsonc" "stack_structures.jsonc",
); );
const typeCastData = getCastFileData( const typeCastData = getCastFileData(
projectRoot, projectRoot,
document, document,
"type_casts.jsonc" "type_casts.jsonc",
); );
let funcName = undefined; let funcName = undefined;
@ -331,7 +331,7 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
// Label casts are file-level, so the func name doesn't matter // Label casts are file-level, so the func name doesn't matter
if (labelCastData !== undefined && fileName in labelCastData) { if (labelCastData !== undefined && fileName in labelCastData) {
hints = hints.concat( hints = hints.concat(
await this.generateLabelCastHints(labelCastData[fileName], i, line) await this.generateLabelCastHints(labelCastData[fileName], i, line),
); );
} }
@ -348,12 +348,12 @@ export class IRInlayHintsProvider implements vscode.InlayHintsProvider {
// Collect any potential hints for this line // Collect any potential hints for this line
if (typeCastData !== undefined && funcName in typeCastData) { if (typeCastData !== undefined && funcName in typeCastData) {
hints = hints.concat( hints = hints.concat(
await this.generateTypeCastHints(typeCastData[funcName], i, line) await this.generateTypeCastHints(typeCastData[funcName], i, line),
); );
} }
if (stackCastData !== undefined && funcName in stackCastData) { if (stackCastData !== undefined && funcName in stackCastData) {
hints = hints.concat( hints = hints.concat(
await this.generateStackCastHints(stackCastData[funcName], i, line) await this.generateStackCastHints(stackCastData[funcName], i, line),
); );
} }
} }

View file

@ -9,7 +9,7 @@ export class IRRenameProvider implements vscode.RenameProvider {
document: vscode.TextDocument, document: vscode.TextDocument,
position: vscode.Position, position: vscode.Position,
newName: string, newName: string,
token: vscode.CancellationToken token: vscode.CancellationToken,
): Promise<vscode.WorkspaceEdit | undefined> { ): Promise<vscode.WorkspaceEdit | undefined> {
const symbol = getSymbolAtPosition(document, position); const symbol = getSymbolAtPosition(document, position);
if (symbol === undefined) { if (symbol === undefined) {

View file

@ -4,7 +4,7 @@ import * as vscode from "vscode";
// This is somewhat guaranteed by the fact that this is how the embded syntax highlighting works // This is somewhat guaranteed by the fact that this is how the embded syntax highlighting works
export function insideGoalCodeInIR( export function insideGoalCodeInIR(
document: vscode.TextDocument, document: vscode.TextDocument,
position: vscode.Position position: vscode.Position,
): boolean { ): boolean {
// Somewhat primitive, walk back until we find a `;;-*-OpenGOAL-Start-*-` before we find a `.function` // Somewhat primitive, walk back until we find a `;;-*-OpenGOAL-Start-*-` before we find a `.function`
let idx = position.line; let idx = position.line;
@ -23,7 +23,7 @@ export function insideGoalCodeInIR(
export async function getFuncNameFromPosition( export async function getFuncNameFromPosition(
document: vscode.TextDocument, document: vscode.TextDocument,
position: vscode.Position position: vscode.Position,
): Promise<string | undefined> { ): Promise<string | undefined> {
const funcNameRegex = /; \.function (.*).*/g; const funcNameRegex = /; \.function (.*).*/g;
for (let i = position.line; i >= 0; i--) { for (let i = position.line; i >= 0; i--) {
@ -34,14 +34,14 @@ export async function getFuncNameFromPosition(
} }
} }
await vscode.window.showErrorMessage( await vscode.window.showErrorMessage(
"Couldn't determine function or method name" "Couldn't determine function or method name",
); );
return undefined; return undefined;
} }
export async function getFuncNameFromSelection( export async function getFuncNameFromSelection(
document: vscode.TextDocument, document: vscode.TextDocument,
selection: vscode.Selection selection: vscode.Selection,
): Promise<string | undefined> { ): Promise<string | undefined> {
return await getFuncNameFromPosition(document, selection.start); return await getFuncNameFromPosition(document, selection.start);
} }

View file

@ -11,7 +11,7 @@ export class OpenGOALDisasmRenameProvider implements vscode.RenameProvider {
document: vscode.TextDocument, document: vscode.TextDocument,
position: vscode.Position, position: vscode.Position,
newName: string, newName: string,
token: vscode.CancellationToken token: vscode.CancellationToken,
): Promise<vscode.WorkspaceEdit | undefined> { ): Promise<vscode.WorkspaceEdit | undefined> {
const symbol = getSymbolAtPosition(document, position); const symbol = getSymbolAtPosition(document, position);
if (symbol === undefined) { if (symbol === undefined) {

View file

@ -12,7 +12,7 @@ export interface ArgumentDefinition {
} }
export function getArgumentsInSignature( export function getArgumentsInSignature(
signature: string signature: string,
): ArgumentDefinition[] { ): ArgumentDefinition[] {
const isArgument = const isArgument =
signature.includes("defun") || signature.includes("defun") ||
@ -50,7 +50,7 @@ export function getArgumentsInSignature(
// TODO - likely doesn't work on states // TODO - likely doesn't work on states
export function getSymbolsArgumentInfo( export function getSymbolsArgumentInfo(
line: string, line: string,
symbol: string symbol: string,
): ArgumentMeta | undefined { ): ArgumentMeta | undefined {
// TODO - 'new' method handling // TODO - 'new' method handling
// If it's an argument, we have to figure out the index // If it's an argument, we have to figure out the index
@ -80,7 +80,7 @@ export function getSymbolsArgumentInfo(
// Determines the name of the current function/method that we are in // Determines the name of the current function/method that we are in
export function determineCurrentFunctionName( export function determineCurrentFunctionName(
document: vscode.TextDocument, document: vscode.TextDocument,
position: vscode.Position position: vscode.Position,
): string | undefined { ): string | undefined {
for (let i = position.line; i > 0; i--) { for (let i = position.line; i > 0; i--) {
const currLine = document.lineAt(i).text; const currLine = document.lineAt(i).text;

View file

@ -5,7 +5,7 @@ import { downloadFromUrl } from "../utils/download";
export async function downloadLsp( export async function downloadLsp(
extensionPath: string, extensionPath: string,
version: string version: string,
): Promise<string | undefined> { ): Promise<string | undefined> {
const assetName = getLspReleaseAssetName(version); const assetName = getLspReleaseAssetName(version);
if (assetName === undefined) { if (assetName === undefined) {

View file

@ -90,12 +90,12 @@ class LSPStatusItem {
} }
const statusItem = new LSPStatusItem( const statusItem = new LSPStatusItem(
vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 0) vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 0),
); );
async function ensureServerDownloaded(): Promise<string | undefined> { async function ensureServerDownloaded(): Promise<string | undefined> {
const installedVersion = getVersionFromMetaFile( const installedVersion = getVersionFromMetaFile(
extensionContext.extensionPath extensionContext.extensionPath,
); );
const configuredVersion = getConfig().opengoalLspVersion; const configuredVersion = getConfig().opengoalLspVersion;
@ -116,7 +116,7 @@ async function ensureServerDownloaded(): Promise<string | undefined> {
// Check that the file wasn't unexpectedly removed // Check that the file wasn't unexpectedly removed
const lspPath = getLspPath( const lspPath = getLspPath(
extensionContext.extensionPath, extensionContext.extensionPath,
installedVersion installedVersion,
); );
if (lspPath === undefined) { if (lspPath === undefined) {
versionToDownload = latestVersion; versionToDownload = latestVersion;
@ -130,7 +130,7 @@ async function ensureServerDownloaded(): Promise<string | undefined> {
statusItem.updateStatus("downloading", versionToDownload); statusItem.updateStatus("downloading", versionToDownload);
const newLspPath = await downloadLsp( const newLspPath = await downloadLsp(
extensionContext.extensionPath, extensionContext.extensionPath,
versionToDownload versionToDownload,
); );
if (newLspPath === undefined) { if (newLspPath === undefined) {
statusItem.updateStatus("error"); statusItem.updateStatus("error");
@ -149,7 +149,7 @@ async function maybeDownloadLspServer(): Promise<void> {
// Copy the binary to the extension directory so it doesn't block future compilations // Copy the binary to the extension directory so it doesn't block future compilations
const lspPath = path.join( const lspPath = path.join(
extensionContext.extensionPath, extensionContext.extensionPath,
`opengoal-lsp-local.bin` `opengoal-lsp-local.bin`,
); );
fs.copyFileSync(userConfiguredOpengoalLspPath, lspPath); fs.copyFileSync(userConfiguredOpengoalLspPath, lspPath);
opengoalLspPath = lspPath; opengoalLspPath = lspPath;
@ -202,7 +202,7 @@ function createClient(lspPath: string): LanguageClient {
"opengoal-lsp", "opengoal-lsp",
"OpenGOAL LSP", "OpenGOAL LSP",
serverOptions, serverOptions,
clientOptions clientOptions,
); );
} }
@ -255,7 +255,7 @@ class StatusBarFeature implements StaticFeature {
disposeAll(this.requestHandlers); disposeAll(this.requestHandlers);
} }
}); });
}) }),
); );
} }
} }
@ -300,7 +300,7 @@ async function restartClient() {
function showMenu( function showMenu(
items: vscode.QuickPickItem[], items: vscode.QuickPickItem[],
commands: Record<string, string> commands: Record<string, string>,
) { ) {
void vscode.window void vscode.window
.showQuickPick(items, { title: "OpenGOAL LSP" }) .showQuickPick(items, { title: "OpenGOAL LSP" })
@ -336,24 +336,24 @@ function startedMenuCommand() {
function registerLifeCycleCommands(context: vscode.ExtensionContext): void { function registerLifeCycleCommands(context: vscode.ExtensionContext): void {
context.subscriptions.push( context.subscriptions.push(
vscode.commands.registerCommand("opengoal.lsp.start", startClientCommand) vscode.commands.registerCommand("opengoal.lsp.start", startClientCommand),
); );
context.subscriptions.push( context.subscriptions.push(
vscode.commands.registerCommand("opengoal.lsp.stop", stopClient) vscode.commands.registerCommand("opengoal.lsp.stop", stopClient),
); );
context.subscriptions.push( context.subscriptions.push(
vscode.commands.registerCommand("opengoal.lsp.restart", restartClient) vscode.commands.registerCommand("opengoal.lsp.restart", restartClient),
); );
context.subscriptions.push( context.subscriptions.push(
vscode.commands.registerCommand( vscode.commands.registerCommand(
"opengoal.lsp.showLspStartedMenu", "opengoal.lsp.showLspStartedMenu",
startedMenuCommand startedMenuCommand,
) ),
); );
} }
export async function activate( export async function activate(
context: vscode.ExtensionContext context: vscode.ExtensionContext,
): Promise<void> { ): Promise<void> {
extensionContext = context; extensionContext = context;
registerLifeCycleCommands(context); registerLifeCycleCommands(context);

View file

@ -13,7 +13,7 @@ const versionFileName = "lsp-metadata.json";
export function getLspReleaseAssetName( export function getLspReleaseAssetName(
version: string, version: string,
platform: string = process.platform platform: string = process.platform,
): string | undefined { ): string | undefined {
if (!(platform in artifactNameTemplates)) { if (!(platform in artifactNameTemplates)) {
console.log(`Unsupported platform '${platform}'`); console.log(`Unsupported platform '${platform}'`);
@ -31,7 +31,7 @@ export function getLspReleaseAssetName(
export async function getLatestVersion(): Promise<string> { export async function getLatestVersion(): Promise<string> {
try { try {
const releasesJSON = await fetchFromUrl( const releasesJSON = await fetchFromUrl(
"https://api.github.com/repos/open-goal/jak-project/releases" "https://api.github.com/repos/open-goal/jak-project/releases",
); );
const releases = JSON.parse(releasesJSON); const releases = JSON.parse(releasesJSON);
return releases[0].tag_name; return releases[0].tag_name;
@ -42,7 +42,7 @@ export async function getLatestVersion(): Promise<string> {
export function getLspPath( export function getLspPath(
extensionPath: string, extensionPath: string,
version: string version: string,
): string | undefined { ): string | undefined {
const lspName = getLspReleaseAssetName(version); const lspName = getLspReleaseAssetName(version);
if (lspName === undefined) { if (lspName === undefined) {
@ -73,7 +73,7 @@ export function writeLspMetadata(extensionPath: string, version: string): void {
filePath, filePath,
JSON.stringify({ JSON.stringify({
version: version, version: version,
}) }),
); );
} catch (e: any) { } catch (e: any) {
console.log("Could not write lsp metadata file.", e.message); console.log("Could not write lsp metadata file.", e.message);

View file

@ -9,7 +9,7 @@ let socket: PromiseSocket<Socket> | undefined = undefined;
const nreplStatusItem = vscode.window.createStatusBarItem( const nreplStatusItem = vscode.window.createStatusBarItem(
vscode.StatusBarAlignment.Left, vscode.StatusBarAlignment.Left,
0 0,
); );
function updateStatus() { function updateStatus() {
@ -95,7 +95,7 @@ export async function reloadFile(fileName: string) {
export function registerNReplCommands(context: vscode.ExtensionContext): void { export function registerNReplCommands(context: vscode.ExtensionContext): void {
context.subscriptions.push( context.subscriptions.push(
vscode.commands.registerCommand("opengoal.nrepl.jackin", jackIn), vscode.commands.registerCommand("opengoal.nrepl.jackin", jackIn),
vscode.commands.registerCommand("opengoal.nrepl.unjack", unJack) vscode.commands.registerCommand("opengoal.nrepl.unjack", unJack),
); );
updateStatus(); updateStatus();
nreplStatusItem.show(); nreplStatusItem.show();

View file

@ -21,7 +21,7 @@ export async function fetchFromUrl(fullUrl: string): Promise<string> {
res.on("end", () => { res.on("end", () => {
resolve(data); resolve(data);
}); });
} },
) )
.on("error", (err: any) => { .on("error", (err: any) => {
console.error(`Error downloading file from ${url}: ${err.message}`); console.error(`Error downloading file from ${url}: ${err.message}`);
@ -32,7 +32,7 @@ export async function fetchFromUrl(fullUrl: string): Promise<string> {
export async function downloadFromUrl( export async function downloadFromUrl(
url: string, url: string,
filePath: string filePath: string,
): Promise<void> { ): Promise<void> {
console.log("Downloading file from", url); console.log("Downloading file from", url);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View file

@ -56,7 +56,7 @@ export function determineGameFromPath(path: vscode.Uri): GameName | undefined {
} }
export function determineGameFromAllTypes( export function determineGameFromAllTypes(
path: vscode.Uri path: vscode.Uri,
): GameName | undefined { ): GameName | undefined {
if (path.fsPath.includes("jak2")) { if (path.fsPath.includes("jak2")) {
return GameName.Jak2; return GameName.Jak2;
@ -86,12 +86,12 @@ async function* walkForName(dir: string, name: string): any {
export async function findFileInGoalSrc( export async function findFileInGoalSrc(
rootFolder: vscode.Uri, rootFolder: vscode.Uri,
gameName: string, gameName: string,
fileName: string fileName: string,
): Promise<string | undefined> { ): Promise<string | undefined> {
const searchFolder = vscode.Uri.joinPath( const searchFolder = vscode.Uri.joinPath(
rootFolder, rootFolder,
"goal_src", "goal_src",
gameName gameName,
).fsPath; ).fsPath;
if (!fileName.includes(".gc")) { if (!fileName.includes(".gc")) {
@ -110,7 +110,7 @@ export async function findFileInGoalSrc(
export async function updateFileBeforeDecomp( export async function updateFileBeforeDecomp(
filePath: string, filePath: string,
content: string content: string,
) { ) {
const fileContents = await fs.readFile(filePath, "utf-8"); const fileContents = await fs.readFile(filePath, "utf-8");
const fileLines = fileContents.split(/\r?\n/); const fileLines = fileContents.split(/\r?\n/);

View file

@ -24,7 +24,7 @@ export function getFileNamesFromUris(uris: vscode.Uri[]): string[] {
export function truncateFileNameEndings( export function truncateFileNameEndings(
names: string[], names: string[],
toRemove: string toRemove: string,
): string[] { ): string[] {
return names.map((name) => name.split(toRemove)[0]); return names.map((name) => name.split(toRemove)[0]);
} }

View file

@ -15,7 +15,7 @@ export class PdfPreview extends Disposable {
constructor( constructor(
private readonly extensionRoot: vscode.Uri, private readonly extensionRoot: vscode.Uri,
private readonly resource: vscode.Uri, private readonly resource: vscode.Uri,
private readonly webviewEditor: vscode.WebviewPanel private readonly webviewEditor: vscode.WebviewPanel,
) { ) {
super(); super();
this.associatedUri = resource; this.associatedUri = resource;
@ -36,42 +36,42 @@ export class PdfPreview extends Disposable {
"vscode.openWith", "vscode.openWith",
resource, resource,
"default", "default",
webviewEditor.viewColumn webviewEditor.viewColumn,
); );
break; break;
} }
} }
}) }),
); );
this._register( this._register(
webviewEditor.onDidChangeViewState(() => { webviewEditor.onDidChangeViewState(() => {
this.update(); this.update();
}) }),
); );
this._register( this._register(
webviewEditor.onDidDispose(() => { webviewEditor.onDidDispose(() => {
this._previewState = "Disposed"; this._previewState = "Disposed";
}) }),
); );
const watcher = this._register( const watcher = this._register(
vscode.workspace.createFileSystemWatcher(resource.fsPath) vscode.workspace.createFileSystemWatcher(resource.fsPath),
); );
this._register( this._register(
watcher.onDidChange((e) => { watcher.onDidChange((e) => {
if (e.toString() === this.resource.toString()) { if (e.toString() === this.resource.toString()) {
this.reload(); this.reload();
} }
}) }),
); );
this._register( this._register(
watcher.onDidDelete((e) => { watcher.onDidDelete((e) => {
if (e.toString() === this.resource.toString()) { if (e.toString() === this.resource.toString()) {
this.webviewEditor.dispose(); this.webviewEditor.dispose();
} }
}) }),
); );
this.webviewEditor.webview.html = this.getWebviewContents(); this.webviewEditor.webview.html = this.getWebviewContents();
@ -133,7 +133,7 @@ export class PdfPreview extends Disposable {
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; connect-src ${cspSource}; script-src 'unsafe-inline' ${cspSource}; style-src 'unsafe-inline' ${cspSource}; img-src blob: data: ${cspSource};"> <meta http-equiv="Content-Security-Policy" content="default-src 'none'; connect-src ${cspSource}; script-src 'unsafe-inline' ${cspSource}; style-src 'unsafe-inline' ${cspSource}; img-src blob: data: ${cspSource};">
<meta id="pdf-preview-config" data-config="${escapeAttribute( <meta id="pdf-preview-config" data-config="${escapeAttribute(
JSON.stringify(settings) JSON.stringify(settings),
)}"> )}">
<title>PDF.js viewer</title> <title>PDF.js viewer</title>
<link rel="resource" type="application/l10n" href="${resolveAsUri( <link rel="resource" type="application/l10n" href="${resolveAsUri(
@ -141,25 +141,25 @@ export class PdfPreview extends Disposable {
"pdfjs", "pdfjs",
"web", "web",
"locale", "locale",
"locale.properties" "locale.properties",
)}"> )}">
<link rel="stylesheet" href="${resolveAsUri( <link rel="stylesheet" href="${resolveAsUri(
"lib", "lib",
"pdfjs", "pdfjs",
"web", "web",
"viewer.css" "viewer.css",
)}"> )}">
<link rel="stylesheet" href="${resolveAsUri( <link rel="stylesheet" href="${resolveAsUri(
"lib", "lib",
"vscode-pdfviewer", "vscode-pdfviewer",
"pdf.css" "pdf.css",
)}"> )}">
<script src="${resolveAsUri("lib", "pdfjs", "build", "pdf.js")}"></script> <script src="${resolveAsUri("lib", "pdfjs", "build", "pdf.js")}"></script>
<script src="${resolveAsUri( <script src="${resolveAsUri(
"lib", "lib",
"pdfjs", "pdfjs",
"build", "build",
"pdf.worker.js" "pdf.worker.js",
)}"></script> )}"></script>
<script src="${resolveAsUri("lib", "pdfjs", "web", "viewer.js")}"></script> <script src="${resolveAsUri("lib", "pdfjs", "web", "viewer.js")}"></script>
<script src="${resolveAsUri("lib", "vscode-pdfviewer", "main.js")}"></script> <script src="${resolveAsUri("lib", "vscode-pdfviewer", "main.js")}"></script>

View file

@ -16,12 +16,12 @@ export class PdfCustomProvider implements vscode.CustomReadonlyEditorProvider {
public async resolveCustomEditor( public async resolveCustomEditor(
document: vscode.CustomDocument, document: vscode.CustomDocument,
webviewEditor: vscode.WebviewPanel webviewEditor: vscode.WebviewPanel,
): Promise<void> { ): Promise<void> {
const preview = new PdfPreview( const preview = new PdfPreview(
this.extensionRoot, this.extensionRoot,
document.uri, document.uri,
webviewEditor webviewEditor,
); );
this._previews.set(document.uri, preview); this._previews.set(document.uri, preview);
this.setActivePreview(preview); this.setActivePreview(preview);