summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/clang.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/clang.rs b/src/clang.rs
index 12ac46ce..f5f4fa1a 100644
--- a/src/clang.rs
+++ b/src/clang.rs
@@ -793,13 +793,16 @@ impl<'a> Drop for RawTokens<'a> {
}
}
-/// A raw clang token, that exposes only the kind and spelling. This is a
+/// A raw clang token, that exposes only kind, spelling, and extent. This is a
/// slightly more convenient version of `CXToken` which owns the spelling
-/// string.
+/// string and extent.
#[derive(Debug)]
pub struct ClangToken {
spelling: CXString,
- /// The kind of token, this is the same as the relevant member from
+ /// The extent of the token. This is the same as the relevant member from
+ /// `CXToken`.
+ pub extent: CXSourceRange,
+ /// The kind of the token. This is the same as the relevant member from
/// `CXToken`.
pub kind: CXTokenKind,
}
@@ -834,7 +837,12 @@ impl<'a> Iterator for ClangTokenIterator<'a> {
unsafe {
let kind = clang_getTokenKind(*raw);
let spelling = clang_getTokenSpelling(self.tu, *raw);
- Some(ClangToken { kind, spelling })
+ let extent = clang_getTokenExtent(self.tu, *raw);
+ Some(ClangToken {
+ kind,
+ extent,
+ spelling,
+ })
}
}
}