Esempio n. 1
0
 public FSharpMethodParameter(FSharpParameter fsParam, [NotNull] IParametersOwner owner,
                              int index, IType type)
 {
     FSharpSymbol = fsParam;
     Type         = type;
     Owner        = owner;
     Index        = index;
 }
        public static IDeclaredElement GetOwner([NotNull] this FSharpParameter fsParameter,
                                                [NotNull] FSharpSymbolReference reference)
        {
            var referenceOwner = reference.GetElement();

            if (referenceOwner is IReferenceExpr referenceExpr)
            {
                var infixAppExpr = BinaryAppExprNavigator.GetByLeftArgument(referenceExpr);
                if (!(infixAppExpr?.Operator is { ShortName : "=" }))
        public static ParameterKind GetParameterKind([NotNull] FSharpParameter param)
        {
            var fsType = param.Type;

            if (fsType.HasTypeDefinition && fsType.TypeDefinition.IsByRef)
            {
                return(param.IsOut ? ParameterKind.OUTPUT : ParameterKind.REFERENCE);
            }
            return(ParameterKind.VALUE);
        }
Esempio n. 4
0
 public FSharpMethodParameter(FSharpParameter fsParam, [NotNull] IParametersOwner parametersOwner,
                              int parameterIndex, ParameterKind kind, IType type, string name)
 {
     FSharpSymbol      = fsParam;
     Type              = type;
     Kind              = kind;
     ShortName         = name;
     myParametersOwner = parametersOwner;
     myParameterIndex  = parameterIndex;
 }
Esempio n. 5
0
        public static IDeclaredElement GetOwner([NotNull] this FSharpParameter fsParameter,
                                                [NotNull] FSharpSymbolReference reference)
        {
            var referenceOwner = reference.GetElement();

            if (referenceOwner is IReferenceExpr referenceExpr)
            {
                var infixAppExpr = BinaryAppExprNavigator.GetByLeftArgument(referenceExpr);

                if (!(infixAppExpr?.Operator is var funExpr) || funExpr?.GetText() != "=")
                {
                    return(null);
                }

                var innerExpr = (IFSharpExpression)TupleExprNavigator.GetByExpression(infixAppExpr) ?? infixAppExpr;
                var parenExpr = ParenExprNavigator.GetByInnerExpression(innerExpr);

                if (!(PrefixAppExprNavigator.GetByArgumentExpression(parenExpr)?.FunctionExpression is IReferenceExpr expr))
                {
                    return(null);
                }

                var fsSymbol = expr.Reference.GetFSharpSymbol();
                switch (fsSymbol)
                {
                case FSharpUnionCase unionCase:
                    return(GetFieldDeclaredElement(reference, unionCase, referenceOwner));

                case FSharpMemberOrFunctionOrValue mfv:
                    // todo: fix member param declarations
                    return(mfv.GetDeclaredElement(referenceOwner.GetPsiModule(), referenceOwner) is IFunction functionElement
              ? functionElement.Parameters.FirstOrDefault(p => p.ShortName == reference.GetName())
              : null);
                }
            }

            if (referenceOwner is IExpressionReferenceName referenceName)
            {
                var fieldPat           = FieldPatNavigator.GetByReferenceName(referenceName);
                var parametersOwnerPat = ParametersOwnerPatNavigator.GetByParameter(fieldPat);
                if (parametersOwnerPat == null)
                {
                    return(null);
                }

                return(parametersOwnerPat.ReferenceName.Reference.GetFSharpSymbol() is FSharpUnionCase unionCase
          ? GetFieldDeclaredElement(reference, unionCase, referenceOwner)
          : null);
            }

            return(null);
        }
Esempio n. 6
0
 public FSharpMethodParameter(FSharpParameter fsParam, [NotNull] IParametersOwner owner,
                              int index, [NotNull] IType type) : base(owner, index, type) =>