public void FindUsesOfTest()
        {
            string text = "if='if'\r\n"+
                          "<expr>::=<Expr>'+'<add>\r\n"+
                          "<add>::=x!*<mul>if*! !<mul>\r\n"+
                          "if = 'IF'";

            var target = new GoldParsedDocument ();
            target.Parse (text);
            var enumerator = target.FindUsesOf ("<expr>").GetEnumerator();
            //should be exactly 2 uses (ignored case)
            Assert.IsTrue (enumerator.MoveNext ());
            Assert.IsTrue (enumerator.MoveNext ());
            Assert.IsFalse (enumerator.MoveNext ());

            enumerator = target.FindUsesOf ("<mul>").GetEnumerator();
            //should find none because it was in a comment
            Assert.IsFalse (enumerator.MoveNext ());
        }
示例#2
0
        void findSegmentsForRenaming(string text, int documentPosition)
        {
            var doc = new GoldParsedDocument ();
            doc.Parse (text);

            //not everything can be renamed
            var token = doc.GetTokenAt (documentPosition);

            if (tokenIsRenameable (token))
            {
                primarySegment = tokenToSegment (token);
                symbolType = TokenUtil.GetDefinitionType(token);

                //get our list of items to rename
                var renameItems = doc.FindUsesOf(token.Text);

                TextSegment segment;
                foreach (Token renameItem in renameItems)
                {
                    segment = tokenToSegment (renameItem);
                    textSegmentList.Add (segment);
                }
            }
        }