postProcessing method

List<String> postProcessing(
  1. List<String> results,
  2. List<String> postProcessingList
)

Implementation

List<String> postProcessing(List<String> results, List<String> postProcessingList) {
  List<String> finalResults = [];
  for (String res in results) {
    List<int> splitIdx = [];
    List<String> qoutes = [];
    bool findQuotes = false;
    qoutes.addAll(Const.singleQuotes);
    qoutes.addAll(Const.doubleQuotes);
    qoutes.addAll(Const.bracket);

    for (String qt in qoutes) {
      if (res.contains(qt)) {
        findQuotes = true;
        break;
      }
    }
    if (!findQuotes) {
      for (var i = 0; i < postProcessingList.length; i++) {
        var post = postProcessingList[i];
        if (res.contains(post)) {
          splitIdx.addAll(findAll(res, postProcessingList[i + 1]));
        }
      }
      // for (String post in postProcessingList) {
      //     if (res.contains(post)) {
      //         splitIdx.addAll(findAll(res, post + 1));
      //     }
      // }
    }
    splitIdx.sort((a, b) => a.compareTo(b));
    finalResults.addAll(lindexSplit(res, splitIdx));
  }
  return finalResults;
}