Beispiel #1
0
        public void RegularSearch()
        {
            // Arrange
            var tree = new TernaryTree(Language.Swedish);
            tree.Add("abcd", "aecd");

            // Act
            var matches = tree.Matches("aecd");

            // Assert
            Assert.AreEqual(1, matches.Count);
        }
Beispiel #2
0
        public void VowelsSearch()
        {
            // Arrange
            var tree = new TernaryTree(Language.Swedish);
            tree.Add("abcd", "ebcd", "tbcd", "ubcd");

            // Act
            var matches = tree.Matches("@bcd");

            // Assert
            Assert.AreEqual(3, matches.Count);
        }
Beispiel #3
0
        public void ConsonantsSearch()
        {
            // Arrange
            var tree = new TernaryTree(Language.Swedish);
            tree.Add("abeg", "abhg", "abfg", "abug", "abtg");

            // Act
            var matches = tree.Matches("ab#g");

            // Assert
            Assert.AreEqual(3, matches.Count);
        }
        public IList <Declaration> FindCompletions(object result, int line, int col)
        {
            CompletionContext completionContext = result as CompletionContext;

            if (completionContext == null)
            {
                return(new List <Babel.Declaration>());
            }

            List <Declaration> declarations = null;

            switch (completionContext.TokenToComplete)
            {
            case (int)Tokens.TABLENAME:
            case (int)Tokens.FUNCTION:
            default:
                // Both Function names, Table names and KEYWORDS are IDs hence should consider
                if (this._bismInfoPerovider != null && this._bismInfoPerovider.IsDaxFunctionInformationAvailable())
                {
                    declarations = new List <Declaration>();
                    declarations.AddRange(this._bismInfoPerovider.GetTableDeclarations());
                    declarations.AddRange(this._bismInfoPerovider.GetTableMemberDeclarations(null));
                    declarations.AddRange(this._bismInfoPerovider.GetDaxFunctionDeclarations());

                    // Add keyword declarations
                    DaxKeywords keywords = new DaxKeywords();
                    foreach (var keywordDeclaration in keywords.GetDeclarations())
                    {
                        declarations.Add(keywordDeclaration);
                    }
                }
                else
                {
                    // Get the declarations from static tree
                    return(_declarationsTree.Matches(string.Empty));
                }
                break;

            case (int)Tokens.PARTIALTABLENAME:
                // We have incomplete table name starting with a single quote, no function/keyword should be considered
                if (this._bismInfoPerovider != null)
                {
                    declarations = this._bismInfoPerovider.GetTableDeclarations();
                }
                break;

            case (int)Tokens.PARTIALCOLUMNNAME:
            case (int)Tokens.COLUMNNAME:
                // We have incomplete column/measure name starting with a square bracket
                if (this._bismInfoPerovider != null)
                {
                    declarations = this._bismInfoPerovider.GetTableMemberDeclarations(completionContext.ParentTokenName);
                }
                break;
            }

            if (declarations != null)
            {
                declarations.Sort(delegate(Declaration a, Declaration b) { return(a.DisplayText.CompareTo(b.DisplayText)); });
            }

            return(declarations);
        }