Skip to content

Commit

Permalink
Removed extra \' from the optional args doc text. Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Druue committed Dec 19, 2022
1 parent 4849516 commit 0f8f8a6
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/language-server/src/completion/completionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,13 +516,8 @@ export function getNativeTypes(document: TextDocument, prismaType: string): Comp
nativeTypes = nativeTypes.filter((n) => n.prisma_types.includes(prismaType))
nativeTypes.forEach((element) => {
if (element._number_of_args + element._number_of_optional_args !== 0) {
let documentation = ''
if (element._number_of_optional_args !== 0) {
documentation = `${documentation}Number of optional arguments: ${element._number_of_optional_args}.\n'`
}
if (element._number_of_args !== 0) {
documentation = `${documentation}Number of required arguments: ${element._number_of_args}.\n`
}
const documentation = buildDocumentation(element)

suggestions.push({
label: `${element.name}()`,
kind: CompletionItemKind.TypeParameter,
Expand All @@ -540,3 +535,14 @@ export function getNativeTypes(document: TextDocument, prismaType: string): Comp

return suggestions
}

const buildDocumentation = (element: NativeTypeConstructors, documentation = ''): string => {
if (element._number_of_optional_args !== 0) {
documentation = `${documentation}Number of optional arguments: ${element._number_of_optional_args}.\n`
}
if (element._number_of_args !== 0) {
documentation = `${documentation}Number of required arguments: ${element._number_of_args}.\n`
}

return documentation
}

0 comments on commit 0f8f8a6

Please sign in to comment.