private void ValidateInput()
        {
            string      symbolName = inputBox.Text;
            IParserData data       = _parserService.GetParserData(symbolName, Settings.Default.CaseSensitive).FirstOrDefault();

            SetInputError(data == null ? "Invalid symbol name" : string.Empty);
        }
        private void TextArea_ToolTipRequest(object sender, ToolTipRequestEventArgs e)
        {
            if (!e.InDocument)
            {
                return;
            }

            var segment = Document.GetLineSegment(e.LogicalPosition.Line);
            var word    = segment.GetWord(e.LogicalPosition.Column);

            if (word == null || string.IsNullOrEmpty(word.Word))
            {
                return;
            }

            string text = word.Word;
            string tooltip;

            try
            {
                IParserData data = _parserService.GetParserData(text, Settings.Default.CaseSensitive).FirstOrDefault();

                if (data == null)
                {
                    var address = _symbolService.SymbolTable.GetAddressFromLabel(text);
                    tooltip = address == null ? string.Empty : address.Value.ToString();
                }
                else
                {
                    tooltip = data.Description;
                }
            }
            catch (Exception)
            {
                return;
            }

            if (string.IsNullOrEmpty(tooltip))
            {
                if (_debuggerService.CurrentDebugger == null)
                {
                    return;
                }

                ushort?regValue = _debuggerService.CurrentDebugger.GetRegisterValue(text);
                if (!regValue.HasValue)
                {
                    return;
                }

                tooltip = "$" + regValue.Value.ToString("X");
            }

            e.ShowToolTip(tooltip);
        }
        public override void SetupDataProvider(string fileName, TextArea textArea)
        {
            base.SetupDataProvider(fileName, textArea);

            string word = TextEditor.GetWordBeforeCaret();

            IParserService parserService = DependencyFactory.Resolve <IParserService>();
            var            parserData    = parserService.GetParserData(word, Settings.Default.CaseSensitive).ToList();

            Data.AddRange(parserData.Select(d =>
            {
                IParserData data = d;
                while (data != null)
                {
                    string description = data.Description;
                    IMacro macro       = data as IMacro;
                    if (macro != null)
                    {
                        string argDesc = macro.Arguments.Aggregate(macro.Name + "(", (current, arg) => current + (arg + ", "));
                        if (argDesc.Length > 2)
                        {
                            argDesc = argDesc.Remove(argDesc.Length - 2);
                        }
                        argDesc += ")";
                        return(argDesc + "\n" + description);
                    }

                    if (!string.IsNullOrEmpty(data.Description))
                    {
                        return(description);
                    }

                    if (d is IDefine)
                    {
                        data = parserService.TryResolveDefine(d as IDefine, Settings.Default.CaseSensitive);
                    }
                    else
                    {
                        break;
                    }
                }

                return(null);
            })
                          .Where(d => d != null));
        }
Beispiel #4
0
        protected override void Execute()
        {
            IList <IParserData> parserData;

            if (_text.StartsWith("+") || _text.StartsWith("-") || _text == "_")
            {
                int steps = _text.Count(c => c == '+') - _text.Count(c => c == '-');
                if (steps > 0)
                {
                    steps--;
                }
                var           parserInfo     = _parserService.GetParserInfo(_fileName);
                List <ILabel> reusableLabels = parserInfo.LabelsList.Where(l => l.IsReusable).ToList();
                ILabel        currentLabel   = reusableLabels.FirstOrDefault(l => l.Location.Line >= _currentLine);
                if (currentLabel == null)
                {
                    return;
                }

                int index = reusableLabels.IndexOf(currentLabel) + steps;
                parserData = new List <IParserData> {
                    reusableLabels[index]
                };
            }
            else
            {
                parserData = _parserService.GetParserData(_text, Settings.Default.CaseSensitive).ToList();
            }

            if (parserData.Count == 1)
            {
                RunCommand(new GotoLabelAction(parserData.Single()));
            }
            else
            {
                _findResults.NewFindResults(_text, _projectService.Project.ProjectName);
                foreach (IParserData data in parserData)
                {
                    string line = _fileService.GetLine(data.Parent.SourceFile, data.Location.Line + 1);
                    _findResults.AddFindResult(data.Parent.SourceFile, data.Location.Line, line);
                }
                _findResults.DoneSearching();
                _dockingService.ShowDockPanel(_findResults);
            }
        }
        private string GetParsedLabelFromLine(bool isInclude, Match match, string line, out bool shouldEnableButton)
        {
            var    caret   = _editor.ActiveTextAreaControl.Caret;
            var    segment = _editor.Document.GetLineSegment(caret.Line);
            var    word    = segment.GetWord(caret.Column);
            string text    = word == null ? string.Empty : word.Word;

            if (word != null && !string.IsNullOrEmpty(text) && !isInclude)
            {
                IEnumerable <IParserData> parserData =
                    _parserService.GetParserData(text, Settings.Default.CaseSensitive).ToList();
                if (parserData.Any())
                {
                    shouldEnableButton = true;

                    foreach (IParserData data in parserData.Where(data => data.Name != text))
                    {
                        _fixCaseContext.Visible = true;
                        MenuItem item = new MenuItem(data.Name, fixCaseContext_Click);
                        _fixCaseContext.MenuItems.Add(item);
                    }
                }
                else
                {
                    shouldEnableButton = false;
                }
            }
            else
            {
                shouldEnableButton = false;
            }

            string gotoLabel = isInclude ? match.Groups["includeFile"].Value.Replace('"', ' ').Trim() : text;

            if (gotoLabel != "_")
            {
                return(gotoLabel);
            }

            match     = Regex.Match(line, "(?<offset>(\\+|\\-)*)_");
            gotoLabel = match.Groups["offset"].Value + gotoLabel;
            return(gotoLabel);
        }
Beispiel #6
0
        private void editorBox_MouseHover(object sender, EventArgs e)
        {
            RemoveCurrentMarker();

            if ((Control.ModifierKeys & Keys.Control) == 0)
            {
                return;
            }

            TextArea textArea = (TextArea)sender;
            var      point    = textArea.PointToClient(Control.MousePosition);
            var      location = GetWordUnderCursor(point);
            var      textWord = GetTextWordAtLocation(location);

            if (textWord == null)
            {
                return;
            }

            string      symbolName = textWord.Word;
            IParserData data       = _parserService.GetParserData(symbolName, Settings.Default.CaseSensitive).FirstOrDefault();

            if (data == null)
            {
                return;
            }

            IDocument document = textArea.Document;
            int       offset   = document.GetOffsetForLineNumber(location.Line) + textWord.Offset;

            _currentMarkerLine = location.Line;
            _currentMarker     = new TextMarker(offset, textWord.Length, TextMarkerType.Underlined, Color.Black);
            document.MarkerStrategy.AddMarker(_currentMarker);
            document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, _currentMarkerLine));
            document.CommitUpdate();
        }