resolve method

  1. @override
Success<String, CitrusSemanticException> resolve(
  1. CitrusSymbolTable symbolTable,
  2. String generateLocation,
  3. Iterable<String> fragments
)
override

Implementation

@override
Success<String, CitrusSemanticException> resolve(CitrusSymbolTable symbolTable, String generateLocation, Iterable<String> fragments) {

    final log = Log(classLocation: runtimeType, functionLocation: 'resolve');

    final inResolveResult = inSetting.resolve(symbolTable);
    log.add(inResolveResult);
    if (inResolveResult is! Success<CitrusArray, CitrusSemanticException>) return Success(source, log);

    final box = joinSettingBox;
    late final String join;
    switch (box) {
    case Some():

        final result = box.wrapped.resolve(symbolTable);
        log.add(result);
        if (result is! Success<String, CitrusSemanticException>) return Success(source, log);

        join = result.wrapped;

    case None():

        join = '';

    }

    // InSetting を SymbolTable にセット.
    final addTemporarySymbolResult = symbolTable.addTemporarySymbol(inSetting.temporaryAccesser.identifier, inResolveResult.wrapped);
    log.add(addTemporarySymbolResult);
    if (addTemporarySymbolResult is! Success<CitrusSymbolTable, CitrusSymbolTableException>) return Success(source, log);

    // WithSetting を SymbolTable にセット.
    CitrusSymbolTable newSymbolTable = addTemporarySymbolResult.wrapped;

    for (final i in withSettingList) {

        final resolveResult = i.resolve(newSymbolTable);
        log.add(resolveResult);
        if (resolveResult is! Success<CitrusArray, CitrusSemanticException>) return Success(source, log);

        final addResult = newSymbolTable.addTemporarySymbol(i.temporaryAccesser.identifier, resolveResult.wrapped);
        log.add(addResult);
        if (addResult is! Success<CitrusSymbolTable, CitrusSymbolTableException>) return Success(source, log);

        newSymbolTable = addResult.wrapped;

    }

    List<String> temporarySymbolNameList = [inSetting.temporaryAccesser.identifier];
    for (final i in withSettingList) temporarySymbolNameList.add(i.temporaryAccesser.identifier);

    final limit = inResolveResult.wrapped.value.length;
    var count = 1;
    final List<String> list = [];


    final indentResult = finishCitrusSemanticList.forBlockSandwichContent();
    log.add(indentResult);

    while (true) {

        if (count > limit) return Success(list.join(join), log);

        final resolveResult = indentResult.wrapped.resolve(newSymbolTable, generateLocation, fragments);
        log.add(resolveResult);

        list.add(resolveResult.wrapped);

        // すべての laps を進める.
        for (final i in temporarySymbolNameList) {

            final incrementLapsResult = newSymbolTable.incrementLaps(i);
            log.add(incrementLapsResult);
            if (incrementLapsResult is! Success<CitrusSymbolTable, CitrusSymbolTableException>) return Success(source, log);

            newSymbolTable = incrementLapsResult.wrapped;

        }

        count = count + 1;

    }

}