about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorDonato Sciarra <sciarp@gmail.com>2018-08-18 12:13:52 +0200
committerDonato Sciarra <sciarp@gmail.com>2018-08-19 23:00:59 +0200
commitd6dcbcd4e11a1b787a9db1fa43a49907e8bccecf (patch)
tree37af96f2adba41bfc3ff98e45006918de702d44c /src/libsyntax
parentc65547337831babea8d9052b960649309263df36 (diff)
downloadrust-d6dcbcd4e11a1b787a9db1fa43a49907e8bccecf.tar.gz
rust-d6dcbcd4e11a1b787a9db1fa43a49907e8bccecf.zip
mv FileMap SourceFile
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/codemap.rs56
-rw-r--r--src/libsyntax/ext/quote.rs2
-rw-r--r--src/libsyntax/json.rs2
-rw-r--r--src/libsyntax/parse/lexer/mod.rs10
-rw-r--r--src/libsyntax/parse/mod.rs8
-rw-r--r--src/libsyntax/test.rs2
6 files changed, 40 insertions, 40 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 8175e2495c5..c9a9fbf4d7b 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -12,7 +12,7 @@
 //! from integer byte positions to the original source code location. Each bit
 //! of source parsed during crate parsing (typically files, in-memory strings,
 //! or various bits of macro expansion) cover a continuous range of bytes in the
-//! SourceMap and are represented by FileMaps. Byte positions are stored in
+//! SourceMap and are represented by SourceFiles. Byte positions are stored in
 //! `spans` and used pervasively in the compiler. They are absolute positions
 //! within the SourceMap, which upon request can be converted to line and column
 //! information, source code snippets, etc.
@@ -62,7 +62,7 @@ pub fn dummy_spanned<T>(t: T) -> Spanned<T> {
 }
 
 // _____________________________________________________________________________
-// FileMap, MultiByteChar, FileName, FileLines
+// SourceFile, MultiByteChar, FileName, FileLines
 //
 
 /// An abstraction over the fs operations used by the Parser.
@@ -102,14 +102,14 @@ impl FileLoader for RealFileLoader {
     }
 }
 
-// This is a FileMap identifier that is used to correlate FileMaps between
+// This is a SourceFile identifier that is used to correlate SourceFiles between
 // subsequent compilation sessions (which is something we need to do during
 // incremental compilation).
 #[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)]
 pub struct StableFilemapId(u128);
 
 impl StableFilemapId {
-    pub fn new(filemap: &FileMap) -> StableFilemapId {
+    pub fn new(filemap: &SourceFile) -> StableFilemapId {
         let mut hasher = StableHasher::new();
 
         filemap.name.hash(&mut hasher);
@@ -125,15 +125,15 @@ impl StableFilemapId {
 //
 
 pub(super) struct SourceMapFiles {
-    pub(super) file_maps: Vec<Lrc<FileMap>>,
-    stable_id_to_filemap: FxHashMap<StableFilemapId, Lrc<FileMap>>
+    pub(super) file_maps: Vec<Lrc<SourceFile>>,
+    stable_id_to_filemap: FxHashMap<StableFilemapId, Lrc<SourceFile>>
 }
 
 pub struct SourceMap {
     pub(super) files: Lock<SourceMapFiles>,
     file_loader: Box<dyn FileLoader + Sync + Send>,
     // This is used to apply the file path remapping as specified via
-    // --remap-path-prefix to all FileMaps allocated within this SourceMap.
+    // --remap-path-prefix to all SourceFiles allocated within this SourceMap.
     path_mapping: FilePathMapping,
     /// In case we are in a doctest, replace all file names with the PathBuf,
     /// and add the given offsets to the line info
@@ -184,7 +184,7 @@ impl SourceMap {
         self.file_loader.file_exists(path)
     }
 
-    pub fn load_file(&self, path: &Path) -> io::Result<Lrc<FileMap>> {
+    pub fn load_file(&self, path: &Path) -> io::Result<Lrc<SourceFile>> {
         let src = self.file_loader.read_file(path)?;
         let filename = if let Some((ref name, _)) = self.doctest_offset {
             name.clone()
@@ -194,11 +194,11 @@ impl SourceMap {
         Ok(self.new_filemap(filename, src))
     }
 
-    pub fn files(&self) -> LockGuard<Vec<Lrc<FileMap>>> {
+    pub fn files(&self) -> LockGuard<Vec<Lrc<SourceFile>>> {
         LockGuard::map(self.files.borrow(), |files| &mut files.file_maps)
     }
 
-    pub fn filemap_by_stable_id(&self, stable_id: StableFilemapId) -> Option<Lrc<FileMap>> {
+    pub fn filemap_by_stable_id(&self, stable_id: StableFilemapId) -> Option<Lrc<SourceFile>> {
         self.files.borrow().stable_id_to_filemap.get(&stable_id).map(|fm| fm.clone())
     }
 
@@ -212,8 +212,8 @@ impl SourceMap {
     }
 
     /// Creates a new filemap.
-    /// This does not ensure that only one FileMap exists per file name.
-    pub fn new_filemap(&self, filename: FileName, src: String) -> Lrc<FileMap> {
+    /// This does not ensure that only one SourceFile exists per file name.
+    pub fn new_filemap(&self, filename: FileName, src: String) -> Lrc<SourceFile> {
         let start_pos = self.next_start_pos();
 
         // The path is used to determine the directory for loading submodules and
@@ -230,7 +230,7 @@ impl SourceMap {
             },
             other => (other, false),
         };
-        let filemap = Lrc::new(FileMap::new(
+        let filemap = Lrc::new(SourceFile::new(
             filename,
             was_remapped,
             unmapped_path,
@@ -246,7 +246,7 @@ impl SourceMap {
         filemap
     }
 
-    /// Allocates a new FileMap representing a source file from an external
+    /// Allocates a new SourceFile representing a source file from an external
     /// crate. The source code of such an "imported filemap" is not available,
     /// but we still know enough to generate accurate debuginfo location
     /// information for things inlined from other crates.
@@ -260,7 +260,7 @@ impl SourceMap {
                                 mut file_local_lines: Vec<BytePos>,
                                 mut file_local_multibyte_chars: Vec<MultiByteChar>,
                                 mut file_local_non_narrow_chars: Vec<NonNarrowChar>)
-                                -> Lrc<FileMap> {
+                                -> Lrc<SourceFile> {
         let start_pos = self.next_start_pos();
 
         let end_pos = Pos::from_usize(start_pos + source_len);
@@ -278,7 +278,7 @@ impl SourceMap {
             *swc = *swc + start_pos;
         }
 
-        let filemap = Lrc::new(FileMap {
+        let filemap = Lrc::new(SourceFile {
             name: filename,
             name_was_remapped,
             unmapped_path: None,
@@ -326,7 +326,7 @@ impl SourceMap {
     pub fn lookup_char_pos(&self, pos: BytePos) -> Loc {
         let chpos = self.bytepos_to_file_charpos(pos);
         match self.lookup_line(pos) {
-            Ok(FileMapAndLine { fm: f, line: a }) => {
+            Ok(SourceFileAndLine { fm: f, line: a }) => {
                 let line = a + 1; // Line numbers start at 1
                 let linebpos = f.lines[a];
                 let linechpos = self.bytepos_to_file_charpos(linebpos);
@@ -386,13 +386,13 @@ impl SourceMap {
     }
 
     // If the relevant filemap is empty, we don't return a line number.
-    pub fn lookup_line(&self, pos: BytePos) -> Result<FileMapAndLine, Lrc<FileMap>> {
+    pub fn lookup_line(&self, pos: BytePos) -> Result<SourceFileAndLine, Lrc<SourceFile>> {
         let idx = self.lookup_filemap_idx(pos);
 
         let f = (*self.files.borrow().file_maps)[idx].clone();
 
         match f.lookup_line(pos) {
-            Some(line) => Ok(FileMapAndLine { fm: f, line: line }),
+            Some(line) => Ok(SourceFileAndLine { fm: f, line: line }),
             None => Err(f)
         }
     }
@@ -463,7 +463,7 @@ impl SourceMap {
 
     pub fn span_to_unmapped_path(&self, sp: Span) -> FileName {
         self.lookup_char_pos(sp.lo()).file.unmapped_path.clone()
-            .expect("SourceMap::span_to_unmapped_path called for imported FileMap?")
+            .expect("SourceMap::span_to_unmapped_path called for imported SourceFile?")
     }
 
     pub fn is_multiline(&self, sp: Span) -> bool {
@@ -798,7 +798,7 @@ impl SourceMap {
         }
     }
 
-    pub fn get_filemap(&self, filename: &FileName) -> Option<Lrc<FileMap>> {
+    pub fn get_filemap(&self, filename: &FileName) -> Option<Lrc<SourceFile>> {
         for fm in self.files.borrow().file_maps.iter() {
             if *filename == fm.name {
                 return Some(fm.clone());
@@ -807,12 +807,12 @@ impl SourceMap {
         None
     }
 
-    /// For a global BytePos compute the local offset within the containing FileMap
-    pub fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos {
+    /// For a global BytePos compute the local offset within the containing SourceFile
+    pub fn lookup_byte_offset(&self, bpos: BytePos) -> SourceFileAndBytePos {
         let idx = self.lookup_filemap_idx(bpos);
         let fm = (*self.files.borrow().file_maps)[idx].clone();
         let offset = bpos - fm.start_pos;
-        FileMapAndBytePos {fm: fm, pos: offset}
+        SourceFileAndBytePos {fm: fm, pos: offset}
     }
 
     /// Converts an absolute BytePos to a CharPos relative to the filemap.
@@ -820,7 +820,7 @@ impl SourceMap {
         let idx = self.lookup_filemap_idx(bpos);
         let map = &(*self.files.borrow().file_maps)[idx];
 
-        // The number of extra bytes due to multibyte chars in the FileMap
+        // The number of extra bytes due to multibyte chars in the SourceFile
         let mut total_extra_bytes = 0;
 
         for mbc in map.multibyte_chars.iter() {
@@ -966,7 +966,7 @@ impl SourceMapper for SourceMap {
         }
         sp
     }
-    fn ensure_filemap_source_present(&self, file_map: Lrc<FileMap>) -> bool {
+    fn ensure_filemap_source_present(&self, file_map: Lrc<SourceFile>) -> bool {
         file_map.add_external_src(
             || match file_map.name {
                 FileName::Real(ref name) => self.file_loader.read_file(name).ok(),
@@ -1192,7 +1192,7 @@ mod tests {
     /// `substring` in `source_text`.
     trait SourceMapExtension {
         fn span_substr(&self,
-                    file: &Lrc<FileMap>,
+                    file: &Lrc<SourceFile>,
                     source_text: &str,
                     substring: &str,
                     n: usize)
@@ -1201,7 +1201,7 @@ mod tests {
 
     impl SourceMapExtension for SourceMap {
         fn span_substr(&self,
-                    file: &Lrc<FileMap>,
+                    file: &Lrc<SourceFile>,
                     source_text: &str,
                     substring: &str,
                     n: usize)
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs
index bc891700fc1..a4b19681164 100644
--- a/src/libsyntax/ext/quote.rs
+++ b/src/libsyntax/ext/quote.rs
@@ -802,7 +802,7 @@ fn mk_stmts_let(cx: &ExtCtxt, sp: Span) -> Vec<ast::Stmt> {
     // they happen to have a compiler on hand). Over all, the phase distinction
     // just makes quotes "hard to attribute". Possibly this could be fixed
     // by recreating some of the original qq machinery in the tt regime
-    // (pushing fake FileMaps onto the parser to account for original sites
+    // (pushing fake SourceFiles onto the parser to account for original sites
     // of quotes, for example) but at this point it seems not likely to be
     // worth the hassle.
 
diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs
index 22de184938f..a090083f608 100644
--- a/src/libsyntax/json.rs
+++ b/src/libsyntax/json.rs
@@ -340,7 +340,7 @@ impl DiagnosticSpan {
 }
 
 impl DiagnosticSpanLine {
-    fn line_from_filemap(fm: &syntax_pos::FileMap,
+    fn line_from_filemap(fm: &syntax_pos::SourceFile,
                          index: usize,
                          h_start: usize,
                          h_end: usize)
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs
index c1919434e37..654ac692338 100644
--- a/src/libsyntax/parse/lexer/mod.rs
+++ b/src/libsyntax/parse/lexer/mod.rs
@@ -49,7 +49,7 @@ pub struct StringReader<'a> {
     pub pos: BytePos,
     /// The current character (which has been read from self.pos)
     pub ch: Option<char>,
-    pub filemap: Lrc<syntax_pos::FileMap>,
+    pub filemap: Lrc<syntax_pos::SourceFile>,
     /// Stop reading src at this index.
     pub end_src_index: usize,
     // cached:
@@ -180,7 +180,7 @@ impl<'a> StringReader<'a> {
     }
 
     /// For comments.rs, which hackily pokes into next_pos and ch
-    fn new_raw(sess: &'a ParseSess, filemap: Lrc<syntax_pos::FileMap>, override_span: Option<Span>)
+    fn new_raw(sess: &'a ParseSess, filemap: Lrc<syntax_pos::SourceFile>, override_span: Option<Span>)
         -> Self
     {
         let mut sr = StringReader::new_raw_internal(sess, filemap, override_span);
@@ -189,7 +189,7 @@ impl<'a> StringReader<'a> {
         sr
     }
 
-    fn new_raw_internal(sess: &'a ParseSess, filemap: Lrc<syntax_pos::FileMap>,
+    fn new_raw_internal(sess: &'a ParseSess, filemap: Lrc<syntax_pos::SourceFile>,
         override_span: Option<Span>) -> Self
     {
         if filemap.src.is_none() {
@@ -221,7 +221,7 @@ impl<'a> StringReader<'a> {
         }
     }
 
-    pub fn new(sess: &'a ParseSess, filemap: Lrc<syntax_pos::FileMap>, override_span: Option<Span>)
+    pub fn new(sess: &'a ParseSess, filemap: Lrc<syntax_pos::SourceFile>, override_span: Option<Span>)
         -> Self
     {
         let mut sr = StringReader::new_raw(sess, filemap, override_span);
@@ -468,7 +468,7 @@ impl<'a> StringReader<'a> {
     }
 
     /// Advance the StringReader by one character. If a newline is
-    /// discovered, add it to the FileMap's list of line start offsets.
+    /// discovered, add it to the SourceFile's list of line start offsets.
     crate fn bump(&mut self) {
         let next_src_index = self.src_index(self.next_pos);
         if next_src_index < self.end_src_index {
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index d43cbf38064..65bab94c6bc 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -14,7 +14,7 @@ use rustc_data_structures::sync::{Lrc, Lock};
 use ast::{self, CrateConfig, NodeId};
 use early_buffered_lints::{BufferedEarlyLint, BufferedEarlyLintId};
 use codemap::{SourceMap, FilePathMapping};
-use syntax_pos::{Span, FileMap, FileName, MultiSpan};
+use syntax_pos::{Span, SourceFile, FileName, MultiSpan};
 use errors::{Handler, ColorConfig, DiagnosticBuilder};
 use feature_gate::UnstableFeatures;
 use parse::parser::Parser;
@@ -203,7 +203,7 @@ crate fn new_sub_parser_from_file<'a>(sess: &'a ParseSess,
 }
 
 /// Given a filemap and config, return a parser
-fn filemap_to_parser(sess: & ParseSess, filemap: Lrc<FileMap>) -> Parser {
+fn filemap_to_parser(sess: & ParseSess, filemap: Lrc<SourceFile>) -> Parser {
     let end_pos = filemap.end_pos;
     let mut parser = stream_to_parser(sess, filemap_to_stream(sess, filemap, None));
 
@@ -226,7 +226,7 @@ pub fn new_parser_from_tts(sess: &ParseSess, tts: Vec<TokenTree>) -> Parser {
 /// Given a session and a path and an optional span (for error reporting),
 /// add the path to the session's codemap and return the new filemap.
 fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
-                   -> Lrc<FileMap> {
+                   -> Lrc<SourceFile> {
     match sess.codemap().load_file(path) {
         Ok(filemap) => filemap,
         Err(e) => {
@@ -240,7 +240,7 @@ fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
 }
 
 /// Given a filemap, produce a sequence of token-trees
-pub fn filemap_to_stream(sess: &ParseSess, filemap: Lrc<FileMap>, override_span: Option<Span>)
+pub fn filemap_to_stream(sess: &ParseSess, filemap: Lrc<SourceFile>, override_span: Option<Span>)
                          -> TokenStream {
     let mut srdr = lexer::StringReader::new(sess, filemap, override_span);
     srdr.real_token();
diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs
index 633de812a87..b85fbae587a 100644
--- a/src/libsyntax/test.rs
+++ b/src/libsyntax/test.rs
@@ -20,7 +20,7 @@ use std::slice;
 use std::mem;
 use std::vec;
 use attr::{self, HasAttrs};
-use syntax_pos::{self, DUMMY_SP, NO_EXPANSION, Span, FileMap, BytePos};
+use syntax_pos::{self, DUMMY_SP, NO_EXPANSION, Span, SourceFile, BytePos};
 
 use codemap::{self, SourceMap, ExpnInfo, MacroAttribute, dummy_spanned};
 use errors;