public static ParseResult parseContent(ParseContext context) {
        CharSequence sequence = context.content();

        ArrayList<Diagnostic> diagnostics = new ArrayList<Diagnostic>();
        SchemaParser parserFaultTolerant = new SchemaParser(context.fileURI(), sequence);

        try {
            parserFaultTolerant.Root();
        } catch (ParseException e) {
            // Ignore, marked by "Dirty Node"
        } catch (IllegalArgumentException e) {
            // Some internal error from config-model Parsed*, invalidate whole document.
            diagnostics.add(new SchemaDiagnostic.Builder()
                .setRange(
                    new Range(
                        new Position(0, 0),
                        new Position((int)context.content().lines().count() - 1, 0)
                    )
                )
                .setMessage(e.getMessage())
                .setSeverity(DiagnosticSeverity.Error)
                .build());
        }

        Node node = parserFaultTolerant.rootNode();

        var tolerantResult = parseCST(node, context);

        diagnostics.addAll(InheritanceResolver.resolveInheritances(context));

        for (SchemaNode typeNode : context.unresolvedTypeNodes()) {
            TypeNodeResolver.resolveType(context, typeNode.getSymbol());
        }
        
        context.clearUnresolvedTypeNodes();
        
        if (tolerantResult.CST().isPresent()) {
            //diagnostics.addAll(RankExpressionSymbolResolver.resolveRankExpressionReferences(tolerantResult.CST().get(), context));

            diagnostics.addAll(StructFieldDefinitionResolver.resolve(context, tolerantResult.CST().get()));

            diagnostics.addAll(ResolverTraversal.traverse(context, tolerantResult.CST().get()));

            // Unresolved field arguments (type and indexing settings) need to be resolved after 'ResolverTraversal'
            // because the indexing language is traversed in the ResolverTraversal
            for (UnresolvedFieldArgument fieldArg : context.unresolvedFieldArguments()) {
                Optional<Diagnostic> diagnostic = FieldArgumentResolver.resolveFieldArgument(context, fieldArg);
                if (diagnostic.isPresent()) {
                    diagnostics.add(diagnostic.get());
                }
            }

            diagnostics.addAll(DocumentReferenceResolver.resolveDocumentReferences(context));
        }

        diagnostics.addAll(tolerantResult.diagnostics());

        return new ParseResult(diagnostics, tolerantResult.CST());
    }
SchemaDocument parses and represents .sd files
integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/schemadocument/SchemaDocument.java