Esempio n. 1
0
            /// <summary>
            /// Find textPoint marked with '<code>'<Gen Type="InsertPoint" /></code>
            /// </summary>
            /// <returns></returns>
            /// <remarks>
            /// </remarks>
            static public GeneratedSegment FindInsertionPoint(TaggedRange range)
            {
                //insertion points are always single comment, override the writer info
                var copy = range.Clone();

                copy.SegmentType = SegmentTypes.SingleLineComment;
                return(Find(copy, TagTypes.InsertPoint).FirstOrDefault());
            }
Esempio n. 2
0
            /// <summary>
            /// Find tagged segment within GenInfo.SearchStart and GenInfo.SearchEnd
            /// </summary>
            /// <returns></returns>
            /// <remarks>
            /// Not using EditPoint.FindPattern because it can only search from startpoint to end of doc, no way to limit to selection
            /// Not using DTE Find because it has to change params of current find dialog, might screw up normal find usage
            ///  </remarks>
            static public GeneratedSegment[] FindSegments(TaggedRange searchRange)
            {
                try {
                    var regex      = _regexDict[searchRange.TagFormat][searchRange.SegmentType];
                    var searchText = searchRange.GetText();
                    var matches    = regex.Matches(searchText);
                    var segments   = new List <GeneratedSegment>();
                    foreach (var m in matches.Cast <Match>())
                    {
                        var matchRange = ConvertRegexMatchToTextRange(m, searchRange.StartPoint);
                        var segment    = new GeneratedSegment(matchRange);
                        switch (searchRange.TagFormat)
                        {
                        case TagFormat.Json:
                            var json = ExtractJson(m);
                            try {
                                JsonConvert.PopulateObject(json, segment);
                            }
                            catch (Exception e) {
                                Debug.DebugHere(e);
                                throw;
                            }
                            break;

                        case TagFormat.Xml:
                            var x = ExtractXml(m, searchRange.SegmentType);
                            PopulateSegmentWithXml(segment, x);
                            break;
                        }
                        segments.Add(segment);
                    }
                    return(segments.ToArray());
                }
                catch (Exception e) {
                    Debug.DebugHere(e);
                    throw;
                }
            }
Esempio n. 3
0
 static public IEnumerable <GeneratedSegment> Find(TaggedRange range, TagTypes tagType)
 {
     return(FindSegments(range).Where(x => x.TagType == tagType));
 }
Esempio n. 4
0
 static public GeneratedSegment[] Find(TaggedRange range, string category)
 {
     return(Find(range, TagTypes.Generated).Where(x => x.Category == category).ToArray());
 }