Skip to content
Permalink
Browse files

fix(language-service): The pipe method should not include parentheses (

…#34485)

PR Close #34485
  • Loading branch information
ivanwonder authored and alxhub committed Dec 19, 2019
1 parent 5f640c4 commit 284559614ef474074289f66e858310bebee9071c
@@ -469,11 +469,15 @@ class ExpressionVisitor extends NullTemplateVisitor {
if (s.name.startsWith('__') || !s.public || this.completions.has(s.name)) {
continue;
}

// The pipe method should not include parentheses.
// e.g. {{ value_expression | slice : start [ : end ] }}
const shouldInsertParentheses = s.callable && s.kind !== ng.CompletionKind.PIPE;
this.completions.set(s.name, {
name: s.name,
kind: s.kind as ng.CompletionKind,
sortText: s.name,
insertText: s.callable ? `${s.name}()` : s.name,
insertText: shouldInsertParentheses ? `${s.name}()` : s.name,
});
}
}
@@ -208,6 +208,18 @@ describe('completions', () => {
}));
});

it('for methods of pipe should not include parentheses', () => {
mockHost.override(TEST_TEMPLATE, `<h1>{{title | lowe~{pipe-method} }}`);
const marker = mockHost.getLocationMarkerFor(TEST_TEMPLATE, 'pipe-method');
const completions = ngLS.getCompletionsAt(TEST_TEMPLATE, marker.start);
expect(completions).toBeDefined();
expect(completions !.entries).toContain(jasmine.objectContaining({
name: 'lowercase',
kind: CompletionKind.PIPE as any,
insertText: 'lowercase',
}));
});

describe('in external template', () => {
it('should be able to get entity completions in external template', () => {
const marker = mockHost.getLocationMarkerFor(TEST_TEMPLATE, 'entity-amp');

0 comments on commit 2845596

Please sign in to comment.
You can’t perform that action at this time.