Merge pull request #12140 from ethereum/partsOfLSP

Trivialities needed by LSP
This commit is contained in:
Mathias L. Baumann 2021-10-14 18:20:04 +02:00 committed by GitHub
commit 6d47168af2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -59,6 +59,13 @@ struct SourceLocation
return start <= _other.start && _other.end <= end; return start <= _other.start && _other.end <= end;
} }
bool containsOffset(int _pos) const
{
if (!hasText() || _pos < 0)
return false;
return start <= _pos && _pos < end;
}
bool intersects(SourceLocation const& _other) const bool intersects(SourceLocation const& _other) const
{ {
if (!hasText() || !_other.hasText() || !equalSources(_other)) if (!hasText() || !_other.hasText() || !equalSources(_other))

View File

@ -246,7 +246,10 @@ public:
/// @returns the declared name. /// @returns the declared name.
ASTString const& name() const { return *m_name; } ASTString const& name() const { return *m_name; }
/// @returns the location of the declared name itself or empty location if not available or unknown.
SourceLocation const& nameLocation() const noexcept { return m_nameLocation; } SourceLocation const& nameLocation() const noexcept { return m_nameLocation; }
bool noVisibilitySpecified() const { return m_visibility == Visibility::Default; } bool noVisibilitySpecified() const { return m_visibility == Visibility::Default; }
Visibility visibility() const { return m_visibility == Visibility::Default ? defaultVisibility() : m_visibility; } Visibility visibility() const { return m_visibility == Visibility::Default ? defaultVisibility() : m_visibility; }
bool isPublic() const { return visibility() >= Visibility::Public; } bool isPublic() const { return visibility() >= Visibility::Public; }