public override FSharpSymbol GetFSharpSymbol()
        {
            var symbolUse = GetSymbolUse();

            if (symbolUse?.Symbol is FSharpField field)
            {
                return(field.DeclaringEntity?.Value);
            }

            // todo: cover other contexts
            var sequentialExpr = SequentialExprNavigator.GetByExpression(RecordExpr.IgnoreParentParens());

            if (sequentialExpr != null && sequentialExpr.Expressions.Last() != RecordExpr)
            {
                return(null);
            }
            var exprToGetBy = sequentialExpr ?? RecordExpr.IgnoreParentParens();

            var binding = BindingNavigator.GetByExpression(exprToGetBy);

            if (!(binding is { HeadPattern : INamedPat namedPat }))
Exemple #2
0
        public override FSharpSymbol GetFSharpSymbol()
        {
            var symbolUse = GetSymbolUse();

            if (symbolUse?.Symbol is FSharpField field)
            {
                return(field.DeclaringEntity?.Value);
            }

            // todo: cover other contexts
            var sequentialExpr = SequentialExprNavigator.GetByExpression(RecordExpr.IgnoreParentParens());

            if (sequentialExpr != null && sequentialExpr.Expressions.Last() != RecordExpr)
            {
                return(null);
            }
            var exprToGetBy = sequentialExpr ?? RecordExpr.IgnoreParentParens();

            var binding = BindingNavigator.GetByExpression(exprToGetBy);

            if (binding == null || !(binding.HeadPattern is INamedPat namedPat))
            {
                return(null);
            }

            var mfv = namedPat.GetFSharpSymbol() as FSharpMemberOrFunctionOrValue;
            var returnParameterType = mfv?.ReturnParameter.Type;

            if (returnParameterType == null || !returnParameterType.HasTypeDefinition)
            {
                return(null);
            }

            var entity = returnParameterType.TypeDefinition;

            return(entity.IsFSharpRecord ? entity : null);
        }