private void ActivateEntries(int position) { if (_entries == null) { return; } int currentModuleIndex; _dropDownBar.GetCurrentSelection(ModuleComboBoxId, out currentModuleIndex); ModuleEntry newModule = _entries.LocateModule(position); Debug.Assert(newModule != null); MethodEntry newMethod = newModule.LocateMethod(position); int newMethodIndex = newMethod != null ? newMethod.Index : -1; if (newModule.Index != currentModuleIndex) { _dropDownBar.SetCurrentSelection(ModuleComboBoxId, newModule.Index); _dropDownBar.RefreshCombo(MethodComboBoxId, newMethodIndex); } else { int currentMethodIndex; _dropDownBar.GetCurrentSelection(MethodComboBoxId, out currentMethodIndex); if (newMethodIndex != currentMethodIndex) { _dropDownBar.SetCurrentSelection(MethodComboBoxId, newMethodIndex); } } }
private void EnterModule(string /*!*/ name, Node /*!*/ definition, bool isExpressionBound, bool isSingleton) { string displayName = name; int count; if (_definitions.TryGetValue(name, out count)) { count++; displayName = name + " (" + count + ")"; } else { count = 1; } _definitions[name] = count; var entry = new ModuleEntry(displayName, name, definition, isExpressionBound, isSingleton); _entries.Add(entry); _outerModules.Peek().AddNested(entry); _outerName.Add(name); _outerModules.Push(entry); // add a boundary for method nesting: _outerMethods.Push(null); }
public void AddNested(ModuleEntry /*!*/ module) { if (_nestedModules == null) { _nestedModules = new List <ModuleEntry>(); } else { // children need to be sorted by position: Debug.Assert(_nestedModules.Last().End <= module.Start); } _nestedModules.Add(module); }
/// <summary> /// Wired to parser event for when the parser has completed parsing a new tree and we need /// to update the navigation bar with the new data. /// </summary> private void ParserOnNewParseTree(object sender, EventArgs e) { if (_dropDownBar != null) { Action callback = () => { BuildModel(); int position = _textView.Caret.Position.BufferPosition.Position; ModuleEntry newModule = _entries.LocateModule(position); MethodEntry newMethod = newModule.LocateMethod(position); _dropDownBar.RefreshCombo(ModuleComboBoxId, newModule.Index); _dropDownBar.RefreshCombo(MethodComboBoxId, newMethod != null ? newMethod.Index : -1); }; _dispatcher.BeginInvoke(callback, DispatcherPriority.Background); } }
public ModelBuilder(SourceUnitTree /*!*/ tree) { _tree = tree; var top = new ModuleEntry("<main>", "<main>", tree, false, false); _outerName = new List <string>(); _outerName.Add(null); _outerModules = new Stack <ModuleEntry>(); _outerModules.Push(top); _outerMethods = new Stack <MethodEntry>(); _definitions = new Dictionary <string, int>(); _entries = new List <ModuleEntry>(); _entries.Add(top); }
public void AddNested(ModuleEntry/*!*/ module) { if (_nestedModules == null) { _nestedModules = new List<ModuleEntry>(); } else { // children need to be sorted by position: Debug.Assert(_nestedModules.Last().End <= module.Start); } _nestedModules.Add(module); }
private void EnterModule(string/*!*/ name, Node/*!*/ definition, bool isExpressionBound, bool isSingleton) { string displayName = name; int count; if (_definitions.TryGetValue(name, out count)) { count++; displayName = name + " (" + count + ")"; } else { count = 1; } _definitions[name] = count; var entry = new ModuleEntry(displayName, name, definition, isExpressionBound, isSingleton); _entries.Add(entry); _outerModules.Peek().AddNested(entry); _outerName.Add(name); _outerModules.Push(entry); // add a boundary for method nesting: _outerMethods.Push(null); }
public ModelBuilder(SourceUnitTree/*!*/ tree) { _tree = tree; var top = new ModuleEntry("<main>", "<main>", tree, false, false); _outerName = new List<string>(); _outerName.Add(null); _outerModules = new Stack<ModuleEntry>(); _outerModules.Push(top); _outerMethods = new Stack<MethodEntry>(); _definitions = new Dictionary<string, int>(); _entries = new List<ModuleEntry>(); _entries.Add(top); }
public Model(ModuleEntry/*!*/ top, ModuleEntry[]/*!*/ moduleEntries) { _top = top; _moduleEntries = moduleEntries; }
private readonly ModuleEntry[] /*!*/ _moduleEntries; // entries for modules of the file public Model(ModuleEntry /*!*/ top, ModuleEntry[] /*!*/ moduleEntries) { _top = top; _moduleEntries = moduleEntries; }