Skip to content

Commit c462892

Browse files
kulpemilio
authored andcommitted
Introduce extent to ClangToken
1 parent 2ba27bf commit c462892

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/clang.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -793,13 +793,16 @@ impl<'a> Drop for RawTokens<'a> {
793793
}
794794
}
795795

796-
/// A raw clang token, that exposes only the kind and spelling. This is a
796+
/// A raw clang token, that exposes only kind, spelling, and extent. This is a
797797
/// slightly more convenient version of `CXToken` which owns the spelling
798-
/// string.
798+
/// string and extent.
799799
#[derive(Debug)]
800800
pub struct ClangToken {
801801
spelling: CXString,
802-
/// The kind of token, this is the same as the relevant member from
802+
/// The extent of the token. This is the same as the relevant member from
803+
/// `CXToken`.
804+
pub extent: CXSourceRange,
805+
/// The kind of the token. This is the same as the relevant member from
803806
/// `CXToken`.
804807
pub kind: CXTokenKind,
805808
}
@@ -834,7 +837,12 @@ impl<'a> Iterator for ClangTokenIterator<'a> {
834837
unsafe {
835838
let kind = clang_getTokenKind(*raw);
836839
let spelling = clang_getTokenSpelling(self.tu, *raw);
837-
Some(ClangToken { kind, spelling })
840+
let extent = clang_getTokenExtent(self.tu, *raw);
841+
Some(ClangToken {
842+
kind,
843+
extent,
844+
spelling,
845+
})
838846
}
839847
}
840848
}

0 commit comments

Comments
 (0)