/// ------------------------------------------------------------------------------------
        public SearchEngine(SearchQuery query)
        {
            CurrentSearchQuery = query;

            _errors.Clear();

            try
            {
                var parser = new PatternParser(App.Project);
                SrchItemPatternGroup  = parser.Parse(query.SearchItem, EnvironmentType.Item);
                EnvBeforePatternGroup = parser.Parse(query.PrecedingEnvironment, EnvironmentType.Before);
                EnvAfterPatternGroup  = parser.Parse(query.FollowingEnvironment, EnvironmentType.After);
            }
            catch
            {
                var error = new SearchQueryValidationError(
                    string.Format(GetPatternSyntaxErrorMsg(), App.kEmptyDiamondPattern));

                _errors.Add(error);
            }

            m_srchItemStr  = query.SearchItem;
            m_envBeforeStr = query.PrecedingEnvironment;
            m_envAfterStr  = query.FollowingEnvironment;

            if (_errors != null && _errors.Count > 0)
            {
                query.Errors.AddRange(_errors);
            }
        }
        public void SearchGroup_OrGroupInAndGroup_ReturnsMatch()
        {
            int ip    = 0;
            var group = _parser.Parse("[{[+high],[-cons]}[C]]", EnvironmentType.After);

            Assert.AreEqual(CompareResultType.Match, group.SearchGroup(new[] { "d" }, ref ip));
        }
Example #3
0
        /// ------------------------------------------------------------------------------------
        public bool Parse()
        {
            if (!DoesPatternPassBasicChecks())
            {
                return(false);
            }

            _parser = new PatternParser(_project, _query);

            if (_parser.Parse())
            {
                return(true);
            }

            Errors.AddRange(_parser.Errors);
            return(false);
        }