public Highlighter(SourceViewer sourceViewer)
 {
     this.sourceViewer = sourceViewer;
     this.textBox = this.sourceViewer.TextBox;
     this.output = new StringBuilder();
     this.currentType = SyntaxType.Default;
 }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExceptionExplorerController"/> class.
        /// </summary>
        /// <param name="classTree">The class tree.</param>
        /// <param name="exceptionTree">The exception tree.</param>
        /// <param name="callStackList">The exception list.</param>
        internal ExceptionExplorerController(ClassTree classTree, ExceptionTree exceptionTree, CallStackList callStackList, SourceViewer sourceViewer)
        {
            this.History = new History();
            this.History.Changed += new EventHandler(HistoryChanged);

            this.CreateExceptionTree = (IEnumerable<ThrownException> list) => { return new ExceptionTree(); };

            this.ClassTree = classTree;
            this.ExceptionTree = exceptionTree;
            this.CallStackList = callStackList;
            this.SourceViewer = sourceViewer;

            this.ClassTree.Controller = this.ExceptionTree.Controller = this.CallStackList.Controller = this;

            this.Settings = Options.Current;

            this.ExceptionFinder = ExceptionFinder.Instance;
            this.ExceptionFinder.DocumentedExceptionsCallback = Decompiler.Extensions.XmlDocumentation.GetDocumentedExceptions;
            this.ExceptionFinder.SynchronizeInvoke = this.ClassTree;

            this.ClassTree.PathSeparator = "\a";
            this.ExceptionTree.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(ExceptionTree_BeforeSelect);
            this.ClassTree.AfterSelect += new TreeViewEventHandler(ClassTree_AfterSelect);

            this.CallStackList.MethodSelected += new EventHandler<UI.CallStackList.MethodEventArgs>(callStackList_MethodSelected);

            this.ClassTree.AllowDrop = true;
            this.ClassTree.DragEnter += new DragEventHandler(ClassTree_DragEnter);
            this.ClassTree.DragDrop += new DragEventHandler(ClassTree_DragDrop);

            this.ExceptionFinder.Settings.Changed += new EventHandler<SettingChangedEventArgs>(SettingsChangeReload);
            this.Settings.InheritedMemberFullname.Changed += new EventHandler<SettingChangedEventArgs>(SettingsChangeUpdate);
            this.Settings.MemberFullname.Changed += new EventHandler<SettingChangedEventArgs>(SettingsChangeUpdate);
            this.Settings.SeparateBaseClassItem.Changed += new EventHandler<SettingChangedEventArgs>(SettingsChangeUpdate);

            this.Settings.BulkChange += new EventHandler<EventArgs>(Settings_BulkChange);

            this.Settings.Source.Changed += new EventHandler<SettingChangedEventArgs>(Source_Changed);
            this.Settings.ShowSource.Changed += new EventHandler<SettingChangedEventArgs>(Source_Changed);

            this.UpdateSourceViewerSettings();

            // context menus
            ContextActionCallbacks callbacks = new ContextActionCallbacks(this);

            this.NodeActions = new ContextActionController();
            ContextAction[] a =
            {
                new ContextAction("Show Call") {
                    Controls = { this.CallStackList },
                    Callback = callbacks.ShowSource,
                    Predicate = (nodeInfo) =>
                    {
                        return !this.Settings.Source.AutoDecompile.Value || !this.Settings.ShowSource.Value;
                    }
                },

                new ContextAction("Load declaring assembly", ~NodeType.Assembly) {
                    Controls = { this.CallStackList, this.ClassTree },
                    Callback = callbacks.LoadAssembly,
                    Predicate = (nodeInfo) =>
                    {
                        return this.ClassTree.GetAssemblyNode(nodeInfo.AnalysisObject.GetAssembly()) == null;
                    }
                },

                new ContextAction("Show Source", ~(NodeType.Assembly | NodeType.Namespace)) {
                    Controls = { this.ClassTree },
                    Callback = callbacks.ShowSource,
                    Predicate = (nodeInfo) =>
                    {
                        return !this.Settings.Source.AutoDecompile.Value || !this.Settings.ShowSource.Value;
                    }
                },

                new ContextAction("Unload", NodeType.Assembly) {
                    Callback = callbacks.UnloadAssembly,
                    Controls = { this.ClassTree },
                },

                new ContextAction("Copy name") {
                    Callback = callbacks.CopyFullName
                }
            };

            this.NodeActions.AddRange(a);
            this.NodeActions.AddControl(this.ClassTree);
            this.NodeActions.AddControl(this.ExceptionTree);
            this.NodeActions.AddControl(this.CallStackList);
        }
            public Highlighter(SourceViewer sourceViewer, IEnumerable<HighlightItem> highlightItems)
                : this(sourceViewer)
            {
                this.highlightItems = highlightItems.ToList();

                List<int> offs = new List<int>(this.highlightItems.Count);
                this.HighlightMapping = new Dictionary<int, List<SourceCodeMapping>>(offs.Count);

                foreach (HighlightItem item in this.highlightItems)
                {
                    offs.Add(item.Offset);
                    this.HighlightMapping[item.Offset] = new List<SourceCodeMapping>();
                    this.HighlightOffsets = offs.ToArray();
                }
            }