Validate body
This commit is contained in:
parent
bc015eba1a
commit
f2e8888c94
|
@ -296,9 +296,19 @@
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const { arguments: expectedArguments = [] } =
|
const { arguments: expectedArguments = [], requiresBlock } =
|
||||||
validations[helperName]
|
validations[helperName]
|
||||||
|
|
||||||
|
if (requiresBlock && !isBlockStatement(node)) {
|
||||||
|
diagnostics.push({
|
||||||
|
from,
|
||||||
|
to,
|
||||||
|
severity: "error",
|
||||||
|
message: `Helper "${helperName}" requires a body.`,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const providedParams = node.params
|
const providedParams = node.params
|
||||||
|
|
||||||
if (providedParams.length !== expectedArguments.length) {
|
if (providedParams.length !== expectedArguments.length) {
|
||||||
|
|
|
@ -84,6 +84,7 @@ const helpersToCompletion = (
|
||||||
return {
|
return {
|
||||||
label: helperName,
|
label: helperName,
|
||||||
args: helper.args,
|
args: helper.args,
|
||||||
|
requiresBlock: helper.requiresBlock,
|
||||||
info: () => buildHelperInfoNode(helper),
|
info: () => buildHelperInfoNode(helper),
|
||||||
type: "helper",
|
type: "helper",
|
||||||
section: helperSection,
|
section: helperSection,
|
||||||
|
|
|
@ -113,6 +113,7 @@
|
||||||
...helperOptions.reduce<CodeValidator>((validations, option) => {
|
...helperOptions.reduce<CodeValidator>((validations, option) => {
|
||||||
validations[option.label] = {
|
validations[option.label] = {
|
||||||
arguments: option.args,
|
arguments: option.args,
|
||||||
|
requiresBlock: option.requiresBlock,
|
||||||
}
|
}
|
||||||
return validations
|
return validations
|
||||||
}, {}),
|
}, {}),
|
||||||
|
|
|
@ -7,11 +7,13 @@ export type BindingCompletion = (context: CompletionContext) => {
|
||||||
|
|
||||||
export interface BindingCompletionOption extends Completion {
|
export interface BindingCompletionOption extends Completion {
|
||||||
args?: any[]
|
args?: any[]
|
||||||
|
requiresBlock?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CodeValidator = Record<
|
export type CodeValidator = Record<
|
||||||
string,
|
string,
|
||||||
{
|
{
|
||||||
arguments?: any[]
|
arguments?: any[]
|
||||||
|
requiresBlock?: boolean
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|
|
@ -2,4 +2,5 @@ export interface Helper {
|
||||||
example: string
|
example: string
|
||||||
description: string
|
description: string
|
||||||
args: any[]
|
args: any[]
|
||||||
|
requiresBlock?: boolean
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue