protected void VerifyNavigateToResultItem(
            NavigateToItem result, string name, string displayMarkup,
            MatchKind matchKind, string navigateToItemKind,
            string additionalInfo = null)
        {
            // Verify symbol information
            Assert.Equal(name, result.Name);
            Assert.Equal(matchKind, result.MatchKind);
            Assert.Equal(this.Language, result.Language);
            Assert.Equal(navigateToItemKind, result.Kind);

            MarkupTestFile.GetSpans(displayMarkup, out displayMarkup,
                                    out ImmutableArray <TextSpan> expectedDisplayNameSpans);

            var itemDisplay = (AbstractNavigateToItemDisplay)result.DisplayFactory.CreateItemDisplay(result);

            Assert.Equal(displayMarkup, itemDisplay.Name);
            Assert.Equal <TextSpan>(
                expectedDisplayNameSpans,
                itemDisplay.GetNameMatchRuns("").Select(s => s.ToTextSpan()).ToImmutableArray());

            if (additionalInfo != null)
            {
                Assert.Equal(additionalInfo, itemDisplay.AdditionalInformation);
            }

            // Make sure to fetch the glyph
            var unused = itemDisplay.Glyph;

            _glyphServiceMock.Verify();
        }
示例#2
0
 public Method(Type parent, string name, MatchKind match, MethodAction?action = null)
 {
     Parent = parent;
     Name   = name;
     Match  = match;
     Action = action;
 }
		public FilepathTextMatchFilter(ObjectListView olv, string text, MatchKind match) :
			base(olv, text, match, StringComparison.CurrentCultureIgnoreCase) {

			this.Columns = new OLVColumn[]{
				(OLVColumn)olv.Columns[1]
			};
		}
示例#4
0
 protected TagMatchCondition(IDeserializer deserializer)
     : base(deserializer)
 {
     MatchScopes  = deserializer.GetValue <TagScope>(nameof(MatchScopes));
     MatchKey     = deserializer.GetValue <string>(nameof(MatchKey));
     KeyMatchKind = deserializer.GetValue <MatchKind>(nameof(KeyMatchKind));
 }
示例#5
0
    public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex) {
      // If we are the last operation, don't match
      if (operatorIndex == operators.Count - 1)
        return -1;

      // If we reach the end of the "path", or we are not on a path separator, don't match
      if (pathIndex == path.Length || !FileNameMatching.IsPathSeparator(path[pathIndex]))
        return -1;

      pathIndex++;

      while (pathIndex < path.Length) {
        var result = Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex);
        if (result == path.Length)
          return result;

        // Look for next path separator in path
        var nextPathIndex = path.IndexOf(Path.DirectorySeparatorChar, pathIndex, path.Length - pathIndex);
        if (nextPathIndex < 0)
          break;

        pathIndex = nextPathIndex + 1;
      }

      return -1;
    }
 public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex)
 {
     var result = Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex);
       if (kind == MatchKind.File && result == path.Length)
     return -1;
       return result;
 }
示例#7
0
        public static bool IsMatch(string test, string match, MatchKind matchKind, bool isCaseSensitive)
        {
            var compareInfo = CultureInfo.CurrentCulture.CompareInfo;
            var options     = isCaseSensitive ? CompareOptions.None : CompareOptions.IgnoreCase;

            switch (matchKind)
            {
            case MatchKind.Exact:
                return(compareInfo.Compare(test, match, options) == 0);

            case MatchKind.Contains:
                return(compareInfo.IndexOf(test, match, options) != -1);

            case MatchKind.Prefix:
                return(compareInfo.IsPrefix(test, match, options));

            case MatchKind.Suffix:
                return(compareInfo.IsSuffix(test, match, options));

            case MatchKind.Regex:
            {
                var regex = new Regex(match, isCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase);
                return(regex.IsMatch(test));
            }

            default:
                throw new NotImplementedException($"Unhandled MatchKind: {matchKind}");
            }
        }
示例#8
0
        internal void VerifyNavigateToResultItem(
            NavigateToItem result, string name, string displayMarkup,
            MatchKind matchKind, string navigateToItemKind,
            Glyph glyph, string additionalInfo = null)
        {
            // Verify symbol information
            Assert.Equal(name, result.Name);
            Assert.Equal(matchKind, result.MatchKind);
            Assert.Equal(this.Language, result.Language);
            Assert.Equal(navigateToItemKind, result.Kind);

            MarkupTestFile.GetSpans(displayMarkup, out displayMarkup,
                                    out ImmutableArray <TextSpan> expectedDisplayNameSpans);

            var itemDisplay = (NavigateToItemDisplay)result.DisplayFactory.CreateItemDisplay(result);

            Assert.Equal(itemDisplay.GlyphMoniker, glyph.GetImageMoniker());

            Assert.Equal(displayMarkup, itemDisplay.Name);
            Assert.Equal <TextSpan>(
                expectedDisplayNameSpans,
                itemDisplay.GetNameMatchRuns("").Select(s => s.ToTextSpan()).ToImmutableArray());

            if (additionalInfo != null)
            {
                Assert.Equal(additionalInfo, itemDisplay.AdditionalInformation);
            }
        }
示例#9
0
        private void VerifyNavigateToResultItem(NavigateToItem result, string name, MatchKind matchKind, string navigateToItemKind,
                                                string displayName = " ", string additionalInfo = " ")
        {
            string itemDisplayName;

            // Verify symbol information
            Assert.Equal(name, result.Name);
            Assert.Equal(matchKind, result.MatchKind);
            Assert.Equal("csharp", result.Language);
            Assert.Equal(navigateToItemKind, result.Kind);

            // Verify display
            var itemDisplay = result.DisplayFactory.CreateItemDisplay(result);

            itemDisplayName = string.IsNullOrWhiteSpace(displayName) ? name : displayName;
            Assert.Equal(itemDisplayName, itemDisplay.Name);

            if (!string.IsNullOrWhiteSpace(additionalInfo))
            {
                Assert.Equal(additionalInfo, itemDisplay.AdditionalInformation);
            }

            // Make sure to fetch the glyph
            var unused = itemDisplay.Glyph;

            _glyphServiceMock.Verify();
        }
示例#10
0
 public FilepathTextMatchFilter(ObjectListView olv, string text, MatchKind match) :
     base(olv, text, match, StringComparison.CurrentCultureIgnoreCase)
 {
     this.Columns = new OLVColumn[] {
         (OLVColumn)olv.Columns[1]
     };
 }
            public SearchResult(Document document, DeclaredSymbolInfo declaredSymbolInfo, string kind, MatchKind matchKind, bool isCaseSensitive, INavigableItem navigableItem)
            {
                _document = document;
                _declaredSymbolInfo = declaredSymbolInfo;
                Kind = kind;
                MatchKind = matchKind;
                IsCaseSensitive = isCaseSensitive;
                NavigableItem = navigableItem;
                SecondarySort = ConstructSecondarySortString(declaredSymbolInfo);

                var declaredNavigableItem = navigableItem as NavigableItemFactory.DeclaredSymbolNavigableItem;
                Debug.Assert(declaredNavigableItem != null);

                _lazySummary = new Lazy<string>(() => declaredNavigableItem.Symbol?.GetDocumentationComment()?.SummaryText);
                _lazyAdditionalInfo = new Lazy<string>(() =>
                {
                    switch (declaredSymbolInfo.Kind)
                    {
                        case DeclaredSymbolInfoKind.Class:
                        case DeclaredSymbolInfoKind.Enum:
                        case DeclaredSymbolInfoKind.Interface:
                        case DeclaredSymbolInfoKind.Module:
                        case DeclaredSymbolInfoKind.Struct:
                            return EditorFeaturesResources.Project + document.Project.Name;
                        default:
                            return EditorFeaturesResources.Type + declaredSymbolInfo.ContainerDisplayName;
                    }
                });
            }
        private IEnumerable<NavigateToItem> FilterResults(
            string projectName,
            IEnumerable<AP.Completion> completions,
            IEnumerable<Tuple<FuzzyStringMatcher, string, MatchKind>> matchers
        ) {
            foreach (var c in completions) {
                MatchKind matchKind = MatchKind.None;
                foreach (var m in matchers) {
                    if (m.Item1.IsCandidateMatch(c.name, m.Item2)) {
                        matchKind = m.Item3;
                        break;
                    }
                }
                if (matchKind == MatchKind.None) {
                    continue;
                }

                var itemTag = new ItemTag {
                    Site = _serviceProvider,
                    Completion = c,
                    GlyphService = _glyphService,
                    ProjectName = projectName
                };

                yield return new NavigateToItem(
                    c.name,
                    c.memberType.ToString(),
                    "Python",
                    "",
                    itemTag,
                    matchKind,
                    PythonNavigateToItemDisplayFactory.Instance
                );
            }
        }
示例#13
0
            public SearchResult(Document document, DeclaredSymbolInfo declaredSymbolInfo, string kind, MatchKind matchKind, bool isCaseSensitive, INavigableItem navigableItem)
            {
                _document           = document;
                _declaredSymbolInfo = declaredSymbolInfo;
                Kind            = kind;
                MatchKind       = matchKind;
                IsCaseSensitive = isCaseSensitive;
                NavigableItem   = navigableItem;
                SecondarySort   = ConstructSecondarySortString(declaredSymbolInfo);

                var declaredNavigableItem = navigableItem as NavigableItemFactory.DeclaredSymbolNavigableItem;

                Debug.Assert(declaredNavigableItem != null);

                _lazySummary        = new Lazy <string>(() => declaredNavigableItem.Symbol?.GetDocumentationComment()?.SummaryText);
                _lazyAdditionalInfo = new Lazy <string>(() =>
                {
                    switch (declaredSymbolInfo.Kind)
                    {
                    case DeclaredSymbolInfoKind.Class:
                    case DeclaredSymbolInfoKind.Enum:
                    case DeclaredSymbolInfoKind.Interface:
                    case DeclaredSymbolInfoKind.Module:
                    case DeclaredSymbolInfoKind.Struct:
                        return(EditorFeaturesResources.Project + document.Project.Name);

                    default:
                        return(EditorFeaturesResources.Type + declaredSymbolInfo.ContainerDisplayName);
                    }
                });
            }
示例#14
0
        public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex)
        {
            // Heuristic: If last operator, there is a full match (since "*" at the
            // end matches everything)
            if (operatorIndex == operators.Count - 1)
            {
                if (path.IndexOf(Path.DirectorySeparatorChar, pathIndex) < 0)
                {
                    return(path.Length);
                }
                return(-1);
            }

            // Heuristic for "*[a-z]+":
            // * if we are matching a file name and
            // * if there are not path separators after "pathIndex" and
            // * if the only operator after us is "OpText"
            // * then we only need to check that path end with the text.
            if (kind == MatchKind.File)
            {
                if (path.IndexOf(Path.DirectorySeparatorChar, pathIndex) < 0)
                {
                    if (operatorIndex + 1 == operators.Count - 1)
                    {
                        var opText = operators[operatorIndex + 1] as OpText;
                        if (opText != null)
                        {
                            if (comparer.EndsWith(path, opText.Text))
                            {
                                var remaining = path.Length - pathIndex;
                                if (remaining >= opText.Text.Length)
                                {
                                    return(path.Length);
                                }
                            }
                            return(-1);
                        }
                    }
                }
            }

            // Full "*" semantics: any character except "/"
            for (var i = pathIndex; i < path.Length; i++)
            {
                // If we reach "/", move on to next operator
                if (FileNameMatching.IsPathSeparator(path[i]))
                {
                    return(Match(kind, comparer, operators, operatorIndex + 1, path, i));
                }

                var result = Match(kind, comparer, operators, operatorIndex + 1, path, i);
                if (result == path.Length)
                {
                    return(result);
                }
            }

            return(-1);
        }
示例#15
0
 public Type(Type parent, string name, string fullName, MatchKind match, TypeAction?action = null)
 {
     Parent   = parent;
     Name     = name;
     FullName = fullName;
     Match    = match;
     Action   = action;
 }
示例#16
0
 private void radbtnRegex_Click(object sender, EventArgs e)
 {
     if (this._kind != MatchKind.Regex)
     {
         this._kind = MatchKind.Regex;
         this.TimedFilter(this.ListView, this.tbFind.Text);
     }
 }
示例#17
0
 public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex)
 {
     if (pathIndex < path.Length && path[pathIndex] == Path.DirectorySeparatorChar)
     {
         return(Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex + 1));
     }
     return(-1);
 }
示例#18
0
        public void RemoveTags(string key, MatchKind keyMatchKind)
        {
            var tagKeys = string.Join(", ", m_tags.Where(x => MatchKindUtility.IsMatch(x.Key, key, keyMatchKind, false)).Select(x => x.Key));

            Log.Info($"Removing tag from {Owner.RenderForLog()}: '{tagKeys}'.");

            m_tags.RemoveAll(x => MatchKindUtility.IsMatch(x.Key, key, keyMatchKind, false));
        }
示例#19
0
 private bool PrePassWontMatch(MatchKind kind, string path, IPathComparer comparer) {
   // Note: Use a "for" loop to avoid allocation with "Any"
   for (var index = 0; index < _prePassOperators.Length; index++) {
     if (_prePassOperators[index].PrePassWontMatch(kind, path, comparer))
       return true;
   }
   return false;
 }
示例#20
0
 /// <summary>
 /// Create a TextFilter
 /// </summary>
 /// <param name="olv"></param>
 /// <param name="text"></param>
 /// <param name="columns"></param>
 /// <param name="matchKind"></param>
 /// <param name="comparison"></param>
 public TextMatchFilter(ObjectListView olv, string text, OLVColumn[] columns, MatchKind matchKind, StringComparison comparison)
 {
     this.ListView         = olv;
     this.Text             = text;
     this.Match            = matchKind;
     this.StringComparison = comparison;
     this.Columns          = columns;
 }
示例#21
0
        public MatchInfo(string name, string?value, MatchKind kind)
        {
            _ = string.IsNullOrWhiteSpace(name) ? throw new ArgumentException($"{nameof(name)} should not be null or empty") : false;

            Name  = name;
            Value = value;
            Kind  = kind;
        }
示例#22
0
    public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex) {
      var len = _text.Length;

      if (comparer.Compare(_text, 0, path, pathIndex, len) != 0)
        return -1;

      return Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex + len);
    }
 public CopyTagsEffect(string tagKey, MatchKind tagKeyMatchKind, TagScope tagScope, ConditionBase condition, string newTagKey, KeyConflictResolutionKind conflictResolution, EffectTarget target)
     : base(condition, target)
 {
     TagKey             = tagKey;
     TagKeyMatchKind    = tagKeyMatchKind;
     TagScope           = tagScope;
     NewTagKey          = newTagKey;
     ConflictResolution = conflictResolution;
 }
示例#24
0
 private CopyTagsEffectViewModel(string tagKey, MatchKind tagKeyMatchKind, TagScope tagScope, string newTagKey, KeyConflictResolutionKind conflictResolution, ConditionViewModelBase condition, EffectTarget target)
     : base(condition, target)
 {
     m_tagKey             = tagKey;
     m_tagKeyMatchKind    = tagKeyMatchKind;
     m_tagScope           = tagScope;
     m_newTagKey          = newTagKey;
     m_conflictResolution = conflictResolution;
 }
示例#25
0
        public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex)
        {
            var result = Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex);

            if (kind == MatchKind.File && result == path.Length)
            {
                return(-1);
            }
            return(result);
        }
示例#26
0
        public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex)
        {
            var len = _text.Length;

            if (String.Compare(_text, 0, path, pathIndex, len, comparer.Comparison) != 0)
            {
                return(-1);
            }

            return(Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex + len));
        }
示例#27
0
 private bool PrePassWontMatch(MatchKind kind, string path, IPathComparer comparer)
 {
     // Note: Use a "for" loop to avoid allocation with "Any"
     for (var index = 0; index < _prePassOperators.Length; index++)
     {
         if (_prePassOperators[index].PrePassWontMatch(kind, path, comparer))
         {
             return(true);
         }
     }
     return(false);
 }
示例#28
0
    /// <summary>
    /// Returns -1 if "path" does not conform to the pattern defined by "operators"
    /// Returns the index of the first character "path" which does not match the pattern.
    /// This means that if "index" == "path.Length", the whole path matches the pattern.
    /// </summary>
    public static int Match(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex) {
      if (operatorIndex > operators.Count)
        throw new ArgumentException("operator index outside of bounds.", "operatorIndex");

      if (pathIndex > path.Length)
        throw new ArgumentException("path index outside of bounds.", "pathIndex");

      // If we reach past the last operator, it means "we matched until this point".
      if (operatorIndex == operators.Count)
        return pathIndex;

      return operators[operatorIndex].MatchWorker(kind, comparer, operators, operatorIndex, path, pathIndex);
    }
示例#29
0
    public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex) {
      while (pathIndex < path.Length) {
        var result = Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex);
        if (result >= 0)
          return result;

        // Look for next path separator in path
        var nextPathIndex = path.IndexOf(Path.DirectorySeparatorChar, pathIndex, path.Length - pathIndex);
        if (nextPathIndex < 0)
          break;
        pathIndex = nextPathIndex + 1;
      }

      return -1;
    }
示例#30
0
        protected static void SetName(XElement element, string name, MatchKind match)
        {
            switch (match)
            {
            case MatchKind.Substring:
                element.SetAttributeValue("substring", name);
                break;

            case MatchKind.FullName:
                element.SetAttributeValue("fullname", name);
                break;

            default:
                element.SetAttributeValue("name", name);
                break;
            }
        }
示例#31
0
    public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex) {
      // Heuristic: If last operator, there is a full match (since "*" at the
      // end matches everything)
      if (operatorIndex == operators.Count - 1) {
        if (path.IndexOf(Path.DirectorySeparatorChar, pathIndex) < 0)
          return path.Length;
        return -1;
      }

      // Heuristic for "*[a-z]+":
      // * if we are matching a file name and
      // * if there are not path separators after "pathIndex" and
      // * if the only operator after us is "OpText"
      // * then we only need to check that path end with the text.
      if (kind == MatchKind.File) {
        if (path.IndexOf(Path.DirectorySeparatorChar, pathIndex) < 0) {
          if (operatorIndex + 1 == operators.Count - 1) {
            var opText = operators[operatorIndex + 1] as OpText;
            if (opText != null) {
              if (comparer.EndsWith(path, opText.Text)) {
                var remaining = path.Length - pathIndex;
                if (remaining >= opText.Text.Length)
                  return path.Length;
              }
              return -1;
            }
          }
        }
      }

      // Full "*" semantics: any character except "/"
      for (var i = pathIndex; i < path.Length; i++) {
        // If we reach "/", move on to next operator
        if (FileNameMatching.IsPathSeparator(path[i]))
          return Match(kind, comparer, operators, operatorIndex + 1, path, i);

        var result = Match(kind, comparer, operators, operatorIndex + 1, path, i);
        if (result == path.Length)
          return result;
      }

      return -1;
    }
示例#32
0
        /// <summary>
        /// Returns -1 if "path" does not conform to the pattern defined by "operators"
        /// Returns the index of the first character "path" which does not match the pattern.
        /// This means that if "index" == "path.Length", the whole path matches the pattern.
        /// </summary>
        public static int Match(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex)
        {
            if (operatorIndex > operators.Count)
            {
                throw new ArgumentException("operator index outside of bounds.", "operatorIndex");
            }

            if (pathIndex > path.Length)
            {
                throw new ArgumentException("path index outside of bounds.", "pathIndex");
            }

            // If we reach past the last operator, it means "we matched until this point".
            if (operatorIndex == operators.Count)
            {
                return(pathIndex);
            }

            return(operators[operatorIndex].MatchWorker(kind, comparer, operators, operatorIndex, path, pathIndex));
        }
示例#33
0
        public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex)
        {
            while (pathIndex < path.Length)
            {
                var result = Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex);
                if (result >= 0)
                {
                    return(result);
                }

                // Look for next path separator in path
                var nextPathIndex = path.IndexOf(Path.DirectorySeparatorChar, pathIndex, path.Length - pathIndex);
                if (nextPathIndex < 0)
                {
                    break;
                }
                pathIndex = nextPathIndex + 1;
            }

            return(-1);
        }
示例#34
0
        public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex)
        {
            // Heuristic: If last operator, there is a full match (since "*" at the end matches everything)
              if (operatorIndex == operators.Count - 1)
            return path.Length;

              // Heuristic:
              // * if we are matching a file name
              // * if there are not path separators after "pathIndex"
              // * if the only operator after us is "OpText", and
              // * then we only need to check that path end with the text.
              if (kind == MatchKind.File) {
            if (path.IndexOf(Path.DirectorySeparatorChar, pathIndex) < 0) {
              if (operatorIndex + 1 == operators.Count - 1) {
            var opText = operators[operatorIndex + 1] as OpText;
            if (opText != null) {
              if (path.EndsWith(opText.Text, comparer.Comparison)) {
                var remaining = path.Length - pathIndex;
                if (remaining >= opText.Text.Length)
                  return path.Length;
              }
              return -1;
            }
              }
            }
              }

              // Full "*" semantics (recursive...)
              for (var i = pathIndex; i < path.Length; i++) {
            // Stop at first path separator
            if (FileNameMatching.IsPathSeparator(path[i]))
              break;

            var result = Match(kind, comparer, operators, operatorIndex + 1, path, i);
            if (result == path.Length)
              return result;
              }

              return -1;
        }
示例#35
0
        bool GetName(XPathNavigator nav, out string name, out MatchKind match)
        {
            name = GetAttribute(nav, "name");
            var fullname  = GetAttribute(nav, "fullname");
            var substring = GetAttribute(nav, "substring");

            if (fullname != null)
            {
                match = MatchKind.FullName;
                if (name != null || substring != null)
                {
                    return(false);
                }
                name = fullname;
            }
            else if (name != null)
            {
                match = MatchKind.Name;
                if (fullname != null || substring != null)
                {
                    return(false);
                }
            }
            else if (substring != null)
            {
                match = MatchKind.Substring;
                if (name != null || fullname != null)
                {
                    return(false);
                }
                name = substring;
            }
            else
            {
                match = MatchKind.Name;
                return(false);
            }

            return(true);
        }
        private static void AssertMatch(MatchKind kind, object[,] expectedResults, bool optimize)
        {
            Debug.WriteLine(string.Format("===================================================================="));
            Debug.WriteLine(string.Format("Verifying expected result for {0} entries with optimization={1}.",
                                          expectedResults.GetLength(0), optimize));
            Debug.WriteLine(string.Format("===================================================================="));
            for (var i = 0; i < expectedResults.GetLength(0); i++)
            {
                var pattern = (string)expectedResults[i, 0];
                var path    = (string)expectedResults[i, 1];
                var result  = (bool)expectedResults[i, 2];
                Debug.WriteLine(string.Format("Matching \"{0}\" pattern \"{1}\" against path \"{2}\" should return {3}.", kind,
                                              pattern, path, result));

                pattern = pattern.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
                path    = path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);

                IPathMatcher matcher;
                if (optimize)
                {
                    matcher = new AggregatePathMatcher(Enumerable.Repeat(PatternParser.ParsePattern(pattern), 1));
                }
                else
                {
                    matcher = PatternParser.ParsePattern(pattern);
                }

                if (kind == MatchKind.Directory)
                {
                    Assert.AreEqual(result, matcher.MatchDirectoryName(path, SystemPathComparer.Instance));
                }
                else
                {
                    Assert.AreEqual(result, matcher.MatchFileName(path, SystemPathComparer.Instance));
                }
            }
        }
示例#37
0
        public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList <BaseOperator> operators, int operatorIndex, string path, int pathIndex)
        {
            // If we are the last operation, don't match
            if (operatorIndex == operators.Count - 1)
            {
                return(-1);
            }

            // If we reach the end of the "path", or we are not on a path separator, don't match
            if (pathIndex == path.Length || !FileNameMatching.IsPathSeparator(path[pathIndex]))
            {
                return(-1);
            }

            pathIndex++;

            while (pathIndex < path.Length)
            {
                var result = Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex);
                if (result == path.Length)
                {
                    return(result);
                }

                // Look for next path separator in path
                var nextPathIndex = path.IndexOf(Path.DirectorySeparatorChar, pathIndex, path.Length - pathIndex);
                if (nextPathIndex < 0)
                {
                    break;
                }

                pathIndex = nextPathIndex + 1;
            }

            return(-1);
        }
示例#38
0
 public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex) {
   if (pathIndex < path.Length && path[pathIndex] == Path.DirectorySeparatorChar)
     return Match(kind, comparer, operators, operatorIndex + 1, path, pathIndex + 1);
   return -1;
 }
示例#39
0
        protected void VerifyNavigateToResultItem(NavigateToItem result, string name, MatchKind matchKind, string navigateToItemKind,
                                                  string displayName = null, string additionalInfo = null)
        {
            // Verify symbol information
            Assert.Equal(name, result.Name);
            Assert.Equal(matchKind, result.MatchKind);
            Assert.Equal(this.Language, result.Language);
            Assert.Equal(navigateToItemKind, result.Kind);

            // Verify display
            var itemDisplay = result.DisplayFactory.CreateItemDisplay(result);

            Assert.Equal(displayName ?? name, itemDisplay.Name);

            if (additionalInfo != null)
            {
                Assert.Equal(additionalInfo, itemDisplay.AdditionalInformation);
            }

            // Make sure to fetch the glyph
            var unused = itemDisplay.Glyph;

            _glyphServiceMock.Verify();
        }
 private static void AssertMatch(MatchKind kind, object[,] expectedResults)
 {
     AssertMatch(kind, expectedResults, false);
     AssertMatch(kind, expectedResults, true);
 }
示例#41
0
 public bool PrePassWontMatch(MatchKind kind, string path, IPathComparer comparer) {
   return comparer.IndexOf(path, _text, 0, path.Length) < 0;
 }
示例#42
0
 public bool PrePassWontMatch(MatchKind kind, string path, IPathComparer comparer)
 {
     return(path.IndexOf(_text, 0, path.Length, comparer.Comparison) < 0);
 }
示例#43
0
		/// <summary>
		/// Create a TextFilter
		/// </summary>
		/// <param name="olv"></param>
		/// <param name="text"></param>
		/// <param name="match"></param>
		/// <param name="comparison"></param>
		public TextMatchFilter(ObjectListView olv, string text, MatchKind match, StringComparison comparison)
			: this(olv, text, null, match, comparison) {
		}
示例#44
0
        private void VerifyNavigateToResultItem(NavigateToItem result, string name, MatchKind matchKind, string navigateToItemKind,
           string displayName = null, string additionalInfo = null)
        {
            // Verify symbol information
            Assert.Equal(name, result.Name);
            Assert.Equal(matchKind, result.MatchKind);
            Assert.Equal("csharp", result.Language);
            Assert.Equal(navigateToItemKind, result.Kind);

            // Verify display
            var itemDisplay = result.DisplayFactory.CreateItemDisplay(result);

            Assert.Equal(displayName ?? name, itemDisplay.Name);

            if (additionalInfo != null)
            {
                Assert.Equal(additionalInfo, itemDisplay.AdditionalInformation);
            }

            // Make sure to fetch the glyph
            var unused = itemDisplay.Glyph;
            _glyphServiceMock.Verify();
        }
示例#45
0
        private static void AssertMatch(MatchKind kind, object[,] expectedResults, bool optimize)
        {
            Debug.WriteLine(string.Format("===================================================================="));
              Debug.WriteLine(string.Format("Verifying expected result for {0} entries with optimization={1}.",
                                    expectedResults.GetLength(0), optimize));
              Debug.WriteLine(string.Format("===================================================================="));
              for (var i = 0; i < expectedResults.GetLength(0); i++) {
            var pattern = (string)expectedResults[i, 0];
            var path = (string)expectedResults[i, 1];
            var result = (bool)expectedResults[i, 2];
            Debug.WriteLine(string.Format("Matching \"{0}\" pattern \"{1}\" against path \"{2}\" should return {3}.", kind,
                                      pattern, path, result));

            pattern = pattern.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
            path = path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);

            IPathMatcher matcher;
            if (optimize) {
              matcher = new AggregatePathMatcher(Enumerable.Repeat(PatternParser.ParsePattern(pattern), 1));
            } else {
              matcher = PatternParser.ParsePattern(pattern);
            }

            if (kind == MatchKind.Directory)
              Assert.AreEqual(result, matcher.MatchDirectoryName(path, SystemPathComparer.Instance));
            else
              Assert.AreEqual(result, matcher.MatchFileName(path, SystemPathComparer.Instance));
              }
        }
示例#46
0
 private static void AssertMatch(MatchKind kind, object[,] expectedResults)
 {
     AssertMatch(kind, expectedResults, false);
       AssertMatch(kind, expectedResults, true);
 }
示例#47
0
		/// <summary>
		/// Create a TextFilter
		/// </summary>
		/// <param name="olv"></param>
		/// <param name="text"></param>
		/// <param name="match"></param>
		public TextMatchFilter(ObjectListView olv, string text, MatchKind match)
			: this(olv, text, null, match, StringComparison.InvariantCultureIgnoreCase) {
		}
示例#48
0
 public bool PrePassWontMatch(MatchKind kind, string path, IPathComparer comparer) {
   return true;
 }
示例#49
0
		/// <summary>
		/// Create a TextFilter
		/// </summary>
		/// <param name="olv"></param>
		/// <param name="text"></param>
		/// <param name="columns"></param>
		/// <param name="matchKind"></param>
		/// <param name="comparison"></param>
		public TextMatchFilter(ObjectListView olv, string text, OLVColumn[] columns, MatchKind matchKind, StringComparison comparison) {
			this.ListView = olv;
			this.Text = text;
			this.Match = matchKind;
			this.StringComparison = comparison;
			this.Columns = columns;
		}
示例#50
0
 public override int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex) {
   return -1;
 }
示例#51
0
 public abstract int MatchWorker(MatchKind kind, IPathComparer comparer, IList<BaseOperator> operators, int operatorIndex, string path, int pathIndex);
示例#52
0
 public bool PrePassWontMatch(MatchKind kind, string path, IPathComparer comparer)
 {
     return path.IndexOf(_text, 0, path.Length, comparer.Comparison) < 0;
 }