Angular2 Dart Analysis Plugins

Integration with Dart Analysis Server

To provide information for DAS clients the server_plugin plugin contributes several extensions.

  • Angular analysis errors are automatically merged into normal errors notifications for Dart and HTML files.

Preview gif

Installing

Download chrome depot tools, and clone this repository.

Then run

./tools/get_deps.sh
cd server_plugin/bin
./make_snapshot

Back up sdk_path/snapshots/analysis_server.dart.snapshot and replace it with server.snapshot. Restart the dart analysis server by clicking the skull.

Check the pubspec.yaml in your project for transformers. They are not supported. You must manually add CORE_DIRECTIVES to your components right now for this plugin to work.

Chart of Current Features

All regular dart errors (that is to say, errors defined purely by the dart language spec) are not shown in this list.

Autocomplete is available in a branch, and only in editors that support it, and maybe with bugs (many don't replace the correct content during autocomplete within html, for instance).

Bootstrapping Validation Auto-Complete Navigation Refactoring
bootstrap(AppComponent, [MyService, provide(...)]); 🚷 🚷 🚷 🚷
Template syntax Validation Auto-Complete Navigation Refactoring
<input [value]="firstName"> ✅ soundness of expression, type of expression, existence of value on element or directive 🌗 in some editors
<input bind-value="firstName"> 🌗 in some editors; complete inside binding but binding not suggested
<div [attr.role]="myAriaRole"> 🌗 soundness of expression, but no other validation 🌗 in some editors; complete inside binding but binding not suggested
<div [class.extra-sparkle]="isDelightful"> ✅ validity of clasname, soundness of expression, type of expression must be bool 🌗 in some editors; complete inside binding but binding not suggested
<div [style.width.px]="mySize"> 🌖 soundness of expression, css properties are generally checked but not against a dictionary, same for units, expression must type to int if units are present 🌗 in some editors; complete inside binding but binding not suggested
<button (click)="readRainbow($event)"> ✅ in some editors; soundness of expression, type of $event, existence of output on component/element and DOM events which propagate can be tracked anywhere 🌗 in some editors
<button on-click="readRainbow($event)"> :white_check_mark 🌗 in some editors; complete inside binding but binding not suggested
<div title="Hello {{ponyName}}"> ✅ in some editors; soundness of expression, matching mustache delimiters 🌗 in some editors
<p>Hello {{ponyName}}</p> ✅ in some editors; soundness of expression, matching mustache delimiters 🌗 in some editors
<my-cmp></my-cmp> ✅ in some editors; Existence of directive 🌗 in some editors
<my-cmp [(title)]="name"> ✅ soundness of expression, existence of title input and titleChange output on directive or component with proper type 🌗 in some editors; complete inside binding but binding not suggested
<video #movieplayer ...></video><button (click)="movieplayer.play()"> ✅ in some editors; Type of new variable tracked and checked in other expressions 🌗 in some editors
<video ref-movieplayer ...></video><button (click)="movieplayer.play()"> ✅ in some editors 🌗 in some editors
<p *myUnless="myExpression">...</p> ✅ desugared to <template [myUnless]="myExpression"><p>... and checked from there 🌗 in some editors; complete inside binding but binding not suggested
`

Card No.: {{cardNumber

myCardNumberFormatter}}

`
❌ Pipes are not typechecked yet
Built-in directives Validation Auto-Complete Navigation Refactoring
<section *ngIf="showSection"> ✅ type checking, check for the star 🌗 in some editors; complete inside binding but binding not suggested
<li *ngFor="let item of list"> ✅ type checking and new var, check for the star, catch accidental usage of #item 🌗 in some editors; complete after of only
<div [ngClass]="{active: isActive, disabled: isDisabled}"> ⚠️ Requires quotes around key value strings to work 🌗 in some editors;
Forms Validation Auto-Complete Navigation Refactoring
<input [(ngModel)]="userName"> 🌗 in some editors; completion inside binding but binding not suggested
<form #myform="ngForm"> ✅ if ngForm is not an exported directive 🌗 in some editors; completion of variable but ngForm not suggested
Class decorators Validation Auto-Complete Navigation Refactoring
@Component(...) class MyComponent {} ✅ Validates directives list is all directives, that the template file exists, that a template is specified via string or URL but not both, requires a valid selector 🚷 🚷 🚷
@View(...) class MyComponent {} ⚠️ Supported, requires @Directive or @Component, but doesn't catch ambigous cases such as templates defined in the @View as well as @Component 🚷 🚷 🚷
@Directive(...) class MyDirective {} ✅ Validates directives list is all directives, that the template file exists, that a template is specified via string or URL but not both, requires a valid selector 🚷 🚷 🚷
@Pipe(...) class MyPipe {} 🚷 🚷
@Injectable() class MyService {} 🚷 🚷
Directive configuration Validation Auto-Complete Navigation Refactoring
@Directive(property1: value1, ...) ⚠️ deprecated, but supported 🚷 🚷 🚷
selector: '.cool-button:not(a)' 🚷
providers: [MyService, provide(...)]
inputs: ['myprop', 'myprop2: byname']
outputs: ['myprop', 'myprop2: byname']

@Component extends @Directive, so the @Directive configuration applies to components as well

Component Configuration Validation Auto-Complete Navigation Refactoring
viewProviders: [MyService, provide(...)]
template: 'Hello {{name}}' 🌗 in some editors
templateUrl: 'my-component.html'
styles: ['.primary {color: red}'] 🚷 🚷 🚷
styleUrls: ['my-component.css']
directives: [MyDirective, MyComponent] ✅ must be directives or lists of directives, configuration affects view errors
pipes: [MyPipe, OtherPipe]
Class field decorators for directives and components Validation Auto-Complete Navigation Refactoring
@Input() myProperty; 🚷
@Input("name") myProperty; 🚷
@Output() myEvent = new EventEmitter(); ✅ Subtype of Stream<T> required, streamed type determines $event type 🚷
@Output("name") myEvent = new EventEmitter(); 🚷
@Attribute("name") String ctorArg
@HostBinding('[class.valid]') isValid; 🚷 🚷 🚷
@HostListener('click', ['$event']) onClick(e) {...}
@ContentChild(myPredicate) myChildComponent; 🚷
@ContentChildren(myPredicate) myChildComponents; 🚷
@ViewChild(myPredicate) myChildComponent; 🚷
@ViewChildren(myPredicate) myChildComponents; 🚷
Transclusions Validation Auto-Complete Navigation Refactoring
<ng-content></ng-content> 🚷 🚷 🚷
<my-comp>text content</my-comp>
<ng-content select="foo"></ng-content> 🌗 in some editors
<my-comp><foo></foo></my-comp> 🌗 in some editors
<ng-content select=".foo[bar]"></ng-content> 🌗 in some editors
<my-comp><div class="foo" bar></div></my-comp> 🌗 in some editors
Directive and component change detection and lifecycle hooks (implemented as class methods) Validation Auto-Complete Navigation Refactoring
MyAppComponent(MyService myService, ...) { ... } 🚷 🚷
ngOnChanges(changeRecord) { ... } 🚷 🚷
ngOnInit() { ... } 🚷 🚷
ngDoCheck() { ... } 🚷 🚷
ngAfterContentInit() { ... } 🚷 🚷
ngAfterContentChecked() { ... } 🚷 🚷
ngAfterViewInit() { ... } 🚷 🚷
ngAfterViewChecked() { ... } 🚷 🚷
ngOnDestroy() { ... } 🚷 🚷
Dependency injection configuration Validation Auto-Complete Navigation Refactoring
provide(MyService, useClass: MyMockService) 🚷 🚷
provide(MyService, useFactory: myFactory) 🚷 🚷
provide(MyValue, useValue: 41) 🚷 🚷
Routing and navigation Validation Auto-Complete Navigation Refactoring
@RouteConfig(const [ const Route(...) ]) 🚷 🚷 🚷
<router-outlet></router-outlet> 🚷 🚷 🚷
<a [routerLink]="[ '/MyCmp', {myParam: 'value' } ]"> 🚷 🚷
@CanActivate(() => ...)class MyComponent() {} 🚷 🚷 🚷
routerOnActivate(nextInstruction, prevInstruction) { ... } 🚷 🚷 🚷
routerCanReuse(nextInstruction, prevInstruction) { ... } 🚷 🚷 🚷
routerOnReuse(nextInstruction, prevInstruction) { ... } 🚷 🚷
routerCanDeactivate(nextInstruction, prevInstruction) { ... } 🚷 🚷 🚷
routerOnDeactivate(nextInstruction, prevInstruction) { ... } 🚷 🚷 🚷