fix autocompletion for gamelib with adapter
This commit is contained in:
parent
a4ab74112b
commit
dac13a4973
@ -134,7 +134,7 @@ export class Gamelib {
|
||||
}
|
||||
}
|
||||
|
||||
class GamelibAdapter {
|
||||
export class GamelibAdapter {
|
||||
MouseButton = {
|
||||
Left: 0,
|
||||
Right: 1,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Gamelib } from "./gamelib.js";
|
||||
import { GamelibAdapter } from "./gamelib.js";
|
||||
|
||||
export class GamelibCompleter {
|
||||
getCompletions(_editor, session, pos, _prefix, callback) {
|
||||
@ -9,21 +9,24 @@ export class GamelibCompleter {
|
||||
return;
|
||||
}
|
||||
|
||||
const functions = Object.getOwnPropertyNames(Gamelib.prototype);
|
||||
const functions = Object.getOwnPropertyNames(GamelibAdapter.prototype);
|
||||
|
||||
const wordList = functions
|
||||
.filter((func) => func !== "constructor")
|
||||
.map((func) => {
|
||||
const definition = Gamelib.prototype[func].toString();
|
||||
const getter = GamelibAdapter.prototype.__lookupGetter__(func);
|
||||
|
||||
const definition = getter?.name ?? GamelibAdapter.prototype[func].toString();
|
||||
|
||||
const signature = definition.slice(0, definition.indexOf(")") + 1);
|
||||
|
||||
return {
|
||||
name: func,
|
||||
value: func,
|
||||
snippet: func + "($0)",
|
||||
snippet: func + (getter ? "" : "($0)"),
|
||||
caption: func,
|
||||
score: 0,
|
||||
meta: "function",
|
||||
meta: getter ? "property" : "function",
|
||||
docHTML: signature,
|
||||
};
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user