Skip to content

Commit

Permalink
Rename CodeMap/FileMap to SourceMap/SourceFile
Browse files Browse the repository at this point in the history
  • Loading branch information
CAD97 committed Aug 23, 2018
1 parent 693c7d6 commit 04d804c
Show file tree
Hide file tree
Showing 34 changed files with 203 additions and 203 deletions.
70 changes: 35 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ env_logger = "0.5"
getopts = "0.2"
derive-new = "0.5"
cargo_metadata = "0.6"
rustc-ap-rustc_target = "230.0.0"
rustc-ap-syntax = "230.0.0"
rustc-ap-syntax_pos = "230.0.0"
rustc-ap-rustc_target = "235.0.0"
rustc-ap-syntax = "235.0.0"
rustc-ap-syntax_pos = "235.0.0"
failure = "0.1.1"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use utils::{count_newlines, mk_sp};

use std::borrow::Cow;
use syntax::ast;
use syntax::codemap::{BytePos, Span, DUMMY_SP};
use syntax::source_map::{BytePos, Span, DUMMY_SP};

/// Returns attributes on the given statement.
pub fn get_attrs_from_stmt(stmt: &ast::Stmt) -> &[ast::Attribute] {
Expand Down
4 changes: 2 additions & 2 deletions src/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
//! .qux
//! ```
use codemap::SpanUtils;
use source_map::SpanUtils;
use comment::rewrite_comment;
use config::IndentStyle;
use expr::rewrite_call;
Expand All @@ -82,7 +82,7 @@ use std::borrow::Cow;
use std::cmp::min;
use std::iter;

use syntax::codemap::{BytePos, Span};
use syntax::source_map::{BytePos, Span};
use syntax::{ast, ptr};

pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -> Option<String> {
Expand Down
10 changes: 5 additions & 5 deletions src/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
// except according to those terms.

use config::lists::*;
use syntax::codemap::Span;
use syntax::source_map::Span;
use syntax::parse::classify;
use syntax::{ast, ptr};

use codemap::SpanUtils;
use source_map::SpanUtils;
use expr::{block_contains_comment, is_simple_block, is_unsafe_block, rewrite_cond, ToExpr};
use items::{span_hi_for_arg, span_lo_for_arg};
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
Expand Down Expand Up @@ -51,7 +51,7 @@ pub fn rewrite_closure(

if let ast::ExprKind::Block(ref block, _) = body.node {
// The body of the closure is an empty block.
if block.stmts.is_empty() && !block_contains_comment(block, context.codemap) {
if block.stmts.is_empty() && !block_contains_comment(block, context.source_map) {
return body
.rewrite(context, shape)
.map(|s| format!("{} {}", prefix, s));
Expand Down Expand Up @@ -114,7 +114,7 @@ fn get_inner_expr<'a>(
fn needs_block(block: &ast::Block, prefix: &str, context: &RewriteContext) -> bool {
is_unsafe_block(block)
|| block.stmts.len() > 1
|| block_contains_comment(block, context.codemap)
|| block_contains_comment(block, context.source_map)
|| prefix.contains('\n')
}

Expand Down Expand Up @@ -304,7 +304,7 @@ pub fn rewrite_last_closure(
let body = match body.node {
ast::ExprKind::Block(ref block, _)
if !is_unsafe_block(block)
&& is_simple_block(block, Some(&body.attrs), context.codemap) =>
&& is_simple_block(block, Some(&body.attrs), context.source_map) =>
{
stmt_expr(&block.stmts[0]).unwrap_or(body)
}
Expand Down
6 changes: 3 additions & 3 deletions src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use std::{self, borrow::Cow, iter};

use itertools::{multipeek, MultiPeek};
use syntax::codemap::Span;
use syntax::source_map::Span;

use config::Config;
use rewrite::RewriteContext;
Expand Down Expand Up @@ -1151,10 +1151,10 @@ pub fn recover_comment_removed(
// We missed some comments. Warn and keep the original text.
if context.config.error_on_unformatted() {
context.report.append(
context.codemap.span_to_filename(span).into(),
context.source_map.span_to_filename(span).into(),
vec![FormattingError::from_span(
&span,
&context.codemap,
&context.source_map,
ErrorKind::LostComment,
)],
);
Expand Down
12 changes: 6 additions & 6 deletions src/config/file_lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ use serde::de::{Deserialize, Deserializer};
use serde::ser::{self, Serialize, Serializer};
use serde_json as json;

use syntax::codemap::{self, FileMap};
use syntax::source_map::{self, SourceFile};

/// A range of lines in a file, inclusive of both ends.
pub struct LineRange {
pub file: Rc<FileMap>,
pub file: Rc<SourceFile>,
pub lo: usize,
pub hi: usize,
}
Expand All @@ -35,11 +35,11 @@ pub enum FileName {
Stdin,
}

impl From<codemap::FileName> for FileName {
fn from(name: codemap::FileName) -> FileName {
impl From<source_map::FileName> for FileName {
fn from(name: source_map::FileName) -> FileName {
match name {
codemap::FileName::Real(p) => FileName::Real(p),
codemap::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
source_map::FileName::Real(p) => FileName::Real(p),
source_map::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
_ => unreachable!(),
}
}
Expand Down
28 changes: 14 additions & 14 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ use std::borrow::Cow;
use std::cmp::min;

use config::lists::*;
use syntax::codemap::{BytePos, CodeMap, Span};
use syntax::source_map::{BytePos, SourceMap, Span};
use syntax::parse::token::DelimToken;
use syntax::{ast, ptr};

use chains::rewrite_chain;
use closures;
use codemap::{LineRangeUtils, SpanUtils};
use source_map::{LineRangeUtils, SpanUtils};
use comment::{
combine_strs_with_missing_comments, contains_comment, recover_comment_removed, rewrite_comment,
rewrite_missing_comment, CharClasses, FindUncommented,
Expand Down Expand Up @@ -425,7 +425,7 @@ fn rewrite_empty_block(
return None;
}

if block.stmts.is_empty() && !block_contains_comment(block, context.codemap) && shape.width >= 2
if block.stmts.is_empty() && !block_contains_comment(block, context.source_map) && shape.width >= 2
{
return Some(format!("{}{}{{}}", prefix, label_str));
}
Expand Down Expand Up @@ -483,7 +483,7 @@ fn rewrite_single_line_block(
label: Option<ast::Label>,
shape: Shape,
) -> Option<String> {
if is_simple_block(block, attrs, context.codemap) {
if is_simple_block(block, attrs, context.source_map) {
let expr_shape = shape.offset_left(last_line_width(prefix))?;
let expr_str = block.stmts[0].rewrite(context, expr_shape)?;
let label_str = rewrite_label(label);
Expand Down Expand Up @@ -769,8 +769,8 @@ impl<'a> ControlFlow<'a> {
let fixed_cost = self.keyword.len() + " { } else { }".len();

if let ast::ExprKind::Block(ref else_node, _) = else_block.node {
if !is_simple_block(self.block, None, context.codemap)
|| !is_simple_block(else_node, None, context.codemap)
if !is_simple_block(self.block, None, context.source_map)
|| !is_simple_block(else_node, None, context.source_map)
|| pat_expr_str.contains('\n')
{
return None;
Expand Down Expand Up @@ -1113,8 +1113,8 @@ fn extract_comment(span: Span, context: &RewriteContext, shape: Shape) -> Option
}
}

pub fn block_contains_comment(block: &ast::Block, codemap: &CodeMap) -> bool {
let snippet = codemap.span_to_snippet(block.span).unwrap();
pub fn block_contains_comment(block: &ast::Block, source_map: &SourceMap) -> bool {
let snippet = source_map.span_to_snippet(block.span).unwrap();
contains_comment(&snippet)
}

Expand All @@ -1125,11 +1125,11 @@ pub fn block_contains_comment(block: &ast::Block, codemap: &CodeMap) -> bool {
pub fn is_simple_block(
block: &ast::Block,
attrs: Option<&[ast::Attribute]>,
codemap: &CodeMap,
source_map: &SourceMap,
) -> bool {
(block.stmts.len() == 1
&& stmt_is_expr(&block.stmts[0])
&& !block_contains_comment(block, codemap)
&& !block_contains_comment(block, source_map)
&& attrs.map_or(true, |a| a.is_empty()))
}

Expand All @@ -1138,10 +1138,10 @@ pub fn is_simple_block(
pub fn is_simple_block_stmt(
block: &ast::Block,
attrs: Option<&[ast::Attribute]>,
codemap: &CodeMap,
source_map: &SourceMap,
) -> bool {
block.stmts.len() <= 1
&& !block_contains_comment(block, codemap)
&& !block_contains_comment(block, source_map)
&& attrs.map_or(true, |a| a.is_empty())
}

Expand All @@ -1150,10 +1150,10 @@ pub fn is_simple_block_stmt(
pub fn is_empty_block(
block: &ast::Block,
attrs: Option<&[ast::Attribute]>,
codemap: &CodeMap,
source_map: &SourceMap,
) -> bool {
block.stmts.is_empty()
&& !block_contains_comment(block, codemap)
&& !block_contains_comment(block, source_map)
&& attrs.map_or(true, |a| inner_attributes(a).is_empty())
}

Expand Down
Loading

0 comments on commit 04d804c

Please sign in to comment.