diff options
author | Darren Kulp <darren@kulp.ch> | 2020-05-22 16:22:01 -0700 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2020-06-21 01:40:52 +0200 |
commit | c462892ad1f2de2599aa6b2cbb6d3ca3e47d6db1 (patch) | |
tree | a06ba3747fe78b00dcdd5992e4480b780f0d3ed3 | |
parent | 2ba27bf996e81319385c1b55a09cd4bdd562d353 (diff) |
Introduce extent to ClangToken
-rw-r--r-- | src/clang.rs | 16 |
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, + }) } } } |