Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Commit

Permalink
add InterfaceDetails.isEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed Feb 16, 2022
1 parent eb529b0 commit d4f5254
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
20 changes: 20 additions & 0 deletions source/workspaced/dparseext.d
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,23 @@ unittest
assert(getIfElse(p("if (x) {} else if (y) {} else {}")) !is null);
assert(cast(IfStatement)getIfElse(p("if (x) {} else if (y) {} else {}")) is null);
}

C[] substr(C)(C[] s, size_t[2] range)
{
return substr(s, range[0], range[1]);
}

C[] substr(C)(C[] s, size_t start, size_t end)
{
if (!s.length)
return s;
if (start < 0)
start = 0;
if (start >= s.length)
start = s.length - 1; // @suppress(dscanner.suspicious.length_subtraction)
if (end > s.length)
end = s.length;
if (end < start)
return s[start .. start];
return s[start .. end];
}
6 changes: 6 additions & 0 deletions source/workspaced/visitors/methodfinder.d
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ struct InterfaceDetails
size_t[2] blockRange;
/// A (name-based) sorted set of referenced types with first occurences of every type or alias not including built-in types, but including object.d types and aliases.
ReferencedType[] referencedTypes;

/// Returns true if there are no non-whitespace characters inside the block.
bool isEmpty() const
{
return !code.substr(blockRange).strip.length;
}
}

class InterfaceMethodFinder : AttributesVisitor
Expand Down

0 comments on commit d4f5254

Please sign in to comment.