private Stream<? extends K> performParse(Map<String, ParsedSentence> cache, ParseInModule parser, Scanner scanner, Bubble b) {
int startLine = b.att().get("contentStartLine", Integer.class);
int startColumn = b.att().get("contentStartColumn", Integer.class);
Source source = b.att().get(Source.class);
Tuple2<Either<java.util.Set<ParseFailedException>, K>, java.util.Set<ParseFailedException>> result;
if (cache.containsKey(b.contents())) {
ParsedSentence parse = cache.get(b.contents());
Optional<Source> cacheSource = parse.getParse().source();
if (cacheSource.isPresent() && cacheSource.get().equals(source)) {
cachedBubbles.getAndIncrement();
kem.addAllKException(parse.getWarnings().stream().map(e -> e.getKException()).collect(Collectors.toList()));
return Stream.of(parse.getParse());
}
}
result = parser.parseString(b.contents(), START_SYMBOL, scanner, source, startLine, startColumn, !b.att().contains("macro") && !b.att().contains("alias"));
parsedBubbles.getAndIncrement();
kem.addAllKException(result._2().stream().map(e -> e.getKException()).collect(Collectors.toList()));
if (result._1().isRight()) {
KApply k = (KApply) new TreeNodesToKORE(Outer::parseSort, isStrict).down(result._1().right().get());
k = KApply(k.klabel(), k.klist(), k.att().addAll(b.att().remove("contentStartLine").remove("contentStartColumn").remove(Source.class).remove(Location.class)));
cache.put(b.contents(), new ParsedSentence(k, new HashSet<>(result._2())));
return Stream.of(k);
} else {
errors.addAll(result._1().left().get());
return Stream.empty();
}
}
}