From 6c3d1df3f46eb0244f24f371468cc800a32cbaf7 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Fri, 9 May 2014 13:30:14 +0200 Subject: [PATCH] refactor: annotate with @Inject All class/function providers have to be annotated with `@Inject` (even if they don't have any arguments). Otherwise the token gets injected as value. TODO: We should extract all the annotations (such as `Inject`, `Provide`) into a separate module so that expressionist does not have to include entire di. --- package.json | 3 ++- src/parser.js | 4 ++++ src/watch_parser.js | 4 ++++ test-main.js | 3 ++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6980a4f..e64a268 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ }, "dependencies": { "es6-shim": "~0.9.2", - "watchtower": "angular/watchtower.js" + "watchtower": "angular/watchtower.js", + "di": "angular/di.js" }, "devDependencies": { "gulp": "^3.5.6", diff --git a/src/parser.js b/src/parser.js index ca285e9..3f6c5bb 100644 --- a/src/parser.js +++ b/src/parser.js @@ -1,3 +1,6 @@ +// TODO(vojta): use only di-annotations +import {Inject} from 'di'; + import {Lexer,Token} from './lexer'; import {Expression,ArrayOfExpression,Chain,Filter,Assign, Conditional, AccessScope, AccessMember, AccessKeyed, @@ -6,6 +9,7 @@ import {Expression,ArrayOfExpression,Chain,Filter,Assign, var EOF = new Token(-1, null); +@Inject export class Parser { constructor(){ this.cache = {}; diff --git a/src/watch_parser.js b/src/watch_parser.js index f9515ee..732c202 100644 --- a/src/watch_parser.js +++ b/src/watch_parser.js @@ -1,3 +1,6 @@ +// TODO(vojta): use only di-annotations +import {Inject} from 'di'; + import {AST, ContextReferenceAST, CollectionAST, MethodAST, FieldReadAST, PureFunctionAST, ConstantAST} from 'watchtower'; @@ -12,6 +15,7 @@ import {Expression,ArrayOfExpression,Chain,Filter,Assign, var scopeContextRef = new ContextReferenceAST(); +@Inject export class WatchParser { constructor(parser:Parser){ this._parser = parser; diff --git a/test-main.js b/test-main.js index b4eb627..686b3c0 100644 --- a/test-main.js +++ b/test-main.js @@ -22,7 +22,8 @@ require.config({ }, map: { '*': { - 'watchtower': 'node_modules/watchtower/src/index' + 'watchtower': 'node_modules/watchtower/src/index', + 'di': 'node_modules/di/src/index' } },