Better error handling
This commit is contained in:
@@ -64,9 +64,7 @@ export class ScriptCompiler {
|
||||
const readStart = Date.now();
|
||||
for (const entry of entries) {
|
||||
if (entry.isFile() && entry.name.endsWith('.lua')) {
|
||||
|
||||
|
||||
const fullPath = path.join(entry.parentPath ?? entry.path, entry.name);
|
||||
const fullPath = path.join(entry.parentPath, entry.name);
|
||||
const relativePath = path.relative(this.options.sourcePath, fullPath);
|
||||
const content = fs.readFileSync(fullPath, 'utf-8');
|
||||
|
||||
@@ -90,7 +88,7 @@ export class ScriptCompiler {
|
||||
const writeEnd = Date.now();
|
||||
metricsMeter.writeTimeMs = (writeEnd - writeStart);
|
||||
|
||||
writer.logDependencyTree();
|
||||
// writer.logDependencyTree();
|
||||
this.logger.info(`Compilation complete. Output written to ${path.join(this.options.outputPath, this.options.outputFileName!)}`);
|
||||
const end = Date.now();
|
||||
|
||||
@@ -370,16 +368,19 @@ class Writer {
|
||||
const depth : number = 1;
|
||||
this.logger.writeLine('Dependency Tree <root>:');
|
||||
const logFileRecursive = (parsedFile: ParsedFile, currentDepth: number) => {
|
||||
if (visited.has(parsedFile.fileKey)) {
|
||||
if(currentDepth === 0 && visited.has(parsedFile.fileKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
visited.add(parsedFile.fileKey);
|
||||
let padding = ' '.repeat(currentDepth);
|
||||
let padding = ' '.repeat(currentDepth * 2);
|
||||
if (currentDepth > 0) {
|
||||
padding = ' '.repeat(currentDepth) + '└─>';
|
||||
padding += '└─>';
|
||||
}
|
||||
|
||||
const printable = parsedFile.fileKey.replace(LUA_SCRIPT_GLOBAL_KEYWORD + '.', '');
|
||||
this.logger.writeLine(padding + printable);
|
||||
const lastPart = printable.split('.').pop();
|
||||
this.logger.writeLine(`${padding} ${lastPart} ${' '.repeat(Math.max(0, 64 - padding.length - (lastPart ? lastPart.length : 0)))} ${printable}`);
|
||||
for (const dep of parsedFile.dependencies) {
|
||||
const depFile = this.files.get(dep.fileKey);
|
||||
if (depFile) {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "Node16",
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2022"],
|
||||
"strict": true,
|
||||
"sourceMap": true,
|
||||
"types": ["node"],
|
||||
"esModuleInterop": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
@@ -26,9 +26,9 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
pluginPath = context.asAbsolutePath('lua-addons');
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand('dutchies-dcs-scripting-tools.enable', () => {
|
||||
vscode.commands.registerCommand('dutchies-dcs-scripting-tools.enable', async () => {
|
||||
addPluginPathToSettings();
|
||||
vscode.commands.executeCommand(
|
||||
await vscode.commands.executeCommand(
|
||||
"lua.startServer"
|
||||
);
|
||||
vscode.window.showInformationMessage('Dutchies DCS Scripting Tools enabled.');
|
||||
@@ -36,9 +36,9 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
);
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand('dutchies-dcs-scripting-tools.disable', () => {
|
||||
vscode.commands.registerCommand('dutchies-dcs-scripting-tools.disable', async () => {
|
||||
removePluginPathFromSettings();
|
||||
vscode.commands.executeCommand(
|
||||
await vscode.commands.executeCommand(
|
||||
"lua.startServer"
|
||||
);
|
||||
vscode.window.showInformationMessage('Dutchies DCS Scripting Tools disabled.');
|
||||
@@ -46,8 +46,8 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
);
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand('dutchies-dcs-scripting-tools.openSettings', () => {
|
||||
vscode.commands.executeCommand("workbench.action.openSettings", `@ext:${extensionSettingsFilter}`);
|
||||
vscode.commands.registerCommand('dutchies-dcs-scripting-tools.openSettings', async () => {
|
||||
await vscode.commands.executeCommand("workbench.action.openSettings", `@ext:${extensionSettingsFilter}`);
|
||||
}));
|
||||
|
||||
context.subscriptions.push(
|
||||
@@ -74,6 +74,18 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
}
|
||||
});
|
||||
|
||||
vscode.workspace.onDidChangeConfiguration(async(event) => {
|
||||
if (event.affectsConfiguration(`${extensionName}.dcsTypes`)) {
|
||||
const config = vscode.workspace.getConfiguration(extensionName);
|
||||
const dcsTypesEnabled = config.get<boolean>('dcsTypes') || false;
|
||||
if (dcsTypesEnabled) {
|
||||
addPluginPathToSettings();
|
||||
} else {
|
||||
removePluginPathFromSettings();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
logger.info('Dutchies DCS Scripting Tools extension activated');
|
||||
}
|
||||
|
||||
@@ -148,6 +160,22 @@ async function compileLuaScripts() {
|
||||
}
|
||||
}
|
||||
|
||||
async function enableIntellisense() {
|
||||
addPluginPathToSettings();
|
||||
await vscode.commands.executeCommand(
|
||||
"lua.startServer"
|
||||
);
|
||||
vscode.window.showInformationMessage('Dutchies DCS Scripting Tools enabled.');
|
||||
}
|
||||
|
||||
async function disableIntellisense() {
|
||||
removePluginPathFromSettings();
|
||||
await vscode.commands.executeCommand(
|
||||
"lua.startServer"
|
||||
);
|
||||
vscode.window.showInformationMessage('Dutchies DCS Scripting Tools disabled.');
|
||||
}
|
||||
|
||||
function addPluginPathToSettings() {
|
||||
if (pluginPath) {
|
||||
const luaSettings = vscode.workspace.getConfiguration(luaWorkSpaceSettingKey);
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"dcs-script-compiler": ["../compiler/src/ScriptCompiler.ts"]
|
||||
},
|
||||
"types": [
|
||||
"node"
|
||||
"node",
|
||||
"mocha"
|
||||
],
|
||||
/* Additional Checks */
|
||||
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
|
||||
Generated
+1
-5
@@ -10,6 +10,7 @@
|
||||
"dutchies-dcs-scripting-tools"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^10.0.10",
|
||||
"@types/node": "^25.5.2"
|
||||
}
|
||||
},
|
||||
@@ -911,7 +912,6 @@
|
||||
"integrity": "sha512-BtE0k6cjwjLZoZixN0t5AKP0kSzlGu7FctRXYuPAm//aaiZhmfq1JwdYpYr1brzEspYyFeF+8XF5j2VK6oalrA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "8.54.0",
|
||||
"@typescript-eslint/types": "8.54.0",
|
||||
@@ -1144,7 +1144,6 @@
|
||||
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
@@ -2081,7 +2080,6 @@
|
||||
"integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.8.0",
|
||||
"@eslint-community/regexpp": "^4.12.1",
|
||||
@@ -5171,7 +5169,6 @@
|
||||
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
@@ -5302,7 +5299,6 @@
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
|
||||
+10
-1
@@ -6,6 +6,15 @@
|
||||
"dutchies-dcs-scripting-tools"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^25.5.2"
|
||||
"@types/vscode": "^1.108.1",
|
||||
"@types/mocha": "^10.0.10",
|
||||
"@types/node": "22.x",
|
||||
"typescript-eslint": "^8.52.0",
|
||||
"eslint": "^9.39.2",
|
||||
"esbuild": "^0.27.2",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"typescript": "^5.9.3",
|
||||
"@vscode/test-cli": "^0.0.12",
|
||||
"@vscode/test-electron": "^2.5.2"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user