[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 4098f46 049/405: Started with incremental lex
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 4098f46 049/405: Started with incremental lexer |
Date: |
Sat, 13 Jul 2019 09:59:40 -0400 (EDT) |
branch: externals/phps-mode
commit 4098f46f2ce9296836b6eacc04430bbaa232d11b
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Started with incremental lexer
---
phps-functions.el | 5 +++++
phps-lexer.el | 13 +++++++++++--
phps-mode.el | 3 +++
sample-php-files/class.php | 8 ++++++--
4 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/phps-functions.el b/phps-functions.el
index bcd50ce..8b1538d 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -41,6 +41,7 @@
(autoload 'phps-mode/lexer-get-point-data "phps-lexer")
+;; TODO Should also format white-space inside the line, i.e. after function
declarations
(defun phps-mode/indent-line ()
"Indent line."
(let ((data (phps-mode/lexer-get-point-data)))
@@ -92,6 +93,7 @@
;; (message "inside scripting, start: %s, end: %s, indenting to
column %s " start end indent-level)
(indent-line-to (* indent-level tab-width)))))))))
+;; TODO Implement this
(defun phps-mode/indent-region ()
"Indent region."
)
@@ -101,6 +103,9 @@
(defun phps-mode/after-change-functions (start stop length)
"Track buffer change from START to STOP with length LENGTH."
(when (string= major-mode "phps-mode")
+ (when (and (not phps-mode/buffer-changes--start)
+ (boundp 'phps-mode/idle-interval))
+ (run-with-idle-timer phps-mode/idle-interval nil
#'phps-mode/run-incremental-lex))
(setq phps-mode/buffer-changes--start start)
(message "phps-mode/after-change-functions %s %s %s" start stop length)
))
diff --git a/phps-lexer.el b/phps-lexer.el
index 37e1c56..04b0edd 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1327,9 +1327,11 @@ ANY_CHAR'
(defun phps-mode/lex--SETUP (start end)
"Just prepare other lexers for lexing region START to END."
- (when (eq start 1)
+ (when (and (eq start 1)
+ end)
;; (message "SETUP %s %s" start end)
- (setq phps-mode/buffer-changes--start nil)
+ (when (boundp 'phps-mode/buffer-changes--start)
+ (setq phps-mode/buffer-changes--start nil))
(phps-mode/BEGIN phps-mode/ST_INITIAL)))
(defun phps-mode/lex--RUN ()
@@ -1337,6 +1339,13 @@ ANY_CHAR'
(interactive)
(setq phps-mode/lexer-tokens (semantic-lex-buffer)))
+(defun phps-mode/run-incremental-lex ()
+ "Run incremental lexer based on `phps-mode/buffer-changes--start'."
+ (when (boundp 'phps-mode/buffer-changes--start)
+ (message "Should run incremental lex here %s - %s"
phps-mode/buffer-changes--start (point-max))
+ (semantic-lex phps-mode/buffer-changes--start (point-max))
+ (setq phps-mode/buffer-changes--start nil)))
+
(define-lex phps-mode/tags-lexer
"Lexer that handles PHP buffers."
diff --git a/phps-mode.el b/phps-mode.el
index d950c00..cc4a714 100644
--- a/phps-mode.el
+++ b/phps-mode.el
@@ -60,6 +60,9 @@
(defvar phps-mode/use-psr-2 t
"Whether to use PSR-2 guidelines for white-space or not.")
+(defvar phps-mode/idle-interval 1
+ "Idle seconds before running incremental lexer.")
+
(define-derived-mode phps-mode prog-mode "PHPs"
"Major mode for PHP with Semantic integration."
diff --git a/sample-php-files/class.php b/sample-php-files/class.php
index 50c292a..c7ac743 100644
--- a/sample-php-files/class.php
+++ b/sample-php-files/class.php
@@ -4,16 +4,20 @@
* @todo was here
*/
-class MyClass {
+class MyClass
+{
/**
* @var string
*/
- private $var = 'abc';
+ private $var = 'abcdef';
public function myMethod()
{
echo "Some stuff here"; // Just a comment
+ if ($this->var) {
+
+ }
}
public function myMethod2() {
- [elpa] externals/phps-mode e36d477 045/405: token-number from point now is the same format as (nth), (continued)
- [elpa] externals/phps-mode e36d477 045/405: token-number from point now is the same format as (nth), Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b437374 040/405: Fixed bug in parsing of object parameters inside double quoted string, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7161184 041/405: Handles stacked states better, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c625217 042/405: Added flag for PSR-2 white-space settings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b629c4b 050/405: Updated comments and TODOs, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 4b4a375 043/405: Using lexical bindings for all files, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c040358 046/405: Point lexer token information makes more sense, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 94492c4 048/405: Added changes tracking to functions from lexer, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode be46d9c 044/405: Added lexer autoload to functions, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a259292 047/405: Changed indentation function to work solely on tokens, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 4098f46 049/405: Started with incremental lexer,
Stefan Monnier <=
- [elpa] externals/phps-mode da1d1de 051/405: Temporary lexer after change until other work is ready, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 990d3dd 054/405: Added test for indentation of multiple-line doc comment, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode dd80d27 055/405: Started work on detecting doc comment blocks, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e1b7160 053/405: (newline-and-indent) now working, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8aa1ab6 059/405: Another test for getting point data inside doc block, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 09daec3 052/405: Foundation for incremental lexer and syntax colorer completed, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3f4c344 056/405: Fixed detection of doc comment blocks, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3824abf 060/405: Resolved indent with trailing parenthesis, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a61cb8b 062/405: Fixed issue with doc comment indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 6c597fb 065/405: Updated readme, Stefan Monnier, 2019/07/13