| 1 | import { AutoCompleteOption } from './AutoCompleteOption.js'; |
| 2 | |
| 3 | |
| 4 | export class AutoCompleteNameResultBase { |
| 5 | /**@type {string} */ name; |
| 6 | /**@type {number} */ start; |
| 7 | /**@type {AutoCompleteOption[]} */ optionList = []; |
| 8 | /**@type {boolean} */ canBeQuoted = false; |
| 9 | /**@type {()=>string} */ makeNoMatchText = () => `No matches found for "${this.name}"`; |
| 10 | /**@type {()=>string} */ makeNoOptionsText = () => 'No options'; |
| 11 | |
| 12 | |
| 13 | /** |
| 14 | * @param {string} name Name (potentially partial) of the name at the requested index. |
| 15 | * @param {number} start Index where the name starts. |
| 16 | * @param {AutoCompleteOption[]} optionList A list of autocomplete options found in the current scope. |
| 17 | * @param {boolean} canBeQuoted Whether the name can be inside quotes. |
| 18 | * @param {()=>string} makeNoMatchText Function that returns text to show when no matches where found. |
| 19 | * @param {()=>string} makeNoOptionsText Function that returns text to show when no options are available to match against. |
| 20 | */ |
| 21 | constructor(name, start, optionList = [], canBeQuoted = false, makeNoMatchText = null, makeNoOptionsText = null) { |
| 22 | this.name = name; |
| 23 | this.start = start; |
| 24 | this.optionList = optionList; |
| 25 | this.canBeQuoted = canBeQuoted; |
| 26 | if (makeNoMatchText) this.makeNoMatchText = makeNoMatchText; |
| 27 | if (makeNoOptionsText) this.makeNoOptionsText = makeNoOptionsText; |
| 28 | } |
| 29 | } |