Commit Graph

261 Commits

Author SHA1 Message Date
Tobias Bosch f5c8e0989d feat(core): properly support inheritance
## Inheritance Semantics:

Decorators:
1) list the decorators of the class and its parents in the ancestor first order
2) only use the last decorator of each kind (e.g. @Component / ...)

Constructor parameters:
If a class inherits from a parent class and does not declare
a constructor, it inherits the parent class constructor,
and with it the parameter metadata of that parent class.

Lifecycle hooks:
Follow the normal class inheritance model,
i.e. lifecycle hooks of parent classes will be called
even if the method is not overwritten in the child class.

## Example

E.g. the following is a valid use of inheritance and it will
also inherit all metadata:

```
@Directive({selector: 'someDir'})
class ParentDirective {
  constructor(someDep: SomeDep) {}

  ngOnInit() {}
}

class ChildDirective extends ParentDirective {}
```

Closes #11606
Closes #12892
2016-11-28 14:12:12 -08:00
Tobias Bosch 2a5bd2f345 refactor(compiler): Reintroduce `ReflectorHost` and move `Extractor` into `@angular/compiler` 2016-11-18 10:04:14 -08:00
Tobias Bosch 3c06a5dc25 refactor(comiler): various cleanups 2016-11-18 10:04:14 -08:00
Tobias Bosch adeea5d86a refactor(compiler): renames
- `NgHost` to `CompilerHost`
- `AotCompilerHost.resolveFileToImport` to `AotCompilerHost.fileNameToModuleName`
- `AotCompilerHoset.resolveImportToFile` to `AotCompilerHost.moduleNameToFileName`
2016-11-18 10:04:14 -08:00
Tobias Bosch dddbb1c1cb refactor(tsc-wrapped): collect all exported functions and classes and bump metadata version from 1 to 2
This is needed to resolve symbols without `.d.ts` files.
This bumps the version of the metadata from 1 to 2.
This adds logic into `ng_host.ts` to automatically upgrade
version 1 to version 2 metadata by adding the exported symbols
from the `.d.ts` file.
2016-11-18 10:04:14 -08:00
Tobias Bosch 2235048432 refactor(compiler): add `createAotCompiler` factory
Also adds 2 more methods to the `AotCompilerHost`:
- `loadResource`
- `resolveFileToImport`
2016-11-18 10:04:14 -08:00
Tobias Bosch 484119e59f refactor(compiler): remove `asset:` urls
These urls were just relicts from Dart.
2016-11-18 10:04:14 -08:00
Tobias Bosch 24099bdbd2 refactor(compiler): move `findDeclaration` into the `StaticReflector`
Previously, this was part of the `AotCompilerHost`.
The `AotCompilerHost` is now also greatly simplified.
2016-11-18 10:04:14 -08:00
Tobias Bosch 912ca44979 refactor(compiler): move `static_reflector` into `@angular/compiler` and rename files
- `src/runtime_compiler.ts` -> `src/jit/compiler.ts`
- `src/compiler.ts` -> `src/jit/compiler_factory.ts`
- `src/offline_compiler` -> `src/aot/compiler.ts`

Part of #12867
2016-11-18 10:04:14 -08:00
Victor Berchet 7908679c4b fix(compiler): assert xliff messages have translations
fixes #12815
closes #12604
2016-11-14 12:55:56 -08:00
Victor Berchet 9ed9ff40b3 test(compiler): improve xliff tests 2016-11-14 12:55:48 -08:00
Victor Berchet 2f14415836 fix(compiler): updates hash algo for xmb/xtb files 2016-11-14 12:55:48 -08:00
Victor Berchet 76e4911e8b fix(core): fix placeholders handling in i18n.
Prior to this commit, translations were built in the serializers. This
could not work as a single translation can be used for different source
messages having different placeholder content.

Serializers do not try to replace the placeholders any more.
Placeholders are replaced by the translation bundle and the source
message is given as parameter so that the content of the placeholders is
taken into account.

Also XMB ids are now independent of the expression which is replaced by
a placeholder in the extracted file.
fixes #12512
2016-11-14 12:55:48 -08:00
Victor Berchet 05beffe0d0 test(core): fix a typo in the i18n integration spec 2016-11-14 12:55:48 -08:00
Victor Berchet 08c038ebd9 fix(core): xmb serializer uses decimal messaged IDs
fixes #12511
2016-11-14 12:55:48 -08:00
Victor Berchet 582550a90d feat(core): implements a decimal fingerprint for i18n 2016-11-14 12:55:48 -08:00
Joao Dias 77ee27c59e refactor(): use const and let instead of var 2016-11-12 16:40:17 -08:00
Chuck Jazdzewski a965d11cce fix(compiler): generate safe access strictNullChecks compatible code (#12800)
fixes #12795
2016-11-11 17:12:17 -08:00
Tobias Bosch fcb4e66493 refactor(compiler): introduce summaries for metadata (#12799)
This does not yet introduce loading / serialization of summaries.

Part of #12787
2016-11-10 16:27:53 -08:00
Tobias Bosch 79383ce150 refactor(compiler): never create CompileDirectiveMetadata with not loaded resources (#12788)
Part of #12787
2016-11-10 14:07:30 -08:00
Chuck Jazdzewski c3c0e2e2a2 refactor(compiler): add `span` to `TemplateBinding` (#12792)
fix(compiler): corrected error location for implicit templates expressions
2016-11-10 13:15:09 -08:00
Matias Niemelä a0e9fde653 fix(animations): always normalize style properties and values during compilation (#12755)
Closes #11582
Closes #12481
Closes #12755
2016-11-08 15:45:30 -08:00
Victor Berchet 778e6ad3b4 refactor: cleanup ICU message syntax 2016-11-08 15:44:18 -08:00
Victor Berchet 55dc0e4a5f fix(compiler): use the other case by default in ICU messages 2016-11-08 15:44:18 -08:00
Victor Berchet acbf1d859c fix(core): fix pseudo-selector shimming (#12754)
fixes #12730
fixes #12354
2016-11-07 13:56:04 -08:00
Victor Berchet ec92f4b198 refactor: remove `keys()` and `values()` from MapWrapper 2016-11-04 13:27:38 -07:00
Pawel Kozlowski f0cdb428f5 fix(compiler): don't convert undefined to null literals (#11503)
Fixes #11493
2016-11-04 10:55:21 -07:00
Tobias Bosch d1035da85c refactor(compiler): don’t use `AppElement`s for creating component views 2016-11-02 17:06:27 -07:00
Tobias Bosch a178bc6c83 fix(compiler): dedupe NgModule declarations, …
This is important so that we don’t generate things multiple times.
2016-10-31 14:43:50 -07:00
Zaven Muradyan e9fd8645ed fix(core): improve error when multiple components match the same element
Closes #7067
2016-10-31 11:28:03 -07:00
Dzmitry Shylovich d321b0ebf5 fix(selectors): use Maps instead of objects 2016-10-26 14:55:59 -07:00
Tobias Bosch 178fb79b5c refactor(compiler): move host properties into DirectiveWrapper
Part of #11683
2016-10-26 14:32:24 -07:00
Tobias Bosch fe299f4dfc refactor(compiler): minor cleanups 2016-10-26 14:32:24 -07:00
Tobias Bosch faa3478514 refactor(compiler): set element attributes via one call
This makes the cost of using directives that have host attributes
smaller.

Part of #11683
2016-10-26 14:32:23 -07:00
Tobias Bosch 867494a060 fix(compiler): don't access view local variables nor pipes in host expressions (#12396)
Fixes #12004
Closes #12071
2016-10-20 15:24:58 -07:00
Tobias Bosch b0a03fcab3 refactor(compiler): introduce directive wrappers to generate less code
- for now only wraps the `@Input` properties and calls
  to `ngOnInit`, `ngDoCheck` and `ngOnChanges` of directives.
- also groups eval sources by NgModule.

Part of #11683
2016-10-20 10:41:43 -07:00
Victor Berchet 76dd026447 refactor: remove some facades (#12335) 2016-10-19 13:42:39 -07:00
Victor Berchet df1718d624 fix(compiler): allow WS as `<ng-content>` content (#12225) 2016-10-12 07:58:06 -07:00
Chuck Jazdzewski 7275e1beb3 refactor(compiler): add optional `visit()` to `TemplateAstVisitor` (#12209) 2016-10-11 15:46:11 -07:00
Victor Berchet e6e007e2f1 refactor(core): cleanup SpyObject (#12221) 2016-10-11 15:44:48 -07:00
Victor Berchet d972d82354 refactor: simplify `isPresent(x) ? x : y` to `x || y` (#12166)
Closes #12166
2016-10-10 09:20:58 -07:00
Victor Berchet bdcf46f82e refactor(compiler): improve types, misc 2016-10-10 09:20:58 -07:00
Victor Berchet aa92512ac6 fix(compiler): properly shim `:host:before` and `:host(:before)` (#12171)
fixes #12165
2016-10-10 09:15:15 -07:00
Chuck Jazdzewski 4202936bbf refactor(compiler): add optional `visit()` to html AST `Visitor` (#12135) 2016-10-10 09:13:50 -07:00
Chuck Jazdzewski e1faca6386 refactor(compiler): template element ast has endSourceSpan (#12138) 2016-10-10 09:12:05 -07:00
Victor Berchet 13ecc140e8 fix(compiler): validate `@HostBinding` name (#12139)
relates to #7500
2016-10-07 13:53:53 -07:00
Chuck Jazdzewski 709a6dea06 refactor(compiler): attribute ast records span of the value (#12132) 2016-10-07 13:53:29 -07:00
Chuck Jazdzewski d641c36a45 fix(compiler): interpolation expressions report the correct offset (#12125) 2016-10-06 15:22:10 -07:00
Alex Eagle 8c975ed156 refactor(facade): inline StringWrapper (#12051) 2016-10-06 15:10:27 -07:00
Victor Berchet 50c37d45dc refactor: simplify arrow functions (#12057) 2016-10-04 15:57:37 -07:00