Skip to content

Commit d81d0c4

Browse files
committed
Fix PIPE location
1 parent 01cbbe1 commit d81d0c4

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed

src/transform-node.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,11 @@ class Transformer extends Source {
178178
}
179179

180180
if (node instanceof angular.BindingPipe) {
181-
const { exp: expressionNode, name, args: originalArguments } = node;
181+
const { name } = node;
182182
const left = this.transform<babel.Expression>(
183-
expressionNode,
183+
node.exp,
184184
childTransformOptions,
185185
);
186-
const start = getOuterStart(left);
187186
const leftEnd = getOuterEnd(left);
188187
const rightStart = this.getCharacterIndex(
189188
/\S/,
@@ -198,20 +197,16 @@ class Transformer extends Source {
198197
},
199198
ancestors,
200199
);
201-
const argumentNodes = originalArguments.map<babel.Expression>((node) =>
200+
const arguments_ = node.args.map<babel.Expression>((node) =>
202201
this.transform(node, childTransformOptions),
203202
);
204203
return this.#create<NGPipeExpression>(
205204
{
206205
type: 'NGPipeExpression',
207206
left,
208207
right,
209-
arguments: argumentNodes,
210-
start,
211-
end: getOuterEnd(
212-
// TODO[@fisker]: End seems not correct, since there should be `()`
213-
argumentNodes.length === 0 ? right : argumentNodes.at(-1)!,
214-
),
208+
arguments: arguments_,
209+
...node.sourceSpan,
215210
},
216211
ancestors,
217212
);

src/utils.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
11
import type { LocationInformation, RawNGSpan } from './types.ts';
22

3-
function expandSurroundingSpaces(
4-
{ start: startIndex, end: endIndex }: RawNGSpan,
5-
text: string,
6-
) {
7-
let start = startIndex;
8-
let end = endIndex;
9-
10-
while (end !== text.length && /\s/.test(text[end])) {
11-
end++;
12-
}
13-
14-
while (start !== 0 && /\s/.test(text[start - 1])) {
15-
start--;
16-
}
17-
18-
return { start, end };
19-
}
20-
213
function getCharacterSearchTestFunction(pattern: RegExp | string) {
224
if (typeof pattern === 'string') {
235
return (character: string) => character === pattern;

tests/__snapshots__/transform.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ NGPipeExpression {
1313
"comments": []
1414
}
1515
> 1 | ( ( ( ( a ) ) | b ))
16-
| ^^^^^^^^^^^^^^^^^^
16+
| ^^^^^^^^^^^^^^
1717
--------------------------------------------------------------------------------
1818
Identifier {
1919
"name": "a",
@@ -82,7 +82,7 @@ NGPipeExpression {
8282
"comments": []
8383
}
8484
> 1 | ( ( ( ( a ) ) | b ))
85-
| ^^^^^^^^^^^^^^^^^^
85+
| ^^^^^^^^^^^^^^
8686
--------------------------------------------------------------------------------
8787
Identifier {
8888
"name": "a",

0 commit comments

Comments
 (0)