Remove support for inputs/outputs in @Component/@Directive
diff --git a/angular_analyzer_plugin/lib/src/directive_extraction.dart b/angular_analyzer_plugin/lib/src/directive_extraction.dart
index bb6d018..836702f 100644
--- a/angular_analyzer_plugin/lib/src/directive_extraction.dart
+++ b/angular_analyzer_plugin/lib/src/directive_extraction.dart
@@ -189,8 +189,6 @@
final selector = _parseSelector(annotationNode) ?? new AndSelector([]);
final exportAs = _parseExportAs(annotationNode);
final elementTags = <ElementNameSelector>[];
- inputElements.addAll(_parseHeaderInputs(annotationNode));
- outputElements.addAll(_parseHeaderOutputs(annotationNode));
_parseMemberInputsAndOutputs(
classDeclaration, inputElements, outputElements);
selector.recordElementNameSelectors(elementTags);
@@ -366,137 +364,6 @@
return new AngularElementImpl(name, offset, name.length, _source);
}
- InputElement _parseHeaderInput(ast.Expression expression) {
- // ignore: omit_local_variable_types
- final Tuple4<String, SourceRange, String, SourceRange> nameValueAndRanges =
- _parseHeaderNameValueSourceRanges(expression);
- if (nameValueAndRanges != null && expression is ast.SimpleStringLiteral) {
- final boundName = nameValueAndRanges.item1;
- final boundRange = nameValueAndRanges.item2;
- final name = nameValueAndRanges.item3;
- final nameRange = nameValueAndRanges.item4;
-
- final setter = _resolveSetter(expression, name);
- if (setter == null) {
- return null;
- }
-
- return new InputElement(
- boundName,
- boundRange.offset,
- boundRange.length,
- _source,
- setter,
- nameRange,
- _bindingTypeSynthesizer.getSetterType(setter));
- } else {
- // TODO(mfairhurst) report a warning
- return null;
- }
- }
-
- List<InputElement> _parseHeaderInputs(ast.Annotation node) {
- final descList = _getListLiteralNamedArgument(
- node, const <String>['inputs', 'properties']);
- if (descList == null) {
- return const <InputElement>[];
- }
- // Create an input for each element.
- final inputElements = <InputElement>[];
- // ignore: omit_local_variable_types
- for (ast.Expression element in descList.elements) {
- final inputElement = _parseHeaderInput(element);
- if (inputElement != null) {
- inputElements.add(inputElement);
- }
- }
- return inputElements;
- }
-
- Tuple4<String, SourceRange, String, SourceRange>
- _parseHeaderNameValueSourceRanges(ast.Expression expression) {
- if (expression is ast.SimpleStringLiteral) {
- final offset = expression.contentsOffset;
- final value = expression.value;
- // TODO(mfairhurst) support for pipes
- final colonIndex = value.indexOf(':');
- if (colonIndex == -1) {
- final name = value;
- final nameRange = new SourceRange(offset, name.length);
- return new Tuple4<String, SourceRange, String, SourceRange>(
- name, nameRange, name, nameRange);
- } else {
- // Resolve the setter.
- final setterName = value.substring(0, colonIndex).trimRight();
- // Find the name.
- var boundOffset = colonIndex;
- while (true) {
- boundOffset++;
- if (boundOffset >= value.length) {
- // TODO(mfairhurst) report a warning
- return null;
- }
- if (value.substring(boundOffset, boundOffset + 1) != ' ') {
- break;
- }
- }
- final boundName = value.substring(boundOffset);
- // TODO(mfairhurst) test that a valid bound name
- return new Tuple4<String, SourceRange, String, SourceRange>(
- boundName,
- new SourceRange(offset + boundOffset, boundName.length),
- setterName,
- new SourceRange(offset, setterName.length));
- }
- } else {
- // TODO(mfairhurst) report a warning
- return null;
- }
- }
-
- OutputElement _parseHeaderOutput(ast.Expression expression) {
- // ignore: omit_local_variable_types
- final Tuple4<String, SourceRange, String, SourceRange> nameValueAndRanges =
- _parseHeaderNameValueSourceRanges(expression);
- if (nameValueAndRanges != null && expression is ast.SimpleStringLiteral) {
- final boundName = nameValueAndRanges.item1;
- final boundRange = nameValueAndRanges.item2;
- final name = nameValueAndRanges.item3;
- final nameRange = nameValueAndRanges.item4;
-
- final getter = _resolveGetter(expression, name);
- if (getter == null) {
- return null;
- }
-
- final eventType = _bindingTypeSynthesizer.getEventType(getter, name);
-
- return new OutputElement(boundName, boundRange.offset, boundRange.length,
- _source, getter, nameRange, eventType);
- } else {
- // TODO(mfairhurst) report a warning
- return null;
- }
- }
-
- List<OutputElement> _parseHeaderOutputs(ast.Annotation node) {
- final descList =
- _getListLiteralNamedArgument(node, const <String>['outputs']);
- if (descList == null) {
- return const <OutputElement>[];
- }
- // Create an output for each element.
- final outputs = <OutputElement>[];
- // ignore: omit_local_variable_types
- for (ast.Expression element in descList.elements) {
- final outputElement = _parseHeaderOutput(element);
- if (outputElement != null) {
- outputs.add(outputElement);
- }
- }
- return outputs;
- }
-
/// Create a new input or output for the given class member [node] with
/// the given `@Input` or `@Output` [annotation], and add it to the
/// [inputElements] or [outputElements] array.
diff --git a/angular_analyzer_plugin/test/abstract_angular.dart b/angular_analyzer_plugin/test/abstract_angular.dart
index 83cd19d..cc4640b 100644
--- a/angular_analyzer_plugin/test/abstract_angular.dart
+++ b/angular_analyzer_plugin/test/abstract_angular.dart
@@ -257,10 +257,6 @@
abstract class Directive {
const Directive(
{String selector,
- List<String> inputs,
- List<String> outputs,
- @Deprecated('Use `inputs` or `@Input` instead') List<String> properties,
- @Deprecated('Use `outputs` or `@Output` instead') List<String> events,
Map<String, String> host,
@Deprecated('Use `providers` instead') List bindings,
List providers,
@@ -269,8 +265,6 @@
Map<String, dynamic> queries})
: super(
selector: selector,
- inputs: inputs,
- outputs: outputs,
properties: properties,
events: events,
host: host,
@@ -285,10 +279,6 @@
final List<Object> directives;
const Component(
{String selector,
- List<String> inputs,
- List<String> outputs,
- @Deprecated('Use `inputs` or `@Input` instead') List<String> properties,
- @Deprecated('Use `outputs` or `@Output` instead') List<String> events,
Map<String, String> host,
@Deprecated('Use `providers` instead') List bindings,
List providers,
@@ -397,8 +387,9 @@
newSource('/angular/src/core/ng_if.dart', r'''
import 'metadata.dart';
-@Directive(selector: "[ngIf]", inputs: const ["ngIf"])
+@Directive(selector: "[ngIf]")
class NgIf {
+ @Input()
NgIf(TemplateRef tpl);
@Input()
@@ -409,11 +400,13 @@
import 'metadata.dart';
@Directive(
- selector: "[ngFor][ngForOf]",
- inputs: const ["ngForOf", "ngForTemplate", "ngForTrackBy"])
+ selector: "[ngFor][ngForOf]")
class NgFor {
+ @Input()
NgFor(TemplateRef tpl);
+ @Input()
set ngForOf(dynamic value) {}
+ @Input()
set ngForTrackBy(TrackByFn value) {}
}
diff --git a/angular_analyzer_plugin/test/angular_driver_test.dart b/angular_analyzer_plugin/test/angular_driver_test.dart
index 329e090..11c17cf 100644
--- a/angular_analyzer_plugin/test/angular_driver_test.dart
+++ b/angular_analyzer_plugin/test/angular_driver_test.dart
@@ -2791,23 +2791,6 @@
}
// ignore: non_constant_identifier_names
- Future test_finalPropertyInputStringError() async {
- final code = r'''
-import 'package:angular2/angular2.dart';
-
-@Component(selector: 'my-component', template: '<p></p>', inputs: const ['immutable'])
-class MyComponent {
- final int immutable = 1;
-}
-''';
- final source = newSource('/test.dart', code);
- await getDirectives(source);
- // validate. Can't easily assert position though because its all 'immutable'
- errorListener
- .assertErrorsWithCodes([StaticTypeWarningCode.UNDEFINED_SETTER]);
- }
-
- // ignore: non_constant_identifier_names
Future test_FunctionalDirective() async {
final source = newSource('/test.dart', r'''
import 'package:angular2/angular2.dart';
@@ -3058,59 +3041,6 @@
}
// ignore: non_constant_identifier_names
- Future test_hasError_UndefinedSetter_fullSyntax() async {
- final source = newSource('/test.dart', r'''
-import 'package:angular2/angular2.dart';
-
-@Component(selector: 'my-component', inputs: const ['noSetter: no-setter'], template: '')
-class ComponentA {
-}
-''');
- await getDirectives(source);
- final component = directives.single;
- final inputs = component.inputs;
- // the bad input should NOT show up, it is not usable see github #183
- expect(inputs, hasLength(0));
- // validate
- errorListener.assertErrorsWithCodes(
- <ErrorCode>[StaticTypeWarningCode.UNDEFINED_SETTER]);
- }
-
- // ignore: non_constant_identifier_names
- Future test_hasError_UndefinedSetter_shortSyntax() async {
- final source = newSource('/test.dart', r'''
-import 'package:angular2/angular2.dart';
-
-@Component(selector: 'my-component', inputs: const ['noSetter'], template: '')
-class ComponentA {
-}
-''');
- await getDirectives(source);
- // validate
- errorListener.assertErrorsWithCodes(
- <ErrorCode>[StaticTypeWarningCode.UNDEFINED_SETTER]);
- }
-
- // ignore: non_constant_identifier_names
- Future test_hasError_UndefinedSetter_shortSyntax_noInputMade() async {
- final source = newSource('/test.dart', r'''
-import 'package:angular2/angular2.dart';
-
-@Component(selector: 'my-component', inputs: const ['noSetter'], template: '')
-class ComponentA {
-}
-''');
- await getDirectives(source);
- final component = directives.single;
- final inputs = component.inputs;
- // the bad input should NOT show up, it is not usable see github #183
- expect(inputs, hasLength(0));
- // validate
- errorListener.assertErrorsWithCodes(
- <ErrorCode>[StaticTypeWarningCode.UNDEFINED_SETTER]);
- }
-
- // ignore: non_constant_identifier_names
Future test_hasExports() async {
final code = r'''
import 'package:angular2/angular2.dart';
@@ -3216,11 +3146,8 @@
@Component(
selector: 'my-component',
- template: '<p></p>',
- inputs: const ['leadingText', 'trailingText: tailText'])
+ template: '<p></p>')
class MyComponent {
- String leadingText;
- int trailingText;
@Input()
bool firstField;
@Input('secondInput')
@@ -3233,31 +3160,9 @@
await getDirectives(source);
final component = directives.single;
final inputs = component.inputs;
- expect(inputs, hasLength(5));
+ expect(inputs, hasLength(3));
{
final input = inputs[0];
- expect(input.name, 'leadingText');
- expect(input.nameOffset, code.indexOf("leadingText',"));
- expect(input.setterRange.offset, input.nameOffset);
- expect(input.setterRange.length, 'leadingText'.length);
- expect(input.setter, isNotNull);
- expect(input.setter.isSetter, isTrue);
- expect(input.setter.displayName, 'leadingText');
- expect(input.setterType.toString(), equals("String"));
- }
- {
- final input = inputs[1];
- expect(input.name, 'tailText');
- expect(input.nameOffset, code.indexOf("tailText']"));
- expect(input.setterRange.offset, code.indexOf("trailingText: "));
- expect(input.setterRange.length, 'trailingText'.length);
- expect(input.setter, isNotNull);
- expect(input.setter.isSetter, isTrue);
- expect(input.setter.displayName, 'trailingText');
- expect(input.setterType.toString(), equals("int"));
- }
- {
- final input = inputs[2];
expect(input.name, 'firstField');
expect(input.nameOffset, code.indexOf('firstField'));
expect(input.nameLength, 'firstField'.length);
@@ -3269,7 +3174,7 @@
expect(input.setterType.toString(), equals("bool"));
}
{
- final input = inputs[3];
+ final input = inputs[1];
expect(input.name, 'secondInput');
expect(input.nameOffset, code.indexOf('secondInput'));
expect(input.setterRange.offset, code.indexOf('secondField'));
@@ -3280,7 +3185,7 @@
expect(input.setterType.toString(), equals("String"));
}
{
- final input = inputs[4];
+ final input = inputs[2];
expect(input.name, 'someSetter');
expect(input.nameOffset, code.indexOf('someSetter'));
expect(input.setterRange.offset, input.nameOffset);
@@ -3296,47 +3201,6 @@
}
// ignore: non_constant_identifier_names
- Future test_inputs_deprecatedProperties() async {
- final code = r'''
-import 'package:angular2/angular2.dart';
-
-@Component(
- selector: 'my-component',
- template: '<p></p>',
- properties: const ['leadingText', 'trailingText: tailText'])
-class MyComponent {
- String leadingText;
- String trailingText;
-}
-''';
- final source = newSource('/test.dart', code);
- await getDirectives(source);
- final component = directives.single;
- final inputs = component.inputs;
- expect(inputs, hasLength(2));
- {
- final input = inputs[0];
- expect(input.name, 'leadingText');
- expect(input.nameOffset, code.indexOf("leadingText',"));
- expect(input.setterRange.offset, input.nameOffset);
- expect(input.setterRange.length, 'leadingText'.length);
- expect(input.setter, isNotNull);
- expect(input.setter.isSetter, isTrue);
- expect(input.setter.displayName, 'leadingText');
- }
- {
- final input = inputs[1];
- expect(input.name, 'tailText');
- expect(input.nameOffset, code.indexOf("tailText']"));
- expect(input.setterRange.offset, code.indexOf("trailingText: "));
- expect(input.setterRange.length, 'trailingText'.length);
- expect(input.setter, isNotNull);
- expect(input.setter.isSetter, isTrue);
- expect(input.setter.displayName, 'trailingText');
- }
- }
-
- // ignore: non_constant_identifier_names
Future test_noDirectives() async {
final source = newSource('/test.dart', r'''
class A {}
@@ -3372,15 +3236,12 @@
@Component(
selector: 'my-component',
- template: '<p></p>',
- outputs: const ['outputOne', 'secondOutput: outputTwo'])
+ template: '<p></p>')
class MyComponent {
- EventEmitter<MyComponent> outputOne;
- EventEmitter<String> secondOutput;
@Output()
- EventEmitter<int> outputThree;
- @Output('outputFour')
- EventEmitter fourthOutput;
+ EventEmitter<int> outputOne;
+ @Output('outputTwo')
+ EventEmitter secondOutput;
@Output()
EventEmitter get someGetter => null;
}
@@ -3389,58 +3250,34 @@
await getDirectives(source);
final component = directives.single;
final compOutputs = component.outputs;
- expect(compOutputs, hasLength(5));
+ expect(compOutputs, hasLength(3));
{
final output = compOutputs[0];
expect(output.name, 'outputOne');
- expect(output.nameOffset, code.indexOf("outputOne"));
+ expect(output.nameOffset, code.indexOf('outputOne'));
+ expect(output.nameLength, 'outputOne'.length);
expect(output.getterRange.offset, output.nameOffset);
- expect(output.getterRange.length, 'outputOne'.length);
+ expect(output.getterRange.length, output.nameLength);
expect(output.getter, isNotNull);
expect(output.getter.isGetter, isTrue);
expect(output.getter.displayName, 'outputOne');
expect(output.eventType, isNotNull);
- expect(output.eventType.toString(), equals("MyComponent"));
+ expect(output.eventType.toString(), equals("int"));
}
{
final output = compOutputs[1];
expect(output.name, 'outputTwo');
- expect(output.nameOffset, code.indexOf("outputTwo']"));
- expect(output.getterRange.offset, code.indexOf("secondOutput: "));
+ expect(output.nameOffset, code.indexOf('outputTwo'));
+ expect(output.getterRange.offset, code.indexOf('secondOutput'));
expect(output.getterRange.length, 'secondOutput'.length);
expect(output.getter, isNotNull);
expect(output.getter.isGetter, isTrue);
expect(output.getter.displayName, 'secondOutput');
expect(output.eventType, isNotNull);
- expect(output.eventType.toString(), equals("String"));
- }
- {
- final output = compOutputs[2];
- expect(output.name, 'outputThree');
- expect(output.nameOffset, code.indexOf('outputThree'));
- expect(output.nameLength, 'outputThree'.length);
- expect(output.getterRange.offset, output.nameOffset);
- expect(output.getterRange.length, output.nameLength);
- expect(output.getter, isNotNull);
- expect(output.getter.isGetter, isTrue);
- expect(output.getter.displayName, 'outputThree');
- expect(output.eventType, isNotNull);
- expect(output.eventType.toString(), equals("int"));
- }
- {
- final output = compOutputs[3];
- expect(output.name, 'outputFour');
- expect(output.nameOffset, code.indexOf('outputFour'));
- expect(output.getterRange.offset, code.indexOf('fourthOutput'));
- expect(output.getterRange.length, 'fourthOutput'.length);
- expect(output.getter, isNotNull);
- expect(output.getter.isGetter, isTrue);
- expect(output.getter.displayName, 'fourthOutput');
- expect(output.eventType, isNotNull);
expect(output.eventType.isDynamic, isTrue);
}
{
- final output = compOutputs[4];
+ final output = compOutputs[2];
expect(output.name, 'someGetter');
expect(output.nameOffset, code.indexOf('someGetter'));
expect(output.getterRange.offset, output.nameOffset);
@@ -4365,19 +4202,13 @@
import 'package:angular2/angular2.dart';
class Generic<T> {
- T inputViaChildDecl;
- EventEmitter<T> outputViaChildDecl;
@Input()
T inputViaParentDecl;
@Output()
EventEmitter<T> outputViaParentDecl;
}
-@Component(
- selector: 'my-component',
- template: '<p></p>',
- inputs: const ['inputViaChildDecl'],
- outputs: const ['outputViaChildDecl'])
+@Component(selector: 'my-component', template: '<p></p>')
class MyComponent extends Generic {
}
''';
@@ -4385,14 +4216,7 @@
await getDirectives(source);
final component = directives.single;
final compInputs = component.inputs;
- expect(compInputs, hasLength(2));
- {
- final input =
- compInputs.singleWhere((i) => i.name == 'inputViaChildDecl');
- expect(input, isNotNull);
- expect(input.setterType, isNotNull);
- expect(input.setterType.toString(), equals("dynamic"));
- }
+ expect(compInputs, hasLength(1));
{
final input =
compInputs.singleWhere((i) => i.name == 'inputViaParentDecl');
@@ -4402,14 +4226,7 @@
}
final compOutputs = component.outputs;
- expect(compOutputs, hasLength(2));
- {
- final output =
- compOutputs.singleWhere((o) => o.name == 'outputViaChildDecl');
- expect(output, isNotNull);
- expect(output.eventType, isNotNull);
- expect(output.eventType.toString(), equals("dynamic"));
- }
+ expect(compOutputs, hasLength(1));
{
final output =
compOutputs.singleWhere((o) => o.name == 'outputViaParentDecl');
@@ -4425,19 +4242,13 @@
import 'package:angular2/angular2.dart';
class Generic<T> {
- T inputViaChildDecl;
- EventEmitter<T> outputViaChildDecl;
@Input()
T inputViaParentDecl;
@Output()
EventEmitter<T> outputViaParentDecl;
}
-@Component(
- selector: 'my-component',
- template: '<p></p>',
- inputs: const ['inputViaChildDecl'],
- outputs: const ['outputViaChildDecl'])
+@Component(selector: 'my-component', template: '<p></p>')
class MyComponent extends Generic<String> {
}
''';
@@ -4445,14 +4256,7 @@
await getDirectives(source);
final component = directives.single;
final compInputs = component.inputs;
- expect(compInputs, hasLength(2));
- {
- final input =
- compInputs.singleWhere((i) => i.name == 'inputViaChildDecl');
- expect(input, isNotNull);
- expect(input.setterType, isNotNull);
- expect(input.setterType.toString(), equals("String"));
- }
+ expect(compInputs, hasLength(1));
{
final input =
compInputs.singleWhere((i) => i.name == 'inputViaParentDecl');
@@ -4462,14 +4266,7 @@
}
final compOutputs = component.outputs;
- expect(compOutputs, hasLength(2));
- {
- final output =
- compOutputs.singleWhere((o) => o.name == 'outputViaChildDecl');
- expect(output, isNotNull);
- expect(output.eventType, isNotNull);
- expect(output.eventType.toString(), equals("String"));
- }
+ expect(compOutputs, hasLength(1));
{
final output =
compOutputs.singleWhere((o) => o.name == 'outputViaParentDecl');
@@ -4672,9 +4469,9 @@
final code = r'''
import 'package:angular2/angular2.dart';
-@Component(selector: 'text-panel', inputs: const ['text'],
- template: r"<div>some text</div>")
+@Component(selector: 'text-panel', template: r"<div>some text</div>")
class TextPanel {
+ @Input()
String text;
}
@@ -4867,9 +4664,9 @@
final code = r'''
import 'package:angular2/angular2.dart';
-@Component(selector: 'text-panel', inputs: const ['text'],
- template: r"<div>some text</div>")
+@Component(selector: 'text-panel', template: r"<div>some text</div>")
class TextPanel {
+ @Input()
String text;
}
@@ -4928,11 +4725,12 @@
@Component(
selector: 'comp-a',
- inputs: const ['firstValue', 'vtoroy: second'],
template: r"<div>AAA</div>")
class ComponentA {
+ @Input()
int firstValue;
- int vtoroy;
+ @Input()
+ int second;
}
@Component(selector: 'comp-b', template: r"""
@@ -5230,7 +5028,7 @@
final code = r'''
import 'package:angular2/angular2.dart';
-@Component(selector: 'text-panel', inputs: const ['text'],
+@Component(selector: 'text-panel',
template: r"<div> <h2> {{text}} </h2> and {{text.length}} </div>")
class TextPanel {
String text; // 1
diff --git a/angular_analyzer_plugin/test/completion_contributor_test.dart b/angular_analyzer_plugin/test/completion_contributor_test.dart
index f9413a4..d3f1bf3 100644
--- a/angular_analyzer_plugin/test/completion_contributor_test.dart
+++ b/angular_analyzer_plugin/test/completion_contributor_test.dart
@@ -227,8 +227,7 @@
@Component(template: '<child-tag ^<div></div>', selector: 'my-tag',
directives: const [MyChildComponent])
class MyComponent {}
-@Component(template: '', selector: 'child-tag',
- inputs: const ['myDynamicInput'])
+@Component(template: '', selector: 'child-tag')
class MyChildComponent {
@Input() String stringInput;
@Input() int intInput;
@@ -236,6 +235,7 @@
bool _myDynamicInput = false;
bool get myDynamicInput => _myDynamicInput;
+ @Input()
void set myDynamicInput(value) {}
}
''');
@@ -1816,13 +1816,14 @@
directives: const [OtherComp])
class MyComp {
}
-@Component(template: '', selector: 'my-tag', inputs: const ['myDynamicInput'])
+@Component(template: '', selector: 'my-tag')
class OtherComp {
@Input() String name;
@Input() int intInput;
bool _myDynamicInput = false;
bool get myDynamicInput => _myDynamicInput;
+ @Input()
void set myDynamicInput(value) {}
}
''');
@@ -1848,13 +1849,14 @@
directives: const [OtherComp])
class MyComp {
}
-@Component(template: '', selector: 'my-tag', inputs: const ['myDynamicInput'])
+@Component(template: '', selector: 'my-tag')
class OtherComp {
@Input() String name;
@Input() int intInput;
bool _myDynamicInput = false;
bool get myDynamicInput => _myDynamicInput;
+ @Input()
void set myDynamicInput(value) {}
}
''');
diff --git a/angular_analyzer_plugin/test/navigation_test.dart b/angular_analyzer_plugin/test/navigation_test.dart
index e481388..b728791 100644
--- a/angular_analyzer_plugin/test/navigation_test.dart
+++ b/angular_analyzer_plugin/test/navigation_test.dart
@@ -80,10 +80,9 @@
code = r'''
import '/angular/src/core/metadata.dart';
-@Component(selector: 'text-panel', inputs: const ['text: my-text'],
- template: r"<div>some text</div>")
+@Component(selector: 'text-panel', template: r"<div>some text</div>")
class TextPanel {
- String text; // 1
+ @Input('my-text') String text; // 1
@Input() longform; // 4
}
@@ -106,34 +105,26 @@
new AngularNavigation(angularDriver.contentOverlay).computeNavigation(
new AngularNavigationRequest(null, null, null, result), collector,
templatesOnly: false);
- // input references setter
- {
- _findRegionString('text', ': my-text');
- // TODO: reenable this check
- //expect(region.targetKind, protocol.ElementKind.SETTER);
- expect(targetLocation.file, '/test.dart');
- expect(targetLocation.offset, code.indexOf('text; // 1'));
- }
// template references component (open tag)
{
_findRegionString('text-panel', ' [my-text]');
expect(region.targetKind, protocol.ElementKind.UNKNOWN);
expect(targetLocation.file, '/test.dart');
- expect(targetLocation.offset, code.indexOf("text-panel', inputs"));
+ expect(targetLocation.offset, code.indexOf("text-panel', template"));
}
// template references component (close tag)
{
_findRegionString('text-panel', '> // close');
expect(region.targetKind, protocol.ElementKind.UNKNOWN);
expect(targetLocation.file, '/test.dart');
- expect(targetLocation.offset, code.indexOf("text-panel', inputs"));
+ expect(targetLocation.offset, code.indexOf("text-panel', template"));
}
// template references input
{
_findRegionString('my-text', ']=');
expect(region.targetKind, protocol.ElementKind.UNKNOWN);
expect(targetLocation.file, '/test.dart');
- expect(targetLocation.offset, code.indexOf("my-text'],"));
+ expect(targetLocation.offset, code.indexOf("my-text"));
}
// template references field
{
diff --git a/angular_analyzer_plugin/test/resolver_test.dart b/angular_analyzer_plugin/test/resolver_test.dart
index 249825c..1914242 100644
--- a/angular_analyzer_plugin/test/resolver_test.dart
+++ b/angular_analyzer_plugin/test/resolver_test.dart
@@ -627,14 +627,17 @@
String string;
}
class Generic<T> {
+ @Output()
EventEmitter<T> output;
+ @Input()
T input;
+ @Output()
EventEmitter<T> twoWayChange;
+ @Input()
T twoWay;
}
-@Component(selector: 'generic-comp', template: '', inputs: ['input', 'twoWay'],
- outputs: ['output', 'twoWayChange'])
+@Component(selector: 'generic-comp', template: '')
class GenericComponent<T> extends Generic {
}
''');
@@ -733,14 +736,17 @@
String string;
}
class Generic<T> {
+ @Output()
EventEmitter<T> output;
+ @Input()
T input;
+ @Output()
EventEmitter<T> twoWayChange;
+ @Input()
T twoWay;
}
-@Component(selector: 'generic-comp', template: '', inputs: ['input', 'twoWay'],
- outputs: ['output', 'twoWayChange'])
+@Component(selector: 'generic-comp', template: '')
class GenericComponent<T> extends Generic<T> {
}
''');
@@ -977,7 +983,7 @@
class TestPanel {
String text; // 1
}
-@Component(selector: 'title-comp', template: '', inputs: 'title')
+@Component(selector: 'title-comp', template: '')
class TitleComponent {
@Input() int title;
}
@@ -1073,7 +1079,7 @@
class TestPanel {
String text; // 1
}
-@Component(selector: 'title-comp', template: '', inputs: 'title')
+@Component(selector: 'title-comp', template: '')
class TitleComponent {
@Input() int title;
}
@@ -1134,7 +1140,7 @@
class TestPanel {
String text; // 1
}
-@Component(selector: 'title-comp', template: '', inputs: 'title')
+@Component(selector: 'title-comp', template: '')
class TitleComponent {
@Input() int title;
}
@@ -1192,7 +1198,7 @@
class TestPanel {
String text; // 1
}
-@Directive(selector: '[titled]', template: '', inputs: 'title')
+@Directive(selector: '[titled]', template: '')
class TitleComponent {
@Input() String title;
}
@@ -1403,7 +1409,7 @@
class TestPanel {
String text; // 1
}
-@Component(selector: 'title-comp', template: '', inputs: 'title')
+@Component(selector: 'title-comp', template: '')
class TitleComponent {
@Output() EventEmitter<int> title;
}
@@ -1931,7 +1937,7 @@
class TestPanel {
String text; // 1
}
-@Component(selector: 'title-comp', template: '', inputs: 'title')
+@Component(selector: 'title-comp', template: '')
class TitleComponent {
@Input() int title;
@Output() EventEmitter<String> titleChange;
@@ -1954,7 +1960,7 @@
class TestPanel {
String text; // 1
}
-@Directive(selector: '[titled]', template: '', inputs: 'title')
+@Directive(selector: '[titled]', template: '')
class TitleComponent {
@Input() String twoWay;
@Output() EventEmitter<String> twoWayChange;
@@ -1977,7 +1983,7 @@
class TestPanel {
String text; // 1
}
-@Component(selector: 'title-comp', template: '', inputs: 'title')
+@Component(selector: 'title-comp', template: '')
class TitleComponent {
@Output() EventEmitter<String> noInputChange;
}
@@ -1999,7 +2005,7 @@
class TestPanel {
String text; // 1
}
-@Component(selector: 'title-comp', template: '', inputs: 'title')
+@Component(selector: 'title-comp', template: '')
class TitleComponent {
@Input() String inputOnly;
}
@@ -2021,7 +2027,7 @@
class TestPanel {
String text; // 1
}
-@Component(selector: 'title-comp', template: '', inputs: 'title')
+@Component(selector: 'title-comp', template: '')
class TitleComponent {
@Input() String title;
@Output() EventEmitter<String> titleChange;
@@ -2046,7 +2052,7 @@
class TestPanel {
String text; // 1
}
-@Component(selector: 'title-comp', template: '', inputs: 'title')
+@Component(selector: 'title-comp', template: '')
class TitleComponent {
@Input() String title;
@Output() EventEmitter<int> titleChange;
@@ -2069,7 +2075,7 @@
class TestPanel {
String text; // 1
}
-@Directive(selector: '[titled]', template: '', inputs: 'title')
+@Directive(selector: '[titled]', template: '')
class TitleComponent {
@Input() String title;
@Output() EventEmitter<String> titleChange;
@@ -2622,11 +2628,13 @@
// ignore: non_constant_identifier_names
Future test_inputReference() async {
_addDartSource(r'''
-@Component(selector: 'name-panel', inputs: const ['aaa', 'bbb', 'ccc'],
- template: r"<div>AAA</div>")
+@Component(selector: 'name-panel', template: r"<div>AAA</div>")
class NamePanel {
+ @Input()
int aaa;
+ @Input()
int bbb;
+ @Input()
int ccc;
}
@Component(selector: 'test-panel', templateUrl: 'test_panel.html',
@@ -2637,9 +2645,9 @@
<name-panel aaa='1' [bbb]='2' bind-ccc='3' id="someid"></name-panel>
""");
await _resolveSingleTemplate(dartSource);
- _assertElement("aaa=").input.at("aaa', ");
- _assertElement("bbb]=").input.at("bbb', ");
- _assertElement("ccc=").input.at("ccc']");
+ _assertElement("aaa=").input.at("aaa;");
+ _assertElement("bbb]=").input.at("bbb;");
+ _assertElement("ccc=").input.at("ccc;");
_assertElement("id=").input.inCoreHtml;
}
@@ -2792,8 +2800,9 @@
_addDartSource(r'''
import 'dart:html';
-@Component(selector: 'aaa', inputs: const ['target'], template: '')
+@Component(selector: 'aaa', template: '')
class ComponentA {
+ @Input()
void set target(ComponentB b) {}
}