Add get_origin

This commit is contained in:
dalance 2019-10-21 20:41:10 +09:00
parent d4cff2926f
commit 945eb436dd
2 changed files with 7 additions and 1 deletions

View File

@ -2,6 +2,8 @@
## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.2.0...Unreleased) - ReleaseDate
* [Added] get_origin to SyntaxTree
## [v0.2.0](https://github.com/dalance/sv-parser/compare/v0.1.4...v0.2.0) - 2019-10-16
* [Added] parse error position

View File

@ -4,7 +4,7 @@ use nom::combinator::all_consuming;
use nom_greedyerror::error_position;
use std::collections::HashMap;
use std::fmt;
use std::path::Path;
use std::path::{Path, PathBuf};
use sv_parser_error::{Error, ErrorKind};
use sv_parser_parser::{lib_parser, sv_parser, Span, SpanInfo};
use sv_parser_pp::preprocess::{preprocess, Define, Defines, PreprocessedText};
@ -23,6 +23,10 @@ impl SyntaxTree {
.get_unchecked(locate.offset..locate.offset + locate.len)
}
}
pub fn get_origin(&self, locate: &Locate) -> Option<(&PathBuf, usize)> {
self.text.origin(locate.offset)
}
}
impl fmt::Display for SyntaxTree {