refactor(language-service): Migrate completions_spec to new testing API (#40966)
refactor(language-service): Migrate completions_spec to new testing API PR Close #40966
This commit is contained in:
parent
23360d1215
commit
bc5c9ee234
@ -6,13 +6,11 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {absoluteFrom, AbsoluteFsPath} from '@angular/compiler-cli/src/ngtsc/file_system';
|
|
||||||
import {initMockFileSystem} from '@angular/compiler-cli/src/ngtsc/file_system/testing';
|
import {initMockFileSystem} from '@angular/compiler-cli/src/ngtsc/file_system/testing';
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
import {DisplayInfoKind, unsafeCastDisplayInfoKindToScriptElementKind} from '../display_parts';
|
import {DisplayInfoKind, unsafeCastDisplayInfoKindToScriptElementKind} from '../display_parts';
|
||||||
import {LanguageService} from '../language_service';
|
|
||||||
|
|
||||||
import {extractCursorInfo, LanguageServiceTestEnvironment} from './env';
|
import {LanguageServiceTestEnv, OpenBuffer} from '../testing';
|
||||||
|
|
||||||
const DIR_WITH_INPUT = {
|
const DIR_WITH_INPUT = {
|
||||||
'Dir': `
|
'Dir': `
|
||||||
@ -99,40 +97,43 @@ describe('completions', () => {
|
|||||||
|
|
||||||
describe('in the global scope', () => {
|
describe('in the global scope', () => {
|
||||||
it('should be able to complete an interpolation', () => {
|
it('should be able to complete an interpolation', () => {
|
||||||
const {ngLS, fileName, cursor} = setup('{{ti¦}}', `title!: string; hero!: number;`);
|
const {templateFile} = setup('{{ti}}', `title!: string; hero!: number;`);
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
templateFile.moveCursorToText('{{ti¦}}');
|
||||||
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title', 'hero']);
|
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title', 'hero']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to complete an empty interpolation', () => {
|
it('should be able to complete an empty interpolation', () => {
|
||||||
const {ngLS, fileName, cursor} = setup('{{ ¦ }}', `title!: string; hero!: number;`);
|
const {templateFile} = setup('{{ }}', `title!: string; hero!52: number;`);
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
templateFile.moveCursorToText('{{ ¦ }}');
|
||||||
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title', 'hero']);
|
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title', 'hero']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to complete a property binding', () => {
|
it('should be able to complete a property binding', () => {
|
||||||
const {ngLS, fileName, cursor} =
|
const {templateFile} = setup('<h1 [model]="ti"></h1>', `title!: string; hero!: number;`);
|
||||||
setup('<h1 [model]="ti¦"></h1>', `title!: string; hero!: number;`);
|
templateFile.moveCursorToText('"ti¦');
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title', 'hero']);
|
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title', 'hero']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to complete an empty property binding', () => {
|
it('should be able to complete an empty property binding', () => {
|
||||||
const {ngLS, fileName, cursor} =
|
const {templateFile} = setup('<h1 [model]=""></h1>', `title!: string; hero!: number;`);
|
||||||
setup('<h1 [model]="¦"></h1>', `title!: string; hero!: number;`);
|
templateFile.moveCursorToText('[model]="¦"');
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title', 'hero']);
|
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title', 'hero']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to retrieve details for completions', () => {
|
it('should be able to retrieve details for completions', () => {
|
||||||
const {ngLS, fileName, cursor} = setup('{{ti¦}}', `
|
const {templateFile} = setup('{{ti}}', `
|
||||||
/** This is the title of the 'AppCmp' Component. */
|
/** This is the title of the 'AppCmp' Component. */
|
||||||
title!: string;
|
title!: string;
|
||||||
/** This comment should not appear in the output of this test. */
|
/** This comment should not appear in the output of this test. */
|
||||||
hero!: number;
|
hero!: number;
|
||||||
`);
|
`);
|
||||||
const details = ngLS.getCompletionEntryDetails(
|
templateFile.moveCursorToText('{{ti¦}}');
|
||||||
fileName, cursor, 'title', /* formatOptions */ undefined,
|
const details = templateFile.getCompletionEntryDetails(
|
||||||
|
'title', /* formatOptions */ undefined,
|
||||||
/* preferences */ undefined)!;
|
/* preferences */ undefined)!;
|
||||||
expect(details).toBeDefined();
|
expect(details).toBeDefined();
|
||||||
expect(toText(details.displayParts)).toEqual('(property) AppCmp.title: string');
|
expect(toText(details.displayParts)).toEqual('(property) AppCmp.title: string');
|
||||||
@ -141,54 +142,60 @@ describe('completions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return reference completions when available', () => {
|
it('should return reference completions when available', () => {
|
||||||
const {ngLS, fileName, cursor} = setup(`<div #todo></div>{{t¦}}`, `title!: string;`);
|
const {templateFile} = setup(`<div #todo></div>{{t}}`, `title!: string;`);
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
templateFile.moveCursorToText('{{t¦}}');
|
||||||
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title']);
|
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title']);
|
||||||
expectContain(completions, DisplayInfoKind.REFERENCE, ['todo']);
|
expectContain(completions, DisplayInfoKind.REFERENCE, ['todo']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return variable completions when available', () => {
|
it('should return variable completions when available', () => {
|
||||||
const {ngLS, fileName, cursor} = setup(
|
const {templateFile} = setup(
|
||||||
`<div *ngFor="let hero of heroes">
|
`<div *ngFor="let hero of heroes">
|
||||||
{{h¦}}
|
{{h}}
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
`heroes!: {name: string}[];`);
|
`heroes!: {name: string}[];`);
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
templateFile.moveCursorToText('{{h¦}}');
|
||||||
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['heroes']);
|
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['heroes']);
|
||||||
expectContain(completions, DisplayInfoKind.VARIABLE, ['hero']);
|
expectContain(completions, DisplayInfoKind.VARIABLE, ['hero']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return completions inside an event binding', () => {
|
it('should return completions inside an event binding', () => {
|
||||||
const {ngLS, fileName, cursor} = setup(`<button (click)='t¦'></button>`, `title!: string;`);
|
const {templateFile} = setup(`<button (click)='t'></button>`, `title!: string;`);
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
templateFile.moveCursorToText(`(click)='t¦'`);
|
||||||
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title']);
|
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return completions inside an empty event binding', () => {
|
it('should return completions inside an empty event binding', () => {
|
||||||
const {ngLS, fileName, cursor} = setup(`<button (click)='¦'></button>`, `title!: string;`);
|
const {templateFile} = setup(`<button (click)=''></button>`, `title!: string;`);
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
templateFile.moveCursorToText(`(click)='¦'`);
|
||||||
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title']);
|
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return completions inside the RHS of a two-way binding', () => {
|
it('should return completions inside the RHS of a two-way binding', () => {
|
||||||
const {ngLS, fileName, cursor} = setup(`<h1 [(model)]="t¦"></h1>`, `title!: string;`);
|
const {templateFile} = setup(`<h1 [(model)]="t"></h1>`, `title!: string;`);
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
templateFile.moveCursorToText('[(model)]="t¦"');
|
||||||
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title']);
|
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return completions inside an empty RHS of a two-way binding', () => {
|
it('should return completions inside an empty RHS of a two-way binding', () => {
|
||||||
const {ngLS, fileName, cursor} = setup(`<h1 [(model)]="¦"></h1>`, `title!: string;`);
|
const {templateFile} = setup(`<h1 [(model)]=""></h1>`, `title!: string;`);
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
templateFile.moveCursorToText('[(model)]="¦"');
|
||||||
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title']);
|
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['title']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('in an expression scope', () => {
|
describe('in an expression scope', () => {
|
||||||
it('should return completions in a property access expression', () => {
|
it('should return completions in a property access expression', () => {
|
||||||
const {ngLS, fileName, cursor} =
|
const {templateFile} = setup(`{{name.f}}`, `name!: {first: string; last: string;};`);
|
||||||
setup(`{{name.f¦}}`, `name!: {first: string; last: string;};`);
|
templateFile.moveCursorToText('{{name.f¦}}');
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectAll(completions, {
|
expectAll(completions, {
|
||||||
first: ts.ScriptElementKind.memberVariableElement,
|
first: ts.ScriptElementKind.memberVariableElement,
|
||||||
last: ts.ScriptElementKind.memberVariableElement,
|
last: ts.ScriptElementKind.memberVariableElement,
|
||||||
@ -196,9 +203,9 @@ describe('completions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return completions in an empty property access expression', () => {
|
it('should return completions in an empty property access expression', () => {
|
||||||
const {ngLS, fileName, cursor} =
|
const {templateFile} = setup(`{{name.}}`, `name!: {first: string; last: string;};`);
|
||||||
setup(`{{name.¦}}`, `name!: {first: string; last: string;};`);
|
templateFile.moveCursorToText('{{name.¦}}');
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectAll(completions, {
|
expectAll(completions, {
|
||||||
first: ts.ScriptElementKind.memberVariableElement,
|
first: ts.ScriptElementKind.memberVariableElement,
|
||||||
last: ts.ScriptElementKind.memberVariableElement,
|
last: ts.ScriptElementKind.memberVariableElement,
|
||||||
@ -206,9 +213,10 @@ describe('completions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return completions in a property write expression', () => {
|
it('should return completions in a property write expression', () => {
|
||||||
const {ngLS, fileName, cursor} = setup(
|
const {templateFile} = setup(
|
||||||
`<button (click)="name.fi¦ = 'test"></button>`, `name!: {first: string; last: string;};`);
|
`<button (click)="name.fi = 'test"></button>`, `name!: {first: string; last: string;};`);
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
templateFile.moveCursorToText('name.fi¦');
|
||||||
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectAll(completions, {
|
expectAll(completions, {
|
||||||
first: ts.ScriptElementKind.memberVariableElement,
|
first: ts.ScriptElementKind.memberVariableElement,
|
||||||
last: ts.ScriptElementKind.memberVariableElement,
|
last: ts.ScriptElementKind.memberVariableElement,
|
||||||
@ -216,9 +224,9 @@ describe('completions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return completions in a method call expression', () => {
|
it('should return completions in a method call expression', () => {
|
||||||
const {ngLS, fileName, cursor} =
|
const {templateFile} = setup(`{{name.f()}}`, `name!: {first: string; full(): string;};`);
|
||||||
setup(`{{name.f¦()}}`, `name!: {first: string; full(): string;};`);
|
templateFile.moveCursorToText('{{name.f¦()}}');
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectAll(completions, {
|
expectAll(completions, {
|
||||||
first: ts.ScriptElementKind.memberVariableElement,
|
first: ts.ScriptElementKind.memberVariableElement,
|
||||||
full: ts.ScriptElementKind.memberFunctionElement,
|
full: ts.ScriptElementKind.memberFunctionElement,
|
||||||
@ -226,9 +234,9 @@ describe('completions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return completions in an empty method call expression', () => {
|
it('should return completions in an empty method call expression', () => {
|
||||||
const {ngLS, fileName, cursor} =
|
const {templateFile} = setup(`{{name.()}}`, `name!: {first: string; full(): string;};`);
|
||||||
setup(`{{name.¦()}}`, `name!: {first: string; full(): string;};`);
|
templateFile.moveCursorToText('{{name.¦()}}');
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectAll(completions, {
|
expectAll(completions, {
|
||||||
first: ts.ScriptElementKind.memberVariableElement,
|
first: ts.ScriptElementKind.memberVariableElement,
|
||||||
full: ts.ScriptElementKind.memberFunctionElement,
|
full: ts.ScriptElementKind.memberFunctionElement,
|
||||||
@ -236,9 +244,9 @@ describe('completions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return completions in a safe property navigation context', () => {
|
it('should return completions in a safe property navigation context', () => {
|
||||||
const {ngLS, fileName, cursor} =
|
const {templateFile} = setup(`{{name?.f}}`, `name?: {first: string; last: string;};`);
|
||||||
setup(`{{name?.f¦}}`, `name?: {first: string; last: string;};`);
|
templateFile.moveCursorToText('{{name?.f¦}}');
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectAll(completions, {
|
expectAll(completions, {
|
||||||
first: ts.ScriptElementKind.memberVariableElement,
|
first: ts.ScriptElementKind.memberVariableElement,
|
||||||
last: ts.ScriptElementKind.memberVariableElement,
|
last: ts.ScriptElementKind.memberVariableElement,
|
||||||
@ -246,9 +254,9 @@ describe('completions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return completions in an empty safe property navigation context', () => {
|
it('should return completions in an empty safe property navigation context', () => {
|
||||||
const {ngLS, fileName, cursor} =
|
const {templateFile} = setup(`{{name?.}}`, `name?: {first: string; last: string;};`);
|
||||||
setup(`{{name?.¦}}`, `name?: {first: string; last: string;};`);
|
templateFile.moveCursorToText('{{name?.¦}}');
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectAll(completions, {
|
expectAll(completions, {
|
||||||
first: ts.ScriptElementKind.memberVariableElement,
|
first: ts.ScriptElementKind.memberVariableElement,
|
||||||
last: ts.ScriptElementKind.memberVariableElement,
|
last: ts.ScriptElementKind.memberVariableElement,
|
||||||
@ -256,9 +264,9 @@ describe('completions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return completions in a safe method call context', () => {
|
it('should return completions in a safe method call context', () => {
|
||||||
const {ngLS, fileName, cursor} =
|
const {templateFile} = setup(`{{name?.f()}}`, `name!: {first: string; full(): string;};`);
|
||||||
setup(`{{name?.f¦()}}`, `name!: {first: string; full(): string;};`);
|
templateFile.moveCursorToText('{{name?.f¦()}}');
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectAll(completions, {
|
expectAll(completions, {
|
||||||
first: ts.ScriptElementKind.memberVariableElement,
|
first: ts.ScriptElementKind.memberVariableElement,
|
||||||
full: ts.ScriptElementKind.memberFunctionElement,
|
full: ts.ScriptElementKind.memberFunctionElement,
|
||||||
@ -266,9 +274,9 @@ describe('completions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return completions in an empty safe method call context', () => {
|
it('should return completions in an empty safe method call context', () => {
|
||||||
const {ngLS, fileName, cursor} =
|
const {templateFile} = setup(`{{name?.()}}`, `name!: {first: string; full(): string;};`);
|
||||||
setup(`{{name?.¦()}}`, `name!: {first: string; full(): string;};`);
|
templateFile.moveCursorToText('{{name?.¦()}}');
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectAll(completions, {
|
expectAll(completions, {
|
||||||
first: ts.ScriptElementKind.memberVariableElement,
|
first: ts.ScriptElementKind.memberVariableElement,
|
||||||
full: ts.ScriptElementKind.memberFunctionElement,
|
full: ts.ScriptElementKind.memberFunctionElement,
|
||||||
@ -278,8 +286,9 @@ describe('completions', () => {
|
|||||||
|
|
||||||
describe('element tag scope', () => {
|
describe('element tag scope', () => {
|
||||||
it('should return DOM completions', () => {
|
it('should return DOM completions', () => {
|
||||||
const {ngLS, fileName, cursor} = setup(`<div¦>`, '');
|
const {templateFile} = setup(`<div>`, '');
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
templateFile.moveCursorToText('<div¦>');
|
||||||
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.ELEMENT),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.ELEMENT),
|
||||||
['div', 'span']);
|
['div', 'span']);
|
||||||
@ -293,14 +302,14 @@ describe('completions', () => {
|
|||||||
export class OtherDir {}
|
export class OtherDir {}
|
||||||
`,
|
`,
|
||||||
};
|
};
|
||||||
const {ngLS, fileName, cursor} = setup(`<div¦>`, '', OTHER_DIR);
|
const {templateFile} = setup(`<div>`, '', OTHER_DIR);
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
templateFile.moveCursorToText('<div¦>');
|
||||||
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.DIRECTIVE),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.DIRECTIVE),
|
||||||
['other-dir']);
|
['other-dir']);
|
||||||
|
|
||||||
const details =
|
const details = templateFile.getCompletionEntryDetails('other-dir')!;
|
||||||
ngLS.getCompletionEntryDetails(fileName, cursor, 'other-dir', undefined, undefined)!;
|
|
||||||
expect(details).toBeDefined();
|
expect(details).toBeDefined();
|
||||||
expect(ts.displayPartsToString(details.displayParts))
|
expect(ts.displayPartsToString(details.displayParts))
|
||||||
.toEqual('(directive) AppModule.OtherDir');
|
.toEqual('(directive) AppModule.OtherDir');
|
||||||
@ -315,15 +324,15 @@ describe('completions', () => {
|
|||||||
export class OtherCmp {}
|
export class OtherCmp {}
|
||||||
`,
|
`,
|
||||||
};
|
};
|
||||||
const {ngLS, fileName, cursor} = setup(`<div¦>`, '', OTHER_CMP);
|
const {templateFile} = setup(`<div>`, '', OTHER_CMP);
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
templateFile.moveCursorToText('<div¦>');
|
||||||
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.COMPONENT),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.COMPONENT),
|
||||||
['other-cmp']);
|
['other-cmp']);
|
||||||
|
|
||||||
|
|
||||||
const details =
|
const details = templateFile.getCompletionEntryDetails('other-cmp')!;
|
||||||
ngLS.getCompletionEntryDetails(fileName, cursor, 'other-cmp', undefined, undefined)!;
|
|
||||||
expect(details).toBeDefined();
|
expect(details).toBeDefined();
|
||||||
expect(ts.displayPartsToString(details.displayParts))
|
expect(ts.displayPartsToString(details.displayParts))
|
||||||
.toEqual('(component) AppModule.OtherCmp');
|
.toEqual('(component) AppModule.OtherCmp');
|
||||||
@ -333,10 +342,10 @@ describe('completions', () => {
|
|||||||
describe('element attribute scope', () => {
|
describe('element attribute scope', () => {
|
||||||
describe('dom completions', () => {
|
describe('dom completions', () => {
|
||||||
it('should return completions for a new element attribute', () => {
|
it('should return completions for a new element attribute', () => {
|
||||||
const {ngLS, fileName, cursor} = setup(`<input ¦>`, '');
|
const {templateFile} = setup(`<input >`, '');
|
||||||
|
templateFile.moveCursorToText('<input ¦>');
|
||||||
|
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.ATTRIBUTE),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.ATTRIBUTE),
|
||||||
['value']);
|
['value']);
|
||||||
@ -346,24 +355,24 @@ describe('completions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return completions for a partial attribute', () => {
|
it('should return completions for a partial attribute', () => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`<input val¦>`, '');
|
const {templateFile} = setup(`<input val>`, '');
|
||||||
|
templateFile.moveCursorToText('<input val¦>');
|
||||||
|
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.ATTRIBUTE),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.ATTRIBUTE),
|
||||||
['value']);
|
['value']);
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PROPERTY),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PROPERTY),
|
||||||
['[value]']);
|
['[value]']);
|
||||||
expectReplacementText(completions, text, 'val');
|
expectReplacementText(completions, templateFile.contents, 'val');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return completions for a partial property binding', () => {
|
it('should return completions for a partial property binding', () => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`<input [val¦]>`, '');
|
const {templateFile} = setup(`<input [val]>`, '');
|
||||||
|
templateFile.moveCursorToText('[val¦]');
|
||||||
|
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
|
||||||
expectDoesNotContain(
|
expectDoesNotContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.ATTRIBUTE),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.ATTRIBUTE),
|
||||||
['value']);
|
['value']);
|
||||||
@ -373,16 +382,16 @@ describe('completions', () => {
|
|||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PROPERTY),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PROPERTY),
|
||||||
['value']);
|
['value']);
|
||||||
expectReplacementText(completions, text, 'val');
|
expectReplacementText(completions, templateFile.contents, 'val');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('directive present', () => {
|
describe('directive present', () => {
|
||||||
it('should return directive input completions for a new attribute', () => {
|
it('should return directive input completions for a new attribute', () => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`<input dir ¦>`, '', DIR_WITH_INPUT);
|
const {templateFile} = setup(`<input dir >`, '', DIR_WITH_INPUT);
|
||||||
|
templateFile.moveCursorToText('dir ¦>');
|
||||||
|
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PROPERTY),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PROPERTY),
|
||||||
['[myInput]']);
|
['[myInput]']);
|
||||||
@ -392,10 +401,10 @@ describe('completions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return directive input completions for a partial attribute', () => {
|
it('should return directive input completions for a partial attribute', () => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`<input dir my¦>`, '', DIR_WITH_INPUT);
|
const {templateFile} = setup(`<input dir my>`, '', DIR_WITH_INPUT);
|
||||||
|
templateFile.moveCursorToText('my¦>');
|
||||||
|
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PROPERTY),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PROPERTY),
|
||||||
['[myInput]']);
|
['[myInput]']);
|
||||||
@ -405,10 +414,10 @@ describe('completions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return input completions for a partial property binding', () => {
|
it('should return input completions for a partial property binding', () => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`<input dir [my¦]>`, '', DIR_WITH_INPUT);
|
const {templateFile} = setup(`<input dir [my]>`, '', DIR_WITH_INPUT);
|
||||||
|
templateFile.moveCursorToText('[my¦]');
|
||||||
|
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PROPERTY),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PROPERTY),
|
||||||
['myInput']);
|
['myInput']);
|
||||||
@ -417,10 +426,10 @@ describe('completions', () => {
|
|||||||
|
|
||||||
describe('structural directive present', () => {
|
describe('structural directive present', () => {
|
||||||
it('should return structural directive completions for an empty attribute', () => {
|
it('should return structural directive completions for an empty attribute', () => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`<li ¦>`, '', NG_FOR_DIR);
|
const {templateFile} = setup(`<li >`, '', NG_FOR_DIR);
|
||||||
|
templateFile.moveCursorToText('<li ¦>');
|
||||||
|
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.DIRECTIVE),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.DIRECTIVE),
|
||||||
['*ngFor']);
|
['*ngFor']);
|
||||||
@ -428,49 +437,49 @@ describe('completions', () => {
|
|||||||
|
|
||||||
it('should return structural directive completions for an existing non-structural attribute',
|
it('should return structural directive completions for an existing non-structural attribute',
|
||||||
() => {
|
() => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`<li ng¦>`, '', NG_FOR_DIR);
|
const {templateFile} = setup(`<li ng>`, '', NG_FOR_DIR);
|
||||||
|
templateFile.moveCursorToText('<li ng¦>');
|
||||||
|
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
|
||||||
expectContain(
|
expectContain(
|
||||||
completions,
|
completions,
|
||||||
unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.DIRECTIVE),
|
unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.DIRECTIVE),
|
||||||
['*ngFor']);
|
['*ngFor']);
|
||||||
expectReplacementText(completions, text, 'ng');
|
expectReplacementText(completions, templateFile.contents, 'ng');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return structural directive completions for an existing structural attribute',
|
it('should return structural directive completions for an existing structural attribute',
|
||||||
() => {
|
() => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`<li *ng¦>`, '', NG_FOR_DIR);
|
const {templateFile} = setup(`<li *ng>`, '', NG_FOR_DIR);
|
||||||
|
templateFile.moveCursorToText('*ng¦>');
|
||||||
|
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
|
||||||
expectContain(
|
expectContain(
|
||||||
completions,
|
completions,
|
||||||
unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.DIRECTIVE),
|
unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.DIRECTIVE),
|
||||||
['ngFor']);
|
['ngFor']);
|
||||||
expectReplacementText(completions, text, 'ng');
|
expectReplacementText(completions, templateFile.contents, 'ng');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return structural directive completions for just the structural marker', () => {
|
it('should return structural directive completions for just the structural marker', () => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`<li *¦>`, '', NG_FOR_DIR);
|
const {templateFile} = setup(`<li *>`, '', NG_FOR_DIR);
|
||||||
|
templateFile.moveCursorToText('*¦>');
|
||||||
|
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.DIRECTIVE),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.DIRECTIVE),
|
||||||
['ngFor']);
|
['ngFor']);
|
||||||
// The completion should not try to overwrite the '*'.
|
// The completion should not try to overwrite the '*'.
|
||||||
expectReplacementText(completions, text, '');
|
expectReplacementText(completions, templateFile.contents, '');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('directive not present', () => {
|
describe('directive not present', () => {
|
||||||
it('should return input completions for a new attribute', () => {
|
it('should return input completions for a new attribute', () => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`<input ¦>`, '', DIR_WITH_SELECTED_INPUT);
|
const {templateFile} = setup(`<input >`, '', DIR_WITH_SELECTED_INPUT);
|
||||||
|
templateFile.moveCursorToText('¦>');
|
||||||
|
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
|
||||||
// This context should generate two completions:
|
// This context should generate two completions:
|
||||||
// * `[myInput]` as a property
|
// * `[myInput]` as a property
|
||||||
// * `myInput` as an attribute
|
// * `myInput` as an attribute
|
||||||
@ -484,10 +493,10 @@ describe('completions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return input completions for a partial attribute', () => {
|
it('should return input completions for a partial attribute', () => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`<input my¦>`, '', DIR_WITH_SELECTED_INPUT);
|
const {templateFile} = setup(`<input my>`, '', DIR_WITH_SELECTED_INPUT);
|
||||||
|
templateFile.moveCursorToText('my¦>');
|
||||||
|
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
|
||||||
// This context should generate two completions:
|
// This context should generate two completions:
|
||||||
// * `[myInput]` as a property
|
// * `[myInput]` as a property
|
||||||
// * `myInput` as an attribute
|
// * `myInput` as an attribute
|
||||||
@ -497,50 +506,49 @@ describe('completions', () => {
|
|||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.ATTRIBUTE),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.ATTRIBUTE),
|
||||||
['myInput']);
|
['myInput']);
|
||||||
expectReplacementText(completions, text, 'my');
|
expectReplacementText(completions, templateFile.contents, 'my');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return input completions for a partial property binding', () => {
|
it('should return input completions for a partial property binding', () => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`<input [my¦]>`, '', DIR_WITH_SELECTED_INPUT);
|
const {templateFile} = setup(`<input [my]>`, '', DIR_WITH_SELECTED_INPUT);
|
||||||
|
templateFile.moveCursorToText('[my¦');
|
||||||
|
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
|
||||||
// This context should generate two completions:
|
// This context should generate two completions:
|
||||||
// * `[myInput]` as a property
|
// * `[myInput]` as a property
|
||||||
// * `myInput` as an attribute
|
// * `myInput` as an attribute
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PROPERTY),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PROPERTY),
|
||||||
['myInput']);
|
['myInput']);
|
||||||
expectReplacementText(completions, text, 'my');
|
expectReplacementText(completions, templateFile.contents, 'my');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return output completions for an empty binding', () => {
|
it('should return output completions for an empty binding', () => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`<input dir ¦>`, '', DIR_WITH_OUTPUT);
|
const {templateFile} = setup(`<input dir >`, '', DIR_WITH_OUTPUT);
|
||||||
|
templateFile.moveCursorToText('¦>');
|
||||||
|
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.EVENT),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.EVENT),
|
||||||
['(myOutput)']);
|
['(myOutput)']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return output completions for a partial event binding', () => {
|
it('should return output completions for a partial event binding', () => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`<input dir (my¦)>`, '', DIR_WITH_OUTPUT);
|
const {templateFile} = setup(`<input dir (my)>`, '', DIR_WITH_OUTPUT);
|
||||||
|
templateFile.moveCursorToText('(my¦)');
|
||||||
|
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.EVENT),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.EVENT),
|
||||||
['myOutput']);
|
['myOutput']);
|
||||||
expectReplacementText(completions, text, 'my');
|
expectReplacementText(completions, templateFile.contents, 'my');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return completions inside an LHS of a partially complete two-way binding', () => {
|
it('should return completions inside an LHS of a partially complete two-way binding', () => {
|
||||||
const {ngLS, fileName, cursor, text} =
|
const {templateFile} = setup(`<h1 dir [(mod)]></h1>`, ``, DIR_WITH_TWO_WAY_BINDING);
|
||||||
setup(`<h1 dir [(mod¦)]></h1>`, ``, DIR_WITH_TWO_WAY_BINDING);
|
templateFile.moveCursorToText('[(mod¦)]');
|
||||||
const completions =
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
expectReplacementText(completions, templateFile.contents, 'mod');
|
||||||
expectReplacementText(completions, text, 'mod');
|
|
||||||
|
|
||||||
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['model']);
|
expectContain(completions, ts.ScriptElementKind.memberVariableElement, ['model']);
|
||||||
|
|
||||||
@ -560,26 +568,29 @@ describe('completions', () => {
|
|||||||
|
|
||||||
describe('pipe scope', () => {
|
describe('pipe scope', () => {
|
||||||
it('should complete a pipe binding', () => {
|
it('should complete a pipe binding', () => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`{{ foo | some¦ }}`, '', SOME_PIPE);
|
const {templateFile} = setup(`{{ foo | some¦ }}`, '', SOME_PIPE);
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
templateFile.moveCursorToText('some¦');
|
||||||
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PIPE),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PIPE),
|
||||||
['somePipe']);
|
['somePipe']);
|
||||||
expectReplacementText(completions, text, 'some');
|
expectReplacementText(completions, templateFile.contents, 'some');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should complete an empty pipe binding', () => {
|
it('should complete an empty pipe binding', () => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`{{foo | ¦}}`, '', SOME_PIPE);
|
const {templateFile} = setup(`{{foo | }}`, '', SOME_PIPE);
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
templateFile.moveCursorToText('{{foo | ¦}}');
|
||||||
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expectContain(
|
expectContain(
|
||||||
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PIPE),
|
completions, unsafeCastDisplayInfoKindToScriptElementKind(DisplayInfoKind.PIPE),
|
||||||
['somePipe']);
|
['somePipe']);
|
||||||
expectReplacementText(completions, text, '');
|
expectReplacementText(completions, templateFile.contents, '');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not return extraneous completions', () => {
|
it('should not return extraneous completions', () => {
|
||||||
const {ngLS, fileName, cursor, text} = setup(`{{ foo | some¦ }}`, '');
|
const {templateFile} = setup(`{{ foo | some }}`, '');
|
||||||
const completions = ngLS.getCompletionsAtPosition(fileName, cursor, /* options */ undefined);
|
templateFile.moveCursorToText('{{ foo | some¦ }}');
|
||||||
|
const completions = templateFile.getCompletionsAtPosition();
|
||||||
expect(completions?.entries.length).toBe(0);
|
expect(completions?.entries.length).toBe(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -632,27 +643,16 @@ function toText(displayParts?: ts.SymbolDisplayPart[]): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setup(
|
function setup(
|
||||||
templateWithCursor: string, classContents: string,
|
template: string, classContents: string, otherDeclarations: {[name: string]: string} = {}): {
|
||||||
otherDeclarations: {[name: string]: string} = {}): {
|
templateFile: OpenBuffer,
|
||||||
env: LanguageServiceTestEnvironment,
|
|
||||||
fileName: AbsoluteFsPath,
|
|
||||||
AppCmp: ts.ClassDeclaration,
|
|
||||||
ngLS: LanguageService,
|
|
||||||
cursor: number,
|
|
||||||
text: string,
|
|
||||||
} {
|
} {
|
||||||
const codePath = absoluteFrom('/test.ts');
|
|
||||||
const templatePath = absoluteFrom('/test.html');
|
|
||||||
|
|
||||||
const decls = ['AppCmp', ...Object.keys(otherDeclarations)];
|
const decls = ['AppCmp', ...Object.keys(otherDeclarations)];
|
||||||
|
|
||||||
const otherDirectiveClassDecls = Object.values(otherDeclarations).join('\n\n');
|
const otherDirectiveClassDecls = Object.values(otherDeclarations).join('\n\n');
|
||||||
|
|
||||||
const {cursor, text: templateWithoutCursor} = extractCursorInfo(templateWithCursor);
|
const env = LanguageServiceTestEnv.setup();
|
||||||
const env = LanguageServiceTestEnvironment.setup([
|
const project = env.addProject('test', {
|
||||||
{
|
'test.ts': `
|
||||||
name: codePath,
|
|
||||||
contents: `
|
|
||||||
import {Component, Directive, NgModule, Pipe, TemplateRef} from '@angular/core';
|
import {Component, Directive, NgModule, Pipe, TemplateRef} from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -670,19 +670,7 @@ function setup(
|
|||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
`,
|
`,
|
||||||
isRoot: true,
|
'test.html': template,
|
||||||
},
|
});
|
||||||
{
|
return {templateFile: project.openFile('test.html')};
|
||||||
name: templatePath,
|
|
||||||
contents: templateWithoutCursor,
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
return {
|
|
||||||
env,
|
|
||||||
fileName: templatePath,
|
|
||||||
AppCmp: env.getClass(codePath, 'AppCmp'),
|
|
||||||
ngLS: env.ngLS,
|
|
||||||
text: templateWithoutCursor,
|
|
||||||
cursor,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
@ -64,4 +64,16 @@ export class OpenBuffer {
|
|||||||
getDefinitionAndBoundSpan(): ts.DefinitionInfoAndBoundSpan|undefined {
|
getDefinitionAndBoundSpan(): ts.DefinitionInfoAndBoundSpan|undefined {
|
||||||
return this.ngLS.getDefinitionAndBoundSpan(this.scriptInfo.fileName, this._cursor);
|
return this.ngLS.getDefinitionAndBoundSpan(this.scriptInfo.fileName, this._cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCompletionsAtPosition(options?: ts.GetCompletionsAtPositionOptions):
|
||||||
|
ts.WithMetadata<ts.CompletionInfo>|undefined {
|
||||||
|
return this.ngLS.getCompletionsAtPosition(this.scriptInfo.fileName, this._cursor, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
getCompletionEntryDetails(
|
||||||
|
entryName: string, formatOptions?: ts.FormatCodeOptions|ts.FormatCodeSettings,
|
||||||
|
preferences?: ts.UserPreferences): ts.CompletionEntryDetails|undefined {
|
||||||
|
return this.ngLS.getCompletionEntryDetails(
|
||||||
|
this.scriptInfo.fileName, this._cursor, entryName, formatOptions, preferences);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user