Use regex for better getter/setter function detection

This commit is contained in:
Hackerpilot 2015-06-04 16:17:56 -07:00
parent 377c9955f5
commit a078e7bbe1
1 changed files with 5 additions and 5 deletions
src/analysis

View File

@ -9,6 +9,7 @@ import std.d.ast;
import std.d.lexer;
import analysis.base;
import std.regex : ctRegex, matchAll;
import std.stdio;
/**
@ -38,9 +39,7 @@ class UndocumentedDeclarationCheck : BaseAnalyzer
if (isProtection(attr.attribute.type))
set(attr.attribute.type);
else if (attr.attribute == tok!"override")
{
setOverride(true);
}
}
immutable bool shouldPop = dec.attributeDeclaration is null;
@ -92,7 +91,7 @@ class UndocumentedDeclarationCheck : BaseAnalyzer
override void visit(const ConditionalDeclaration cond)
{
const VersionCondition ver = cond.compileCondition.versionCondition;
if (ver is null || ver.token != tok!"unittest" && ver.token.text != "none")
if ((ver is null || ver.token != tok!"unittest") && ver.token.text != "none")
cond.accept(this);
else if (cond.falseDeclaration !is null)
visit(cond.falseDeclaration);
@ -156,8 +155,7 @@ private:
static bool isGetterOrSetter(string name)
{
import std.algorithm:startsWith;
return name.startsWith("get") || name.startsWith("set");
return !matchAll(name, getSetRe).empty;
}
static bool isProperty(const FunctionDeclaration dec)
@ -232,3 +230,5 @@ private immutable string[] ignoredFunctionNames = [
"toHash",
"main"
];
private enum getSetRe = ctRegex!`^(?:get|set)(?:\p{Lu}|_).*`;