Skip to content

Commit

Permalink
upgrade dprint to 0.9.10 (#4601)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju authored Apr 3, 2020
1 parent 13db64f commit efb022a
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 118 deletions.
13 changes: 4 additions & 9 deletions Cargo.lock

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

8 changes: 1 addition & 7 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ byteorder = "1.3.4"
clap = "2.33.0"
dirs = "2.0.2"
dlopen = "0.1.8"
dprint-plugin-typescript = "0.9.6"
dprint-plugin-typescript = "0.9.10"
futures = { version = "0.3.4", features = ["compat", "io-compat"] }
glob = "0.3.0"
http = "0.2.0"
Expand Down Expand Up @@ -63,12 +63,6 @@ webpki-roots = "0.19.0"
walkdir = "2.3.1"
warp = "0.2.2"
semver-parser = "0.9.0"
# TODO(bartlomieju): make sure we're using exactly same versions
# of "swc_*" as dprint-plugin-typescript
swc_common = "=0.5.9"
swc_ecma_ast = "=0.18.1"
swc_ecma_parser = "=0.21.8"
swc_ecma_parser_macros = "=0.4.1"
uuid = { version = "0.8", features = ["v4"] }

[target.'cfg(windows)'.dependencies]
Expand Down
19 changes: 9 additions & 10 deletions cli/doc/class.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use crate::swc_common::SourceMap;
use crate::swc_common::Spanned;
use crate::swc_ecma_ast;
use serde::Serialize;
use swc_common;
use swc_common::SourceMap;
use swc_common::Spanned;
use swc_ecma_ast;

use super::function::function_to_function_def;
use super::function::FunctionDef;
Expand Down Expand Up @@ -68,7 +67,7 @@ fn prop_name_to_string(
source_map: &SourceMap,
prop_name: &swc_ecma_ast::PropName,
) -> String {
use swc_ecma_ast::PropName;
use crate::swc_ecma_ast::PropName;
match prop_name {
PropName::Ident(ident) => ident.sym.to_string(),
PropName::Str(str_) => str_.value.to_string(),
Expand All @@ -89,7 +88,7 @@ pub fn get_doc_for_class_decl(

let super_class: Option<String> = match &class_decl.class.super_class {
Some(boxed) => {
use swc_ecma_ast::Expr;
use crate::swc_ecma_ast::Expr;
let expr: &Expr = &**boxed;
match expr {
Expr::Ident(ident) => Some(ident.sym.to_string()),
Expand All @@ -107,7 +106,7 @@ pub fn get_doc_for_class_decl(
.collect();

for member in &class_decl.class.body {
use swc_ecma_ast::ClassMember::*;
use crate::swc_ecma_ast::ClassMember::*;

match member {
Constructor(ctor) => {
Expand All @@ -118,8 +117,8 @@ pub fn get_doc_for_class_decl(
let mut params = vec![];

for param in &ctor.params {
use swc_ecma_ast::Pat;
use swc_ecma_ast::PatOrTsParamProp::*;
use crate::swc_ecma_ast::Pat;
use crate::swc_ecma_ast::PatOrTsParamProp::*;

let param_def = match param {
Pat(pat) => match pat {
Expand Down Expand Up @@ -188,7 +187,7 @@ pub fn get_doc_for_class_decl(
.as_ref()
.map(|rt| ts_type_ann_to_def(&doc_parser.source_map, rt));

use swc_ecma_ast::Expr;
use crate::swc_ecma_ast::Expr;
let prop_name = match &*class_prop.key {
Expr::Ident(ident) => ident.sym.to_string(),
_ => "<TODO>".to_string(),
Expand Down
4 changes: 2 additions & 2 deletions cli/doc/enum.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use crate::swc_ecma_ast;
use serde::Serialize;
use swc_ecma_ast;

use super::parser::DocParser;

Expand All @@ -24,7 +24,7 @@ pub fn get_doc_for_ts_enum_decl(
let mut members = vec![];

for enum_member in &enum_decl.members {
use swc_ecma_ast::TsEnumMemberId::*;
use crate::swc_ecma_ast::TsEnumMemberId::*;

let member_name = match &enum_member.id {
Ident(ident) => ident.sym.to_string(),
Expand Down
4 changes: 2 additions & 2 deletions cli/doc/function.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use crate::swc_ecma_ast;
use serde::Serialize;
use swc_ecma_ast;

use super::parser::DocParser;
use super::ts_type::ts_type_ann_to_def;
Expand All @@ -24,7 +24,7 @@ pub fn function_to_function_def(
let mut params = vec![];

for param in &function.params {
use swc_ecma_ast::Pat;
use crate::swc_ecma_ast::Pat;

let param_def = match param {
Pat::Ident(ident) => {
Expand Down
14 changes: 7 additions & 7 deletions cli/doc/interface.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use crate::swc_ecma_ast;
use serde::Serialize;
use swc_ecma_ast;

use super::parser::DocParser;
use super::ts_type::ts_type_ann_to_def;
Expand Down Expand Up @@ -52,8 +52,8 @@ pub struct InterfaceDef {
}

fn expr_to_name(expr: &swc_ecma_ast::Expr) -> String {
use swc_ecma_ast::Expr::*;
use swc_ecma_ast::ExprOrSuper::*;
use crate::swc_ecma_ast::Expr::*;
use crate::swc_ecma_ast::ExprOrSuper::*;

match expr {
Ident(ident) => ident.sym.to_string(),
Expand All @@ -80,7 +80,7 @@ pub fn get_doc_for_ts_interface_decl(
let mut call_signatures = vec![];

for type_element in &interface_decl.body.body {
use swc_ecma_ast::TsTypeElement::*;
use crate::swc_ecma_ast::TsTypeElement::*;

match &type_element {
TsMethodSignature(ts_method_sig) => {
Expand All @@ -89,7 +89,7 @@ pub fn get_doc_for_ts_interface_decl(
let mut params = vec![];

for param in &ts_method_sig.params {
use swc_ecma_ast::TsFnParam::*;
use crate::swc_ecma_ast::TsFnParam::*;

let param_def = match param {
Ident(ident) => {
Expand Down Expand Up @@ -141,7 +141,7 @@ pub fn get_doc_for_ts_interface_decl(
let mut params = vec![];

for param in &ts_prop_sig.params {
use swc_ecma_ast::TsFnParam::*;
use crate::swc_ecma_ast::TsFnParam::*;

let param_def = match param {
Ident(ident) => {
Expand Down Expand Up @@ -188,7 +188,7 @@ pub fn get_doc_for_ts_interface_decl(

let mut params = vec![];
for param in &ts_call_sig.params {
use swc_ecma_ast::TsFnParam::*;
use crate::swc_ecma_ast::TsFnParam::*;

let param_def = match param {
Ident(ident) => {
Expand Down
9 changes: 4 additions & 5 deletions cli/doc/module.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use swc_common;
use swc_common::Spanned;
use swc_ecma_ast;
use crate::swc_common::Spanned;
use crate::swc_ecma_ast;

use super::parser::DocParser;
use super::DocNode;
Expand All @@ -12,7 +11,7 @@ pub fn get_doc_node_for_export_decl(
export_decl: &swc_ecma_ast::ExportDecl,
) -> DocNode {
let export_span = export_decl.span();
use swc_ecma_ast::Decl;
use crate::swc_ecma_ast::Decl;

let js_doc = doc_parser.js_doc_for_span(export_span);
let location = doc_parser
Expand Down Expand Up @@ -165,7 +164,7 @@ pub fn get_doc_nodes_for_named_export(
.specifiers
.iter()
.map(|export_specifier| {
use swc_ecma_ast::ExportSpecifier::*;
use crate::swc_ecma_ast::ExportSpecifier::*;

match export_specifier {
Named(named_export_specifier) => {
Expand Down
8 changes: 4 additions & 4 deletions cli/doc/namespace.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use crate::swc_ecma_ast;
use serde::Serialize;
use swc_ecma_ast;

use super::parser::DocParser;
use super::DocNode;
Expand All @@ -22,7 +22,7 @@ pub fn get_doc_for_ts_namespace_decl(
.into();
let namespace_name = ts_namespace_decl.id.sym.to_string();

use swc_ecma_ast::TsNamespaceBody::*;
use crate::swc_ecma_ast::TsNamespaceBody::*;

let elements = match &*ts_namespace_decl.body {
TsModuleBlock(ts_module_block) => {
Expand Down Expand Up @@ -54,14 +54,14 @@ pub fn get_doc_for_ts_module(
doc_parser: &DocParser,
ts_module_decl: &swc_ecma_ast::TsModuleDecl,
) -> (String, NamespaceDef) {
use swc_ecma_ast::TsModuleName;
use crate::swc_ecma_ast::TsModuleName;
let namespace_name = match &ts_module_decl.id {
TsModuleName::Ident(ident) => ident.sym.to_string(),
TsModuleName::Str(str_) => str_.value.to_string(),
};

let elements = if let Some(body) = &ts_module_decl.body {
use swc_ecma_ast::TsNamespaceBody::*;
use crate::swc_ecma_ast::TsNamespaceBody::*;

match &body {
TsModuleBlock(ts_module_block) => {
Expand Down
4 changes: 2 additions & 2 deletions cli/doc/node.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use crate::swc_common;
use serde::Serialize;
use swc_common;

#[derive(Debug, PartialEq, Serialize, Clone)]
#[serde(rename_all = "camelCase")]
Expand Down Expand Up @@ -30,7 +30,7 @@ pub struct Location {

impl Into<Location> for swc_common::Loc {
fn into(self) -> Location {
use swc_common::FileName::*;
use crate::swc_common::FileName::*;

let filename = match &self.file.name {
Real(path_buf) => path_buf.to_string_lossy().to_string(),
Expand Down
60 changes: 26 additions & 34 deletions cli/doc/parser.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use crate::swc_common;
use crate::swc_common::comments::CommentKind;
use crate::swc_common::comments::Comments;
use crate::swc_common::errors::Diagnostic;
use crate::swc_common::errors::DiagnosticBuilder;
use crate::swc_common::errors::Emitter;
use crate::swc_common::errors::Handler;
use crate::swc_common::errors::HandlerFlags;
use crate::swc_common::FileName;
use crate::swc_common::Globals;
use crate::swc_common::SourceMap;
use crate::swc_common::Span;
use crate::swc_ecma_ast;
use crate::swc_ecma_ast::Decl;
use crate::swc_ecma_ast::ModuleDecl;
use crate::swc_ecma_ast::Stmt;
use crate::swc_ecma_parser::lexer::Lexer;
use crate::swc_ecma_parser::JscTarget;
use crate::swc_ecma_parser::Parser;
use crate::swc_ecma_parser::Session;
use crate::swc_ecma_parser::SourceFileInput;
use crate::swc_ecma_parser::Syntax;
use crate::swc_ecma_parser::TsConfig;
use regex::Regex;
use std::sync::Arc;
use std::sync::RwLock;
use swc_common;
use swc_common::comments::CommentKind;
use swc_common::comments::Comments;
use swc_common::errors::Diagnostic;
use swc_common::errors::DiagnosticBuilder;
use swc_common::errors::Emitter;
use swc_common::errors::Handler;
use swc_common::errors::HandlerFlags;
use swc_common::FileName;
use swc_common::Globals;
use swc_common::SourceMap;
use swc_common::Span;
use swc_ecma_parser::lexer::Lexer;
use swc_ecma_parser::JscTarget;
use swc_ecma_parser::Parser;
use swc_ecma_parser::Session;
use swc_ecma_parser::SourceFileInput;
use swc_ecma_parser::Syntax;
use swc_ecma_parser::TsConfig;

use super::DocNode;
use super::DocNodeKind;
Expand Down Expand Up @@ -118,10 +122,8 @@ impl DocParser {

pub fn get_doc_nodes_for_module_decl(
&self,
module_decl: &swc_ecma_ast::ModuleDecl,
module_decl: &ModuleDecl,
) -> Vec<DocNode> {
use swc_ecma_ast::ModuleDecl;

match module_decl {
ModuleDecl::ExportDecl(export_decl) => {
vec![super::module::get_doc_node_for_export_decl(
Expand All @@ -143,12 +145,7 @@ impl DocParser {
}
}

pub fn get_doc_node_for_stmt(
&self,
stmt: &swc_ecma_ast::Stmt,
) -> Option<DocNode> {
use swc_ecma_ast::Stmt;

pub fn get_doc_node_for_stmt(&self, stmt: &Stmt) -> Option<DocNode> {
match stmt {
Stmt::Decl(decl) => self.get_doc_node_for_decl(decl),
_ => None,
Expand All @@ -161,12 +158,7 @@ impl DocParser {
(js_doc, location)
}

pub fn get_doc_node_for_decl(
&self,
decl: &swc_ecma_ast::Decl,
) -> Option<DocNode> {
use swc_ecma_ast::Decl;

pub fn get_doc_node_for_decl(&self, decl: &Decl) -> Option<DocNode> {
match decl {
Decl::Class(class_decl) => {
if !class_decl.declare {
Expand Down
1 change: 1 addition & 0 deletions cli/doc/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::colors;
use crate::doc;
use crate::doc::ts_type::TsTypeDefKind;
use crate::doc::DocNodeKind;
use crate::swc_ecma_ast;

pub fn format(doc_nodes: Vec<doc::DocNode>) -> String {
format_(doc_nodes, 0)
Expand Down
Loading

0 comments on commit efb022a

Please sign in to comment.