internal FSharpConversionOperator([NotNull] ITypeMemberDeclaration declaration,
                                   [NotNull] FSharpMemberOrFunctionOrValue mfv, [CanBeNull] IFSharpTypeDeclaration typeDeclaration,
                                   bool isExplicitCast)
     : base(declaration, mfv, typeDeclaration)
 {
     myIsExplicitCast = isExplicitCast;
 }
 public FSharpLiteral([NotNull] ITypeMemberDeclaration declaration, FSharpMemberOrFunctionOrValue mfv) :
     base(declaration)
 {
     Type = FSharpTypesUtil.GetType(mfv.FullType, declaration, Module) ??
            TypeFactory.CreateUnknownType(Module);
     ConstantValue = new ConstantValue(mfv.LiteralValue.Value, Type);
 }
        /// <summary>Initializes the specified type member.</summary>
        /// <param name="typeMember">The type member.</param>
        /// <exception cref="ArgumentNullException">The type member cannot be null.</exception>
        private void Initialize([NotNull] ITypeMemberDeclaration typeMember)
        {
            if (typeMember == null)
            {
                throw new ArgumentNullException("typeMember");
            }

            var sourceFile = typeMember.GetSourceFile();

            if (sourceFile == null)
            {
                return;
            }

            var psiServices = typeMember.GetPsiServices();

            if (psiServices == null)
            {
                throw new InvalidOperationException("psiServices");
            }

            var cache = psiServices.GetCodeAnnotationsCache();

            this.notNull   = cache.GetAttributeTypeForElement(typeMember, CodeAnnotationsCache.NotNullAttributeShortName);
            this.canBeNull = cache.GetAttributeTypeForElement(typeMember, CodeAnnotationsCache.CanBeNullAttributeShortName);
        }
 internal FSharpFieldProperty([NotNull] ITypeMemberDeclaration declaration, [NotNull] FSharpField field)
     : base(declaration)
 {
     Field      = field;
     ReturnType = FSharpTypesUtil.GetType(field.FieldType, declaration, Module) ??
                  TypeFactory.CreateUnknownType(Module);
 }
Beispiel #5
0
        protected FSharpPropertyBase([NotNull] ITypeMemberDeclaration declaration,
                                     [NotNull] FSharpMemberOrFunctionOrValue mfv) : base(declaration, mfv)
        {
            IsReadable = mfv.HasGetterMethod || mfv.IsPropertyGetterMethod ||
                         mfv.IsModuleValueOrMember && !mfv.IsMember;

            IsWritable = mfv.IsMutable || mfv.HasSetterMethod || mfv.IsPropertySetterMethod;
        }
Beispiel #6
0
        public virtual bool IsAccept(ITypeMemberDeclaration memberDeclaration)
        {
            if(!predicate(memberDeclaration))
                return false;

            filedDeclarations.Add(memberDeclaration);
            return true;
        }
        private static IList <ITypeParameter> GetOuterTypeParameters(ITypeMemberDeclaration typeMemberDeclaration)
        {
            var typeDeclaration = typeMemberDeclaration.GetContainingTypeDeclaration();
            var parameters      = typeDeclaration?.DeclaredElement?.GetAllTypeParameters();

            return(parameters?.ResultingList() ??
                   EmptyList <ITypeParameter> .Instance);
        }
        /// <summary>Inspects the specified method.</summary>
        /// <param name="property">The method.</param>
        public void Inspect([NotNull] IPropertyDeclaration property)
        {
            this.CodeAnnotation = new CodeAnnotation(property);
            if (!this.CodeAnnotation.IsValid)
            {
                return;
            }

            if (property.IsExtern)
            {
                return;
            }

            this.TypeMember    = property;
            this.AppliedReturn = this.CodeAnnotation.GetAnnotation(property);

            var getter = property.AccessorDeclarations.FirstOrDefault(a => a.Kind == AccessorKind.GETTER);
            var setter = property.AccessorDeclarations.FirstOrDefault(a => a.Kind == AccessorKind.SETTER);

            if (this.AppliedReturn != CodeAnnotationAttribute.Undefined && this.AppliedReturn != CodeAnnotationAttribute.NotSet)
            {
                this.ExpectedReturn = this.AppliedReturn;
            }
            else if (getter != null)
            {
                var attribute = this.CodeAnnotation.InspectControlGraf(getter);
                if (attribute != CodeAnnotationAttribute.Undefined && attribute != CodeAnnotationAttribute.NotSet)
                {
                    this.ExpectedReturn = attribute;
                }
                else if (attribute == CodeAnnotationAttribute.NotSet)
                {
                    this.ExpectedReturn = CodeAnnotationAttribute.NotNull;
                }
            }

            if (getter != null)
            {
                this.BuildValueParameter(this.TypeMember, getter, setter);
            }

            if (setter == null)
            {
                return;
            }

            var body = setter.Body;

            if (body == null)
            {
                return;
            }

            this.Body = body;

            // this.BuildParameters(setter, false);
            this.BuildAssertions(body);
        }
        public static IType GetType([NotNull] FSharpType fsType,
                                    [NotNull] ITypeMemberDeclaration methodDeclaration, [NotNull] IList <ITypeParameter> methodTypeParams,
                                    [NotNull] IPsiModule psiModule, bool isFromReturn)
        {
            var typeParametersFromType = GetOuterTypeParameters(methodDeclaration);
            var typeParamsFromContext  = typeParametersFromType.Prepend(methodTypeParams).ToIList();

            return(GetType(fsType, typeParamsFromContext, psiModule, true, isFromReturn));
        }
        protected FSharpPropertyMemberBase([NotNull] ITypeMemberDeclaration declaration,
                                           [NotNull] FSharpMemberOrFunctionOrValue mfv) : base(declaration)
        {
            var prop = GetProperty(mfv);

            IsReadable = prop.HasGetterMethod || prop.IsPropertyGetterMethod ||
                         prop.IsModuleValueOrMember && !prop.IsMember;

            IsWritable = prop.IsMutable || prop.HasSetterMethod || prop.IsPropertySetterMethod;
        }
        /// <summary>Initializes a new instance of the <see cref="CodeAnnotation"/> class.
        /// Codes the annotation.</summary>
        /// <param name="typeMember">The type member.</param>
        public CodeAnnotation([NotNull] ITypeMemberDeclaration typeMember)
        {
            if (typeMember == null)
            {
                throw new ArgumentNullException("typeMember");
            }

            typeMember.GetPsiServices();

            this.Initialize(typeMember);
        }
        /// <summary>Gets the annotation.</summary>
        /// <param name="parameter">The parameter.</param>
        /// <returns>Returns the annotation.</returns>
        public CodeAnnotationAttribute GetAnnotation([NotNull] ITypeMemberDeclaration parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            var attributesOwner = parameter.DeclaredElement as IAttributesOwner;

            return(attributesOwner != null?this.GetAnnotation(attributesOwner) : CodeAnnotationAttribute.Undefined);
        }
 public static IType GetType([NotNull] FSharpType fsType, [NotNull] ITypeMemberDeclaration typeMemberDeclaration,
                             [NotNull] IPsiModule psiModule)
 {
     try
     {
         return(GetType(fsType, GetOuterTypeParameters(typeMemberDeclaration), psiModule));
     }
     catch (ErrorLogger.UnresolvedPathReferenceNoRange)
     {
         return(TypeFactory.CreateUnknownType(psiModule));
     }
 }
Beispiel #14
0
        public static void AddXmlComment(this ITypeMemberDeclaration declaration, string text, CSharpElementFactory factory)
        {
            var docCommentBlockOwnerNode = XmlDocTemplateUtil.FindDocCommentOwner(declaration);

            if (docCommentBlockOwnerNode == null)
            {
                return;
            }

            var comment = factory.CreateDocCommentBlock(text);

            docCommentBlockOwnerNode.SetDocCommentBlock(comment);
        }
 public FSharpCliEvent([NotNull] ITypeMemberDeclaration declaration, FSharpMemberOrFunctionOrValue mfv)
     : base(declaration, mfv)
 {
     try
     {
         ReturnType = FSharpTypesUtil.GetType(mfv.FullType, declaration, Module) ??
                      TypeFactory.CreateUnknownType(Module);
     }
     catch (ErrorLogger.ReportedError e)
     {
         ReturnType = TypeFactory.CreateUnknownType(Module);
     }
 }
Beispiel #16
0
 public ComplexityCodeInsightsHighlight(
     ITypeMemberDeclaration declaration,
     int complexity,
     int percentage,
     ICodeInsightsProvider provider,
     IconHost iconHost)
     : base(
         declaration.GetNameDocumentRange(),
         GetLensText(percentage),
         GetMoreText(complexity, percentage),
         provider,
         declaration.DeclaredElement,
         iconHost.Transform(GetIconId(percentage)))
 {
 }
        public static IType GetType([NotNull] FSharpType fsType,
                                    [NotNull] ITypeMemberDeclaration methodDeclaration, [NotNull] IList <ITypeParameter> methodTypeParams,
                                    [NotNull] IPsiModule psiModule, bool isFromReturn)
        {
            var typeParametersFromType = GetOuterTypeParameters(methodDeclaration);
            var typeParamsFromContext  = typeParametersFromType.Prepend(methodTypeParams).ToIList();

            try
            {
                return(GetType(fsType, typeParamsFromContext, psiModule, true, isFromReturn));
            }
            catch (ErrorLogger.UnresolvedPathReferenceNoRange)
            {
                return(TypeFactory.CreateUnknownType(psiModule));
            }
        }
        /// <summary>Builds the value parameter.</summary>
        /// <param name="typeMember">The type member.</param>
        /// <param name="getter">The getter.</param>
        /// <param name="setter">The setter.</param>
        private void BuildValueParameter([NotNull] ITypeMemberDeclaration typeMember, [NotNull] IAccessorDeclaration getter, [CanBeNull] IAccessorDeclaration setter)
        {
            if (typeMember == null)
            {
                throw new ArgumentNullException("typeMember");
            }

            if (getter == null)
            {
                throw new ArgumentNullException("getter");
            }

            var returnType = getter.DeclaredElement.ReturnType;

            if (!returnType.IsReferenceType())
            {
                return;
            }

            var expectsAssertion  = false;
            var assertionCode     = string.Empty;
            var appliedAttribute  = this.AppliedReturn;
            var expectedAttribute = this.ExpectedReturn;

            if (appliedAttribute == CodeAnnotationAttribute.CanBeNull)
            {
            }
            else if (appliedAttribute == CodeAnnotationAttribute.NotNull || expectedAttribute == CodeAnnotationAttribute.NotNull)
            {
                if (this.GenerateAssertions)
                {
                    if (setter != null && setter.Body != null)
                    {
                        assertionCode = this.GetCode();
                        if (!string.IsNullOrEmpty(assertionCode))
                        {
                            assertionCode    = string.Format(assertionCode, "value").Trim();
                            expectsAssertion = true;
                        }
                    }
                }
            }

            var descriptor = new ParameterDescriptor(expectedAttribute, appliedAttribute, expectsAssertion, assertionCode);

            this.parameters.Add(descriptor);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ValueAnalysisRefactoring"/> class.
        /// </summary>
        /// <param name="typeMemberDeclaration">
        /// The type member declaration.
        /// </param>
        public ValueAnalysisRefactoring([NotNull] ITypeMemberDeclaration typeMemberDeclaration)
        {
            this.typeMemberDeclaration = typeMemberDeclaration;

              var codeAnnotationsCache = CodeAnnotationsCache.GetInstance(this.Solution);

              this.notNullTypeElement = codeAnnotationsCache.GetAttributeTypeForElement(this.TypeMemberDeclaration, CodeAnnotationsCache.NotNullAttributeShortName);
              this.canBeNullTypeElement = codeAnnotationsCache.GetAttributeTypeForElement(this.TypeMemberDeclaration, CodeAnnotationsCache.CanBeNullAttributeShortName);

              if (this.notNullTypeElement == null || this.canBeNullTypeElement == null)
              {
            return;
              }

              this.notNullableAttributeClrName = new CLRTypeName(this.notNullTypeElement.CLRName);
              this.canBeNullAttributeClrName = new CLRTypeName(this.canBeNullTypeElement.CLRName);
        }
        /// <summary>Inspects this instance.</summary>
        /// <param name="method">The method.</param>
        public void Inspect([NotNull] IMethodDeclaration method)
        {
            this.CodeAnnotation = new CodeAnnotation(method);
            if (!this.CodeAnnotation.IsValid)
            {
                return;
            }

            if (method.IsExtern)
            {
                return;
            }

            var body = method.Body;

            this.TypeMember = method;
            this.Body       = body;

            this.AppliedReturn = this.CodeAnnotation.GetAnnotation(method);

            if (this.AppliedReturn != CodeAnnotationAttribute.Undefined && this.AppliedReturn != CodeAnnotationAttribute.NotSet)
            {
                this.ExpectedReturn = this.AppliedReturn;
            }
            else
            {
                var attribute = this.CodeAnnotation.InspectControlGraf(method);
                if (attribute != CodeAnnotationAttribute.Undefined && attribute != CodeAnnotationAttribute.NotSet)
                {
                    this.ExpectedReturn = attribute;
                }
                else if (attribute == CodeAnnotationAttribute.NotSet)
                {
                    this.ExpectedReturn = CodeAnnotationAttribute.NotNull;
                }
            }

            this.BuildParameters(method, method.IsAbstract);
            if (body != null)
            {
                this.BuildAssertions(body);
            }
        }
Beispiel #21
0
        protected FSharpFunctionBase([NotNull] ITypeMemberDeclaration declaration,
                                     [NotNull] FSharpMemberOrFunctionOrValue mfv, [CanBeNull] IFSharpTypeDeclaration typeDeclaration)
            : base(declaration, mfv)
        {
            var mfvTypeParams        = mfv.GenericParameters;
            var typeParams           = new FrugalLocalList <ITypeParameter>();
            var outerTypeParamsCount = typeDeclaration?.TypeParameters.Count ?? 0;

            for (var i = outerTypeParamsCount; i < mfvTypeParams.Count; i++)
            {
                typeParams.Add(new FSharpTypeParameterOfMethod(this, mfvTypeParams[i].DisplayName, i - outerTypeParamsCount));
            }
            TypeParameters = typeParams.ToList();

            ReturnType = mfv.IsConstructor || mfv.ReturnParameter.Type.IsUnit
        ? Module.GetPredefinedType().Void
        : FSharpTypesUtil.GetType(mfv.ReturnParameter.Type, declaration, TypeParameters, Module, true) ??
                         TypeFactory.CreateUnknownType(Module);

            var methodParams   = new FrugalLocalList <IParameter>();
            var mfvParamGroups = mfv.CurriedParameterGroups;

            if (mfvParamGroups.Count == 1 && mfvParamGroups[0].Count == 1 && mfvParamGroups[0][0].Type.IsUnit)
            {
                Parameters = EmptyList <IParameter> .InstanceList;
                return;
            }

            foreach (var paramsGroup in mfv.CurriedParameterGroups)
            {
                foreach (var param in paramsGroup)
                {
                    var paramType = param.Type;
                    var paramName = param.DisplayName;
                    methodParams.Add(new FSharpMethodParameter(param, this, methodParams.Count,
                                                               FSharpTypesUtil.GetParameterKind(param),
                                                               FSharpTypesUtil.GetType(paramType, declaration, TypeParameters, Module, false),
                                                               paramName.IsEmpty() ? SharedImplUtil.MISSING_DECLARATION_NAME : paramName));
                }
            }
            Parameters = methodParams.ToList();
        }
Beispiel #22
0
        protected FSharpPropertyBase([NotNull] ITypeMemberDeclaration declaration,
                                     [NotNull] FSharpMemberOrFunctionOrValue mfv)
            : base(declaration, mfv)
        {
            var property =
                mfv.IsModuleValueOrMember
          ? mfv.DeclaringEntity?.Value.MembersFunctionsAndValues.FirstOrDefault(
                    m => m.IsProperty && m.DisplayName == mfv.DisplayName) ?? mfv
          : mfv;

            IsReadable = property.HasGetterMethod || property.IsPropertyGetterMethod ||
                         property.IsModuleValueOrMember && !property.IsMember;
            IsWritable = property.IsMutable || property.HasSetterMethod || property.IsPropertySetterMethod;
            var returnType = property.IsPropertySetterMethod
        ? property.CurriedParameterGroups[0][0].Type
        : property.ReturnParameter.Type;

            ReturnType = FSharpTypesUtil.GetType(returnType, declaration, Module) ??
                         TypeFactory.CreateUnknownType(Module);
        }
        /// <summary>
        /// Analyzes the specified statement.
        /// </summary>
        /// <param name="typeMemberDeclaration">
        /// The type member declaration.
        /// </param>
        /// <returns>
        /// Returns the suggestion base[].
        /// </returns>
        public SuggestionBase[] Analyze(ITypeMemberDeclaration typeMemberDeclaration)
        {
            var modifiersOwnerDeclaration = typeMemberDeclaration as IModifiersOwnerDeclaration;
              if (modifiersOwnerDeclaration == null)
              {
            return null;
              }

              var valueAnalysisRefactoring = new ValueAnalysisRefactoring(typeMemberDeclaration);

              if (!valueAnalysisRefactoring.IsAvailable())
              {
            return null;
              }

              var suggestions = new List<SuggestionBase>();

              suggestions.Add(new ValueAnalysisSuggestion(this.solution, typeMemberDeclaration));

              return suggestions.ToArray();
        }
        /// <summary>Inspects the specified method.</summary>
        /// <param name="constructor">The method.</param>
        public void Inspect([NotNull] IConstructorDeclaration constructor)
        {
            this.CodeAnnotation = new CodeAnnotation(constructor);
            if (!this.CodeAnnotation.IsValid)
            {
                return;
            }

            var body = constructor.Body;

            if (body == null)
            {
                return;
            }

            this.TypeMember = constructor;
            this.Body       = body;

            this.AppliedReturn  = CodeAnnotationAttribute.Undefined;
            this.ExpectedReturn = CodeAnnotationAttribute.Undefined;

            this.BuildParameters(constructor, false);
            this.BuildAssertions(body);
        }
Beispiel #25
0
 internal FSharpOperatorBase([NotNull] ITypeMemberDeclaration declaration) : base(declaration)
 {
 }
Beispiel #26
0
 internal FSharpConversionOperator([NotNull] ITypeMemberDeclaration declaration, bool isExplicitCast) :
     base(declaration) =>
    /// <summary>Inspects the specified method.</summary>
    /// <param name="constructor">The method.</param>
    public void Inspect([NotNull] IConstructorDeclaration constructor)
    {
      this.CodeAnnotation = new CodeAnnotation(constructor);
      if (!this.CodeAnnotation.IsValid)
      {
        return;
      }

      var body = constructor.Body;
      if (body == null)
      {
        return;
      }

      this.TypeMember = constructor;
      this.Body = body;

      this.AppliedReturn = CodeAnnotationAttribute.Undefined;
      this.ExpectedReturn = CodeAnnotationAttribute.Undefined;

      this.BuildParameters(constructor, false);
      this.BuildAssertions(body);
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValueAnalysisSuggestion"/> class.
 /// </summary>
 /// <param name="solution">
 /// The solution.
 /// </param>
 /// <param name="typeMemberDeclaration">
 /// The type member declaration.
 /// </param>
 public ValueAnalysisSuggestion(ISolution solution, ITypeMemberDeclaration typeMemberDeclaration)
     : base(Name, typeMemberDeclaration, typeMemberDeclaration.GetNameDocumentRange(), "Type members should be annotated with Value Analysis attributes. [Agent Johnson]")
 {
     this.solution = solution;
       this.typeMemberDeclaration = typeMemberDeclaration;
 }
Beispiel #29
0
 internal FSharpFieldProperty([NotNull] ITypeMemberDeclaration declaration) : base(declaration)
 {
 }
        /// <summary>
        /// Executes the specified type member declaration.
        /// </summary>
        /// <param name="typeMemberDeclaration">
        /// The type member declaration.
        /// </param>
        private void Execute(ITypeMemberDeclaration typeMemberDeclaration)
        {
            var processor = new RecursiveElementProcessor(this.ReplaceReturnValue);

              typeMemberDeclaration.ProcessDescendants(processor);
        }
        /// <summary>
        /// Inserts a returns element to the element if its missing.
        /// </summary>
        /// <param name="memberDeclaration">
        /// The <see cref="ITypeMemberDeclaration"/> to check and fix.
        /// </param>
        /// <param name="returnType">
        /// The text to insert as the return type.
        /// </param>
        public void InsertReturnsElement(ITypeMemberDeclaration memberDeclaration, string returnType)
        {
            Param.RequireNotNull(memberDeclaration, "memberDeclaration");

            DeclarationHeader declarationHeader = new DeclarationHeader(memberDeclaration);

            if (declarationHeader.IsMissing || declarationHeader.IsInherited)
            {
                return;
            }

            string valueText = string.Empty;
            IContextBoundSettingsStore settingsStore = PsiSourceFileExtensions.GetSettingsStore(null, memberDeclaration.GetSolution());
            if (settingsStore.GetValue((StyleCopOptionsSettingsKey key) => key.InsertTextIntoDocumentation))
            {
                valueText = string.Format("The <see cref=\"{0}\"/>.", returnType.SubstringBefore('{'));
            }

            XmlNode xmlNode = declarationHeader.XmlNode;

            XmlNode returnsXmlNode = declarationHeader.ReturnsXmlNode;

            if (declarationHeader.HasReturns)
            {
                if (string.IsNullOrEmpty(returnsXmlNode.InnerText.Trim()))
                {
                    returnsXmlNode.InnerXml = valueText;
                    declarationHeader.Update();
                }
            }
            else
            {
                XmlNode valueNode = CreateNode(xmlNode, "returns");
                valueNode.InnerXml = valueText;
                xmlNode.AppendChild(valueNode);
                declarationHeader.Update();
            }
        }
        /// <summary>
        /// Inserts a returns element to the element if its missing.
        /// </summary>
        /// <param name="memberDeclaration">
        /// The <see cref="ITypeMemberDeclaration"/> to check and fix.
        /// </param>
        public void InsertReturnsElement(ITypeMemberDeclaration memberDeclaration)
        {
            Param.RequireNotNull(memberDeclaration, "memberDeclaration");

            DeclarationHeader declarationHeader = new DeclarationHeader(memberDeclaration);

            if (declarationHeader.IsMissing || declarationHeader.IsInherited)
            {
                return;
            }

            XmlNode xmlNode = declarationHeader.XmlNode;

            XmlNode returnsXmlNode = declarationHeader.ReturnsXmlNode;

            string valueText = string.Empty;
            if (StyleCopOptions.Instance.InsertTextIntoDocumentation)
            {
                valueText = string.Format("The {0}.", Utils.ConvertTextToSentence(memberDeclaration.DeclaredName).ToLower());
            }

            if (declarationHeader.HasReturns)
            {
                if (string.IsNullOrEmpty(returnsXmlNode.InnerText.Trim()))
                {
                    returnsXmlNode.InnerText = valueText;
                    declarationHeader.Update();
                }
                else
                {
                    return;
                }
            }
            else
            {
                XmlNode valueNode = CreateNode(xmlNode, "returns");
                valueNode.InnerText = valueText;
                xmlNode.AppendChild(valueNode);
                declarationHeader.Update();
            }
        }
 /// <summary>
 /// Visits the type member.
 /// </summary>
 /// <param name="typeMemberDeclaration">The type member declaration.</param>
 /// <param name="consumer">The consumer.</param>
 /// <returns></returns>
 private void VisitTypeMember(ITypeMemberDeclaration typeMemberDeclaration, IHighlightingConsumer consumer)
 {
     AddHighlighting(consumer, this.valueAnalysisAnalyzer.Analyze(typeMemberDeclaration));
 }
    /// <summary>Inspects this instance.</summary>
    /// <param name="method">The method.</param>
    public void Inspect([NotNull] IMethodDeclaration method)
    {
      this.CodeAnnotation = new CodeAnnotation(method);
      if (!this.CodeAnnotation.IsValid)
      {
        return;
      }

      if (method.IsExtern)
      {
        return;
      }

      var body = method.Body;

      this.TypeMember = method;
      this.Body = body;

      this.AppliedReturn = this.CodeAnnotation.GetAnnotation(method);

      if (this.AppliedReturn != CodeAnnotationAttribute.Undefined && this.AppliedReturn != CodeAnnotationAttribute.NotSet)
      {
        this.ExpectedReturn = this.AppliedReturn;
      }
      else
      {
        var attribute = this.CodeAnnotation.InspectControlGraf(method);
        if (attribute != CodeAnnotationAttribute.Undefined && attribute != CodeAnnotationAttribute.NotSet)
        {
          this.ExpectedReturn = attribute;
        }
        else if (attribute == CodeAnnotationAttribute.NotSet)
        {
          this.ExpectedReturn = CodeAnnotationAttribute.NotNull;
        }
      }

      this.BuildParameters(method, method.IsAbstract);
      if (body != null)
      {
        this.BuildAssertions(body);
      }
    }
 protected FSharpPropertyBase([NotNull] ITypeMemberDeclaration declaration) : base(declaration)
 {
 }
        /// <summary>
        /// Removes a return element if it currently has one.
        /// </summary>
        /// <param name="memberDeclaration">
        /// The <see cref="ITypeDeclaration"/> to check and fix.
        /// </param>
        public void RemoveReturnsElement(ITypeMemberDeclaration memberDeclaration)
        {
            DeclarationHeader declarationHeader = new DeclarationHeader(memberDeclaration);

            if (declarationHeader.IsMissing || declarationHeader.IsInherited || !declarationHeader.HasReturns)
            {
                return;
            }

            declarationHeader.XmlNode.RemoveChild(declarationHeader.ReturnsXmlNode);
            declarationHeader.Update();
        }
Beispiel #37
0
 internal FSharpUnionCaseField([NotNull] ITypeMemberDeclaration declaration) : base(declaration)
 {
 }
    /// <summary>Inspects the specified indexer.</summary>
    /// <param name="indexer">The indexer.</param>
    public void Inspect([NotNull] IIndexerDeclaration indexer)
    {
      this.CodeAnnotation = new CodeAnnotation(indexer);
      if (!this.CodeAnnotation.IsValid)
      {
        return;
      }

      if (indexer.IsAbstract || indexer.IsExtern)
      {
        return;
      }

      this.TypeMember = indexer;
      this.AppliedReturn = this.CodeAnnotation.GetAnnotation(indexer);

      var getter = indexer.AccessorDeclarations.FirstOrDefault(a => a.Kind == AccessorKind.GETTER);
      var setter = indexer.AccessorDeclarations.FirstOrDefault(a => a.Kind == AccessorKind.SETTER);

      if (this.AppliedReturn != CodeAnnotationAttribute.Undefined && this.AppliedReturn != CodeAnnotationAttribute.NotSet)
      {
        this.ExpectedReturn = this.AppliedReturn;
      }
      else if (getter != null)
      {
        var attribute = this.CodeAnnotation.InspectControlGraf(getter);
        if (attribute != CodeAnnotationAttribute.Undefined && attribute != CodeAnnotationAttribute.NotSet)
        {
          this.ExpectedReturn = attribute;
        }
      }

      if (getter != null)
      {
        this.BuildValueParameter(this.TypeMember, getter, setter);
      }

      if (setter == null)
      {
        return;
      }

      var body = setter.Body;
      if (body == null)
      {
        return;
      }

      this.Body = body;

      // this.BuildParameters(setter, false);
      this.BuildAssertions(body);
    }
 protected FSharpMethodBase([NotNull] ITypeMemberDeclaration declaration,
                            [NotNull] FSharpMemberOrFunctionOrValue mfv) : base(declaration, mfv)
 {
 }
 protected FSharpMethodBase([NotNull] ITypeMemberDeclaration declaration,
                            [NotNull] FSharpMemberOrFunctionOrValue mfv, [CanBeNull] IFSharpTypeDeclaration typeDeclaration)
     : base(declaration, mfv, typeDeclaration)
 {
     ShortName = mfv.GetMemberCompiledName();
 }
Beispiel #41
0
 protected FSharpTypeParametersOwnerBase([NotNull] ITypeMemberDeclaration declaration) : base(declaration)
 {
 }
 public FSharpCliEvent([NotNull] ITypeMemberDeclaration declaration, FSharpMemberOrFunctionOrValue mfv)
     : base(declaration, mfv)
 {
 }