Skip to content

Commit 691140f

Browse files
committed
add commented out code to help with #120
1 parent 6da95e5 commit 691140f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

js/plugins/tern.js

+20
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@
4747
codeMirror.setOption("extraKeys", k);
4848
codeMirror.on("cursorActivity", function(cm) { server.updateArgHints(cm); });
4949
});
50+
51+
/* Ideally espruino.json has:
52+
53+
"require": {
54+
"!type": "fn(moduleName: ?) -> !custom:require_handler",
55+
56+
.. and then this handler gets called and sets the correct return type
57+
when someone uses `require()`.
58+
59+
The type is in espruino.json at the root level at the moment, so
60+
require("http") => "http" object. But what I'm doing below isn't working :(
61+
*/
62+
/*var infer = tern;
63+
infer.registerFunction("require_handler", function(self, args, argNodes) {
64+
if (argNodes.length!=1 || argNodes[0].type!="Literal") return;
65+
var moduleName = argNodes[0].value;
66+
var moduleType = new infer.Obj(null, moduleName); // broken
67+
self.propagate(moduleType);
68+
return infer.ANull;
69+
});*/
5070

5171
/* When we connect to a board and we load its description,
5272
go through an add all the pins as variables so Tern cal autocomplete */

0 commit comments

Comments
 (0)