* Interpolate a message description onto the block. * * @param message Text contains interpolation tokens (%1, %2, ...) that match * with fields or inputs defined in the args array. * @param args Array of arguments to be interpolated. * @param implicitAlign If an implicit input is
(
message: string,
args: AnyDuringMigration[],
implicitAlign: string | undefined,
warningPrefix: string,
)
| 1947 | * @param warningPrefix Warning prefix string identifying block. |
| 1948 | */ |
| 1949 | private interpolate( |
| 1950 | message: string, |
| 1951 | args: AnyDuringMigration[], |
| 1952 | implicitAlign: string | undefined, |
| 1953 | warningPrefix: string, |
| 1954 | ) { |
| 1955 | const tokens = parsing.tokenizeInterpolation(message); |
| 1956 | this.validateTokens(tokens, args.length); |
| 1957 | const elements = this.interpolateArguments(tokens, args, implicitAlign); |
| 1958 | |
| 1959 | // An array of [field, fieldName] tuples. |
| 1960 | const fieldStack = []; |
| 1961 | for (let i = 0, element; (element = elements[i]); i++) { |
| 1962 | if (this.isInputKeyword(element['type'])) { |
| 1963 | const input = this.inputFromJson(element, warningPrefix); |
| 1964 | // Should never be null, but just in case. |
| 1965 | if (input) { |
| 1966 | for (let j = 0, tuple; (tuple = fieldStack[j]); j++) { |
| 1967 | input.appendField(tuple[0], tuple[1]); |
| 1968 | } |
| 1969 | fieldStack.length = 0; |
| 1970 | } |
| 1971 | } else { |
| 1972 | // All other types, including ones starting with 'input_' get routed |
| 1973 | // here. |
| 1974 | const field = this.fieldFromJson(element); |
| 1975 | if (field) { |
| 1976 | fieldStack.push([field, element['name']]); |
| 1977 | } |
| 1978 | } |
| 1979 | } |
| 1980 | } |
| 1981 | |
| 1982 | /** |
| 1983 | * Validates that the tokens are within the correct bounds, with no |
no test coverage detected