Update dsymbol and dparse

This commit is contained in:
Hackerpilot 2016-10-12 19:28:51 -07:00
parent 762dee0482
commit 896d7da6f4
12 changed files with 42 additions and 34 deletions

@ -1 +1 @@
Subproject commit 50d813eda2b2068cc3e681fec19ddbaef92cccf1
Subproject commit 021df81dd8e23da2b76e8cb9c1b27a3c15efb5e7

View File

@ -7,9 +7,9 @@
"targetType": "executable",
"versions": ["built_with_dub"],
"dependencies": {
"libdparse": "0.7.0-alpha.15",
"dsymbol": "0.2.0-alpha.10",
"libdparse": "0.7.0-beta.1",
"dsymbol": "0.2.0-beta.1",
"inifiled": ">=0.0.6",
"emsi_containers": "0.5.0"
"emsi_containers": "0.5.2"
},
}

@ -1 +1 @@
Subproject commit 1e811d2b5da79ae44dd79b68d1379f67d1250cb9
Subproject commit bbc9916182dc5c13950b25b48b2a6df944d52ab7

View File

@ -12,6 +12,7 @@ import dparse.lexer;
import analysis.base;
import analysis.helpers;
import dsymbol.scope_;
import std.algorithm : map;
/**
* The following code should be killed with fire:
@ -56,7 +57,7 @@ class BuiltinPropertyNameCheck : BaseAnalyzer
override void visit(const AutoDeclaration ad)
{
if (depth > 0)
foreach (i; ad.identifiers)
foreach (i; ad.parts.map!(a => a.identifier))
{
if (isBuiltinProperty(i.text))
addErrorMessage(i.line, i.column, KEY, generateErrorMessage(i.text));

View File

@ -8,7 +8,7 @@ module analysis.enumarrayliteral;
import dparse.ast;
import dparse.lexer;
import analysis.base;
import std.algorithm : canFind;
import std.algorithm : canFind, map;
import dsymbol.scope_ : Scope;
void doNothing(string, size_t, size_t, string, bool)
@ -35,19 +35,19 @@ class EnumArrayLiteralCheck : BaseAnalyzer
{
if (autoDec.storageClasses.canFind!(a => a.token == tok!"enum"))
{
foreach (i, initializer; autoDec.initializers)
foreach (part; autoDec.parts)
{
if (initializer is null)
if (part.initializer is null)
continue;
if (initializer.nonVoidInitializer is null)
if (part.initializer.nonVoidInitializer is null)
continue;
if (initializer.nonVoidInitializer.arrayInitializer is null)
if (part.initializer.nonVoidInitializer.arrayInitializer is null)
continue;
addErrorMessage(autoDec.identifiers[i].line, autoDec.identifiers[i].column,
addErrorMessage(part.identifier.line, part.identifier.column,
"dscanner.performance.enum_array_literal",
"This enum may lead to unnecessary allocation at run-time."
~ " Use 'static immutable "
~ autoDec.identifiers[i].text ~ " = [ ...' instead.");
~ part.identifier.text ~ " = [ ...' instead.");
}
}
autoDec.accept(this);

View File

@ -98,9 +98,9 @@ class UndocumentedDeclarationCheck : BaseAnalyzer
return;
if (variable.autoDeclaration !is null)
{
addMessage(variable.autoDeclaration.identifiers[0].line,
variable.autoDeclaration.identifiers[0].column,
variable.autoDeclaration.identifiers[0].text);
addMessage(variable.autoDeclaration.parts[0].identifier.line,
variable.autoDeclaration.parts[0].identifier.column,
variable.autoDeclaration.parts[0].identifier.text);
return;
}
foreach (dec; variable.declarators)

View File

@ -73,11 +73,12 @@ class UnmodifiedFinder : BaseAnalyzer
&& (!autoDeclaration.storageClasses.canFind!(a => a.token == tok!"const"
|| a.token == tok!"enum" || a.token == tok!"immutable")))
{
foreach (size_t i, id; autoDeclaration.identifiers)
foreach (part; autoDeclaration.parts)
{
if (initializedFromCast(autoDeclaration.initializers[i]))
if (initializedFromCast(part.initializer))
continue;
tree[$ - 1].insert(new VariableInfo(id.text, id.line, id.column));
tree[$ - 1].insert(new VariableInfo(part.identifier.text,
part.identifier.line, part.identifier.column));
}
}
autoDeclaration.accept(this);

View File

@ -10,6 +10,7 @@ import analysis.base;
import std.container;
import std.regex : Regex, regex, matchAll;
import dsymbol.scope_ : Scope;
import std.algorithm : map;
/**
* Checks for unused variables.
@ -259,7 +260,7 @@ class UnusedVariableCheck : BaseAnalyzer
override void visit(const AutoDeclaration autoDeclaration)
{
foreach (t; autoDeclaration.identifiers)
foreach (t; autoDeclaration.parts.map!(a => a.identifier))
this.variableDeclared(t.text, t.line, t.column, false, false);
autoDeclaration.accept(this);
}

View File

@ -165,17 +165,22 @@ class XMLPrinter : ASTVisitor
visit(sc);
output.writeln("</storageClasses>");
for (size_t i = 0; i < autoDec.identifiers.length; i++)
{
output.writeln("<item>");
output.writeln("<name line=\"", autoDec.identifiers[i].line, "\">",
autoDec.identifiers[i].text, "</name>");
visit(autoDec.initializers[i]);
output.writeln("</item>");
}
foreach (part; autoDec.parts)
visit(part);
output.writeln("</autoDeclaration>");
}
override void visit(const AutoDeclarationPart part)
{
output.writeln("<autoDeclarationPart>");
output.writeln("<item>");
output.writeln("<name line=\"", part.identifier.line, "\">", part.identifier.text, "</name>");
visit(part.initializer);
output.writeln("</item>");
output.writeln("</autoDeclarationPart>");
}
override void visit(const BreakStatement breakStatement)
{
if (breakStatement.label.type == tok!"")

View File

@ -213,7 +213,7 @@ final class CTagsPrinter : ASTVisitor
override void visit(const AutoDeclaration dec)
{
foreach (i; dec.identifiers)
foreach (i; dec.parts.map!(a => a.identifier))
{
tagLines.insert("%s\t%s\t%d;\"\tv\tline:%d%s%s\n".format(i.text,
fileName, i.line, i.line, context.c, context.access));

View File

@ -234,9 +234,9 @@ final class EtagsPrinter : ASTVisitor
override void visit(const AutoDeclaration dec)
{
foreach (i; dec.identifiers)
foreach (part; dec.parts)
{
maketag(i);
maketag(part.identifier);
}
dec.accept(this);
}

View File

@ -102,10 +102,10 @@ class FinderVisitor : ASTVisitor
override void visit(const AutoDeclaration ad)
{
foreach (id; ad.identifiers)
foreach (part; ad.parts)
{
if (id.text == symbolName)
output.writefln("%s(%d:%d)", fileName, id.line, id.column);
if (part.identifier.text == symbolName)
output.writefln("%s(%d:%d)", fileName, part.identifier.line, part.identifier.column);
}
}