branch: externals/phps-mode commit e0661657727189fdfeec7fffe52c44392fb24621 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Improved lexing of indented endings of nowdoc and heredoc --- phps-mode-cache.el | 3 ++- phps-mode-indent.el | 15 ++++++++++----- phps-mode-lex-analyzer.el | 12 ++++++++---- phps-mode-parser.el | 11 ++++++++--- phps-mode-serial.el | 5 ++++- phps-mode-test.el | 6 ++++-- test/phps-mode-test-indent.el | 3 ++- test/phps-mode-test-syntax-table.el | 3 ++- 8 files changed, 40 insertions(+), 18 deletions(-) diff --git a/phps-mode-cache.el b/phps-mode-cache.el index 01ba098b85..a773fec83a 100644 --- a/phps-mode-cache.el +++ b/phps-mode-cache.el @@ -34,7 +34,8 @@ filename))) (defun phps-mode-cache-test-p (key &optional source-file) - "Test whether KEY exists in cache and that it is optionally not older than SOURCE-FILE." + "Test whether KEY exists in cache and that it is +optionally not older than SOURCE-FILE." (let ((cache-filename (phps-mode-cache--get-filename-for-key key)) (exists)) (when (file-exists-p cache-filename) diff --git a/phps-mode-indent.el b/phps-mode-indent.el index 5b5edd8096..aad359f5b3 100644 --- a/phps-mode-indent.el +++ b/phps-mode-indent.el @@ -40,21 +40,24 @@ nil)))) (defun phps-mode-indent--string-starts-with-regexp (string regexp &optional match-index) - "If STRING start with REGEXP, return it, otherwise nil. With optional MATCH-INDEX." + "If STRING start with REGEXP, return it, +otherwise nil. With optional MATCH-INDEX." (phps-mode-indent--string-match-regexp string (concat "^" regexp) match-index)) (defun phps-mode-indent--string-ends-with-regexp (string regexp &optional match-index) - "If STRING end with REGEXP, return it, otherwise nil. With optional MATCH-INDEX." + "If STRING end with REGEXP, return it, +otherwise nil. With optional MATCH-INDEX." (phps-mode-indent--string-match-regexp string (concat regexp "$") match-index)) (defun phps-mode-indent--string-match-regexp (string regexp &optional match-index) - "If STRING match REGEXP, return it, otherwise nil. With optional MATCH-INDEX." + "If STRING match REGEXP, return it, otherwise nil. +With optional MATCH-INDEX." (unless match-index (setq match-index 0)) (if @@ -216,7 +219,8 @@ html-bracket-level))) (defun phps-mode-indent--get-previous-reference-index-line () - "Get previous index line as reference, if any exist. A index line is a previous element line inside current bracket scope." + "Get previous index line as reference, if any exist. +A index line is a previous element line inside current bracket scope." (let ((reference-line)) (save-excursion (end-of-line) @@ -306,7 +310,8 @@ (defun phps-mode-indent--get-previous-start-of-bracket-line (&optional from-end-of-line) - "Get previous start of bracket line as reference, if any exist. Optionally start FROM-END-OF-LINE." + "Get previous start of bracket line as reference, if any exist. +Optionally start FROM-END-OF-LINE." (let ((reference-line)) (save-excursion (if from-end-of-line diff --git a/phps-mode-lex-analyzer.el b/phps-mode-lex-analyzer.el index 73dce8050a..8d1c61225b 100644 --- a/phps-mode-lex-analyzer.el +++ b/phps-mode-lex-analyzer.el @@ -211,7 +211,8 @@ (cdr (cdr (car phps-mode-lexer--generated-new-tokens))))))))) (defun phps-mode-lex-analyzer--re2c-run (&optional force-synchronous allow-cache-read allow-cache-write) - "Run lexer, optionally FORCE-SYNCHRONOUS mode, ALLOW-CACHE-READ and ALLOW-CACHE-WRITE." + "Run lexer, optionally FORCE-SYNCHRONOUS mode, +ALLOW-CACHE-READ and ALLOW-CACHE-WRITE." (interactive) (require 'phps-mode-macros) (phps-mode-debug-message (message "Lexer run")) @@ -601,7 +602,8 @@ new-states)) (defun phps-mode-lex-analyzer--move-tokens (start diff) - "Update tokens with moved lexer tokens after or equal to START with modification DIFF." + "Update tokens with moved lexer tokens after +or equal to START with modification DIFF." (when phps-mode-lex-analyzer--tokens (setq phps-mode-lex-analyzer--tokens @@ -611,7 +613,8 @@ diff)))) (defun phps-mode-lex-analyzer--get-moved-tokens (old-tokens start diff) - "Return moved lexer OLD-TOKENS positions after (or equal to) START with DIFF points." + "Return moved lexer OLD-TOKENS positions after +(or equal to) START with DIFF points." (let ((new-tokens '())) (when old-tokens @@ -635,7 +638,8 @@ (setq phps-mode-lex-analyzer--change-min nil)) (defun phps-mode-lex-analyzer--process-changes (&optional buffer force-synchronous) - "Run incremental lexer on BUFFER. Return list of performed operations. Optionally do it FORCE-SYNCHRONOUS." + "Run incremental lexer on BUFFER. Return list +of performed operations. Optionally do it FORCE-SYNCHRONOUS." (unless buffer (setq buffer (current-buffer))) (phps-mode-debug-message diff --git a/phps-mode-parser.el b/phps-mode-parser.el index 5814dcde02..aaa49f9603 100644 --- a/phps-mode-parser.el +++ b/phps-mode-parser.el @@ -312,7 +312,10 @@ translation translation-symbol-table-list history) - "Perform a LR-parse via lex-analyzer, optionally PERFORM-SDT means to perform syntax-directed translation and optioanlly start at INPUT-TAPE-INDEX with PUSHDOWN-LIST, OUTPUT, TRANSLATION, TRANSLATION-SYMBOL-TABLE-LIST and HISTORY." + "Perform a LR-parse via lex-analyzer, optionally PERFORM-SDT means to + perform syntax-directed translation and optioanlly start at INPUT-TAPE-INDEX + with PUSHDOWN-LIST, OUTPUT, TRANSLATION, TRANSLATION-SYMBOL-TABLE-LIST + and HISTORY." (unless input-tape-index (setq input-tape-index 1)) (unless pushdown-list @@ -738,7 +741,8 @@ output translation history) - "Perform a LR-parse via lex-analyzer, optionally at INPUT-TAPE-INDEX with PUSHDOWN-LIST, OUTPUT, TRANSLATION and HISTORY." + "Perform a LR-parse via lex-analyzer, optionally at INPUT-TAPE-INDEX with + PUSHDOWN-LIST, OUTPUT, TRANSLATION and HISTORY." (let ((result (phps-mode-parser--parse nil @@ -756,7 +760,8 @@ output translation history) - "Perform a LR-parse via lex-analyzer, optionally at INPUT-TAPE-INDEX with PUSHDOWN-LIST, OUTPUT, TRANSLATION and HISTORY." + "Perform a LR-parse via lex-analyzer, optionally at INPUT-TAPE-INDEX with + PUSHDOWN-LIST, OUTPUT, TRANSLATION and HISTORY." (let ((result (phps-mode-parser--parse t diff --git a/phps-mode-serial.el b/phps-mode-serial.el index e1ca7ed76c..ddec680c63 100644 --- a/phps-mode-serial.el +++ b/phps-mode-serial.el @@ -66,7 +66,10 @@ (thread-signal (gethash key phps-mode-serial--async-threads) 'quit nil))) (defun phps-mode-serial-commands (key start end &optional start-error end-error async async-by-process) - "Run command with KEY, first START and if successfully then END with the result of START as argument. Optional arguments START-ERROR, END-ERROR that are called on errors. ASYNC ASYNC-BY-PROCESS specifies additional options for synchronicity." + "Run command with KEY, first START and if successfully then END with the +result of START as argument. Optional arguments START-ERROR, END-ERROR that are +called on errors. ASYNC ASYNC-BY-PROCESS specifies additional options +for synchronicity." (let ((start-time (current-time))) (when phps-mode-serial--profiling (message "PHPs - Starting serial commands for buffer '%s'.." key)) diff --git a/phps-mode-test.el b/phps-mode-test.el index ef62b64e97..075eb25086 100644 --- a/phps-mode-test.el +++ b/phps-mode-test.el @@ -18,7 +18,8 @@ "The native tokens of PHP parser (if available).") (defmacro phps-mode-test--incremental-vs-intial-buffer (source &optional title &rest change) - "Set up test buffer with SOURCE, TITLE, apply CHANGE and compare incremental values with initial values." + "Set up test buffer with SOURCE, TITLE, apply CHANGE and +compare incremental values with initial values." `(let ((test-buffer-incremental (generate-new-buffer "test-incremental")) (incremental-state) (incremental-state-stack) @@ -168,7 +169,8 @@ (message "\nPassed tests for '%s'\n" ,title)))) (defun phps-mode-test--hash-to-list (hash-table &optional un-sorted) - "Return a list that represent the HASH-TABLE. Each element is a list: (list key value), optionally UN-SORTED." + "Return a list that represent the HASH-TABLE. +Each element is a list: (list key value), optionally UN-SORTED." (let (result) (if (hash-table-p hash-table) (progn diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el index 17ed0ac240..f9ec346a07 100644 --- a/test/phps-mode-test-indent.el +++ b/test/phps-mode-test-indent.el @@ -32,7 +32,8 @@ (execute-kbd-macro (kbd "TAB")))) (defun phps-mode-test-indent--should-equal (string name &optional new-string) - "Test indent of whole buffer containing STRING with NAME with optional NEW-STRING." + "Test indent of whole buffer containing +STRING with NAME with optional NEW-STRING." (phps-mode-test--with-buffer string name diff --git a/test/phps-mode-test-syntax-table.el b/test/phps-mode-test-syntax-table.el index 65d62066ba..dd1995aede 100644 --- a/test/phps-mode-test-syntax-table.el +++ b/test/phps-mode-test-syntax-table.el @@ -17,7 +17,8 @@ ;; TODO Should test `backward-sexp', `forward-sexp', `backward-word', `forward-word', `backward-list', `forward-list' as well (defun phps-mode-test-syntax-table--quote-region () - "Test double quotes, single quotes, curly bracket, square bracket, round bracket, back-quotes on regions." + "Test double quotes, single quotes, curly bracket, +square bracket, round bracket, back-quotes on regions." (phps-mode-test--with-buffer "<?php\n$var = abc;"