Skip to content

Commit b884f7f

Browse files
committed
Migrate nwnsc to nwn_script_compiler
1 parent 0d90955 commit b884f7f

File tree

3 files changed

+24
-33
lines changed

3 files changed

+24
-33
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"url": "https://github.com/PhilippeChab/nwscript-ee-language-server"
99
},
1010
"license": "MIT",
11-
"version": "2.1.0",
11+
"version": "2.2.0",
1212
"author": {
1313
"name": "Philippe Chabot"
1414
},
2.21 MB
Binary file not shown.

server/src/Providers/DiagnosticsProvider.ts

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { ServerManager } from "../ServerManager";
88
import Provider from "./Provider";
99

1010
const lineNumber = /\(([^)]+)\)/;
11-
const lineMessage = /(Error|Warning):(.*)/;
12-
const lineFilename = /^[^(]+/;
11+
const lineMessage = /(ERROR|WARNING):(.*)/;
12+
const lineFilename = /(:\s)([^(]+)/;
1313

1414
enum OS {
1515
linux = "Linux",
@@ -25,7 +25,7 @@ export default class DiagnoticsProvider extends Provider {
2525

2626
private generateDiagnostics(uris: string[], files: FilesDiagnostics, severity: DiagnosticSeverity) {
2727
return (line: string) => {
28-
const uri = uris.find((uri) => basename(fileURLToPath(uri)) === lineFilename.exec(line)![0]);
28+
const uri = uris.find((uri) => basename(fileURLToPath(uri)) === lineFilename.exec(line)![2]);
2929

3030
if (uri) {
3131
const linePosition = Number(lineNumber.exec(line)![1]) - 1;
@@ -52,7 +52,7 @@ export default class DiagnoticsProvider extends Provider {
5252

5353
switch (specifiedOs) {
5454
case OS.linux:
55-
return "../resources/compiler/linux/nwnsc";
55+
return "../resources/compiler/linux/nwn_script_comp";
5656
case OS.mac:
5757
return "../resources/compiler/mac/nwnsc";
5858
case OS.windows:
@@ -98,31 +98,27 @@ export default class DiagnoticsProvider extends Provider {
9898
if (verbose) {
9999
this.server.logger.info(`Compiling ${document.uri}:`);
100100
}
101-
// The compiler command:
101+
// The compiler commands:
102102
// - y; continue on error
103-
// - c; compile includes
104-
// - l; try to load resources if paths are not supplied
105-
// - r; don't generate the compiled file
106-
// - h; game home path
107-
// - n; game installation path
108-
// - i; includes directories
109-
const args = ["-y", "-c", "-l", "-r", "SKIP_OUTPUT"];
103+
// - s; dry run
104+
const args = ["-y", "-s"];
110105
if (Boolean(nwnHome)) {
111-
args.push("-h");
106+
args.push("--userdirectory");
112107
args.push(`"${nwnHome}"`);
113108
} else if (verbose) {
114109
this.server.logger.info("Trying to resolve Neverwinter Nights home directory automatically.");
115110
}
116111
if (Boolean(nwnInstallation)) {
117-
args.push("-n");
112+
args.push("--root");
118113
args.push(`"${nwnInstallation}"`);
119114
} else if (verbose) {
120115
this.server.logger.info("Trying to resolve Neverwinter Nights installation directory automatically.");
121116
}
122-
if (children.length > 0) {
123-
args.push("-i");
124-
args.push(`"${[...new Set(uris.map((uri) => dirname(fileURLToPath(uri))))].join(";")}"`);
125-
}
117+
// if (children.length > 0) {
118+
// args.push("-i");
119+
// args.push(`"${[...new Set(uris.map((uri) => dirname(fileURLToPath(uri))))].join(";")}"`);
120+
// }
121+
args.push("-c");
126122
args.push(`"${fileURLToPath(uri)}"`);
127123

128124
let stdout = "";
@@ -144,38 +140,33 @@ export default class DiagnoticsProvider extends Provider {
144140
});
145141

146142
child.on("close", (_) => {
147-
const lines = stdout
143+
const lines = stderr
148144
.toString()
149145
.split("\n")
150146
.filter((line) => line !== "\r" && line !== "\n" && Boolean(line));
151147
const errors: string[] = [];
152148
const warnings: string[] = [];
153149

154150
lines.forEach((line) => {
155-
if (verbose && !line.includes("Compiling:")) {
151+
if (verbose) {
156152
this.server.logger.info(line);
157153
}
158154

159155
// Diagnostics
160-
if (line.includes("Error:")) {
156+
if (line.includes("ERROR:")) {
161157
errors.push(line);
162158
}
163-
if (reportWarnings && line.includes("Warning:")) {
159+
160+
if (reportWarnings && line.includes("WARNING:")) {
164161
warnings.push(line);
165162
}
166163

167164
// Actual errors
168-
if (line.includes("NOTFOUND")) {
169-
return this.server.logger.error(
170-
"Unable to resolve nwscript.nss. Are your Neverwinter Nights home and/or installation directories valid?",
171-
);
165+
if (line.includes("unhandled exception")) {
166+
this.server.logger.error(line);
172167
}
173-
if (line.includes("Failed to open .key archive")) {
174-
return this.server.logger.error(
175-
"Unable to open nwn_base.key Is your Neverwinter Nights installation directory valid?",
176-
);
177-
}
178-
if (line.includes("Unable to read input file")) {
168+
169+
if (line.includes("Could not locate")) {
179170
if (Boolean(nwnHome) || Boolean(nwnInstallation)) {
180171
return this.server.logger.error(
181172
"Unable to resolve provided Neverwinter Nights home and/or installation directories. Ensure the paths are valid in the extension settings.",

0 commit comments

Comments
 (0)