コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        static List <TextRange> CheckCommentBlocks(ITextSource document)
        {
            List <TextRange> list = new List <TextRange>();

            foreach (Match m in rxCommentBlock.Matches(document.Text))
            {
                list.Add(TextRange.FromMatch(m));
            }
            return(list);
        }
コード例 #2
0
        static public List <NewFolding> GetFoldingRanges(TextDocument document, List <NewFolding> list)
        {
            if (!DetectPragmaFolding)
            {
                return(new List <NewFolding>());
            }
            Stack <Match> stack = new Stack <Match>();

            foreach (Match m in PragmaRegion.Matches(document.Text))
            {
                if (m.Groups[1].Value == "#region")
                {
                    TextRange range = TextRange.FromMatch(m);
                    int       len   = m.Groups[1].Index - m.Groups[0].Index;
                    stack.Push(m);
                }
                else
                {
                    TextRange range = TextRange.FromMatch(m);

                    Match     peeek = stack.Peek();
                    TextRange peek  = TextRange.FromMatch(peeek);
                    int       len   = peeek.Groups[1].Index - peeek.Groups[0].Index;
                    Logger.Log(MessageType.White, "GetFoldingRanges", "{0}", peek.Position);
                    peek.ShrinkRight(len);
                    Logger.Log(MessageType.White, "GetFoldingRanges", "{0}", peek.Position);

                    NewFolding nf = new NewFolding((int)peek.Position, (int)range.EndPosition);
                    nf.Name          = "#pragma";
                    nf.DefaultClosed = UsePragmaFolding;
                    if (peeek.Groups[2].Value == string.Empty)
                    {
                        nf.Name = "‘…’";
                    }
                    else
                    {
                        nf.Name = string.Format("#region “{0}”", peeek.Groups[2].Value.Trim());
                    }
                    Logger.LogG("GetFoldingRanges", "folding - {0}, {1}", nf.StartOffset, nf.EndOffset);

                    if (document.GetLineByOffset(nf.StartOffset) == document.GetLineByOffset(nf.EndOffset))
                    {
                        continue;
                    }
                    else
                    {
                        list.Add(nf);
                    }
                    stack.Pop();
                }
            }
            list.Sort(SortRange);
            //			if (list.Count >0) list.Remove(list[list.Count-1]);
            return(list);
        }
コード例 #3
0
        // The following methods are completely un-necessary.

        #region parse (depreceated)
        /// <summary>
        /// this function is now ignored.  It was the first function written in this class
        /// that was used for testing.
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        static string parse(string input)
        {
            List <string> list = new List <string>();

            list.Add("we have some text");
            foreach (Match m in input.getmatches())
            {
                list.Add(string.Concat("0: ", m.MFormat(0, MatchExtension.mformat1, ',')));
                TextRange.FromMatch(m);
            }
            return(string.Join("\r\n", list.ToArray()));
        }
コード例 #4
0
 void GetResults(TextView view, int start, int length)
 {
     CurrentResults.Clear();
     if (string.IsNullOrEmpty(textToFind))
     {
         return;
     }
     if (string.IsNullOrEmpty(view.Document.Text))
     {
         return;
     }
     foreach (Match m in Expr.Matches(view.Document.Text, start))
     {
         CurrentResults.Add(TextRange.FromMatch(m));
     }
 }
コード例 #5
0
        static public List <TextRange> GetSectionGroups(string input)
        {
            MatchCollection mc = MatchSectionGroups(input);

            if (mc == null)
            {
                return(null);
            }
            List <TextRange> list = new List <TextRange>();

            foreach (Match m in mc)
            {
                if (m.Length > 0)
                {
                    list.Add(TextRange.FromMatch(m));
                }
            }
            return(list);
        }
コード例 #6
0
        /// <returns>A text range with an index to the first word found, otherwise ‘TextRange.Empty’</returns>
        static public TextRange GetFirstWord(string input)
        {
            TextRange       tr = TextRange.Empty;
            MatchCollection mc = MatchFirstWord(input);

            if (mc == null)
            {
                return(tr);
            }
            foreach (Match ma in mc)
            {
                if (ma.Length == 0)
                {
                    continue;
                }
                else if (ma.Length > 0)
                {
                    tr = TextRange.FromMatch(ma); break;
                }
            }
            mc = null;
            return(tr);
        }
コード例 #7
0
 /// <summary>
 /// Pass #1.
 /// <para>
 /// First and foremost, this method finds all comments, and start
 /// locations for most Global Tags such as Charset, Namespace,
 /// Import, FontFace and Media however it only finds the word
 /// such as '@media' and not the block elements or tags in full;
 /// This is for Pass #2.
 /// </para>
 /// </summary>
 void ParseLevel1Pre()
 {
     // all elements other then Comment are checked agains the
     // existing list of comments.
     // none of these elements actually need to be added to different
     // lists given that we're adding the type along with the item.
     this.Defs.Comment.Clear();
     // line breaks (not used at all in this script thus far)
     // in fact they are!—before parsing begins. (see Load(Stream))
     foreach (Match m in CssDefinitions.BreakerExpr.Matches(this.textBuffer))
     {
         this.Defs.Breaker.Add(new CssFragment(TextRange.FromMatch(m))
         {
             FragmentType = CssFragmentType.Breaker
         });
     }
     foreach (Match m in CssDefinitions.CommentExpr.Matches(this.textBuffer))
     {
         this.Defs.Comment.Add(new CssFragment(TextRange.FromMatch(m))
         {
             FragmentType = CssFragmentType.CommentBlock, Tag = "Comment"
         });
     }
     // ————————————————————————————————————
     this.Defs.Charset.Clear();
     foreach (Match m in CssDefinitions.CharsetExpr.Matches(this.textBuffer))
     {
         this.AddListItem(CssFragmentType.Charset, this.Defs.Charset, TextRange.FromMatch(m));
     }
     this.Defs.Namespace.Clear();
     foreach (Match m in CssDefinitions.NamespaceExpr.Matches(this.textBuffer))
     {
         this.AddListItem(CssFragmentType.Namespace, this.Defs.Namespace, TextRange.FromMatch(m));
     }
     this.Defs.Import.Clear();
     foreach (Match m in CssDefinitions.ImportExpr.Matches(this.textBuffer))
     {
         this.AddListItem(CssFragmentType.Import, this.Defs.Import, TextRange.FromMatch(m));
     }
     this.Defs.FontFace.Clear();
     foreach (Match m in CssDefinitions.FontFaceExpr.Matches(this.textBuffer))
     {
         this.AddListItem(CssFragmentType.FontFace, this.Defs.FontFace, TextRange.FromMatch(m));
     }
     this.Defs.Keyframes.Clear();
     foreach (Match m in CssDefinitions.KeyframeExpr.Matches(this.textBuffer))
     {
         this.AddListItem(CssFragmentType.Keyframes, this.Defs.Keyframes, TextRange.FromMatch(m));
     }
     this.Defs.Media.Clear();
     foreach (Match m in CssDefinitions.MediaExpr.Matches(this.textBuffer))
     {
         this.AddListItem(CssFragmentType.Media, this.Defs.Media, TextRange.FromMatch(m));
     }
     this.Defs.Url.Clear();
     foreach (Match m in CssDefinitions.UrlExpr.Matches(this.textBuffer))
     {
         this.AddListItem(CssFragmentType.Url, this.Defs.Url, TextRange.FromMatch(m));
     }
     this.Defs.Quoted.Clear();
     foreach (Match m in CssDefinitions.QuotedStringExpr.Matches(this.textBuffer))
     {
         this.AddListItem(CssFragmentType.StringQuoted, this.Defs.Quoted, TextRange.FromMatch(m));
     }
     // this.DEFS.BlockLevel
 }