Fix location info on FunctionTypeParam nodes (#565)

This commit is contained in:
Michal Srb
2017-06-05 17:41:46 +01:00
committed by Henry Zhu
parent e579109f0b
commit bbc3cd45cf
18 changed files with 64 additions and 256 deletions

View File

@@ -708,7 +708,7 @@ export default (superClass: Class<Parser>): Class<Parser> => class extends super
} }
reinterpretTypeAsFunctionTypeParam(type: N.FlowType): N.FlowFunctionTypeParam { reinterpretTypeAsFunctionTypeParam(type: N.FlowType): N.FlowFunctionTypeParam {
const node = this.startNodeAt(type.start, type.loc); const node = this.startNodeAt(type.start, type.loc.start);
node.name = null; node.name = null;
node.optional = false; node.optional = false;
node.typeAnnotation = type; node.typeAnnotation = type;
@@ -921,7 +921,7 @@ export default (superClass: Class<Parser>): Class<Parser> => class extends super
const param = this.flowParsePrefixType(); const param = this.flowParsePrefixType();
if (!this.state.noAnonFunctionType && this.eat(tt.arrow)) { if (!this.state.noAnonFunctionType && this.eat(tt.arrow)) {
// TODO: This should be a type error. Passing in a SourceLocation, and it expects a Position. // TODO: This should be a type error. Passing in a SourceLocation, and it expects a Position.
const node = this.startNodeAt(param.start, param.loc); const node = this.startNodeAt(param.start, param.loc.start);
node.params = [this.reinterpretTypeAsFunctionTypeParam(param)]; node.params = [this.reinterpretTypeAsFunctionTypeParam(param)];
node.rest = null; node.rest = null;
node.returnType = this.flowParseType(); node.returnType = this.flowParseType();

View File

@@ -66,14 +66,8 @@
"end": 23, "end": 23,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 9
"column": 9
},
"end": {
"line": 1,
"column": 15
}
}, },
"end": { "end": {
"line": 1, "line": 1,
@@ -87,14 +81,8 @@
"end": 18, "end": 18,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 9
"column": 9
},
"end": {
"line": 1,
"column": 15
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -66,14 +66,8 @@
"end": 30, "end": 30,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 9
"column": 9
},
"end": {
"line": 1,
"column": 22
}
}, },
"end": { "end": {
"line": 1, "line": 1,
@@ -87,14 +81,8 @@
"end": 25, "end": 25,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 9
"column": 9
},
"end": {
"line": 1,
"column": 22
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -109,14 +109,8 @@
"end": 27, "end": 27,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 14
"column": 14
},
"end": {
"line": 1,
"column": 20
}
}, },
"end": { "end": {
"line": 1, "line": 1,
@@ -130,14 +124,8 @@
"end": 23, "end": 23,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 14
"column": 14
},
"end": {
"line": 1,
"column": 20
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -96,14 +96,8 @@
"end": 35, "end": 35,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 18
"column": 18
},
"end": {
"line": 1,
"column": 24
}
}, },
"end": { "end": {
"line": 1, "line": 1,
@@ -117,14 +111,8 @@
"end": 27, "end": 27,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 18
"column": 18
},
"end": {
"line": 1,
"column": 24
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -96,14 +96,8 @@
"end": 35, "end": 35,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 18
"column": 18
},
"end": {
"line": 1,
"column": 24
}
}, },
"end": { "end": {
"line": 1, "line": 1,
@@ -117,14 +111,8 @@
"end": 27, "end": 27,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 18
"column": 18
},
"end": {
"line": 1,
"column": 24
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -66,14 +66,8 @@
"end": 27, "end": 27,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 9
"column": 9
},
"end": {
"line": 1,
"column": 16
}
}, },
"end": { "end": {
"line": 1, "line": 1,
@@ -87,14 +81,8 @@
"end": 19, "end": 19,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 9
"column": 9
},
"end": {
"line": 1,
"column": 16
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -66,14 +66,8 @@
"end": 28, "end": 28,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 9
"column": 9
},
"end": {
"line": 1,
"column": 17
}
}, },
"end": { "end": {
"line": 1, "line": 1,
@@ -87,14 +81,8 @@
"end": 20, "end": 20,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 9
"column": 9
},
"end": {
"line": 1,
"column": 17
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -81,20 +81,8 @@
"end": 27, "end": 27,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"start": { "column": 10
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 16
}
},
"end": {
"line": 1,
"column": 27
}
}, },
"end": { "end": {
"line": 1, "line": 1,
@@ -109,14 +97,8 @@
"end": 27, "end": 27,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 10
"column": 10
},
"end": {
"line": 1,
"column": 16
}
}, },
"end": { "end": {
"line": 1, "line": 1,
@@ -130,14 +112,8 @@
"end": 19, "end": 19,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 10
"column": 10
},
"end": {
"line": 1,
"column": 16
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -66,14 +66,8 @@
"end": 35, "end": 35,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 9
"column": 9
},
"end": {
"line": 1,
"column": 15
}
}, },
"end": { "end": {
"line": 1, "line": 1,
@@ -87,14 +81,8 @@
"end": 18, "end": 18,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 9
"column": 9
},
"end": {
"line": 1,
"column": 15
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -66,14 +66,8 @@
"end": 36, "end": 36,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 9
"column": 9
},
"end": {
"line": 1,
"column": 15
}
}, },
"end": { "end": {
"line": 1, "line": 1,
@@ -87,14 +81,8 @@
"end": 18, "end": 18,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 9
"column": 9
},
"end": {
"line": 1,
"column": 15
}
}, },
"end": { "end": {
"line": 1, "line": 1,
@@ -127,14 +115,8 @@
"end": 36, "end": 36,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 19
"column": 19
},
"end": {
"line": 1,
"column": 26
}
}, },
"end": { "end": {
"line": 1, "line": 1,
@@ -148,14 +130,8 @@
"end": 29, "end": 29,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 19
"column": 19
},
"end": {
"line": 1,
"column": 26
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -81,14 +81,8 @@
"end": 16, "end": 16,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 10
"column": 10
},
"end": {
"line": 1,
"column": 16
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -81,14 +81,8 @@
"end": 17, "end": 17,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 10
"column": 10
},
"end": {
"line": 1,
"column": 16
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -81,14 +81,8 @@
"end": 23, "end": 23,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 10
"column": 10
},
"end": {
"line": 1,
"column": 23
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -81,14 +81,8 @@
"end": 24, "end": 24,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 10
"column": 10
},
"end": {
"line": 1,
"column": 23
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -81,14 +81,8 @@
"end": 24, "end": 24,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 10
"column": 10
},
"end": {
"line": 1,
"column": 23
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -124,14 +124,8 @@
"end": 21, "end": 21,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 15
"column": 15
},
"end": {
"line": 1,
"column": 21
}
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@@ -108,14 +108,8 @@
"end": 19, "end": 19,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 1,
"line": 1, "column": 12
"column": 12
},
"end": {
"line": 1,
"column": 18
}
}, },
"end": { "end": {
"line": 1, "line": 1,
@@ -400,14 +394,8 @@
"end": 77, "end": 77,
"loc": { "loc": {
"start": { "start": {
"start": { "line": 2,
"line": 2, "column": 12
"column": 12
},
"end": {
"line": 2,
"column": 18
}
}, },
"end": { "end": {
"line": 2, "line": 2,