emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/realgud ba85207 103/140: Add realgud:js-file-line-loc-p


From: Rocky Bernstein
Subject: [elpa] externals/realgud ba85207 103/140: Add realgud:js-file-line-loc-pat
Date: Sat, 25 May 2019 19:35:42 -0400 (EDT)

branch: externals/realgud
commit ba852071c00a48b09143c3ae0a24a10ea63dac8a
Author: rocky <address@hidden>
Commit: rocky <address@hidden>

    Add realgud:js-file-line-loc-pat
---
 realgud/lang/js.el   | 19 ++++++++++++++++++-
 test/test-lang-js.el | 19 +++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/realgud/lang/js.el b/realgud/lang/js.el
index 8d19847..6ef388b 100644
--- a/realgud/lang/js.el
+++ b/realgud/lang/js.el
@@ -1,4 +1,4 @@
-;; Copyright (C) 2015-2016 Free Software Foundation, Inc
+;; Copyright (C) 2015-2016, 2018 Free Software Foundation, Inc
 
 ;; Author: Rocky Bernstein <address@hidden>
 
@@ -19,6 +19,8 @@
 (require-relative-list '("../common/regexp" "../common/loc" "../common/track")
                       "realgud-")
 
+(declare-function realgud-goto-line-for-pt 'realgud-track)
+
 (defconst realgud:js-term-escape "[[0-9]+[GKJ]"
   "Escape sequence regular expression pattern trepanjs often puts
   in around prompts")
@@ -38,4 +40,19 @@
    :char-offset-group 4)
   "A realgud-loc-pat struct that describes a V8 backtrace location")
 
+(defconst realgud:js-file-line-loc-pat
+  (make-realgud-loc-pat
+   :regexp (format "^\\([^:]+\\):%s" realgud:regexp-captured-num)
+   :file-group 1
+   :line-group 2)
+  "A realgud-loc-pat struct that describes a V8 file/line location")
+
+;; FIXME: there is probably a less redundant way to do the following
+;; FNS.
+(defun realgud:js-goto-file-line (pt)
+  "Display the location mentioned by the js file/line warning or error."
+  (interactive "d")
+  (realgud-goto-line-for-pt pt "file-line"))
+
+
 (provide-me "realgud-lang-")
diff --git a/test/test-lang-js.el b/test/test-lang-js.el
new file mode 100644
index 0000000..19ec308
--- /dev/null
+++ b/test/test-lang-js.el
@@ -0,0 +1,19 @@
+;; Press C-x C-e at the end of the next line to run this file test 
non-interactively
+;; (test-simple-run "emacs -batch -L %s -l %s" (file-name-directory 
(locate-library "test-simple.elc")) buffer-file-name)
+
+(require 'test-simple)
+(require 'load-relative)
+
+(load-file "../realgud/lang/js.el")
+(test-simple-start)
+
+(setq test-text 
"/src/external-vcs/github/rocky/trepan-ni/lib/internal/inspect_repl.js:637")
+(assert-t (string-match (realgud-loc-pat-regexp realgud:js-file-line-loc-pat)
+                       test-text) "basic location")
+(assert-equal 
"/src/external-vcs/github/rocky/trepan-ni/lib/internal/inspect_repl.js"
+             (match-string 1 test-text)   "extract file name")
+(assert-equal "637"
+             (match-string 2 test-text)   "extract line number")
+
+
+(end-tests)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]