/// <summary>
    /// Returns a string containing declared element text presentation made according to this presenter settings.
    ///              This method is usefull when additional processing is required for the returned string,
    ///              e.g. as is done in the following method:
    ///              
    /// <code>
    ///              RichText Foo(IMethod method)
    ///              {
    ///                DeclaredElementPresenterMarking marking;
    ///                RichTextParameters rtp = new RichTextParameters(ourFont);
    ///                // make rich text with declared element presentation
    ///                RichText result = new RichText(ourInvocableFormatter.Format(method, out marking),rtp);
    ///                // highlight name of declared element in rich text
    ///                result.SetColors(SystemColors.HighlightText,SystemColors.Info,marking.NameRange.StartOffset,marking.NameRange.EndOffset);
    ///                return result;
    ///              }
    ///              </code>
    /// </summary>
    /// <param name="style">The style.</param>
    /// <param name="element">Contains <see cref="T:JetBrains.ReSharper.Psi.IDeclaredElement" /> to provide string presentation of.</param>
    /// <param name="substitution">The substitution.</param>
    /// <param name="marking">Returns the markup of the string with a <see cref="T:JetBrains.ReSharper.Psi.IDeclaredElement" /> presentation.</param>
    /// <returns>System.String.</returns>
    public string Format(DeclaredElementPresenterStyle style, IDeclaredElement element, ISubstitution substitution, out DeclaredElementPresenterMarking marking)
    {
      marking = new DeclaredElementPresenterMarking();

      var itemDeclaredElement = (IItemDeclaredElement)element;
      var sb = new StringBuilder();
      
      if (style.ShowEntityKind != EntityKindForm.NONE)
      {
        marking.EntityKindRange = AppendString(sb, style.ShowEntityKind == EntityKindForm.NORMAL_IN_BRACKETS ? "[Item] " : "Item ");
      }
      
      if (style.ShowName != NameStyle.NONE)
      {
        if (style.ShowNameInQuotes)
        {
          sb.Append('"');
        }

        marking.NameRange = style.ShowName == NameStyle.SHORT || style.ShowName == NameStyle.SHORT_RAW ? AppendString(sb, itemDeclaredElement.ShortName) : AppendString(sb, itemDeclaredElement.ItemName);
        if (style.ShowNameInQuotes)
        {
          sb.Append('"');
        }
      }
      
      return sb.ToString();
    }
 public string Format(DeclaredElementPresenterStyle style, IDeclaredElement element, ISubstitution substitution, out DeclaredElementPresenterMarking marking)
 {
   marking = new DeclaredElementPresenterMarking();
   var ruleDeclaration = element as IRuleDeclaration;
   if (ruleDeclaration != null)
   {
     return ruleDeclaration.RuleName.GetText();
   }
   return element.ShortName;
 }
Пример #3
0
 public string Format(DeclaredElementPresenterStyle style, IDeclaredElement element, ISubstitution substitution, out DeclaredElementPresenterMarking marking)
 {
   marking = new DeclaredElementPresenterMarking();
   var ruleDeclaration = element as IRuleDeclaration;
   if (ruleDeclaration != null)
   {
     return ruleDeclaration.RuleName.GetText();
   }
   return element.ShortName;
 }
        public string Format(DeclaredElementPresenterStyle style, IDeclaredElement element, ISubstitution substitution, out DeclaredElementPresenterMarking marking)
        {
            marking = new DeclaredElementPresenterMarking();
            var tokenDeclaration = element as ITokenDeclaration;

            if (tokenDeclaration != null)
            {
                return(tokenDeclaration.TokenName.GetText());
            }
            return(element.ShortName);
        }
 protected override string CalculateDisplayName(DeclaredElementInstance<IDeclaredElement> declaredElement,
     out DeclaredElementPresenterMarking marking)
 {
     string baseRet = base.CalculateDisplayName(declaredElement, out marking);
     ITypeElement typeElement = declaredElement.Element as ITypeElement;
     if (typeElement != null)
         return typeElement.CLRName;
     else
         return
             baseRet;
 }
Пример #6
0
        ///<param name="element">Contains <see cref="T:JetBrains.ReSharper.Psi.IDeclaredElement" /> to provide string presentation of.</param>
        ///<param name="marking">Returns the markup of the string with a <see cref="T:JetBrains.ReSharper.Psi.IDeclaredElement" /> presentation.</param>
        ///<summary>
        ///
        ///             Returns a string containing declared element text presentation made according to this presenter settings.
        ///             This method is usefull when additional processing is required for the returned string,
        ///             e.g. as is done in the following method:
        ///             
        ///<code>
        ///
        ///             RichText Foo(IMethod method)
        ///             {
        ///               DeclaredElementPresenterMarking marking;
        ///               RichTextParameters rtp = new RichTextParameters(ourFont);
        ///               // make rich text with declared element presentation
        ///               RichText result = new RichText(ourInvocableFormatter.Format(method, out marking),rtp);
        ///               // highlight name of declared element in rich text
        ///               result.SetColors(SystemColors.HighlightText,SystemColors.Info,marking.NameRange.StartOffset,marking.NameRange.EndOffset);
        ///               return result;
        ///             }
        ///             
        ///</code>
        ///
        ///</summary>
        ///
        public string Format(DeclaredElementPresenterStyle style, IDeclaredElement element, ISubstitution substitution,
            out DeclaredElementPresenterMarking marking)
        {
            DeclaredElementPresenterMarking m = new DeclaredElementPresenterMarking();

            if (style.ShowName != NameStyle.NONE)
            {
                m.NameRange = new TextRange(0, element.ShortName.Length);
            }

            marking = m;
            return element.ShortName;
        }
Пример #7
0
        public string Format(DeclaredElementPresenterStyle style, IDeclaredElement declaredElement, ISubstitution substitution, out DeclaredElementPresenterMarking marking)
        {
            if (!declaredElement.IsValid())
            throw new ArgumentException("declaredElement should be valid", "declaredElement");

              var nitraDeclaredElement = declaredElement as NitraDeclaredElement;
              if (nitraDeclaredElement == null)
            throw new ArgumentException("declaredElement should have language supported by Nitra", "declaredElement");

              var result = new StringBuilder();
              marking = new DeclaredElementPresenterMarking();

              if (style.ShowEntityKind != EntityKindForm.NONE)
              {
            string entityKind = GetEntityKindStr(nitraDeclaredElement);
            if (entityKind != "")
            {
              if (style.ShowEntityKind == EntityKindForm.NORMAL_IN_BRACKETS)
            entityKind = "(" + entityKind + ")";
              marking.EntityKindRange = AppendString(result, entityKind);
              result.Append(" ");
            }
              }

              if (style.ShowNameInQuotes)
            result.Append("\'");

              if (style.ShowName != NameStyle.NONE)
              {
            var elementName = nitraDeclaredElement.ShortName;

            if (elementName == SharedImplUtil.MISSING_DECLARATION_NAME)
              elementName = "<unknown name>";

            marking.NameRange = AppendString(result, elementName);
              }

              if (style.ShowNameInQuotes)
              {
            if (result[result.Length - 1] == '\'')
              result.Remove(result.Length - 1, 1);
            else
            {
              TrimString(result);
              result.Append("\' ");
            }
              }

              TrimString(result);
              return result.ToString();
        }
        public RichText Format(DeclaredElementPresenterStyle style, IDeclaredElement element, ISubstitution substitution,
                               out DeclaredElementPresenterMarking marking)
        {
            marking = new DeclaredElementPresenterMarking();
            if (!(element is JsonNewDeclaredElementBase))
            {
                return(null);
            }

            var result = new StringBuilder();

            if (style.ShowEntityKind != EntityKindForm.NONE)
            {
                var entityKind = GetEntityKind(element);
                if (entityKind != string.Empty)
                {
                    if (style.ShowEntityKind == EntityKindForm.NORMAL_IN_BRACKETS)
                    {
                        entityKind = "(" + entityKind + ")";
                    }
                    marking.EntityKindRange = AppendString(result, entityKind);
                    result.Append(" ");
                }
            }

            if (style.ShowNameInQuotes)
            {
                result.Append("\'");
            }

            if (style.ShowName != NameStyle.NONE)
            {
                marking.NameRange = AppendString(result, element.ShortName);
                result.Append(" ");
            }

            if (style.ShowNameInQuotes)
            {
                TrimString(result);
                result.Append("\'");
            }

            if (style.ShowConstantValue)
            {
            }

            TrimString(result);
            return(result.ToString());
        }
        public string Format(
            DeclaredElementPresenterStyle style,
            IDeclaredElement element,
            ISubstitution substitution,
            out DeclaredElementPresenterMarking marking)
        {
            marking = new DeclaredElementPresenterMarking();
            var uriIdentifier = element as IUriIdentifierDeclaredElement;
            if (uriIdentifier != null)
            {
                return uriIdentifier.GetUri();
            }

            return element.ShortName;
        }
        public string Format(
            DeclaredElementPresenterStyle style,
            IDeclaredElement element,
            ISubstitution substitution,
            out DeclaredElementPresenterMarking marking)
        {
            marking = new DeclaredElementPresenterMarking();
            var uriIdentifier = element as IUriIdentifierDeclaredElement;

            if (uriIdentifier != null)
            {
                return(uriIdentifier.GetUri());
            }

            return(element.ShortName);
        }
Пример #11
0
 protected override string CalculateDisplayName(DeclaredElementInstance<IDeclaredElement> declaredElement,
     out DeclaredElementPresenterMarking marking)
 {
     base.CalculateDisplayName(declaredElement, out marking);
     return parameterDescriptor.Name;
 }
Пример #12
0
        public string Format(DeclaredElementPresenterStyle style, IDeclaredElement declaredElement, ISubstitution substitution, out DeclaredElementPresenterMarking marking)
        {
            if (!declaredElement.IsValid())
            {
                throw new ArgumentException("declaredElement should be valid", "declaredElement");
            }

            var nitraDeclaredElement = declaredElement as NitraDeclaredElement;

            if (nitraDeclaredElement == null)
            {
                throw new ArgumentException("declaredElement should have language supported by Nitra", "declaredElement");
            }

            var result = new StringBuilder();

            marking = new DeclaredElementPresenterMarking();

            if (style.ShowEntityKind != EntityKindForm.NONE)
            {
                string entityKind = GetEntityKindStr(nitraDeclaredElement);
                if (entityKind != "")
                {
                    if (style.ShowEntityKind == EntityKindForm.NORMAL_IN_BRACKETS)
                    {
                        entityKind = "(" + entityKind + ")";
                    }
                    marking.EntityKindRange = AppendString(result, entityKind);
                    result.Append(" ");
                }
            }

            if (style.ShowNameInQuotes)
            {
                result.Append("\'");
            }

            if (style.ShowName != NameStyle.NONE)
            {
                var elementName = nitraDeclaredElement.ShortName;

                if (elementName == SharedImplUtil.MISSING_DECLARATION_NAME)
                {
                    elementName = "<unknown name>";
                }

                marking.NameRange = AppendString(result, elementName);
            }

            if (style.ShowNameInQuotes)
            {
                if (result[result.Length - 1] == '\'')
                {
                    result.Remove(result.Length - 1, 1);
                }
                else
                {
                    TrimString(result);
                    result.Append("\' ");
                }
            }

            TrimString(result);
            return(result.ToString());
        }
        public RichText Format(DeclaredElementPresenterStyle style, IDeclaredElement element, ISubstitution substitution,
                               out DeclaredElementPresenterMarking marking)
        {
            marking = new DeclaredElementPresenterMarking();
            if (!(element is IShaderLabDeclaredElement))
            {
                return(null);
            }

            var result = new StringBuilder();

            if (style.ShowEntityKind != EntityKindForm.NONE)
            {
                var entityKind = GetEntityKind(element);
                if (entityKind != string.Empty)
                {
                    if (style.ShowEntityKind == EntityKindForm.NORMAL_IN_BRACKETS)
                    {
                        entityKind = "(" + entityKind + ")";
                    }
                    marking.EntityKindRange = AppendString(result, entityKind);
                    result.Append(" ");
                }
            }

            if (style.ShowNameInQuotes)
            {
                result.Append("\'");
            }

            if (style.ShowType == TypeStyle.DEFAULT)
            {
                var typeName = GetTypeName(element);
                if (!string.IsNullOrEmpty(typeName))
                {
                    marking.TypeRange = marking.ScalarTypeRange = AppendString(result, typeName);
                    result.Append(" ");
                }
            }

            if (style.ShowName != NameStyle.NONE)
            {
                marking.NameRange = AppendString(result, element.ShortName);
                result.Append(" ");
            }

            if (style.ShowType == TypeStyle.AFTER)
            {
                var typeName = GetTypeName(element);
                if (!string.IsNullOrEmpty(typeName))
                {
                    result.Append(": ");
                    marking.TypeRange = marking.ScalarTypeRange = AppendString(result, typeName);
                    result.Append(" ");
                }
            }

            if (style.ShowNameInQuotes)
            {
                TrimString(result);
                result.Append("\'");
            }

            if (style.ShowName != NameStyle.NONE && style.ShowName != NameStyle.SHORT &&
                style.ShowName != NameStyle.SHORT_RAW)
            {
                AppendDisplayName(result, element);
            }

            if (style.ShowConstantValue)
            {
            }

            TrimString(result);
            return(result.ToString());
        }