Exemplo n.º 1
0
        private TreeViewItem CreateRelIndTreeViewItem(DkDict.RelInd relind)
        {
            var tvi = CreateStandardTvi(relind.Type == DkDict.RelIndType.Index ? _indexImg : _relationshipImg, relind.Name, relind.Prompt,
                                        new TextBox {
                Text = relind.Definition.QuickInfoTextStr
            }, true);

            tvi.Tag                   = relind;
            tvi.Expanded             += RelIndTvi_Expanded;
            tvi.MouseRightButtonDown += RelIndTvi_MouseRightButtonDown;

            var menu = new ContextMenu();

            var menuItem = new MenuItem();

            menuItem.Header = "Go To Definition";
            menuItem.Click += RelIndGoToDefinition_Click;
            menuItem.Tag    = relind;
            menu.Items.Add(menuItem);

            menuItem        = new MenuItem();
            menuItem.Header = "Find All References";
            menuItem.Click += RelIndFindAllReferences_Click;
            menuItem.Tag    = relind;
            menu.Items.Add(menuItem);

            tvi.ContextMenu = menu;

            return(tvi);
        }
Exemplo n.º 2
0
 private void CreateRelIndInfoItems(TreeViewItem item, DkDict.RelInd relind)
 {
     item.Items.Add(CreateInfoTvi("Name", relind.Name));
     if (!string.IsNullOrWhiteSpace(relind.Prompt))
     {
         item.Items.Add(CreateInfoTvi("Prompt", relind.Prompt));
     }
     if (!string.IsNullOrWhiteSpace(relind.Comment))
     {
         item.Items.Add(CreateInfoTvi("Comment", relind.Comment));
     }
     if (!string.IsNullOrWhiteSpace(relind.Description))
     {
         item.Items.Add(CreateInfoTvi("Description", relind.Description));
     }
     if (!string.IsNullOrWhiteSpace(relind.SortedColumnString))
     {
         item.Items.Add(CreateInfoTvi("Columns", relind.SortedColumnString));
     }
 }
Exemplo n.º 3
0
        private void ParseCreateIndex()
        {
            var code = Code;

            DkDict.RelInd relind = null;
            DkDict.Table  table  = null;
            string        word;

            if (code.ReadExactWholeWord("primary"))
            {
                AddToken(new KeywordToken(Scope, code.Span, "primary"));
            }
            if (code.ReadExactWholeWord("nopick"))
            {
                AddToken(new KeywordToken(Scope, code.Span, "nopick"));
            }
            if (code.ReadExactWholeWord("NOPICK"))
            {
                AddToken(new KeywordToken(Scope, code.Span, "NOPICK"));
            }

            if (!string.IsNullOrEmpty(word = code.PeekWordR()))
            {
                if ((relind = DkDict.Dict.GetRelInd(word)) != null)
                {
                    AddToken(new IdentifierToken(Scope, code.MovePeekedSpan(), word, relind.Definition));
                }
                else
                {
                    var exp = ExpressionToken.TryParse(Scope, _createIndexEndTokens);
                    if (exp != null)
                    {
                        AddToken(exp);
                    }
                }
            }
            else
            {
                var exp = ExpressionToken.TryParse(Scope, _createIndexEndTokens);
                if (exp != null)
                {
                    AddToken(exp);
                }
            }

            if (code.ReadExactWholeWord("on"))
            {
                AddToken(new KeywordToken(Scope, code.Span, "on"));

                if (!string.IsNullOrEmpty(word = code.PeekWordR()) &&
                    (table = DkDict.Dict.GetTable(word)) != null)
                {
                    AddToken(new IdentifierToken(Scope, code.MovePeekedSpan(), word, table.Definition));
                }
                else
                {
                    var exp = ExpressionToken.TryParse(Scope, _createIndexEndTokens);
                    if (exp != null)
                    {
                        AddToken(exp);
                    }
                }
            }

            while (!code.EndOfFile)
            {
                if (code.PeekExact('(') || code.PeekExact('{'))
                {
                    break;
                }

                if (!string.IsNullOrEmpty(word = code.PeekWordR()))
                {
                    if (word == "description")
                    {
                        AddToken(new KeywordToken(Scope, code.MovePeekedSpan(), "description"));
                        var exp = ExpressionToken.TryParse(Scope, _createIndexEndTokens);
                        if (exp != null)
                        {
                            AddToken(exp);
                        }
                    }
                    else if (word == "tag")
                    {
                        ParseTag(Scope, this, new KeywordToken(Scope, code.MovePeekedSpan(), "tag"), _createIndexEndTokens);
                    }
                    else
                    {
                        var exp = ExpressionToken.TryParse(Scope, _createIndexEndTokens);
                        if (exp != null)
                        {
                            AddToken(exp);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    var exp = ExpressionToken.TryParse(Scope, _createIndexEndTokens);
                    if (exp != null)
                    {
                        AddToken(exp);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            if (code.ReadExact('(') || code.ReadExact('{'))
            {
                var brackets = new BracketsToken(Scope);
                brackets.AddOpen(code.Span);
                AddToken(brackets);

                DkDict.Column field = null;

                while (!code.EndOfFile)
                {
                    if (code.ReadExact(')') || code.ReadExact('}'))
                    {
                        brackets.AddClose(code.Span);
                        break;
                    }

                    if (code.ReadExact(','))
                    {
                        brackets.AddToken(new DelimiterToken(Scope, code.Span));
                    }

                    if (table != null &&
                        !string.IsNullOrEmpty(word = code.PeekWordR()) &&
                        (field = table.GetColumn(word)) != null)
                    {
                        brackets.AddToken(new IdentifierToken(Scope, code.MovePeekedSpan(), word, field.Definition));
                    }
                    else
                    {
                        var exp = ExpressionToken.TryParse(Scope, _createIndexColumnEndTokens);
                        if (exp != null)
                        {
                            brackets.AddToken(exp);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }