ParseTypeParameters() private method

private ParseTypeParameters ( IEnumerable typeParameters ) : SortedList
typeParameters IEnumerable
return SortedList
Example #1
0
        private SDMethod GetParsedMethod(IMethodSymbol method, bool isCtor)
        {
            var sdMethod = ParserOptions.SDRepository.GetMethodByIdentifier(method.GetIdentifier());

            if (sdMethod != null)
            {
                return(sdMethod);
            }

            var returnType      = _typeRefParser.GetParsedTypeReference(method.ReturnType);
            var syntaxReference = method.DeclaringSyntaxReferences.Any() ? method.DeclaringSyntaxReferences.Single() : null;

            sdMethod = new SDMethod(method.GetIdentifier(), isCtor ? method.ContainingType.Name : method.Name)
            {
                Namespace      = method.ContainingNamespace.GetIdentifier(),
                DeclaringType  = _typeRefParser.GetParsedTypeReference(method.ContainingType),
                ReturnType     = returnType,
                IsCtor         = isCtor,
                Accessibility  = method.DeclaredAccessibility.ToString().ToLower(),
                IsAbstract     = method.IsAbstract,
                IsOverride     = method.IsOverride,
                IsPrivate      = method.DeclaredAccessibility == Accessibility.Private,
                IsProtected    = method.DeclaredAccessibility == Accessibility.Protected,
                IsPublic       = method.DeclaredAccessibility == Accessibility.Public,
                IsSealed       = method.IsSealed,
                IsVirtual      = method.IsVirtual,
                IsStatic       = method.IsStatic,
                Documentations = DocumentationParser.ParseDocumentation(method),
                Region         = syntaxReference != null ? new SDRegion
                {
                    Start     = syntaxReference.Span.Start,
                    End       = syntaxReference.Span.End,
                    StartLine = syntaxReference.SyntaxTree.GetLineSpan(syntaxReference.Span).StartLinePosition.Line + 1,
                    EndLine   = syntaxReference.SyntaxTree.GetLineSpan(syntaxReference.Span).EndLinePosition.Line + 1,
                    FilePath  = syntaxReference.SyntaxTree.FilePath,
                    Filename  = Path.GetFileName(syntaxReference.SyntaxTree.FilePath)
                } : null
            };

            sdMethod.TypeParameters = _typeParameterParser.ParseTypeParameters(method.TypeParameters);

            foreach (var parameter in method.Parameters)
            {
                sdMethod.Parameters.Add(new SDParameter
                {
                    Name          = parameter.Name,
                    ParamType     = _typeRefParser.GetParsedTypeReference(parameter.Type),
                    IsOptional    = parameter.IsOptional,
                    IsConst       = parameter.HasExplicitDefaultValue,
                    ConstantValue = parameter.HasExplicitDefaultValue ? parameter.ExplicitDefaultValue?.ToString() ?? "null" : null,
                    IsRef         = parameter.RefKind == RefKind.Ref,
                    IsOut         = parameter.RefKind == RefKind.Out
                });
            }

            ParserOptions.SDRepository.AddMethod(sdMethod);
            return(sdMethod);
        }
Example #2
0
        private void ParseTheProjectType(INamedTypeSymbol typeSymbol)
        {
            var sdNamespace = ParserOptions.SDRepository.GetNamespaceByIdentifier(typeSymbol.ContainingNamespace.GetIdentifier());
            var sdType      = ParserOptions.SDRepository.GetTypeByIdentifier(typeSymbol.GetIdentifier());

            if (sdType == null)
            {
                sdType = CreateSDType(typeSymbol, sdNamespace);
                sdNamespace.Types.Add(sdType);
                ParserOptions.SDRepository.AddType(sdType);
            }
            else // already parsed as stranger
            {
                sdType.Namespace         = ParserOptions.SDRepository.GetNamespaceByIdentifier(typeSymbol.ContainingNamespace.GetIdentifier());
                sdType.Regions           = GetRegions(typeSymbol);
                sdType.IsProjectStranger = false;

                if (!sdNamespace.Types.Contains(sdType))
                {
                    sdNamespace.Types.Add(sdType);
                }
            }

            sdType.Documentations = DocumentationParser.ParseDocumentation(typeSymbol);
            AddParsedBaseType(sdType, typeSymbol.BaseType);
            AddParsedInterfaces(sdType, typeSymbol.Interfaces);
            AddParsedNestedTypes(sdType, typeSymbol.GetTypeMembers());

            _propertyParser.ParseProperties(sdType, typeSymbol);
            _fieldParser.ParseFields(sdType, typeSymbol);
            _methodParser.ParseConstructors(sdType, typeSymbol);
            _methodParser.ParseMethods(sdType, typeSymbol);
            _eventParser.ParseEvents(sdType, typeSymbol);

            sdType.TypeParameters = _typeParameterParser.ParseTypeParameters(typeSymbol.TypeParameters);
            foreach (var typeArgument in typeSymbol.TypeArguments)
            {
                sdType.TypeArguments.Add(_typeRefParser.GetParsedTypeReference(typeArgument));
            }
        }