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 # 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. # This file is part of gitinspector.
# #
@ -19,17 +19,18 @@
from __future__ import unicode_literals from __future__ import unicode_literals
__comment_begining__ = {"java": "/*", "c": "/*", "cc": "/*", "cpp": "/*", "h": "/*", "hh": "/*", "hpp": "/*", "hs": "{-", "html": "<!--", __comment_begining__ = { "java": "/*", "c": "/*", "cc": "/*", "cpp": "/*", "cs": "/*", "h": "/*", "hh": "/*", "hpp": "/*",
"php": "/*", "py": "\"\"\"", "glsl": "/*", "rb": "=begin", "js": "/*", "jspx": "<!--", "scala": "/*", "hs": "{-", "html": "<!--", "php": "/*", "py": "\"\"\"", "glsl": "/*", "rb": "=begin", "js": "/*",
"sql": "/*", "tex": "\\begin{comment}", "xhtml": "<!--", "xml": "<!--", "ml": "(*", "mli": "(*" } "jspx": "<!--", "scala": "/*", "sql": "/*", "tex": "\\begin{comment}", "xhtml": "<!--",
"xml": "<!--", "ml": "(*", "mli": "(*" }
__comment_end__ = {"java": "*/", "c": "*/", "cc": "*/", "cpp": "*/", "h": "*/", "hh": "*/", "hpp": "*/", "hs": "-}", "html": "-->", __comment_end__ = { "java": "*/", "c": "*/", "cc": "*/", "cpp": "*/", "cs": "*/", "h": "*/", "hh": "*/", "hpp": "*/", "hs": "-}",
"php": "/*", "py": "\"\"\"", "glsl": "*/", "rb": "=end", "js": "*/", "jspx": "-->", "scala": "*/", "html": "-->", "php": "/*", "py": "\"\"\"", "glsl": "*/", "rb": "=end", "js": "*/", "jspx": "-->",
"sql": "*/", "tex": "\\end{comment}", "xhtml": "-->", "xml": "-->", "ml": "*)", "mli": "*)" } "scala": "*/", "sql": "*/", "tex": "\\end{comment}", "xhtml": "-->", "xml": "-->", "ml": "*)", "mli": "*)" }
__comment__ = {"java": "//", "c": "//", "cc": "//", "cpp": "//", "h": "//", "hh": "//", "hpp": "//", "hs": "--", "pl": "#", "php": "//", __comment__ = { "java": "//", "c": "//", "cc": "//", "cpp": "//", "cs": "//", "h": "//", "hh": "//", "hpp": "//", "hs": "--",
"py": "#", "glsl": "//", "rb": "#", "js": "//", "scala": "//", "sql": "--", "tex": "%", "ada": "--", "ads": "--", "pl": "#", "php": "//", "py": "#", "glsl": "//", "rb": "#", "js": "//", "scala": "//", "sql": "--", "tex": "%",
"adb": "--", "pot": "#", "po": "#" } "ada": "--", "ads": "--", "adb": "--", "pot": "#", "po": "#" }
__comment_markers_must_be_at_begining__ = {"tex": True} __comment_markers_must_be_at_begining__ = {"tex": True}

View file

@ -1,6 +1,6 @@
# coding: utf-8 # 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. # This file is part of gitinspector.
# #
@ -28,12 +28,15 @@ import interval
import re import re
import subprocess 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} "rb": 500, "js": 500, "sql": 1000, "xml": 1000}
__metric_cc_tokens__ = [[["java", "js", "c", "cc", "cpp"], ["else", "for\s+\(.*\)", "if\s+\(.*\)", "case\s+\w+:", __metric_cc_tokens__ = [[["java", "js", "c", "cc", "cpp"], ["else", "for\s+\(.*\)", "if\s+\(.*\)", "case\s+\w+:",
"default:", "while\s+\(.*\)"], "default:", "while\s+\(.*\)"],
["assert", "break", "continue", "return"]], ["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 .*:$"], [["py"], ["^\s+elif .*:$", "^\s+else:$", "^\s+for .*:", "^\s+if .*:$", "^\s+while .*:$"],
["^\s+assert", "break", "continue", "return"]]] ["^\s+assert", "break", "continue", "return"]]]