lib/utils/indent-common.js
function getExpectedIndent (tokens) {
    const trivial = isTrivialToken(tokens[0])
    let expectedIndent = Number.MAX_SAFE_INTEGER

    for (let i = 0; i < tokens.length; ++i) {
      const token = tokens[i]
      const offsetInfo = offsets.get(token)

      // If the first token is not trivial then ignore trivial following tokens.
      if (offsetInfo != null && (trivial || !isTrivialToken(token))) {
        if (offsetInfo.expectedIndent != null) {
          expectedIndent = Math.min(expectedIndent, offsetInfo.expectedIndent)
        } else {
          const baseOffsetInfo = offsets.get(offsetInfo.baseToken)
          if (baseOffsetInfo != null && baseOffsetInfo.expectedIndent != null && (i === 0 || !baseOffsetInfo.baseline)) {
            expectedIndent = Math.min(expectedIndent, baseOffsetInfo.expectedIndent + offsetInfo.offset * options.indentSize)
            if (baseOffsetInfo.baseline) {
              break
            }
          }
        }
      }
    }

    return expectedIndent
  }
function getExpectedIndent (tokens) {
    const trivial = isTrivialToken(tokens[0])
    let expectedIndent = Number.MAX_SAFE_INTEGER

    for (let i = 0; i < tokens.length; ++i) {
      const token = tokens[i]
      const offsetInfo = offsets.get(token)

      // If the first token is not trivial then ignore trivial following tokens.
      if (offsetInfo != null && (trivial || !isTrivialToken(token))) {
        if (offsetInfo.expectedIndent != null) {
          expectedIndent = Math.min(expectedIndent, offsetInfo.expectedIndent)
        } else {
          const baseOffsetInfo = offsets.get(offsetInfo.baseToken)
          if (baseOffsetInfo != null && baseOffsetInfo.expectedIndent != null && (i === 0 || !baseOffsetInfo.baseline)) {
            expectedIndent = Math.min(expectedIndent, baseOffsetInfo.expectedIndent + offsetInfo.offset * options.indentSize)
            if (baseOffsetInfo.baseline) {
              break
            }
          }
        }
      }
    }

    return expectedIndent
  }
function getExpectedIndent ( tokens ) { const trivial = isTrivialToken ( tokens [ 0 ] ) let expectedIndent = Number . MAX_SAFE_INTEGER for ( let i = 0 ; i < tokens . length ; ++ i ) { const token = tokens [ i ] const offsetInfo = offsets . get ( token ) // If the first token is not trivial then ignore trivial following tokens. if ( offsetInfo != null && ( trivial || ! isTrivialToken ( token ) ) ) { if ( offsetInfo . expectedIndent != null ) { expectedIndent = Math . min ( expectedIndent , offsetInfo . expectedIndent ) } else { const baseOffsetInfo = offsets . get ( offsetInfo . baseToken ) if ( baseOffsetInfo != null && baseOffsetInfo . expectedIndent != null && ( i === 0 || ! baseOffsetInfo . baseline ) ) { expectedIndent = Math . min ( expectedIndent , baseOffsetInfo . expectedIndent + offsetInfo . offset * options . indentSize ) if ( baseOffsetInfo . baseline ) { break } } } } } return expectedIndent }
Calculate correct indentation of the line of the given tokens.
@param {Token[]} tokens Tokens which are on the same line.
@returns {number} Correct indentation. If it failed to calculate then `Number.MAX_SAFE_INTEGER`.
Calculate correct indentation of the line of the given tokens .