protected override IDeclaredElement CreateDeclaredElement()

in ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Impl/Tree/TopPatternDeclarationBase.cs [33:66]


    protected override IDeclaredElement CreateDeclaredElement(FSharpSymbol fcsSymbol) =>
      CreateBindingDeclaredElement(fcsSymbol, this);

    public static IDeclaredElement CreateBindingDeclaredElement([NotNull] FSharpSymbol fcsSymbol,
      [NotNull] TopPatternDeclarationBase declaration)
    {
      if (!(fcsSymbol is FSharpMemberOrFunctionOrValue mfv))
        return null;

      var typeDeclaration = declaration.GetContainingNode<ITypeDeclaration>();
      if (typeDeclaration == null)
        return null;

      if (typeDeclaration is IFSharpTypeDeclaration)
      {
        if ((!mfv.CurriedParameterGroups.IsEmpty() || !mfv.GenericParameters.IsEmpty()) && !mfv.IsMutable)
          return new FSharpTypePrivateMethod(declaration);

        if (mfv.LiteralValue != null)
          return new FSharpLiteral(declaration);

        return new FSharpTypePrivateField(declaration);
      }

      if (mfv.LiteralValue != null)
        return new FSharpLiteral(declaration);

      if (!mfv.IsValCompiledAsMethod())
        return new ModuleValue(declaration);

      return !mfv.IsInstanceMember && mfv.CompiledName.StartsWith("op_", StringComparison.Ordinal)
        ? new FSharpSignOperator<TopPatternDeclarationBase>(declaration)
        : new ModuleFunction(declaration);
    }