private static boolean didExpectLabel(SchemaNode node, List<Diagnostic> diagnostics) {
        Node argsNode = node.getParent();
        SchemaNode argsChild = node;

        while (argsNode != null && argsNode.getASTClass() != args.class) {
            argsChild = argsNode.getSchemaNode();
            argsNode = argsNode.getParent();
        }

        if (argsNode == null) return false;

        Node identifierNode = argsNode.getParent().get(0);
        SchemaNode containingFeature = argsNode.getParent().getSchemaNode();

        // we can be certain that this is a ReferenceNode
        ReferenceNode functionExpressionNode = (ReferenceNode)((BaseNode)containingFeature.getOriginalRankExpressionNode()).expressionNode;
        ExpressionNode myArg = ((BaseNode)argsChild.getOriginalRankExpressionNode()).expressionNode;
        int myArgIndex = functionExpressionNode.children().indexOf(myArg);

        if (!identifierNode.hasSymbol() || identifierNode.getSymbol().getStatus() != SymbolStatus.BUILTIN_REFERENCE) return false;

        String functionIdentifier = identifierNode.getSymbol().getShortIdentifier();

        if (functionIdentifier.equals("itemRawScore")) {
            return true;
        }

        if (functionIdentifier.equals("closest")) {
            return myArgIndex == 1;
        }

        if (functionIdentifier.equals("distance") || functionIdentifier.equals("closeness")) {
            switch(myArgIndex) {
                case 0:
                    // TODO: not really label
                    return node.getSymbol().getShortIdentifier().equals("label") || node.getSymbol().getShortIdentifier().equals("field");
                case 1:
                    ExpressionNode firstArg = functionExpressionNode.children().get(0);
                    return ((firstArg instanceof ReferenceNode) && ((ReferenceNode)firstArg).getName().equals("label"));
                default:
                    return false;
            }
        }

        if (functionIdentifier.equals("tensorFromWeightedSet") || functionIdentifier.equals("tensorFromLabels")) {
            return myArgIndex == 1;
        }

        if (functionIdentifier.equals("query")) {
            // TODO: query gotodefinition could be nice to refer to inputs {} where possible
            return myArgIndex == 0;
        }

        return false;
    }
This finds the definition of a field inside a struct, where the struct is used as a type for some parent field
It solves the case where we have 
struct foo { field bar }
field baz type foo {}
And try to access baz.bar

In this case baz is the parent field and bar is the subfield

@param node the node pointing to the subfield declaration 
@param fieldDefinition the symbol where the parent field is *defined*
@param context 

@return the definition of the field inside the struct if found
integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/schemadocument/resolvers/SymbolReferenceResolver.java