Added support for comments and metrics in C# code (Fixes #59).

This commit is contained in:
Adam Waldenberg 2015-09-24 04:10:32 +02:00
parent da1553b57e
commit a6c05cc619
2 changed files with 16 additions and 12 deletions

View File

@ -1,6 +1,6 @@
# coding: utf-8
#
# Copyright © 2012-2014 Ejwa Software. All rights reserved.
# Copyright © 2012-2015 Ejwa Software. All rights reserved.
#
# This file is part of gitinspector.
#
@ -19,17 +19,18 @@
from __future__ import unicode_literals
__comment_begining__ = {"java": "/*", "c": "/*", "cc": "/*", "cpp": "/*", "h": "/*", "hh": "/*", "hpp": "/*", "hs": "{-", "html": "<!--",
"php": "/*", "py": "\"\"\"", "glsl": "/*", "rb": "=begin", "js": "/*", "jspx": "<!--", "scala": "/*",
"sql": "/*", "tex": "\\begin{comment}", "xhtml": "<!--", "xml": "<!--", "ml": "(*", "mli": "(*" }
__comment_begining__ = { "java": "/*", "c": "/*", "cc": "/*", "cpp": "/*", "cs": "/*", "h": "/*", "hh": "/*", "hpp": "/*",
"hs": "{-", "html": "<!--", "php": "/*", "py": "\"\"\"", "glsl": "/*", "rb": "=begin", "js": "/*",
"jspx": "<!--", "scala": "/*", "sql": "/*", "tex": "\\begin{comment}", "xhtml": "<!--",
"xml": "<!--", "ml": "(*", "mli": "(*" }
__comment_end__ = {"java": "*/", "c": "*/", "cc": "*/", "cpp": "*/", "h": "*/", "hh": "*/", "hpp": "*/", "hs": "-}", "html": "-->",
"php": "/*", "py": "\"\"\"", "glsl": "*/", "rb": "=end", "js": "*/", "jspx": "-->", "scala": "*/",
"sql": "*/", "tex": "\\end{comment}", "xhtml": "-->", "xml": "-->", "ml": "*)", "mli": "*)" }
__comment_end__ = { "java": "*/", "c": "*/", "cc": "*/", "cpp": "*/", "cs": "*/", "h": "*/", "hh": "*/", "hpp": "*/", "hs": "-}",
"html": "-->", "php": "/*", "py": "\"\"\"", "glsl": "*/", "rb": "=end", "js": "*/", "jspx": "-->",
"scala": "*/", "sql": "*/", "tex": "\\end{comment}", "xhtml": "-->", "xml": "-->", "ml": "*)", "mli": "*)" }
__comment__ = {"java": "//", "c": "//", "cc": "//", "cpp": "//", "h": "//", "hh": "//", "hpp": "//", "hs": "--", "pl": "#", "php": "//",
"py": "#", "glsl": "//", "rb": "#", "js": "//", "scala": "//", "sql": "--", "tex": "%", "ada": "--", "ads": "--",
"adb": "--", "pot": "#", "po": "#" }
__comment__ = { "java": "//", "c": "//", "cc": "//", "cpp": "//", "cs": "//", "h": "//", "hh": "//", "hpp": "//", "hs": "--",
"pl": "#", "php": "//", "py": "#", "glsl": "//", "rb": "#", "js": "//", "scala": "//", "sql": "--", "tex": "%",
"ada": "--", "ads": "--", "adb": "--", "pot": "#", "po": "#" }
__comment_markers_must_be_at_begining__ = {"tex": True}

View File

@ -1,6 +1,6 @@
# coding: utf-8
#
# Copyright © 2012-2014 Ejwa Software. All rights reserved.
# Copyright © 2012-2015 Ejwa Software. All rights reserved.
#
# This file is part of gitinspector.
#
@ -28,12 +28,15 @@ import interval
import re
import subprocess
__metric_eloc__ = {"java": 500, "c": 500, "cpp": 500, "h": 300, "hpp": 300, "php": 500, "py": 500, "glsl": 1000,
__metric_eloc__ = {"java": 500, "c": 500, "cpp": 500, "cs": 500, "h": 300, "hpp": 300, "php": 500, "py": 500, "glsl": 1000,
"rb": 500, "js": 500, "sql": 1000, "xml": 1000}
__metric_cc_tokens__ = [[["java", "js", "c", "cc", "cpp"], ["else", "for\s+\(.*\)", "if\s+\(.*\)", "case\s+\w+:",
"default:", "while\s+\(.*\)"],
["assert", "break", "continue", "return"]],
[["cs"], ["else", "for\s+\(.*\)", "foreach\s+\(.*\)", "goto\s+\w+:", "if\s+\(.*\)", "case\s+\w+:",
"default:", "while\s+\(.*\)"],
["assert", "break", "continue", "return"]],
[["py"], ["^\s+elif .*:$", "^\s+else:$", "^\s+for .*:", "^\s+if .*:$", "^\s+while .*:$"],
["^\s+assert", "break", "continue", "return"]]]