I’m creating a linter add-on for CoffeeScript that is written in JavaScript. The necessary XPCOM components are coded and configured correctly and work correctly from a macro (see example below). The act of linting is not an issue because the linter currently ignores the input and returns an empty list of results.
Unfortunately, when I open a CoffeeScript file, Komodo crashes. There are no messages in the logs.
I understand that Komodo supports add-ons in both languages via XPCOM, but I find core Python code that appears to avoid honoring the XPCOM interfaces. In particular, there is lint service code that calls UnwrapObject
to access method lint_with_text
. There is no lint_with_text
method in koILinter
and it’s not clear to me why this approach is being used to avoid following the interface.
So is it reasonable to expect a linter written in JavaScript to work? Or will the calls to UnwrapObject
break whatever I write?
Any thoughts on tracking down the crash?
Thanks.
This test macro works fine. I have nothing else to test in my code and I’m not aware of other Komodo parts to look into.
const language = "CoffeeScript";
const linterService = Components.classes["@activestate.com/koLintService;1"].
getService(Components.interfaces.koILintService);
const linterClass = Components.classes["@ervumlens.github.io/elCoffeeScriptLinter;1"];
var linter;
var linterResults;
//Test result/results
try {
const resultClass = Components.classes["@ervumlens.github.io/elLintResult;1"];
const resultsClass = Components.classes["@ervumlens.github.io/elLintResults;1"];
const result = resultClass.createInstance(Components.interfaces.koILintResult);
const results = resultsClass.createInstance(Components.interfaces.koILintResults);
result.severity = 2;
result.lineStart = 2;
result.lineEnd = 3;
result.columnStart = 3;
result.columnEnd = 4;
const countBefore = results.getNumResults();
if (countBefore != 0) {
throw new Error("Invalid number of results on create");
}
results.addResult(result);
const countAfter = results.getNumResults();
if (countAfter != 1) {
throw new Error("Invalid number of results after addResult");
}
alert("Success #1");
} catch (e) {
alert("Failed #1: " + e);
}
//Test linter directly
try {
const linterCID = linterService.getLinter_CID_ForLanguage(language);
if (linterCID != "@ervumlens.github.io/elCoffeeScriptLinter;1") {
throw new Error("Wrong linter registered for CoffeeScript: " + linterCID);
}
linter = linterClass.getService(Components.interfaces.koILinter);
// The linter ignores the request and returns an empty results object.
linterResults = linter.lint(null);
if (linterResults.getNumResults() != 0) {
throw new Error("Dummy result is not empty.");
}
alert("Success #2");
} catch (e) {
alert("Failed #2: " + e);
}
//Test linter via lint service
try {
linter = linterService.getLinterForLanguage(language);
linter = linterClass.getService(Components.interfaces.koILinter);
// The linter ignores the request and returns an empty results object.
linterResults = linter.lint(null);
if (linterResults.getNumResults() != 0) {
throw new Error("Dummy result is not empty.");
}
alert("Success #3");
} catch (e) {
alert("Failed #3: " + e);
}