private XmlNode GetDetails(IDeclaredElement element)
        {
            var xmlDocNode = element.GetXMLDoc(true);

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

            var description = myEventFunction.Description;

            if (!string.IsNullOrWhiteSpace(myParameterName))
            {
                description = myEventFunction.GetParameter(myParameterName)?.Description;
            }

            var details = CreateMemberElement(element);

            if (string.IsNullOrWhiteSpace(description))
            {
                return(details);
            }
            details.CreateLeafElementWithValue("summary", description);
            if (!element.GetPsiServices().Solution.HasComponent <IXmlDocLinkAppender>())
            {
                return(details);
            }
            var uri = element.GetPsiServices().Solution.GetComponent <UnityOnlineHelpProvider>().GetUrl(element);

            element.GetPsiServices().Solution.GetComponent <IXmlDocLinkAppender>().AppendExternalDocumentationLink(uri, element.ShortName, details);

            return(details);
        }
Ejemplo n.º 2
0
        private static IEnumerable <ExceptionContent> GetExceptions([NotNull] IDeclaredElement element, [NotNull] PsiLanguageType languageType,
                                                                    [NotNull] IPsiModule psiModule, [NotNull] IModuleReferenceResolveContext resolveContext)
        {
            XmlNode xmlDoc = element.GetXMLDoc(true);

            if (xmlDoc == null)
            {
                return(EmptyList <ExceptionContent> .InstanceList);
            }

            XmlNodeList exceptionNodes = xmlDoc.SelectNodes("exception");

            if (exceptionNodes == null || exceptionNodes.Count == 0)
            {
                return(EmptyList <ExceptionContent> .InstanceList);
            }

            var exceptions = new LocalList <ExceptionContent>();

            foreach (XmlNode exceptionNode in exceptionNodes)
            {
                ExceptionContent exceptionContent = TryExtractException(exceptionNode as XmlElement, languageType, psiModule, resolveContext);
                if (exceptionContent != null)
                {
                    exceptions.Add(exceptionContent);
                }
            }
            return(exceptions.ResultingList());
        }
Ejemplo n.º 3
0
        public static IEnumerable<ThrownExceptionModel> Read(IAnalyzeUnit analyzeUnit, IExceptionsOriginModel exceptionsOrigin, IDeclaredElement declaredElement)
        {
            if (declaredElement == null)
                return new List<ThrownExceptionModel>();

            var xmlDoc = declaredElement.GetXMLDoc(true);
            if (xmlDoc == null)
                return new List<ThrownExceptionModel>();

            return Read(analyzeUnit, exceptionsOrigin, xmlDoc);
        }
        public static IEnumerable<ThrownExceptionModel> Read(IAnalyzeUnit analyzeUnit, IExceptionsOriginModel exceptionsOrigin, IDeclaredElement declaredElement)
        {
            if (declaredElement == null)
                return new List<ThrownExceptionModel>();

            var xmlDoc = declaredElement.GetXMLDoc(true);
            if (xmlDoc == null)
                return new List<ThrownExceptionModel>();

            return Read(analyzeUnit, exceptionsOrigin, xmlDoc);
        }
        private XmlNode GetDetails(IDeclaredElement element)
        {
            var xmlDocNode = element.GetXMLDoc(true);
            if (xmlDocNode != null)
                return xmlDocNode;

            var description = myEventFunction.Description;
            if (!string.IsNullOrWhiteSpace(myParameterName))
                description = myEventFunction.GetParameter(myParameterName)?.Description;

            var details = CreateMemberElement(element);
            if (!string.IsNullOrWhiteSpace(description))
                details.CreateLeafElementWithValue("summary", description);
            return details;
        }
Ejemplo n.º 6
0
        private XmlNode GetDetails(IDeclaredElement element)
        {
            var xmlDocNode = element.GetXMLDoc(true);

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

            var description = myEventFunction.Description;

            if (!string.IsNullOrWhiteSpace(myParameterName))
            {
                description = myEventFunction.GetParameter(myParameterName)?.Description;
            }

            var details = CreateMemberElement(element);

            if (!string.IsNullOrWhiteSpace(description))
            {
                details.CreateLeafElementWithValue("summary", description);
            }
            return(details);
        }
Ejemplo n.º 7
0
        private IdentifierTooltipContent TryPresentColorized([CanBeNull] DeclaredElementInfo info, [NotNull] IContextBoundSettingsStore settings)
        {
            if (info == null)
            {
                return(null);
            }

            PsiLanguageType  languageType = info.TreeNode.Language;
            IDeclaredElement element      = info.DeclaredElement;
            IPsiModule       psiModule    = info.TreeNode.GetPsiModule();

            HighlighterIdProvider highlighterIdProvider = _highlighterIdProviderFactory.CreateProvider(settings);

            RichText identifierText;

            if (info.DeclaredElement is ICppDeclaredElement cppDeclaredElement)
            {
                identifierText = _solution.TryGetComponent <CppDeclaredElementTooltipProvider>()?.GetTooltip(cppDeclaredElement)?.RichText;
            }
            else
            {
                identifierText = _colorizerPresenter.TryPresent(
                    new DeclaredElementInstance(element, info.Substitution),
                    PresenterOptions.ForIdentifierToolTip(settings, !element.IsEnumMember()),
                    languageType,
                    highlighterIdProvider,
                    info.TreeNode,
                    out _);
            }

            if (identifierText == null || identifierText.IsEmpty)
            {
                return(null);
            }

            var identifierContent = new IdentifierTooltipContent(identifierText, info.SourceRange);

            if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowIcon))
            {
                identifierContent.Icon = TryGetIcon(element);
            }

            if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowDocumentation))
            {
                XmlNode xmlDoc = element.GetXMLDoc(true);
                identifierContent.Description = TryGetDescription(element, xmlDoc, psiModule, languageType);

                if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowObsolete))
                {
                    identifierContent.Obsolete = TryRemoveObsoletePrefix(TryGetObsolete(element, psiModule, languageType));
                }

                if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowReturn))
                {
                    identifierContent.Return = TryPresentDocNode(xmlDoc, "returns", languageType, psiModule);
                }

                if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowValue))
                {
                    identifierContent.Value = TryPresentDocNode(xmlDoc, "value", languageType, psiModule);
                }

                if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowRemarks))
                {
                    identifierContent.Remarks = TryPresentDocNode(xmlDoc, "remarks", languageType, psiModule);
                }

                if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowExceptions))
                {
                    identifierContent.Exceptions.AddRange(GetExceptions(xmlDoc, languageType, psiModule));
                }
            }

            if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowOverloadCount))
            {
                identifierContent.OverloadCount = TryGetOverloadCount(element as IFunction, info.Reference, languageType);
            }

            if (info.DeclaredElement is ITypeElement typeElement)
            {
                var baseTypeDisplayKind = settings.GetValue((IdentifierTooltipSettings s) => s.BaseTypeDisplayKind);
                var implementedInterfacesDisplayKind = settings.GetValue((IdentifierTooltipSettings s) => s.ImplementedInterfacesDisplayKind);
                if (baseTypeDisplayKind != BaseTypeDisplayKind.Never ||
                    implementedInterfacesDisplayKind != ImplementedInterfacesDisplayKind.Never)
                {
                    AddSuperTypes(identifierContent, typeElement, baseTypeDisplayKind, implementedInterfacesDisplayKind, languageType, info.TreeNode, highlighterIdProvider, settings);
                }

                if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowAttributesUsage) && typeElement.IsAttribute())
                {
                    identifierContent.AttributeUsage = GetAttributeUsage((IClass)info.DeclaredElement);
                }
            }

            return(identifierContent);
        }