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 = {
|
MouseButton = {
|
||||||
Left: 0,
|
Left: 0,
|
||||||
Right: 1,
|
Right: 1,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Gamelib } from "./gamelib.js";
|
import { GamelibAdapter } from "./gamelib.js";
|
||||||
|
|
||||||
export class GamelibCompleter {
|
export class GamelibCompleter {
|
||||||
getCompletions(_editor, session, pos, _prefix, callback) {
|
getCompletions(_editor, session, pos, _prefix, callback) {
|
||||||
@ -9,21 +9,24 @@ export class GamelibCompleter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const functions = Object.getOwnPropertyNames(Gamelib.prototype);
|
const functions = Object.getOwnPropertyNames(GamelibAdapter.prototype);
|
||||||
|
|
||||||
const wordList = functions
|
const wordList = functions
|
||||||
.filter((func) => func !== "constructor")
|
.filter((func) => func !== "constructor")
|
||||||
.map((func) => {
|
.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);
|
const signature = definition.slice(0, definition.indexOf(")") + 1);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: func,
|
name: func,
|
||||||
value: func,
|
value: func,
|
||||||
snippet: func + "($0)",
|
snippet: func + (getter ? "" : "($0)"),
|
||||||
caption: func,
|
caption: func,
|
||||||
score: 0,
|
score: 0,
|
||||||
meta: "function",
|
meta: getter ? "property" : "function",
|
||||||
docHTML: signature,
|
docHTML: signature,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user