我正在使用Mongo0.22.2,试图提出关于函数参数的建议。我定义了一个简单的例子,如下所示:
monaco.languages.registerSignatureHelpProvider('myCustomLang', {
signatureHelpTriggerCharacters: ['(', ','],
provideSignatureHelp: (model, position, token) => {
return {
activeParameter: 0,
activeSignautre: 0,
signatures: [{
label:'string of_string(string $string, int $start)',
parameters: [
{
label: 'string $string',
documentation: 'The input string'
},
{
label: 'int $start',
documentation: "if $start is non-negative...",
}
]
}]
};
}
});然而,只要我键入"(“或",”来触发此代码,我就会得到错误:
Cannot read property 'signatures' of undefined
TypeError: Cannot read property 'signatures' of undefined
at ParameterHintsModel.eval (parameterHintsModel.js:166)
at Generator.next (<anonymous>)
at fulfilled (parameterHintsModel.js:19)
at eval (errors.js:24)我做错了什么?我的常规简单建议会出现,但我无法获得潜在的函数参数建议。
发布于 2021-02-14 08:29:29
响应应该是这样构造的:
monaco.languages.registerSignatureHelpProvider("myCustomLang", {
signatureHelpTriggerCharacters: ["(", ","],
provideSignatureHelp: (model, position, token) => {
return {
dispose: () => {},
value: {
activeParameter: 0,
activeSignature: 0,
signatures: [
{
label:
"string substr(string $string, int $start [, int $length])",
parameters: [
{
label: "string $string",
documentation:
"The input string. Must be one character or longer.",
},
{
label: "int $start",
documentation:
"If $start is non-negative, the returned string will start at the $start'th position in string, counting from zero. For instance, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so forth.\r\nIf $start is negative, the returned string will start at the $start'th character from the end of string. If $string is less than $start characters long, FALSE will be returned.",
},
{
label: "int $length",
documentation:
"If $length is given and is positive, the string returned will contain at most $length characters beginning from $start (depending on the length of $string) If $length is given and is negative, then that many characters will be omitted from the end of $string (after the start position has been calculated when a start is negative). If $start denotes the position of this truncation or beyond, FALSE will be returned. If $length is given and is 0, FALSE or NULL, an empty string will be returned. If $length is omitted, the substring starting from $start until the end of the string will be returned.",
},
],
},
],
},
};
},
});响应类型为SignatureHelpResult,它应该有一个value和dispose方法。value应为带有activeParameter activeSignature和signatures的SignatureHelp
https://stackoverflow.com/questions/66109154
复制相似问题