11import * as Lint from 'tslint' ;
22import * as ts from 'typescript' ;
33import * as compiler from '@angular/compiler' ;
4- import { parseTemplate } from './templates/templateParser' ;
4+ import { parseTemplate } from './templates/templateParser' ;
55
66import { parseCss } from './styles/parseCss' ;
77import { CssAst } from './styles/cssAst' ;
88import { BasicCssAstVisitor , CssAstVisitorCtrl } from './styles/basicCssAstVisitor' ;
99
10- import { RecursiveAngularExpressionVisitorCtr , BasicTemplateAstVisitor , TemplateAstVisitorCtr } from './templates/basicTemplateAstVisitor' ;
10+ import {
11+ RecursiveAngularExpressionVisitorCtr ,
12+ BasicTemplateAstVisitor ,
13+ TemplateAstVisitorCtr
14+ } from './templates/basicTemplateAstVisitor' ;
1115import { RecursiveAngularExpressionVisitor } from './templates/recursiveAngularExpressionVisitor' ;
1216import { ReferenceCollectorVisitor } from './templates/referenceCollectorVisitor' ;
1317
@@ -34,9 +38,9 @@ export interface NgWalkerConfig {
3438
3539export class NgWalker extends Lint . RuleWalker {
3640 constructor ( sourceFile : ts . SourceFile ,
37- protected _originalOptions : Lint . IOptions ,
38- private _config ?: NgWalkerConfig ,
39- protected _metadataReader ?: MetadataReader ) {
41+ protected _originalOptions : Lint . IOptions ,
42+ private _config ?: NgWalkerConfig ,
43+ protected _metadataReader ?: MetadataReader ) {
4044
4145 super ( sourceFile , _originalOptions ) ;
4246
@@ -74,34 +78,55 @@ export class NgWalker extends Lint.RuleWalker {
7478 let name = getDecoratorName ( decorator ) ;
7579 if ( name === 'HostListener' ) {
7680 this . visitNgHostListener ( < ts . MethodDeclaration > decorator . parent ,
77- decorator , getDecoratorStringArgs ( decorator ) ) ;
81+ decorator , getDecoratorStringArgs ( decorator ) ) ;
7882 }
7983 }
8084
8185 protected visitPropertyDecorator ( decorator : ts . Decorator ) {
8286 let name = getDecoratorName ( decorator ) ;
8387 switch ( name ) {
8488 case 'Input' :
85- this . visitNgInput ( < ts . PropertyDeclaration > decorator . parent ,
89+ this . visitNgInput ( < ts . PropertyDeclaration > decorator . parent ,
8690 decorator , getDecoratorStringArgs ( decorator ) ) ;
87- break ;
91+ break ;
8892 case 'Output' :
89- this . visitNgOutput ( < ts . PropertyDeclaration > decorator . parent ,
93+ this . visitNgOutput ( < ts . PropertyDeclaration > decorator . parent ,
9094 decorator , getDecoratorStringArgs ( decorator ) ) ;
91- break ;
95+ break ;
9296 case 'HostBinding' :
93- this . visitNgHostBinding ( < ts . PropertyDeclaration > decorator . parent ,
97+ this . visitNgHostBinding ( < ts . PropertyDeclaration > decorator . parent ,
98+ decorator , getDecoratorStringArgs ( decorator ) ) ;
99+ break ;
100+ case 'ContentChild' :
101+ this . visitNgContentChild ( < ts . PropertyDeclaration > decorator . parent ,
102+ decorator , getDecoratorStringArgs ( decorator ) ) ;
103+ break ;
104+ case 'ContentChildren' :
105+ this . visitNgContentChildren ( < ts . PropertyDeclaration > decorator . parent ,
106+ decorator , getDecoratorStringArgs ( decorator ) ) ;
107+ break ;
108+ case 'ViewChild' :
109+ this . visitNgViewChild ( < ts . PropertyDeclaration > decorator . parent ,
94110 decorator , getDecoratorStringArgs ( decorator ) ) ;
95- break ;
111+ break ;
112+ case 'ViewChildren' :
113+ this . visitNgViewChildren ( < ts . PropertyDeclaration > decorator . parent ,
114+ decorator , getDecoratorStringArgs ( decorator ) ) ;
115+ break ;
96116 }
97117 }
98118
99119 protected visitClassDecorator ( decorator : ts . Decorator ) {
100120 let name = getDecoratorName ( decorator ) ;
121+
122+ if ( name === 'Injectable' ) {
123+ this . visitNgInjectable ( < ts . ClassDeclaration > decorator . parent , decorator ) ;
124+ }
125+
101126 // Not invoked @Component or @Pipe, or @Directive
102127 if ( ! ( < ts . CallExpression > decorator . expression ) . arguments ||
103- ! ( < ts . CallExpression > decorator . expression ) . arguments . length ||
104- ! ( < ts . ObjectLiteralExpression > ( < ts . CallExpression > decorator . expression ) . arguments [ 0 ] ) . properties ) {
128+ ! ( < ts . CallExpression > decorator . expression ) . arguments . length ||
129+ ! ( < ts . ObjectLiteralExpression > ( < ts . CallExpression > decorator . expression ) . arguments [ 0 ] ) . properties ) {
105130 return ;
106131 }
107132
@@ -118,7 +143,8 @@ export class NgWalker extends Lint.RuleWalker {
118143 pos = node . pos + 1 ;
119144 try {
120145 pos = node . getStart ( ) + 1 ;
121- } catch ( e ) { }
146+ } catch ( e ) {
147+ }
122148 }
123149 return pos ;
124150 } ;
@@ -143,17 +169,38 @@ export class NgWalker extends Lint.RuleWalker {
143169 }
144170 }
145171
146- protected visitNgDirective ( metadata : DirectiveMetadata ) { }
172+ protected visitNgDirective ( metadata : DirectiveMetadata ) {
173+ }
174+
175+ protected visitNgPipe ( controller : ts . ClassDeclaration , decorator : ts . Decorator ) {
176+ }
177+
178+ protected visitNgInjectable ( classDeclaration : ts . ClassDeclaration , decorator : ts . Decorator ) {
179+ }
147180
148- protected visitNgPipe ( controller : ts . ClassDeclaration , decorator : ts . Decorator ) { }
181+ protected visitNgInput ( property : ts . PropertyDeclaration , input : ts . Decorator , args : string [ ] ) {
182+ }
149183
150- protected visitNgInput ( property : ts . PropertyDeclaration , input : ts . Decorator , args : string [ ] ) { }
184+ protected visitNgOutput ( property : ts . PropertyDeclaration , output : ts . Decorator , args : string [ ] ) {
185+ }
151186
152- protected visitNgOutput ( property : ts . PropertyDeclaration , output : ts . Decorator , args : string [ ] ) { }
187+ protected visitNgHostBinding ( property : ts . PropertyDeclaration , decorator : ts . Decorator , args : string [ ] ) {
188+ }
153189
154- protected visitNgHostBinding ( property : ts . PropertyDeclaration , decorator : ts . Decorator , args : string [ ] ) { }
190+ protected visitNgHostListener ( method : ts . MethodDeclaration , decorator : ts . Decorator , args : string [ ] ) {
191+ }
155192
156- protected visitNgHostListener ( method : ts . MethodDeclaration , decorator : ts . Decorator , args : string [ ] ) { }
193+ protected visitNgContentChild ( property : ts . PropertyDeclaration , input : ts . Decorator , args : string [ ] ) {
194+ }
195+
196+ protected visitNgContentChildren ( property : ts . PropertyDeclaration , input : ts . Decorator , args : string [ ] ) {
197+ }
198+
199+ protected visitNgViewChild ( property : ts . PropertyDeclaration , input : ts . Decorator , args : string [ ] ) {
200+ }
201+
202+ protected visitNgViewChildren ( property : ts . PropertyDeclaration , input : ts . Decorator , args : string [ ] ) {
203+ }
157204
158205 protected visitNgTemplateHelper ( roots : compiler . TemplateAst [ ] , context : ComponentMetadata , baseStart : number ) {
159206 if ( ! roots || ! roots . length ) {
0 commit comments