[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/csharp-mode cd39e53 423/459: Extract compilation suppor
From: |
ELPA Syncer |
Subject: |
[elpa] externals/csharp-mode cd39e53 423/459: Extract compilation support to its own module (#223) |
Date: |
Sun, 22 Aug 2021 14:00:14 -0400 (EDT) |
branch: externals/csharp-mode
commit cd39e5386e4acdc2058e05e19e832c2cee5d436f
Author: Theodor Thornhill <theo@thornhill.no>
Commit: GitHub <noreply@github.com>
Extract compilation support to its own module (#223)
---
csharp-compilation.el | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++
csharp-mode.el | 115 +---------------------------------------
csharp-tree-sitter.el | 2 +
3 files changed, 145 insertions(+), 114 deletions(-)
diff --git a/csharp-compilation.el b/csharp-compilation.el
new file mode 100644
index 0000000..69cca56
--- /dev/null
+++ b/csharp-compilation.el
@@ -0,0 +1,142 @@
+;;; csharp-compilation.el --- compilation support for C# -*- lexical-binding:
t; -*-
+
+;; Author : Theodor Thornhill <theo@thornhill.no>
+;; Maintainer : Jostein Kjønigsen <jostein@gmail.com>
+;; : Theodor Thornhill <theo@thornhill.no>
+;; Created : September 2020
+;; Modified : 2020
+;; Version : 0.11.0
+;; Keywords : c# languages oop mode
+;; X-URL : https://github.com/emacs-csharp/csharp-mode
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+(require 'compile)
+
+;; When invoked by MSBuild, csc’s errors look like this:
+;; subfolder\file.cs(6,18): error CS1006: Name of constructor must
+;; match name of class [c:\Users\user\project.csproj]
+
+(defun csharp--compilation-error-file-resolve ()
+ "Resolve an msbuild error to a (filename . dirname) cons cell."
+ ;; http://stackoverflow.com/a/18049590/429091
+ (cons (match-string 1) (file-name-directory (match-string 4))))
+
+(defconst csharp-compilation-re-msbuild-error
+ (concat
+ "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?"
+ "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?): "
+ "error [[:alnum:]]+: [^\r\n]+\\[\\([^]\r\n]+\\)\\]$")
+ "Regexp to match compilation error from msbuild.")
+
+(defconst csharp-compilation-re-msbuild-warning
+ (concat
+ "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?"
+ "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?): "
+ "warning [[:alnum:]]+: [^\r\n]+\\[\\([^]\r\n]+\\)\\]$")
+ "Regexp to match compilation warning from msbuild.")
+
+;; Notes on xbuild and devenv commonalities
+;;
+;; These regexes were tailored for xbuild, but apart from the concurrent
+;; build-marker ("1>") they share exactly the same match-markers.
+;;
+;; If we don't exclude the match-markers explicitly, these regexes
+;; will also be used to match for devenv as well, including the build-marker
+;; in the file-name, causing the lookup to fail.
+;;
+;; So if we don't want devenv to fail, we actually need to handle it in our
+;; xbuild-regexes, but then we automatically get devenv-support for free.
+
+(defconst csharp-compilation-re-xbuild-error
+ (concat
+ "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?"
+ "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?"
+ ;; handle weird devenv output format with 4 numbers, not 2 by having
optional
+ ;; extra capture-groups.
+ "\\(?:,\\([0-9]+\\)\\)*): "
+ "error [[:alnum:]]+: .+$")
+ "Regexp to match compilation error from xbuild.")
+
+(defconst csharp-compilation-re-xbuild-warning
+ (concat
+ "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?"
+ "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?"
+ ;; handle weird devenv output format with 4 numbers, not 2 by having
optional
+ ;; extra capture-groups.
+ "\\(?:,\\([0-9]+\\)\\)?*): "
+ "warning [[:alnum:]]+: .+$")
+ "Regexp to match compilation warning from xbuild.")
+
+(defconst csharp-compilation-re-dotnet-error
+ "\\([^\r\n]+\\) : error [A-Z]+[0-9]+:")
+
+(defconst csharp-compilation-re-dotnet-warning
+ "\\([^\r\n]+\\) : warning [A-Z]+[0-9]+:")
+
+(defconst csharp-compilation-re-dotnet-testfail
+ (concat
+ "^[[:blank:]]+X \\(?:.+\n\\)"
+ "[[:blank:]]+Error Message:\n"
+ "[[:blank:]]+\\(?:.+\n\\)"
+ "\\(?:^Expected: \\(?:.+\n\\)\\)?"
+ "\\(?:^Actual: \\(?:.+\n\\)\\)?"
+ "[[:blank:]]+Stack Trace:\n"
+ "[[:blank:]]+at [^\n]+ in \\([^\n]+\\):line \\([0-9]+\\)"))
+
+
+(eval-after-load 'compile
+ (lambda ()
+ (dolist
+ (regexp
+ `((dotnet-testfail
+ ,csharp-compilation-re-dotnet-testfail
+ 1 2)
+ (xbuild-error
+ ,csharp-compilation-re-xbuild-error
+ 1 2 3 2)
+ (xbuild-warning
+ ,csharp-compilation-re-xbuild-warning
+ 1 2 3 1)
+ (msbuild-error
+ ,csharp-compilation-re-msbuild-error
+ csharp--compilation-error-file-resolve
+ 2
+ 3
+ 2
+ nil
+ (1 compilation-error-face)
+ (4 compilation-error-face))
+ (msbuild-warning
+ ,csharp-compilation-re-msbuild-warning
+ csharp--compilation-error-file-resolve
+ 2
+ 3
+ 1
+ nil
+ (1 compilation-warning-face)
+ (4 compilation-warning-face))
+ (dotnet-error
+ ,csharp-compilation-re-dotnet-error
+ 1)
+ (dotnet-warning
+ ,csharp-compilation-re-dotnet-warning
+ 1 nil nil 1)))
+ (add-to-list 'compilation-error-regexp-alist-alist regexp)
+ (add-to-list 'compilation-error-regexp-alist (car regexp)))))
+
+(provide 'csharp-compilation)
+
+;;; csharp-compilation.el ends here
diff --git a/csharp-mode.el b/csharp-mode.el
index 3ce66f2..3445d6f 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -34,7 +34,7 @@
(eval-when-compile
(require 'cc-fonts))
-(require 'compile)
+(require 'csharp-compilation)
(defgroup csharp nil
"Major mode for editing C# code."
@@ -374,119 +374,6 @@ compilation and evaluation time conflicts."
(defun csharp-font-lock-keywords ()
(c-compose-keywords-list csharp-font-lock-keywords))
-;;; Compilation support
-;; When invoked by MSBuild, csc’s errors look like this:
-;; subfolder\file.cs(6,18): error CS1006: Name of constructor must
-;; match name of class [c:\Users\user\project.csproj]
-
-(defun csharp--compilation-error-file-resolve ()
- "Resolve an msbuild error to a (filename . dirname) cons cell."
- ;; http://stackoverflow.com/a/18049590/429091
- (cons (match-string 1) (file-name-directory (match-string 4))))
-
-(defconst csharp-compilation-re-msbuild-error
- (concat
- "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?"
- "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?): "
- "error [[:alnum:]]+: [^\r\n]+\\[\\([^]\r\n]+\\)\\]$")
- "Regexp to match compilation error from msbuild.")
-
-(defconst csharp-compilation-re-msbuild-warning
- (concat
- "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?"
- "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?): "
- "warning [[:alnum:]]+: [^\r\n]+\\[\\([^]\r\n]+\\)\\]$")
- "Regexp to match compilation warning from msbuild.")
-
-;; Notes on xbuild and devenv commonalities
-;;
-;; These regexes were tailored for xbuild, but apart from the concurrent
-;; build-marker ("1>") they share exactly the same match-markers.
-;;
-;; If we don't exclude the match-markers explicitly, these regexes
-;; will also be used to match for devenv as well, including the build-marker
-;; in the file-name, causing the lookup to fail.
-;;
-;; So if we don't want devenv to fail, we actually need to handle it in our
-;; xbuild-regexes, but then we automatically get devenv-support for free.
-
-(defconst csharp-compilation-re-xbuild-error
- (concat
- "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?"
- "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?"
- ;; handle weird devenv output format with 4 numbers, not 2 by having
optional
- ;; extra capture-groups.
- "\\(?:,\\([0-9]+\\)\\)*): "
- "error [[:alnum:]]+: .+$")
- "Regexp to match compilation error from xbuild.")
-
-(defconst csharp-compilation-re-xbuild-warning
- (concat
- "^[[:blank:]]*\\(?:[[:digit:]]+>\\)?"
- "\\([^(\r\n)]+\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?"
- ;; handle weird devenv output format with 4 numbers, not 2 by having
optional
- ;; extra capture-groups.
- "\\(?:,\\([0-9]+\\)\\)?*): "
- "warning [[:alnum:]]+: .+$")
- "Regexp to match compilation warning from xbuild.")
-
-(defconst csharp-compilation-re-dotnet-error
- "\\([^\r\n]+\\) : error [A-Z]+[0-9]+:")
-
-(defconst csharp-compilation-re-dotnet-warning
- "\\([^\r\n]+\\) : warning [A-Z]+[0-9]+:")
-
-(defconst csharp-compilation-re-dotnet-testfail
- (concat
- "^[[:blank:]]+X \\(?:.+\n\\)"
- "[[:blank:]]+Error Message:\n"
- "[[:blank:]]+\\(?:.+\n\\)"
- "\\(?:^Expected: \\(?:.+\n\\)\\)?"
- "\\(?:^Actual: \\(?:.+\n\\)\\)?"
- "[[:blank:]]+Stack Trace:\n"
- "[[:blank:]]+at [^\n]+ in \\([^\n]+\\):line \\([0-9]+\\)"))
-
-
-(eval-after-load 'compile
- (lambda ()
- (dolist
- (regexp
- `((dotnet-testfail
- ,csharp-compilation-re-dotnet-testfail
- 1 2)
- (xbuild-error
- ,csharp-compilation-re-xbuild-error
- 1 2 3 2)
- (xbuild-warning
- ,csharp-compilation-re-xbuild-warning
- 1 2 3 1)
- (msbuild-error
- ,csharp-compilation-re-msbuild-error
- csharp--compilation-error-file-resolve
- 2
- 3
- 2
- nil
- (1 compilation-error-face)
- (4 compilation-error-face))
- (msbuild-warning
- ,csharp-compilation-re-msbuild-warning
- csharp--compilation-error-file-resolve
- 2
- 3
- 1
- nil
- (1 compilation-warning-face)
- (4 compilation-warning-face))
- (dotnet-error
- ,csharp-compilation-re-dotnet-error
- 1)
- (dotnet-warning
- ,csharp-compilation-re-dotnet-warning
- 1 nil nil 1)))
- (add-to-list 'compilation-error-regexp-alist-alist regexp)
- (add-to-list 'compilation-error-regexp-alist (car regexp)))))
-
;;; Doc comments
(defconst codedoc-font-lock-doc-comments
diff --git a/csharp-tree-sitter.el b/csharp-tree-sitter.el
index 711817b..4a51970 100644
--- a/csharp-tree-sitter.el
+++ b/csharp-tree-sitter.el
@@ -33,6 +33,8 @@
(require 'tree-sitter-indent)
(require 'tree-sitter-langs)
+(require 'csharp-compilation)
+
(defvar csharp-mode-syntax-table)
(defvar csharp-mode-map)
- [elpa] externals/csharp-mode 1e37eaf 407/459: Add dependency to tree-sitter-indent, (continued)
- [elpa] externals/csharp-mode 1e37eaf 407/459: Add dependency to tree-sitter-indent, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 00a3cd4 410/459: Add new url to csharp-tree-sitter.el, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 91d5161 414/459: Minor fix after version 0.11.0 (#209), ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 8466428 413/459: Version bump to 0.11.0, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 84ff0d0 415/459: Typo from PR-209., ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 74644d4 416/459: Merge pull request #210 from emacs-csharp/minor, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode d3b5b18 419/459: Ensure langs package for tree-sitter support (#214), ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode da26eb6 420/459: Add mode map and syntax table to tree-sitter, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode a402402 421/459: Add lock_statement, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode cb1b16f 417/459: Add some more documentation on tree-sitter support, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode cd39e53 423/459: Extract compilation support to its own module (#223),
ELPA Syncer <=
- [elpa] externals/csharp-mode 57055a7 426/459: Add qualified name to method_declaration, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 03b8284 428/459: Add type constraints and lambda support, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 6f0bf6b 430/459: Add escape_sequence to strings, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 3f963c2 432/459: Make type_of_expression available in strings, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 61e1305 431/459: Indent constructor initializer, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 0e26b88 433/459: Update readme with :ensure t, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode cb2404f 434/459: Correctly handle implicit types in for_each_statement, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 09b4d57 437/459: Add comment-start-skip, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 254b91b 439/459: Fix parse and sigabort errors on latest tree-sitter, ELPA Syncer, 2021/08/22
- [elpa] externals/csharp-mode 76428ef 444/459: Nested type params and using declaration fixes (#233), ELPA Syncer, 2021/08/22