Skip to content

Commit 1a6710b

Browse files
Fix: passing correct file ºarams to lslint but…
… why is it attempting to parese non-LSL files and therefore failing all the time?
1 parent 27bbdb5 commit 1a6710b

File tree

3 files changed

+36
-108
lines changed

3 files changed

+36
-108
lines changed

LSLint/builtins.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ key aaSerializeXML( list keynames, list values )
2525
void aaSetCloudDensity( float density )
2626
void aaSetConeOfSilence( float radius )
2727
void aaSetEnv( string name, list value )
28-
void aaSetFlyDisabled( string userID, bool Value )
29-
void aaSetWalkDisabled( string userID, bool Value )
28+
void aaSetFlyDisabled( string userID, integer Value )
29+
void aaSetWalkDisabled( string userID, integer Value )
3030
void aaThawAvatar( string ID )
3131
void aaUpdateDatabase( string keyname, string value, string token )
3232
integer aaWindlightAddDayCycleFrame( float dayCyclePosition, integer dayCycleFrameToCopy )
@@ -582,7 +582,7 @@ void osClearInertia( )
582582
integer osClearObjectAnimations( )
583583
void osCollisionSound( string impact_sound, float impact_volume )
584584
integer osConsoleCommand( string Command )
585-
bool osConsoleCommand( string Command )
585+
integer osConsoleCommand( string Command )
586586
string osDetectedCountry( integer number )
587587
void osDie( key uuid )
588588
string osDrawEllipse( string drawList, integer width, integer height )
@@ -751,14 +751,14 @@ void osSetContentType( key id, string type )
751751
string osSetDynamicTextureData( string dynamicID, string contentType, string data, string extraParams, integer timer )
752752
string osSetDynamicTextureDataBlend( string dynamicID, string contentType, string data, string extraParams, integer timer, integer alpha )
753753
string osSetDynamicTextureDataBlendFace( string dynamicID, string contentType, string data, string extraParams, integer blend, integer disp, integer timer, integer alpha, integer face )
754-
string osSetDynamicTextureDataBlendFace( string dynamicID, string contentType, string data, string extraParams, bool blend, integer disp, integer timer, integer alpha, integer face )
754+
string osSetDynamicTextureDataBlendFace( string dynamicID, string contentType, string data, string extraParams, integer blend, integer disp, integer timer, integer alpha, integer face )
755755
string osSetDynamicTextureDataFace( string dynamicID, string contentType, string data, string extraParams, integer timer, integer face )
756756
string osSetDynamicTextureURL( string dynamicID, string contentType, string url, string extraParams, integer timer )
757757
string osSetDynamicTextureURLBlend( string dynamicID, string contentType, string url, string extraParams, integer timer, integer alpha )
758758
string osSetDynamicTextureURLBlendFace( string dynamicID, string contentType, string url, string extraParams, integer blend, integer disp, integer timer, integer alpha, integer face )
759-
string osSetDynamicTextureURLBlendFace( string dynamicID, string contentType, string url, string extraParams, bool blend, integer disp, integer timer, integer alpha, integer face )
759+
string osSetDynamicTextureURLBlendFace( string dynamicID, string contentType, string url, string extraParams, integer blend, integer disp, integer timer, integer alpha, integer face )
760+
void osSetEstateSunSettings( integer sunFixed, float sunHour )
760761
void osSetEstateSunSettings( integer sunFixed, float sunHour )
761-
void osSetEstateSunSettings( bool sunFixed, float sunHour )
762762
string osSetFontName( string drawList, string fontName )
763763
string osSetFontSize( string drawList, integer fontSize )
764764
void osSetHealRate( key agentId, float healrate )
@@ -781,12 +781,12 @@ string osSetPenSize( string drawList, integer penSize )
781781
void osSetPrimFloatOnWater( integer floatYN )
782782
void osSetPrimitiveParams( key prim, list rules )
783783
void osSetProjectionParams( integer projection, key texture, float fov, float focus, float amb )
784-
void osSetProjectionParams( bool projection, key texture, float fov, float focus, float amb )
784+
void osSetProjectionParams( integer projection, key texture, float fov, float focus, float amb )
785+
void osSetProjectionParams( key prim, integer projection, key texture, float fov, float focus, float amb )
785786
void osSetProjectionParams( key prim, integer projection, key texture, float fov, float focus, float amb )
786-
void osSetProjectionParams( key prim, bool projection, key texture, float fov, float focus, float amb )
787787
void osSetProjectionParams( integer linknumber, integer projection, key texture, float fov, float focus, float amb )
788788
void osSetRegionSunSettings( integer useEstateSun, integer sunFixed, float sunHour )
789-
void osSetRegionSunSettings( bool useEstateSun, bool sunFixed, float sunHour )
789+
void osSetRegionSunSettings( integer useEstateSun, integer sunFixed, float sunHour )
790790
void osSetRegionWaterHeight( float height )
791791
void osSetSitActiveRange( float v )
792792
void osSetSoundRadius( integer linknum, float radius )

Scripts/main.js

Lines changed: 27 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ class LSLinter {
6262
);
6363
}
6464

65-
let execPath = bundledExecutable ?? globalExecutable;
65+
let execPath = bundledExecutable;
66+
67+
if (!bundledExecutable) execPath = globalExecutable;
6668

6769
if (nova.config.get('gwynethllewelyn.LindenScriptingLanguage.debugging', 'boolean')) {
6870
console.info('getExecutablePath() will return path: "%s"', execPath);
@@ -83,7 +85,7 @@ class LSLinter {
8385
'string'
8486
);
8587

86-
let defaultBuiltins = nova.path.join(
88+
var defaultBuiltins = nova.path.join(
8789
nova.extension.path,
8890
"LSLint",
8991
"builtins.txt"
@@ -92,16 +94,20 @@ class LSLinter {
9294
if (nova.config.get('gwynethllewelyn.LindenScriptingLanguage.debugging', 'boolean')) {
9395
console.info('getBuiltins() constructed defaultBuiltins = "%s"', defaultBuiltins);
9496
}
97+
98+
var selectedBuiltins = defaultBuiltins;
99+
100+
// Do we have our own builtins.txt file, and, if so, is it valid?
95101
try {
96-
customBuiltins = nova.fs.stat(customBuiltins) != undefined ?
97-
customBuiltins :
98-
null;
102+
if (customBuiltins && customBuiltins != '') {
103+
if (nova.fs.stat(customBuiltins) != undefined) {
104+
selectedBuiltins = customBuiltins;
105+
}
106+
}
99107
} catch (error) {
100-
console.warn("getBuiltins() could not find a valid builtins.txt path '%s' — throws: '%s'", customBuiltins, error.toString());
108+
console.warn("getBuiltins() could not find a valid builtins.txt path '%s' — throws: '%s' - going with the default builtins instead", customBuiltins, error.toString());
101109
}
102110

103-
let selectedBuiltins = customBuiltins ?? defaultBuiltins;
104-
105111
if (nova.config.get('gwynethllewelyn.LindenScriptingLanguage.debugging', 'boolean')) {
106112
console.log('getBuiltins() will return path: "%s"', selectedBuiltins);
107113
}
@@ -142,7 +148,7 @@ class LSLinter {
142148
/** Name of the scrap file.
143149
* @type {string}
144150
*/
145-
let scrapFileName = nova.path.join(nova.extension.workspaceStoragePath, fileName);
151+
var scrapFileName = nova.path.join(nova.extension.workspaceStoragePath, fileName);
146152
try {
147153
var lintFile = nova.fs.open(scrapFileName, "w");
148154

@@ -178,7 +184,7 @@ class LSLinter {
178184
args: [
179185
execPath,
180186
'-l',
181-
'-d',
187+
'-b',
182188
builtinsPath,
183189
scrapFileName
184190
],
@@ -252,7 +258,7 @@ class LSLinter {
252258
try {
253259
if (nova.config.get('gwynethllewelyn.LindenScriptingLanguage.debugging', 'boolean')) {
254260
console.info("Started linting.");
255-
console.log(`Running command: ${self.getExecutablePath()} -l -d ${self.getBuiltins()}`);
261+
console.log(`Running command: ${self.getExecutablePath()} -l -b ${self.getBuiltins()} ${scrapFileName}`);
256262
}
257263
// Execution starts here.
258264
linter.start();
@@ -262,15 +268,6 @@ class LSLinter {
262268
});
263269
}
264270

265-
// // probably not required
266-
// outputIsJson(output) {
267-
// try {
268-
// return (JSON.parse(output) && !!output);
269-
// } catch (error) {
270-
// return false;
271-
// }
272-
// }
273-
//
274271
/*
275272
LSLint output is something like this:
276273
@@ -281,13 +278,22 @@ class LSLinter {
281278
WARN:: (204, 36)-(204, 40): Declaration of `data' in this scope shadows previous declaration at (16, 8)
282279
TOTAL:: Errors: 0 Warnings: 5
283280
*/
284-
281+
/**
282+
* Receives the text to be parsed/linted, and returns an array of issues found.
283+
*
284+
* @param {string} output Text to be parsed.
285+
* @returns {string[]} Array of issues found.
286+
*/
285287
parseLinterOutput(output) {
286288
let issues = [];
287289
// Do it the basic way, since I'm no JavaScript expert.
288290
// Split by newlines first:
289291
var lints = output.split(/\r\n|\n/);
290292
for (var lint = 0; lint < lints.length - 1; lint++) {
293+
/**
294+
* Array of matched issues on LSLint output.
295+
* @type {string[]}
296+
*/
291297
let matches = lints[lint].match(/^\W*(\w+)::\s*\(\s*(\d*),\s*(\d*)\)-\(\s*(\d*),\s*(\d*)\):\s*(.*)$/gmi);
292298

293299
if (
@@ -340,83 +346,6 @@ class LSLinter {
340346

341347
return issues;
342348
}
343-
344-
/*
345-
issues = lints.files
346-
.flatMap(function(lint) {
347-
return lint.violations;
348-
})
349-
.map(function(lint) {
350-
let issue = new Issue();
351-
352-
issue.message = lint.description;
353-
issue.severity = IssueSeverity.Error;
354-
355-
if (lint.priority <= 2) {
356-
issue.severity = IssueSeverity.Warning;
357-
}
358-
359-
issue.line = lint.beginLine;
360-
issue.code = lint.rule + "| " + lint.ruleSet + " | lslint";
361-
issue.endLine = issue.line + 1;
362-
363-
if (nova.config.get('gwynethllewelyn.LindenScriptingLanguage.debugging', 'boolean')) {
364-
console.log("Found lint:");
365-
console.log("===========");
366-
console.log("Line: " + issue.line);
367-
console.log("Message: " + issue.message);
368-
console.log("Code: " + issue.code);
369-
console.log("Ruleset: " + lint.ruleSet);
370-
console.log("Severity: " + issue.severity);
371-
console.log("===========");
372-
}
373-
374-
return issue;
375-
})
376-
.filter(function(issue) {
377-
return issue !== null;
378-
});
379-
380-
let errors = (lints.errors || [])
381-
.map(function(lint) {
382-
let issue = new Issue();
383-
384-
if (
385-
lint.message === null ||
386-
lint.message === undefined
387-
) {
388-
return issue;
389-
}
390-
391-
issue.code = "phpmd";
392-
issue.message = (lint.message || "");
393-
let matches = issue.message.match(/^.*? line: (.*?), col: .*$/i);
394-
395-
if (
396-
matches === null ||
397-
matches.length <= 1
398-
) {
399-
return issue;
400-
}
401-
402-
issue.line = matches[1];
403-
issue.endLine = issue.line + 1;
404-
issue.severity = IssueSeverity.Error;
405-
406-
if (nova.config.get('gwynethllewelyn.LindenScriptingLanguage.debugging', 'boolean')) {
407-
console.log("Found error lint:");
408-
console.log("===========");
409-
console.log("Line: " + issue.line);
410-
console.log("Message: " + lint.message);
411-
console.log("===========");
412-
}
413-
414-
return issue;
415-
});
416-
417-
return issues
418-
.concat(errors);
419-
}*/
420349
};
421350

422351
nova.assistants.registerIssueAssistant(["lsl", "ossl"], new LSLinter());

Tests/chatbot.lsl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ list theCodes = [
6767
// List the name of each code.
6868

6969
list theCodenames = [
70-
7170
"TRUE", "FALSE",
7271

7372
"PI",

0 commit comments

Comments
 (0)