2016-04-16 21:05:50 +00:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
use fs::File;
|
|
|
|
|
|
|
|
|
2016-06-11 12:35:31 +00:00
|
|
|
impl<'a> File<'a> {
|
2016-04-16 21:05:50 +00:00
|
|
|
|
|
|
|
/// For this file, return a vector of alternate file paths that, if any of
|
|
|
|
/// them exist, mean that *this* file should be coloured as “compiled”.
|
|
|
|
///
|
|
|
|
/// The point of this is to highlight compiled files such as `foo.o` when
|
|
|
|
/// their source file `foo.c` exists in the same directory. It's too
|
|
|
|
/// dangerous to highlight *all* compiled, so the paths in this vector
|
|
|
|
/// are checked for existence first: for example, `foo.js` is perfectly
|
|
|
|
/// valid without `foo.coffee`.
|
|
|
|
pub fn get_source_files(&self) -> Vec<PathBuf> {
|
|
|
|
if let Some(ref ext) = self.ext {
|
|
|
|
match &ext[..] {
|
|
|
|
"class" => vec![self.path.with_extension("java")], // Java
|
|
|
|
"css" => vec![self.path.with_extension("sass"), self.path.with_extension("less")], // SASS, Less
|
|
|
|
"elc" => vec![self.path.with_extension("el")], // Emacs Lisp
|
|
|
|
"hi" => vec![self.path.with_extension("hs")], // Haskell
|
|
|
|
"js" => vec![self.path.with_extension("coffee"), self.path.with_extension("ts")], // CoffeeScript, TypeScript
|
|
|
|
"o" => vec![self.path.with_extension("c"), self.path.with_extension("cpp")], // C, C++
|
|
|
|
"pyc" => vec![self.path.with_extension("py")], // Python
|
|
|
|
|
2017-05-07 16:39:01 +00:00
|
|
|
"aux" | // TeX: auxiliary file
|
|
|
|
"bbl" | // BibTeX bibliography file
|
|
|
|
"blg" | // BibTeX log file
|
|
|
|
"lof" | // TeX list of figures
|
|
|
|
"log" | // TeX log file
|
|
|
|
"lot" | // TeX list of tables
|
2016-04-16 21:05:50 +00:00
|
|
|
"toc" => vec![self.path.with_extension("tex")], // TeX table of contents
|
|
|
|
|
|
|
|
_ => vec![], // No source files if none of the above
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
vec![] // No source files if there's no extension, either!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|