Commit 5d32ad0 1 parent 2541fc9 commit 5d32ad0 Copy full SHA for 5d32ad0
File tree 3 files changed +20
-29
lines changed
3 files changed +20
-29
lines changed Original file line number Diff line number Diff line change
1
+ module . exports = function ( comments ) {
2
+ for ( var i = 0 ; i < comments . length ; i ++ ) {
3
+ var comment = comments [ i ] ;
4
+ if ( comment . type === "CommentBlock" ) {
5
+ comment . type = "Block" ;
6
+ } else if ( comment . type === "CommentLine" ) {
7
+ comment . type = "Line" ;
8
+ }
9
+ // sometimes comments don't get ranges computed,
10
+ // even with options.ranges === true
11
+ if ( ! comment . range ) {
12
+ comment . range = [ comment . start , comment . end ] ;
13
+ }
14
+ }
15
+ } ;
Original file line number Diff line number Diff line change @@ -3,18 +3,4 @@ exports.attachComments = require("./attachComments");
3
3
exports . toTokens = require ( "./toTokens" ) ;
4
4
exports . toAST = require ( "./toAST" ) ;
5
5
6
- exports . convertComments = function ( comments ) {
7
- for ( var i = 0 ; i < comments . length ; i ++ ) {
8
- var comment = comments [ i ] ;
9
- if ( comment . type === "CommentBlock" ) {
10
- comment . type = "Block" ;
11
- } else if ( comment . type === "CommentLine" ) {
12
- comment . type = "Line" ;
13
- }
14
- // sometimes comments don't get ranges computed,
15
- // even with options.ranges === true
16
- if ( ! comment . range ) {
17
- comment . range = [ comment . start , comment . end ] ;
18
- }
19
- }
20
- } ;
6
+ exports . convertComments = require ( "./convertComments" ) ;
Original file line number Diff line number Diff line change
1
+ var convertComments = require ( "./convertComments" ) ;
2
+
1
3
module . exports = function ( ast , traverse , code ) {
2
4
var state = { source : code } ;
3
5
ast . range = [ ast . start , ast . end ] ;
@@ -15,18 +17,6 @@ function changeToLiteral(node, state) {
15
17
}
16
18
}
17
19
18
- function changeComments ( nodeComments ) {
19
- for ( var i = 0 ; i < nodeComments . length ; i ++ ) {
20
- var comment = nodeComments [ i ] ;
21
- if ( comment . type === "CommentLine" ) {
22
- comment . type = "Line" ;
23
- } else if ( comment . type === "CommentBlock" ) {
24
- comment . type = "Block" ;
25
- }
26
- comment . range = [ comment . start , comment . end ] ;
27
- }
28
- }
29
-
30
20
var astTransformVisitor = {
31
21
noScope : true ,
32
22
enter ( path ) {
@@ -43,11 +33,11 @@ var astTransformVisitor = {
43
33
}
44
34
45
35
if ( node . trailingComments ) {
46
- changeComments ( node . trailingComments ) ;
36
+ convertComments ( node . trailingComments ) ;
47
37
}
48
38
49
39
if ( node . leadingComments ) {
50
- changeComments ( node . leadingComments ) ;
40
+ convertComments ( node . leadingComments ) ;
51
41
}
52
42
53
43
// make '_paths' non-enumerable (babel-eslint #200)
You can’t perform that action at this time.
0 commit comments