UNPKG

616 BJavaScriptView Raw
1// @flow
2export default function createDependencyLocation(
3 start: {|
4 line: number,
5 column: number,
6 |},
7 moduleSpecifier: string,
8 lineOffset: number = 0,
9 columnOffset: number = 0,
10 // Imports are usually wrapped in quotes
11 importWrapperLength: number = 2,
12) {
13 return {
14 filePath: moduleSpecifier,
15 start: {
16 line: start.line + lineOffset,
17 column: start.column + columnOffset,
18 },
19 end: {
20 line: start.line + lineOffset,
21 column:
22 start.column +
23 moduleSpecifier.length -
24 1 +
25 importWrapperLength +
26 columnOffset,
27 },
28 };
29}