public bool Present(IMenuItemDescriptor descriptor, IOccurence occurence,
      OccurencePresentationOptions occurencePresentationOptions)
        {
            var o = ((YouTrackIssueOccurence) occurence);
              descriptor.Text = o.IssueId;
              descriptor.Text.Append(" - ");
              descriptor.Text.Append(o.IssueDescription);
              descriptor.Style = MenuItemStyle.Enabled;

              return true;
        }
Beispiel #2
0
        public bool Present(IMenuItemDescriptor descriptor, IOccurence occurence,
                            OccurencePresentationOptions occurencePresentationOptions)
        {
            var o = ((YouTrackIssueOccurence)occurence);

            descriptor.Text = o.IssueId;
            descriptor.Text.Append(" - ");
            descriptor.Text.Append(o.IssueDescription);
            descriptor.Style = MenuItemStyle.Enabled;

            return(true);
        }
    /// <summary>
    /// Presents the specified descriptor.
    /// </summary>
    /// <param name="descriptor">The descriptor.</param>
    /// <param name="occurence">The occurence.</param>
    /// <param name="occurencePresentationOptions">The occurence presentation options.</param>
    /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
    public bool Present(IMenuItemDescriptor descriptor, IOccurence occurence, OccurencePresentationOptions occurencePresentationOptions)
    {
      var itemOccurence = occurence as ItemOccurence;
      if (itemOccurence == null)
      {
        return false;
      }

      var greyTextStyle = TextStyle.FromForeColor(SystemColors.GrayText);

      var richText = new RichText(itemOccurence.ItemName, TextStyle.FromForeColor(Color.Tomato));

      if (!string.IsNullOrEmpty(itemOccurence.ParentPath))
      {
        richText.Append(string.Format(" (in {0})", itemOccurence.ParentPath), greyTextStyle);
      }

      descriptor.Text = richText;
      descriptor.Style = MenuItemStyle.Enabled;
      descriptor.ShortcutText = new RichText(itemOccurence.ItemUri.Site.Name + "/" + itemOccurence.ItemUri.DatabaseName, greyTextStyle);

      return true;
    }
            public override void VisitProjectFile(IProjectFile projectFile)
            {
                base.VisitProjectFile(projectFile);
                using (ReadLockCookie.Create())
                {
                    // Obtain document for visited project file and find all text occurences
                    IDocument document = myDocumentManager.GetOrCreateDocument(projectFile);

                    // Obtain lexer for projectFile if needed
                    ILexer lexer = null;
                    if (mySearchFlags != FindTextSearchFlags.All)
                    {
                        // Content should be provided to the following call, because sometimes lexer depends on content
                        // E.g. ASP with C# or VB script language
                        IBuffer contentBuffer = document.Buffer;
                        var     factory       = PsiProjectFileTypeCoordinator.Instance;
                        var     lexerFactory  = factory.CreateLexerFactory(mySolution, projectFile.LanguageType, contentBuffer, projectFile.ToSourceFile());
                        if (lexerFactory != null)
                        {
                            lexer = lexerFactory.CreateLexer(contentBuffer);
                            lexer.Start();
                        }
                    }

                    foreach (int offset in mySearcher.FindAll(document.Buffer))
                    {
                        // create TextualOccurence for each found text and add to collection
                        var textRange = new TextRange(offset, offset + mySearcher.Pattern.Length);

                        if (lexer != null)
                        {
                            // Fastforward lexer to found location
                            while (lexer.TokenEnd < offset)
                            {
                                lexer.Advance();
                            }
                        }

                        if (lexer != null && lexer.TokenType != null)
                        {
                            var tokentype = lexer.TokenType;
                            if ((mySearchFlags & FindTextSearchFlags.StringLiterals) == FindTextSearchFlags.None &&
                                tokentype.IsStringLiteral)
                            {
                                continue;
                            }
                            if ((mySearchFlags & FindTextSearchFlags.Comments) == FindTextSearchFlags.None && tokentype.IsComment)
                            {
                                continue;
                            }
                            if ((mySearchFlags & FindTextSearchFlags.Other) == FindTextSearchFlags.None &&
                                (!tokentype.IsComment && !tokentype.IsStringLiteral))
                            {
                                continue;
                            }
                        }
                        else
                        {
                            if ((mySearchFlags & FindTextSearchFlags.Other) == FindTextSearchFlags.None)
                            {
                                continue;
                            }
                        }
                        var options = new OccurencePresentationOptions();
                        myItems.Add(new EmptyTextualOccurence(projectFile, textRange, options));
                    }
                }
            }
      public override void VisitProjectFile(IProjectFile projectFile)
      {
        base.VisitProjectFile(projectFile);
        using (ReadLockCookie.Create())
        {
          // Obtain document for visited project file and find all text occurences
          IDocument document = myDocumentManager.GetOrCreateDocument(projectFile);

          // Obtain lexer for projectFile if needed
          ILexer lexer = null;
          if (mySearchFlags != FindTextSearchFlags.All)
          {
            // Content should be provided to the following call, because sometimes lexer depends on content
            // E.g. ASP with C# or VB script language
            IBuffer contentBuffer = document.Buffer;
            var factory = PsiProjectFileTypeCoordinator.Instance;
            var lexerFactory = factory.CreateLexerFactory(mySolution, projectFile.LanguageType, contentBuffer, projectFile.ToSourceFile());
            if (lexerFactory != null)
            {
              lexer = lexerFactory.CreateLexer(contentBuffer);
              lexer.Start();
            }
          }

          foreach (int offset in mySearcher.FindAll(document.Buffer))
          {
            // create TextualOccurence for each found text and add to collection
            var textRange = new TextRange(offset, offset + mySearcher.Pattern.Length);

            if (lexer != null)
            {
              // Fastforward lexer to found location
              while (lexer.TokenEnd < offset)
                lexer.Advance();
            }

            if (lexer != null && lexer.TokenType != null)
            {
              var tokentype = lexer.TokenType;
              if ((mySearchFlags & FindTextSearchFlags.StringLiterals) == FindTextSearchFlags.None &&
                  tokentype.IsStringLiteral)
                continue;
              if ((mySearchFlags & FindTextSearchFlags.Comments) == FindTextSearchFlags.None && tokentype.IsComment)
                continue;
              if ((mySearchFlags & FindTextSearchFlags.Other) == FindTextSearchFlags.None &&
                  (!tokentype.IsComment && !tokentype.IsStringLiteral))
                continue;
            }
            else
            {
              if ((mySearchFlags & FindTextSearchFlags.Other) == FindTextSearchFlags.None)
                continue;
            }
            var options = new OccurencePresentationOptions();
            myItems.Add(new EmptyTextualOccurence(projectFile, textRange, options));
          }
        }
      }