commit | 4db78b323ab7ca242b555456c956b2104cb295e2 | [log] [tgz] |
---|---|---|
author | Max Kim <mminkim89@gmail.com> | Mon May 15 10:39:33 2017 -0700 |
committer | GitHub <noreply@github.com> | Mon May 15 10:39:33 2017 -0700 |
tree | a336040787becee6af8f127bbbdb4d60fd9f4b5c | |
parent | 530506a072a1c7d3d7a53a06e18896d879bf4451 [diff] |
Latest sync to master (#319) * Defend against files hidden by generated files (#271) * Travis sdk fix (#272) * Sync to origin master * Fix travis build. Fix sdk related errors (ContextRoot and IdeOptions). Clean up imports to remove unused * Tick to 8 (#277) * Sync to origin master * Fix travis build. Fix sdk related errors (ContextRoot and IdeOptions). Clean up imports to remove unused * Tick to 0.0.8 * Track @Attribute annotated constructor parameters (#270) * Resolve plain attributes -- in ranges, and strchecks for inputs. (#278) * Resolve plain attributes -- in ranges, and strchecks for inputs. Record resolved ranges for `x="y"` where `x` is an input or a constructor `@Attribute`. If its an input, check that strings are assignable to it. If not, give it its own error that hopefully explains the semi magical situation. * Track/typecheck std attrs Eventually we should * report errors for <a href="foo" [href]="bar"> * not suggest href after [href] has been used * not suggest [href] after href has been used * Template parsing fix (#279) * Sync to origin master * Fix travis build. Fix sdk related errors (ContextRoot and IdeOptions). Clean up imports to remove unused * Fix issue that caused empty binding on template attribute to crash * Now ready: Priority angular analysis (#273) * Priority dart & html analysis * Starter class, await supplementing errors or they're added too late. * Report has work to analyze for priority requests * Don't await for requesting files, do have a cache busting option * Handle case of files being requested multiple times * Priority html requests, requires serving errors with line infos. * Report all html files for all dart contexts in one method, plus tests I think before we were getting a last-one-wins effect, where the last analyzed dart/html pair would cover up all the errors for every other dart/html pair. As such, I need to carefully test that this change doesn't introduce new false errors (from them being covered up before). But now with this, we can report html errors back for multiple contexts from a single method when that's requested. Next I just have to use that method on getErrors when we have multiple relationships tracked already. * Guess html/dart relationship when none exist, otherwise use what's known using isEmpty rather than == 0 * Get setterType by setter.parameters[0] instead of setter.variable.type (#283) Seems like in the precense of a getter, setter.variable.type is the getter type, not the setter's type. So use the first function argument instead. * Remove contextRoot, won't be required in master soon, and breaks dev (#284) * Disable global attr plaintext typechecking until #280 has a clear solution (#286) * Update test_reflective_loader, fix analyzer warnings&errors (#285) * Update test_reflective_loader, fix analyzer warnings&errors * Fix the single server test too, which prevents build errors * Use var instead of types in angular_driver_test * Add TODOs * Percentage use fix in style.width and style.height. Test cases added (#282) * Percentage use fix in style.width and style.height. Test cases added * Added more property names that use percentage * Update readme (#292) * Dont rehash html contents unless they change (#293) * update dependencies to point to the right place (#296) * Fix moved files (#298) * Fix moved files * Fix server test imports * Autocompletion fix (#297) * Checkpoint * html completion working, dart completion groundwork laid in, just started test * temp revert * Cleaned up completion functionality. Begin testing changes. * Small revert * Test cases fully passing * Removing unused imports * Remove linking of .dart completion - temporarily disabled * view.elementTags is now lazily computed. 'computeSuggestions' will always ensure that standardHtml is calculated before usage * getTemplateForFile now retuns a list of templates. computeSuggestions modified to adjust * Naming change for better accuracy; minor bug fix * @ContentChild and @ContentChildren validation. (#291) * @ContentChild and @ContentChildren validation. Validates: - ElementRef - TemplateRef - Components - Directives - String-based let bindings (and checks property match) - all others as errors - property has QueryList assignability for ContentChildren - ContentChild is only matched once Changes: - elements matching ContentChild of parent are counted as transcluded, error wise - DirectiveResolver is split into two phases, so that transclusions can be checked _after_ inner content is directive resolved (for the sake of ContentChild) - added "StandardAngular" where we get certain special ClassElements before running any other analysis, so that we can check if some random type x is a supertype of angular's ElementRef. - added ContentChildBindings so we can track the results of this process to affect autocompletion suggestions, navigation, refactoring Important edge cases: - proper generic type checking for Iterable<T> as QueryList<T> - using isSupertypeOf instead of isAssignableTo, because downcasting is _known_ to be wrong (otherwise in dart downcasting is assumed deliberate) - don't supress transclusion errors for element A within B just because some parent of B understands A as a contentChild -- has nothing to do with A not belonging to B. - don't report duplicate ContentChild errors when the duplicate is inside a prior match (in fact, don't even report assignability errors!) - directive matches require using exportAs with the #x="y" syntax. - getting the "constant value" fields with inheritance requires using `.getField("(super)")` the correct amount of times. This looks VERY fragile to me. - Native elements get Components, but they become ElementRefs not TableElements. Ensure people don't use @ContentChild(TableElement). Tests: - changed to use 'package:angular2' instead of '/angular2/' because that is required to build StandardAngular. However, not all tests are changed, because its still ok to use '/angular2' too. - added ElementRef and TemplateRef and QueryList classes. Todos: - ViewChild/ViewChildren - track matched #attrs instead of just Elements - revisit the highlighted ranges, can we make them more specific? - instantiate classes to bounds * Look for selector field with arbitrary inheritance * Optimize content child scanning * Fuzz test updates * Another fuzz fix * Avoid element.unit, very slow. Use enclosingElement * Fix server tests failing (#300) * Prevent inf loop of trying to resolve standardAngular in workspaces that don't have angular2 imported (#301) * Implement new methods that will soon be part of AnalysisDriverGeneric (#299) * Change setPriorityFiles to set priorityFiles (#304) * Change event emitter to stream (#305) Change event emitter to stream * Plain attribute autocompletion (#303) * Component and standard inputs - autocomplete as plain attribute * Autocomplete bug fix * Checkpoint * test cases added * Quick fix - still need to follow through null checks * Fix travisCL complaining, also remove unnecessary whitespace * Allows dynamic types to be autocompleted and improved flow * get typeprovider from template * Better validation of plain attributes (#306) * Fix pathing for byte_store (#312) * null check added on source (#311) * Remove searchEngine from CompletionRequest reflecting changes made in… (#314) * Remove searchEngine from CompletionRequest reflecting changes made in completion core, and remove index as per suggestion * Cleaned up unused imports and unused override reflecting recent changes (#315) * Cleaned up unused imports and unused override reflecting recent changes * remove context from completionRequest * Removing unnecessary null check * Omega lint fixup (#313) * Get new plugin architecture in a workable development stage (#316) See readme for how to get set up....currently doesn't do anything, though. * More lint fixes, handle moved file (#317) * Autocomplete stars (#310) * Complete inputs inside of template elements Complete, for instance, `trackBy` inside of an ngFor. * Analyze and suggest directives that appear to want `*star` syntax. If a `TemplateRef` is in the constructor, it works with star syntax. Warn when not used with star syntax, and warn when star syntax is used on a directive that does not have this special ctor as otherwise the template will go unused. Its not a foolproof system, I don't think. So detect that separately from detection of ngIf and ngFor without stars. Especially so that in the cases where this goes wrong, users can opt out of the error without losing errors for those core directives' validation...and give different messages. Not sure what's more likely...that this expects too many things to be used with stars, or not enough... Also suggest this in autocomplete for great profit. Assume that these directives rely on a property binding, so suggest *p for all p which are property selectors. Note this is also a less than perfect system, as it includes suggesting `*ngForOf`, since that's part of `NgFor`s selector. Hardcode that out, at least for now. With this plus suggesting `trackBy:`, we now (I think) suggest everything relevant for two way autocomplete except `template=` attributes themselves and the `let` keyword. Wanted to do the latter but it seemed like it might be a bit treacherous: think `ngIf="^"` vs `ngFor="^"`, it would be the first time we'd suggest both dart and non-dart things at once. * Fix analysis errors * prefer var and final over types * More lint fixes * Include colon in suggestion * Move performance log (#318) * Tests passing * Sync to master; tests passing
To provide information for DAS clients the server_plugin
plugin contributes several extensions.
errors
notifications for Dart and HTML files.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.
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.
Under the next system, you will not need to build to install (woo hoo!). However, these steps currently don't produce anything usable. Installation steps will come once its ready.
Download chrome depot tools, and clone this repository.
Then run
./tools/get_deps.sh cd analyze_angular/tools/plugin cp pubspec.yaml.defaults pubspec.yaml
Modify pubspec.yaml
in this folder to fix the absolute paths. They must be absolute for the moment! Once they can be relative this step will not be required.
Then run pub get
.
You can now use this in projects on your local system which a correctly configured pubspec. For instance, playground/
. Note that you must import 'package:analyze_angular/'
in your project to get the analysis.
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(...)]); | :no_pedestrians: | :no_pedestrians: | :no_pedestrians: | :no_pedestrians: |
Template syntax | Validation | Auto-Complete | Navigation | Refactoring |
---|---|---|---|---|
<input [value]="firstName"> | :white_check_mark: soundness of expression, type of expression, existence of value on element or directive | :last_quarter_moon: in some editors | :x: | :x: |
<input bind-value="firstName"> | :white_check_mark: | :last_quarter_moon: in some editors; complete inside binding but binding not suggested | :x: | :x: |
<div [attr.role]="myAriaRole"> | :last_quarter_moon: soundness of expression, but no other validation | :last_quarter_moon: in some editors; complete inside binding but binding not suggested | :x: | :x: |
<div [class.extra-sparkle]="isDelightful"> | :white_check_mark: validity of clasname, soundness of expression, type of expression must be bool | :last_quarter_moon: in some editors; complete inside binding but binding not suggested | :x: | :x: |
<div [style.width.px]="mySize"> | :waning_gibbous_moon: 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 | :last_quarter_moon: in some editors; complete inside binding but binding not suggested | :x: | :x: |
<button (click)="readRainbow($event)"> | :white_check_mark: in some editors; soundness of expression, type of $event , existence of output on component/element and DOM events which propagate can be tracked anywhere | :last_quarter_moon: in some editors | :x: | :x: |
<button on-click="readRainbow($event)"> | :white_check_mark | :last_quarter_moon: in some editors; complete inside binding but binding not suggested | :x: | :x: |
<div title="Hello {{ponyName}}"> | :white_check_mark: in some editors; soundness of expression, matching mustache delimiters | :last_quarter_moon: in some editors | :x: | :x: |
<p>Hello {{ponyName}}</p> | :white_check_mark: in some editors; soundness of expression, matching mustache delimiters | :last_quarter_moon: in some editors | :x: | :x: |
<my-cmp></my-cmp> | :white_check_mark: in some editors; Existence of directive | :last_quarter_moon: in some editors | :x: | :x: |
<my-cmp [(title)]="name"> | :white_check_mark: soundness of expression, existence of title input and titleChange output on directive or component with proper type | :last_quarter_moon: in some editors; complete inside binding but binding not suggested | :x: | :x: |
<video #movieplayer ...></video><button (click)="movieplayer.play()"> | :white_check_mark: in some editors; Type of new variable tracked and checked in other expressions | :last_quarter_moon: in some editors | :x: | :x: |
<video ref-movieplayer ...></video><button (click)="movieplayer.play()"> | :white_check_mark: in some editors | :last_quarter_moon: in some editors | :x: | :x: |
<p *myUnless="myExpression">...</p> | :white_check_mark: desugared to <template [myUnless]="myExpression"><p>... and checked from there | :last_quarter_moon: in some editors; complete inside binding but binding not suggested | :x: | :x: |
`Card No.: {{cardNumber | myCardNumberFormatter}}` | :x: Pipes are not typechecked yet | :x: | :x: |
Built-in directives | Validation | Auto-Complete | Navigation | Refactoring |
---|---|---|---|---|
<section *ngIf="showSection"> | :white_check_mark: type checking, check for the star | :last_quarter_moon: in some editors; complete inside binding but binding not suggested | :x: | :x: |
<li *ngFor="let item of list"> | :white_check_mark: type checking and new var, check for the star, catch accidental usage of #item | :last_quarter_moon: in some editors; complete after of only | :x: | :x: |
<div [ngClass]="{active: isActive, disabled: isDisabled}"> | :warning: Requires quotes around key value strings to work | :last_quarter_moon: in some editors; | :x: | :x: |
Forms | Validation | Auto-Complete | Navigation | Refactoring |
---|---|---|---|---|
<input [(ngModel)]="userName"> | :white_check_mark: | :last_quarter_moon: in some editors; completion inside binding but binding not suggested | :x: | :x: |
<form #myform="ngForm"> | :white_check_mark: if ngForm is not an exported directive | :last_quarter_moon: in some editors; completion of variable but ngForm not suggested | :x: | :x: |
Class decorators | Validation | Auto-Complete | Navigation | Refactoring |
---|---|---|---|---|
@Component(...) class MyComponent {} | :white_check_mark: 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 | :no_pedestrians: | :no_pedestrians: | :no_pedestrians: |
@View(...) class MyComponent {} | :warning: Supported, requires @Directive or @Component , but doesn't catch ambigous cases such as templates defined in the @View as well as @Component | :no_pedestrians: | :no_pedestrians: | :no_pedestrians: |
@Directive(...) class MyDirective {} | :white_check_mark: 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 | :no_pedestrians: | :no_pedestrians: | :no_pedestrians: |
@Pipe(...) class MyPipe {} | :x: | :no_pedestrians: | :no_pedestrians: | :x: |
@Injectable() class MyService {} | :x: | :no_pedestrians: | :no_pedestrians: | :x: |
Directive configuration | Validation | Auto-Complete | Navigation | Refactoring |
---|---|---|---|---|
@Directive(property1: value1, ...) | :warning: deprecated, but supported | :no_pedestrians: | :no_pedestrians: | :no_pedestrians: |
selector: '.cool-button:not(a)' | :white_check_mark: | :no_pedestrians: | :x: | :x: |
providers: [MyService, provide(...)] | :x: | :x: | :x: | :x: |
inputs: ['myprop', 'myprop2: byname'] | :white_check_mark: | :x: | :x: | :x: |
outputs: ['myprop', 'myprop2: byname'] | :white_check_mark: | :x: | :x: | :x: |
@Component extends @Directive, so the @Directive configuration applies to components as well
Component Configuration | Validation | Auto-Complete | Navigation | Refactoring |
---|---|---|---|---|
viewProviders: [MyService, provide(...)] | :x: | :x: | :x: | :x: |
template: 'Hello {{name}}' | :white_check_mark: | :last_quarter_moon: in some editors | :x: | :x: |
templateUrl: 'my-component.html' | :white_check_mark: | :x: | :x: | :x: |
styles: ['.primary {color: red}'] | :x: | :no_pedestrians: | :no_pedestrians: | :no_pedestrians: |
styleUrls: ['my-component.css'] | :x: | :x: | :x: | :x: |
directives: [MyDirective, MyComponent] | :white_check_mark: must be directives or lists of directives, configuration affects view errors | :x: | :x: | :x: |
pipes: [MyPipe, OtherPipe] | :x: | :x: | :x: | :x: |
Class field decorators for directives and components | Validation | Auto-Complete | Navigation | Refactoring |
---|---|---|---|---|
@Input() myProperty; | :white_check_mark: | :no_pedestrians: | :x: | :x: |
@Input("name") myProperty; | :white_check_mark: | :no_pedestrians: | :x: | :x: |
@Output() myEvent = new EventEmitter(); | :white_check_mark: Subtype of Stream<T> required, streamed type determines $event type | :no_pedestrians: | :x: | :x: |
@Output("name") myEvent = new EventEmitter(); | :white_check_mark: | :no_pedestrians: | :x: | :x: |
@Attribute("name") String ctorArg | :white_check_mark: | :x: | :x: | :x: |
@HostBinding('[class.valid]') isValid; | :x: | :no_pedestrians: | :no_pedestrians: | :no_pedestrians: |
@HostListener('click', ['$event']) onClick(e) {...} | :x: | :x: | :x: | :x: |
@ContentChild(myPredicate) myChildComponent; | :x: | :no_pedestrians: | :x: | :x: |
@ContentChildren(myPredicate) myChildComponents; | :x: | :no_pedestrians: | :x: | :x: |
@ViewChild(myPredicate) myChildComponent; | :x: | :no_pedestrians: | :x: | :x: |
@ViewChildren(myPredicate) myChildComponents; | :x: | :no_pedestrians: | :x: | :x: |
Transclusions | Validation | Auto-Complete | Navigation | Refactoring |
---|---|---|---|---|
<ng-content></ng-content> | :white_check_mark: | :no_pedestrians: | :no_pedestrians: | :no_pedestrians: |
<my-comp>text content</my-comp> | :white_check_mark: | :x: | :x: | :x: |
<ng-content select="foo"></ng-content> | :white_check_mark: | :last_quarter_moon: in some editors | :x: | :x: |
<my-comp><foo></foo></my-comp> | :white_check_mark: | :last_quarter_moon: in some editors | :x: | :x: |
<ng-content select=".foo[bar]"></ng-content> | :white_check_mark: | :last_quarter_moon: in some editors | :x: | :x: |
<my-comp><div class="foo" bar></div></my-comp> | :white_check_mark: | :last_quarter_moon: in some editors | :x: | :x: |
Directive and component change detection and lifecycle hooks (implemented as class methods) | Validation | Auto-Complete | Navigation | Refactoring |
---|---|---|---|---|
MyAppComponent(MyService myService, ...) { ... } | :x: | :no_pedestrians: | :no_pedestrians: | :x: |
ngOnChanges(changeRecord) { ... } | :x: | :no_pedestrians: | :no_pedestrians: | :x: |
ngOnInit() { ... } | :x: | :no_pedestrians: | :no_pedestrians: | :x: |
ngDoCheck() { ... } | :x: | :no_pedestrians: | :no_pedestrians: | :x: |
ngAfterContentInit() { ... } | :x: | :no_pedestrians: | :no_pedestrians: | :x: |
ngAfterContentChecked() { ... } | :x: | :no_pedestrians: | :no_pedestrians: | :x: |
ngAfterViewInit() { ... } | :x: | :no_pedestrians: | :no_pedestrians: | :x: |
ngAfterViewChecked() { ... } | :no_pedestrians: | :no_pedestrians: | :x: | :x: |
ngOnDestroy() { ... } | :x: | :no_pedestrians: | :no_pedestrians: | :x: |
Dependency injection configuration | Validation | Auto-Complete | Navigation | Refactoring |
---|---|---|---|---|
provide(MyService, useClass: MyMockService) | :x: | :no_pedestrians: | :no_pedestrians: | :x: |
provide(MyService, useFactory: myFactory) | :x: | :no_pedestrians: | :no_pedestrians: | :x: |
provide(MyValue, useValue: 41) | :x: | :no_pedestrians: | :no_pedestrians: | :x: |
Routing and navigation | Validation | Auto-Complete | Navigation | Refactoring |
---|---|---|---|---|
@RouteConfig(const [ const Route(...) ]) | :x: | :no_pedestrians: | :no_pedestrians: | :no_pedestrians: |
<router-outlet></router-outlet> | :no_pedestrians: | :x: | :no_pedestrians: | :no_pedestrians: |
<a [routerLink]="[ '/MyCmp', {myParam: 'value' } ]"> | :question: | :x: | :no_pedestrians: | :no_pedestrians: |
@CanActivate(() => ...)class MyComponent() {} | :x: | :no_pedestrians: | :no_pedestrians: | :no_pedestrians: |
routerOnActivate(nextInstruction, prevInstruction) { ... } | :x: | :no_pedestrians: | :no_pedestrians: | :no_pedestrians: |
routerCanReuse(nextInstruction, prevInstruction) { ... } | :x: | :no_pedestrians: | :no_pedestrians: | :no_pedestrians: |
routerOnReuse(nextInstruction, prevInstruction) { ... } | :x: | :x: | :no_pedestrians: | :no_pedestrians: |
routerCanDeactivate(nextInstruction, prevInstruction) { ... } | :x: | :no_pedestrians: | :no_pedestrians: | :no_pedestrians: |
routerOnDeactivate(nextInstruction, prevInstruction) { ... } | :x: | :no_pedestrians: | :no_pedestrians: | :no_pedestrians: |