src/vs/editor/common/model/bracketPairsTextModelPart/fixBrackets.ts/fixBracketsInLine
export function fixBracketsInLine(tokens: IViewLineTokens, languageConfigurationService: ILanguageConfigurationService): string {
	const denseKeyProvider = new DenseKeyProvider<string>();
	const bracketTokens = new LanguageAgnosticBracketTokens(denseKeyProvider, (languageId) =>
		languageConfigurationService.getLanguageConfiguration(languageId)
	);
	const tokenizer = new TextBufferTokenizer(
		new StaticTokenizerSource([tokens]),
		bracketTokens
	);
	const node = parseDocument(tokenizer, [], undefined, true);

	let str = '';
	const line = tokens.getLineContent();

	function processNode(node: AstNode, offset: Length) {
		if (node.kind === AstNodeKind.Pair) {
			processNode(node.openingBracket, offset);
			offset = lengthAdd(offset, node.openingBracket.length);

			if (node.child) {
				processNode(node.child, offset);
				offset = lengthAdd(offset, node.child.length);
			}
			if (node.closingBracket) {
				processNode(node.closingBracket, offset);
				offset = lengthAdd(offset, node.closingBracket.length);
			} else {
				const singleLangBracketTokens = bracketTokens.getSingleLanguageBracketTokens(node.openingBracket.languageId);

				const closingTokenText = singleLangBracketTokens.findClosingTokenText(node.openingBracket.bracketIds);
				str += closingTokenText;
			}
		} else if (node.kind === AstNodeKind.UnexpectedClosingBracket) {
			// remove the bracket
		} else if (node.kind === AstNodeKind.Text || node.kind === AstNodeKind.Bracket) {
			str += line.substring(
				lengthGetColumnCountIfZeroLineCount(offset),
				lengthGetColumnCountIfZeroLineCount(lengthAdd(offset, node.length))
			);
		} else if (node.kind === AstNodeKind.List) {
			for (const child of node.children) {
				processNode(child, offset);
				offset = lengthAdd(offset, child.length);
			}
		}
	}

	processNode(node, lengthZero);

	return str;
}