public RichTextBlock GetElementDescription(IDeclaredElement element, DeclaredElementDescriptionStyle style, PsiLanguageType language, IPsiModule module = null) { if (!element.IsFromUnityProject()) return null; var method = element as IMethod; if (method != null) { var eventFunction = myUnityApi.GetUnityEventFunction(method); if (eventFunction?.Description != null) return new RichTextBlock(eventFunction.Description); } var parameter = element as IParameter; var owner = parameter?.ContainingParametersOwner as IMethod; if (owner != null) { var eventFunction = myUnityApi.GetUnityEventFunction(owner); var eventFunctionParameter = eventFunction?.GetParameter(parameter.ShortName); if (eventFunctionParameter?.Description != null) return new RichTextBlock(eventFunctionParameter.Description); } return null; }
// This is the ReSharper 8.1 version public RichTextBlock GetElementDescription(IDeclaredElement element, DeclaredElementDescriptionStyle style, PsiLanguageType language, IPsiModule module) { var attribute = element as IHtmlAttributeDeclaredElement; if (attribute == null) return null; var attributeDescription = GetAttributeDescription(attribute.ShortName); var block = new RichTextBlock(); var typeDescription = new RichText(htmlDescriptionsCache.GetDescriptionForHtmlValueType(attribute.ValueType)); if (style.IntendedDescriptionPlacement == DescriptionPlacement.AFTER_NAME && (style.ShowSummary || style.ShowFullDescription)) block.SplitAndAdd(typeDescription); string description = null; if (style.ShowSummary && attributeDescription != null) description = attributeDescription.Summary; else if (style.ShowFullDescription && attributeDescription != null) description = attributeDescription.Description; if (!string.IsNullOrEmpty(description)) block.SplitAndAdd(description); if (style.IntendedDescriptionPlacement == DescriptionPlacement.ON_THE_NEW_LINE && (style.ShowSummary || style.ShowFullDescription)) { // TODO: Perhaps we should show Value: Expression for attributes that take an Angular expression, etc typeDescription.Prepend("Value: "); block.SplitAndAdd(typeDescription); } return block; }
public RichTextBlock GetElementDescription(IDeclaredElement element, DeclaredElementDescriptionStyle style, PsiLanguageType language, IPsiModule module = null) { if (!element.IsFromUnityProject()) { return(null); } var method = element as IMethod; if (method != null) { var message = myUnityApi.GetUnityMessage(method); if (message?.Description != null) { return(new RichTextBlock(message.Description)); } } var parameter = element as IParameter; var owner = parameter?.ContainingParametersOwner as IMethod; if (owner != null) { var message = myUnityApi.GetUnityMessage(owner); var messageParameter = message?.GetParameter(parameter.ShortName); if (messageParameter?.Description != null) { return(new RichTextBlock(messageParameter.Description)); } } return(null); }
private RichText TryGetDescription([NotNull] IDeclaredElement element, [NotNull] IPsiModule psiModule, [NotNull] PsiLanguageType languageType, [NotNull] DeclaredElementDescriptionStyle style) { RichTextBlock description = _declaredElementDescriptionPresenter.GetDeclaredElementDescription(element, style, languageType, psiModule); return(description != null ? description.RichText : null); }
public bool?IsElementObsolete(IDeclaredElement element, out RichTextBlock obsoleteDescription, DeclaredElementDescriptionStyle style) { obsoleteDescription = null; var obsoletable = element as IObsoletable; if (obsoletable == null) { return(null); } if (!obsoletable.Obsolete && !obsoletable.NonStandard) { return(false); } obsoleteDescription = new RichTextBlock(); var richText = new RichText(); if (obsoletable.Obsolete) { richText.Append("Obsolete!", new TextStyle(FontStyle.Bold)); } else if (obsoletable.NonStandard) { richText.Append("Non-standard!", new TextStyle(FontStyle.Bold)); } obsoleteDescription.Add(richText); return(true); }
private RichText TryGetDescription( [NotNull] IDeclaredElement element, [NotNull] IPsiModule psiModule, [NotNull] PsiLanguageType languageType, [NotNull] DeclaredElementDescriptionStyle style) => _declaredElementDescriptionPresenter .GetDeclaredElementDescription(element, style, languageType, psiModule) ?.RichText;
// This is the ReSharper 8.1 version public RichTextBlock GetElementDescription(IDeclaredElement element, DeclaredElementDescriptionStyle style, PsiLanguageType language, IPsiModule module) { var attribute = element as IHtmlAttributeDeclaredElement; if (attribute == null) { return(null); } var attributeDescription = GetAttributeDescription(attribute.ShortName); var block = new RichTextBlock(); var typeDescription = new RichText(htmlDescriptionsCache.GetDescriptionForHtmlValueType(attribute.ValueType)); if (style.IntendedDescriptionPlacement == DescriptionPlacement.AFTER_NAME && (style.ShowSummary || style.ShowFullDescription)) { block.SplitAndAdd(typeDescription); } string description = null; if (style.ShowSummary && attributeDescription != null) { description = attributeDescription.Summary; } else if (style.ShowFullDescription && attributeDescription != null) { description = attributeDescription.Description; } if (!string.IsNullOrEmpty(description)) { block.SplitAndAdd(description); } if (style.IntendedDescriptionPlacement == DescriptionPlacement.ON_THE_NEW_LINE && (style.ShowSummary || style.ShowFullDescription)) { // TODO: Perhaps we should show Value: Expression for attributes that take an Angular expression, etc typeDescription.Prepend("Value: "); block.SplitAndAdd(typeDescription); } return(block); }
public bool? IsElementObsolete(IDeclaredElement element, out RichTextBlock obsoleteDescription, DeclaredElementDescriptionStyle style) { obsoleteDescription = null; return false; }
public bool? IsElementObsolete(IDeclaredElement element, out RichTextBlock obsoleteDescription, DeclaredElementDescriptionStyle style) { obsoleteDescription = null; var obsoletable = element as IObsoletable; if (obsoletable == null) return null; if (!obsoletable.Obsolete && !obsoletable.NonStandard) return false; obsoleteDescription = new RichTextBlock(); var richText = new RichText(); if (obsoletable.Obsolete) richText.Append("Obsolete!", new TextStyle(FontStyle.Bold)); else if (obsoletable.NonStandard) richText.Append("Non-standard!", new TextStyle(FontStyle.Bold)); obsoleteDescription.Add(richText); return true; }
// This is the ReSharper 8.2 version. 'context' has a default value of null public RichTextBlock GetElementDescription(IDeclaredElement element, DeclaredElementDescriptionStyle style, PsiLanguageType language, IPsiModule module, IModuleReferenceResolveContext context) { return GetElementDescription(element, style, language, module); }
public bool?IsElementObsolete(IDeclaredElement element, out RichTextBlock obsoleteDescription, DeclaredElementDescriptionStyle style) { obsoleteDescription = null; return(false); }
public RichTextBlock GetElementDescription(IDeclaredElement element, DeclaredElementDescriptionStyle style, PsiLanguageType language, IPsiModule module = null) { if (!element.IsFromUnityProject()) { return(null); } var method = element as IMethod; if (method != null) { var eventFunction = myUnityApi.GetUnityEventFunction(method); if (eventFunction?.Description != null) { var richTextBlock = new RichTextBlock(eventFunction.Description); if (eventFunction.Coroutine) { richTextBlock.Add("This function can be a coroutine."); } if (eventFunction.Undocumented) { richTextBlock.Add("This function is undocumented."); } return(richTextBlock); } } var parameter = element as IParameter; var owner = parameter?.ContainingParametersOwner as IMethod; if (owner != null) { EventFunctionMatch match; var eventFunction = myUnityApi.GetUnityEventFunction(owner, out match); if (eventFunction == null || (match & EventFunctionMatch.MatchingSignature) == 0) { return(null); } var eventFunctionParameter = eventFunction.GetParameter(parameter.ShortName); if (eventFunctionParameter == null) { var parameters = parameter.ContainingParametersOwner.Parameters; for (var i = 0; i < parameters.Count; i++) { if (Equals(parameters[i], parameter)) { eventFunctionParameter = eventFunction.Parameters[i]; break; } } } if (eventFunctionParameter?.Description != null) { var richTextBlock = new RichTextBlock(eventFunctionParameter.Description); if (eventFunctionParameter.IsOptional) { if (string.IsNullOrEmpty(eventFunctionParameter.Justification)) { richTextBlock.Add("This parameter is optional and can be removed if not used."); } else { richTextBlock.Add($"This parameter is optional: {eventFunctionParameter.Justification}"); } } return(richTextBlock); } } return(null); }
// This is the ReSharper 8.2 version. 'context' has a default value of null public RichTextBlock GetElementDescription(IDeclaredElement element, DeclaredElementDescriptionStyle style, PsiLanguageType language, IPsiModule module, IModuleReferenceResolveContext context) { return(GetElementDescription(element, style, language, module)); }