コード例 #1
0
        public override FSharpSymbol GetFSharpSymbol()
        {
            var symbolUse = GetSymbolUse();

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

            // todo: cover other contexts
            var binding = BindingNavigator.GetByExpression(RecordExpr.IgnoreParentParens());

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

            var mfv    = namedPat.GetFSharpSymbol() as FSharpMemberOrFunctionOrValue;
            var fsType = mfv?.FullType;

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

            var entity = fsType.TypeDefinition;

            return(entity.IsFSharpRecord ? entity : null);
        }
コード例 #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 is { HeadPattern : INamedPat namedPat }))
コード例 #3
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);
        }