Function racer::expand_ident
[−]
[src]
pub fn expand_ident<P, C>(filepath: P,
cursor: C,
session: &Session)
-> Option<ExpandedIdent> where P: AsRef<Path>, C: Into<Location>
Given a string and index, return span of identifier
pos
is coerced to be within s
. Note that expand_ident
only backtracks.
If the provided pos
is in the middle of an identifier, the returned
(start, end)
will have end
= pos
.
Examples
extern crate racer; let src = "let x = this_is_an_identifier;"; let pos = racer::Location::Point(29); let path = "lib.rs"; let cache = racer::FileCache::default(); let session = racer::Session::new(&cache); session.cache_file_contents(path, src); let expanded = racer::expand_ident(path, pos, &session).unwrap(); assert_eq!("this_is_an_identifier", expanded.ident());