If constraints: check for same indent level#394
If constraints: check for same indent level#394wilzbach wants to merge 2 commits intodlang-community:masterfrom
Conversation
4012383 to
3ab6368
Compare
|
I see you also made some refactorings here - nice. |
|
cch @Hackerpilot :) |
This is only #348 as this needs access to the raw |
- add allman style check - detect trailing whitespace - check for two or more consecutive empty lines
…e indentation level
3ab6368 to
174139d
Compare
|
@Hackerpilot I am a bit stuck here. Or to be more precise, for the indentation check the plugin looks at a couple of *Declarations in the AST. Then it compares the indent level of its constraint with the indent of the name token itself. For example for override void visit(const FunctionDeclaration decl) {
if (decl.constraint !is null)
checkConstraintSpace(decl.constraint, decl.name);
}Currently auto lineIndent = code[0 .. constraint.location].retro
.until('\n')
.walkLength;
auto tokenLineStart = code[0 .. location].retro
.until('\n')
.walkLength;
auto tokenIndent = code[location - tokenLineStart .. location]
.until!(x => !x.isWhite)
.walkLength;
if (tokenIndent != lineIndent)
addErrorMessage(constraint.expression.line, constraint.expression.column, KEY, MESSAGE);How would I do this with merely the token array? Or can I (as proposed before) just pass the |
|
|
@wilzbach @Hackerpilot I see this needs some rebasing, right? |
Superseded by #450 |
See also: dlang/dlang.org#1534
This is based on #348 as the
sourceCodeis needed to count the whitespace tokens at the beginning of the line.