Beispiel #1
0
        public IEnumerable <MatchingInfo> FindMatchingInfos(IdentifierMatcher matcher, INavigationScope scope, GotoContext gotoContext, Func <bool> checkForInterrupt)
        {
            var fileMemberScope = scope as FileMemberNavigationScope;

            if (fileMemberScope == null)
            {
                return(EmptyList <MatchingInfo> .InstanceList);
            }

            var primaryMembersData = GetPrimaryMembers(fileMemberScope);

            var psiFileMembersMap = new PsiFileMembersMap();

            var result = new Collection <MatchingInfo>();

            foreach (var data in primaryMembersData)
            {
                var quickSearchTexts = GetQuickSearchTexts(data.Element);
                var matchedText      = quickSearchTexts.FirstOrDefault(tuple => matcher.Matches(tuple.A));
                if (matchedText == null)
                {
                    continue;
                }

                psiFileMembersMap.Add(matchedText.A, data);

                var matchingIndicies = matchedText.B ? matcher.MatchingIndicies(matchedText.A) : EmptyArray <IdentifierMatch> .Instance;
                result.Add(new MatchingInfo(matchedText.A, matcher.Filter == "*" ? EmptyList <IdentifierMatch> .InstanceList : matchingIndicies, matchedText.B));
            }

            gotoContext.PutData(PsiFileMembersMap.PsiFileMembersMapKey, psiFileMembersMap);
            return(result);
        }
        /*public IEnumerable<ChainedNavigationItemData> GetNextChainedScopes(
            GotoContext gotoContext, IdentifierMatcher matcher, INavigationScope containingScope, CheckForInterrupt checkCancelled)
        {
            var solution = containingScope.GetSolution();
            var cache = this.GetCache(containingScope, solution, gotoContext);

            return ChainedScopesUtil.GetNextCodeModelScope(matcher, containingScope, checkCancelled, cache, true);
        }
*/

        public IEnumerable<MatchingInfo> FindMatchingInfos(
            IdentifierMatcher matcher, INavigationScope scope, GotoContext gotoContext, Func<bool> checkCancelled)
        {
            var primaryMembersData = this.GetPrimaryMembers(scope.GetSolution());

            var fileMembersMap = new NTriplesFileMembersMap();

            var result = new Collection<MatchingInfo>();
            foreach (var data in primaryMembersData)
            {
                var quickSearchTexts = this.GetQuickSearchTexts(data.Element);
                var matchedText = quickSearchTexts.FirstOrDefault(tuple => matcher.Matches(tuple.A));
                if (matchedText == null)
                {
                    continue;
                }

                fileMembersMap.Add(matchedText.A, data);

                var matchingIndicies = matchedText.B
                                           ? matcher.MatchingIndicies(matchedText.A)
                                           : EmptyArray<IdentifierMatch>.Instance;
                result.Add(
                    new MatchingInfo(
                        matchedText.A,
                        matcher.Filter == "*"
                            ? EmptyList<IdentifierMatch>.InstanceList
                            : matchingIndicies,
                        matchedText.B));
            }

            gotoContext.PutData(NTriplesFileMembersMap.NTriplesFileMembersMapKey, fileMembersMap);
            return result;
        }
   public IEnumerable<MatchingInfo> FindMatchingInfos(IdentifierMatcher matcher, INavigationScope scope, GotoContext gotoContext,
 Func<bool> checkForInterrupt)
   {
       var indices = matcher.MatchingIndicies(matcher.Filter);
         var matchingInfo = new MatchingInfo(matcher.Filter, indices);
         yield return matchingInfo;
   }
        /*public IEnumerable<ChainedNavigationItemData> GetNextChainedScopes(
         *  GotoContext gotoContext, IdentifierMatcher matcher, INavigationScope containingScope, CheckForInterrupt checkCancelled)
         * {
         *  var solution = containingScope.GetSolution();
         *  var cache = this.GetCache(containingScope, solution, gotoContext);
         *
         *  return ChainedScopesUtil.GetNextCodeModelScope(matcher, containingScope, checkCancelled, cache, true);
         * }
         */

        public IEnumerable <MatchingInfo> FindMatchingInfos(
            IdentifierMatcher matcher, INavigationScope scope, GotoContext gotoContext, Func <bool> checkCancelled)
        {
            var primaryMembersData = this.GetPrimaryMembers(scope.GetSolution());

            var fileMembersMap = new NTriplesFileMembersMap();

            var result = new Collection <MatchingInfo>();

            foreach (var data in primaryMembersData)
            {
                var quickSearchTexts = this.GetQuickSearchTexts(data.Element);
                var matchedText      = quickSearchTexts.FirstOrDefault(tuple => matcher.Matches(tuple.A));
                if (matchedText == null)
                {
                    continue;
                }

                fileMembersMap.Add(matchedText.A, data);

                var matchingIndicies = matchedText.B
                                           ? matcher.MatchingIndicies(matchedText.A)
                                           : EmptyArray <IdentifierMatch> .Instance;
                result.Add(
                    new MatchingInfo(
                        matchedText.A,
                        matcher.Filter == "*"
                            ? EmptyList <IdentifierMatch> .InstanceList
                            : matchingIndicies,
                        matchedText.B));
            }

            gotoContext.PutData(NTriplesFileMembersMap.NTriplesFileMembersMapKey, fileMembersMap);
            return(result);
        }
 public override bool Matches(string filter, IdentifierMatcher matcher)
 {
     if (Parent.Matches(filter, matcher))
     {
         return(true);
     }
     return(matcher.Matches(FieldName));
 }
        public IEnumerable <MatchingInfo> FindMatchingInfos(IdentifierMatcher matcher, INavigationScope scope, GotoContext gotoContext,
                                                            Func <bool> checkForInterrupt)
        {
            var indices      = matcher.MatchingIndicies(matcher.Filter);
            var matchingInfo = new MatchingInfo(matcher.Filter, indices);

            yield return(matchingInfo);
        }
 public override bool Matches(string filter, IdentifierMatcher matcher)
 {
     if (myFixture.Matches(filter, matcher))
     {
         return(true);
     }
     return(matcher.Matches((myMethodName)));
 }
        public void TryMatch_InvalidIdentifiersAreGiven_ResultIsNonmatching(string input)
        {
            var matcher = new IdentifierMatcher();

            var result = matcher.TryMatch(input);

            Assert.False(result.IsMatching);
        }
 public override bool Matches(string filter, IdentifierMatcher matcher)
 {
   if (Parent.Matches(filter, matcher))
   {
     return true;
   }
   return matcher.Matches(FieldName);
 }
        public bool IsApplicable(INavigationScope scope, GotoContext gotoContext, IdentifierMatcher matcher)
        {
            // not sure why we have to explicitly do this
              if (matcher.Filter.Length == 0) return false;

              // oops: this means feature only works with open sln
              return scope is SolutionNavigationScope;
        }
        public bool IsApplicable(INavigationScope scope, GotoContext gotoContext, IdentifierMatcher matcher)
        {
            if (!(scope is SolutionNavigationScope))
            {
                return(scope is NamespaceNavigationScope);
            }

            return(true);
        }
        public bool IsApplicable(INavigationScope scope, GotoContext gotoContext, IdentifierMatcher matcher)
        {
            // not sure why we have to explicitly do this
            if (matcher.Filter.Length == 0)
            {
                return(false);
            }

            // oops: this means feature only works with open sln
            return(scope is SolutionNavigationScope);
        }
        public void TryMatch_ValidIdentifiersAreGiven_ResultHasValidProperties(string input, string expectedTokenValue, int expectedNextIndex)
        {
            var matcher = new IdentifierMatcher();

            var result = matcher.TryMatch(input);

            Assert.True(result.IsMatching);
            Assert.AreEqual(expectedTokenValue, result.Token.Value);
            Assert.AreEqual(TokenType.Identifier, result.Token.TokenType);
            Assert.AreEqual(expectedNextIndex, result.NextIndex);
        }
Beispiel #14
0
        private bool TryAddAllItemsForMatchedAbbreviation(IdentifierMatcher matcher,
                                                          HtmlCodeCompletionContext context, GroupedItemsCollector collector)
        {
            var matchedAbbreviation = GetMatchedAbbreviation(matcher);

            if (matchedAbbreviation != null)
            {
                AddAllItemsForSpecificAbbreviation(matchedAbbreviation, context, collector);
                return(true);
            }
            return(false);
        }
        [NotNull] public IEnumerable <MatchingInfo> FindMatchingInfos(
            [NotNull] IdentifierMatcher matcher, [NotNull] INavigationScope scope,
            [NotNull] GotoContext gotoContext, [NotNull] CheckForInterrupt checkCanceled)
        {
            var solution = scope.GetSolution();

            if (solution == null)
            {
                return(EmptyList <MatchingInfo> .InstanceList);
            }

            var navigationScope = scope as FileMemberNavigationScope;

            if (navigationScope != null)
            {
                var sourceFile = navigationScope.GetPrimarySourceFile();
                var consumer   = new List <IOccurence>();
                SearchInFile(matcher.Filter, sourceFile, consumer, checkCanceled);

                foreach (var occurence in consumer)
                {
                    //return new MatchingInfo(matcher.Filter, EmptyList<IdentifierMatch>.InstanceList);
                }
            }


            var filterText  = matcher.Filter;
            var occurrences = new List <IOccurence>();

            myShellLocks.AssertReadAccessAllowed();

            //if (scope.ExtendedSearchFlag == LibrariesFlag.SolutionOnly)
            //{
            //  FindByWords(filterText, solution, occurrences, gotoContext, checkCanceled);
            //}
            //else
            //{
            //  FindTextual(filterText, solution, occurrences, checkCanceled);
            //}

            if (occurrences.Count > 0)
            {
                gotoContext.PutData(GoToWordOccurrences, occurrences);
                return(new[] { new MatchingInfo(filterText, EmptyList <IdentifierMatch> .InstanceList) });
            }

            return(EmptyList <MatchingInfo> .InstanceList);
        }
Beispiel #16
0
        private bool TryAddMatchingAbbreviations(IdentifierMatcher matcher,
                                                 HtmlCodeCompletionContext context, GroupedItemsCollector collector)
        {
            if (matcher == null)
            {
                return(false);
            }

            var added = false;

            foreach (var abbreviation in Abbreviations)
            {
                if (matcher.Matches(abbreviation))
                {
                    added |= AddAbbreviation(context, collector, abbreviation);
                }
            }
            return(added);
        }
Beispiel #17
0
        public IEnumerable <MatchingInfo> FindMatchingInfos(IdentifierMatcher matcher, INavigationScope scope, CheckForInterrupt checkCancelled, GotoContext gotoContext)
        {
            var fileMemberScope = scope as FileMemberNavigationScope;

            if (fileMemberScope == null)
            {
                return(EmptyList <MatchingInfo> .InstanceList);
            }

            var primaryMembersData = GetPrimaryMembers(fileMemberScope);

            var primarySourceFile = fileMemberScope.GetPrimarySourceFile();
            ICollection <ClrFileMemberData> secondaryMembersData = new Collection <ClrFileMemberData>();

            if (scope.ExtendedSearchFlag == LibrariesFlag.SolutionAndLibraries)
            {
                var secondaryFilesGetter = fileMemberScope.GetSecondaryFilesGetter();
                secondaryMembersData = GetSecondaryMembers(primarySourceFile, secondaryFilesGetter);
            }

            var clrFileMembersMap = new ClrFileMembersMap();

            var result = new Collection <MatchingInfo>();

            foreach (var data in primaryMembersData.Concat(secondaryMembersData))
            {
                var quickSearchTexts = GetQuickSearchTexts(data.Element);
                var matchedText      = quickSearchTexts.FirstOrDefault(tuple => matcher.Matches(tuple.A));
                if (matchedText == null)
                {
                    continue;
                }

                clrFileMembersMap.Add(matchedText.A, data);

                var matchingIndicies = matchedText.B ? matcher.MatchingIndicies(matchedText.A) : EmptyArray <IdentifierMatch> .Instance;
                result.Add(new MatchingInfo(matchedText.A, matcher.Filter == "*" ? EmptyList <IdentifierMatch> .InstanceList : matchingIndicies, matchedText.B));
            }

            gotoContext.PutData(ClrFileMembersMap.ClrFileMembersMapKey, clrFileMembersMap);
            return(result);
        }
Beispiel #18
0
        private static string GetMatchedAbbreviation(IdentifierMatcher matcher)
        {
            if (matcher == null)
            {
                return(null);
            }

            foreach (var abbreviation in Abbreviations)
            {
                var matches = matcher.MatchingIndicies(abbreviation);
                if (matches != null)
                {
                    // TODO: This could match multiple? E.g. n- matches ng- and data-ng-
                    // This is relying on ordering of the Abreviations
                    // How to work out best fit? Most number of matched indices in
                    // shortest string?
                    if (matches.Last().TextIndex == abbreviation.Length - 1)
                    {
                        return(abbreviation);
                    }
                }
            }
            return(null);
        }
 public bool IsApplicable(
     [NotNull] INavigationScope scope, [NotNull] GotoContext gotoContext, [NotNull] IdentifierMatcher matcher)
 {
     return(true);
 }
    /// <summary>
    /// Finds matched items and returns a corresponing list of matchingInfos.
    ///             Controller (or some other entity that will use this provider) recieves these items, scores them, sorts 
    ///             and than invoke GetOccurences for the top scored of them.
    /// </summary>
    /// <param name="matcher">matcher to use</param><param name="scope">defines a scope to search in</param><param name="gotoContext"/><param name="checkForInterrupt"/>
    /// <returns/>
    public IEnumerable<MatchingInfo> FindMatchingInfos(IdentifierMatcher matcher, INavigationScope scope, GotoContext gotoContext, Func<bool> checkForInterrupt)
    {
      var occurrences = new List<ItemOccurence>();

      var databases = new List<DatabaseUri>();
      foreach (var project in VisualStudio.Projects.ProjectManager.Projects)
      {
        if (project.Site != null)
        {
          databases.Add(new DatabaseUri(project.Site, DatabaseName.Master));
        }
      }

      using (var fibers = this.myTaskHost.CreateBarrier(this.myLifetime, checkForInterrupt, false, false))
      {
        foreach (var databaseUri in databases)
        {
          var busy = true;
          var db = databaseUri;

          ExecuteCompleted completed = delegate(string response, ExecuteResult executeResult)
          {
            if (!DataService.HandleExecute(response, executeResult, true))
            {
              busy = false;
              return;
            }

            var r = response.ToXElement();
            if (r == null)
            {
              busy = false;
              return;
            }

            foreach (var element in r.Elements())
            {
              occurrences.Add(new ItemOccurence(ItemHeader.Parse(db, element)));
            }

            busy = false;
          };

          databaseUri.Site.DataService.ExecuteAsync("Search.Search", completed, matcher.Filter, string.Empty, string.Empty, string.Empty, string.Empty, 0);
          AppHost.DoEvents(ref busy);
        }
      }

      gotoContext.PutData(SitecoreItemOccurrences, occurrences);

      var matchingInfo = new MatchingInfo(matcher.Filter, EmptyList<IdentifierMatch>.InstanceList);
      return new[] { matchingInfo };
    }
    /// <summary>
    /// Determines whether the specified scope is applicable.
    /// </summary>
    /// <param name="scope">The scope.</param>
    /// <param name="gotoContext">The goto context.</param>
    /// <param name="matcher">The matcher.</param>
    /// <returns><c>true</c> if the specified scope is applicable; otherwise, <c>false</c>.</returns>
    public bool IsApplicable(INavigationScope scope, GotoContext gotoContext, IdentifierMatcher matcher)
    {
      if (string.IsNullOrEmpty(matcher.Filter))
      {
        return false;
      }

      if (matcher.Filter.Length < 3)
      {
        return false;
      }

      if (scope is ProjectModelNavigationScope)
      {
        return true;
      }

      if (scope is SolutionNavigationScope)
      {
        return true;
      }

      return VisualStudio.Projects.ProjectManager.Projects.Any();
    }
 private static IEnumerable<string> SuggestCategories(IUnitTestingCategoriesProvider categoriesProvider, string filter)
 {
     // using camel humps matcher that is used everywhere in ReSharper
       var matcher = new IdentifierMatcher(filter);
       return categoriesProvider.Categories.Where(matcher.Matches);
 }
Beispiel #23
0
 public override bool Matches(string filter, IdentifierMatcher matcher)
 {
     return(matcher.Matches(GetTypeClrName()));
 }
        public bool IsApplicable(INavigationScope scope, GotoContext gotoContext, IdentifierMatcher matcher)
        {
            if (!(scope is SolutionNavigationScope))
            {
                return scope is NamespaceNavigationScope;
            }

            return true;
        }
 public bool IsApplicable(INavigationScope scope, GotoContext gotoContext, IdentifierMatcher matcher)
 {
     return true;
 }
Beispiel #26
0
 public bool IsApplicable(INavigationScope scope, GotoContext gotoContext, IdentifierMatcher matcher)
 {
     return(true);
 }
 public override bool Matches(string filter, IdentifierMatcher matcher)
 {
     return false;
 }
Beispiel #28
0
 public override bool Matches(string filter, IdentifierMatcher matcher)
 {
     return(false);
 }
 [NotNull] public IEnumerable <ChainedNavigationItemData> GetNextChainedScopes(
     [NotNull] GotoContext gotoContext, [NotNull] IdentifierMatcher matcher,
     [NotNull] INavigationScope containingScope, [NotNull] CheckForInterrupt checkForInterrupt)
 {
     return(EmptyList <ChainedNavigationItemData> .InstanceList);
 }
 public override bool Matches(string filter, IdentifierMatcher matcher)
 {
   return matcher.Matches(GetTypeClrName());
 }
Beispiel #31
0
 private static int[] GetMatchingIndicies(IdentifierMatcher matcher, string abbreviation)
 {
     return(matcher.MatchingIndicies(abbreviation));
 }