Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit f918d4d

Browse files
tfortesjbdeboer
authored andcommitted
fix(template_cache_generator): support traversal of partial files
Fixes #662
1 parent 6fe5692 commit f918d4d

File tree

3 files changed

+39
-26
lines changed

3 files changed

+39
-26
lines changed

lib/tools/template_cache_generator.dart

+10-3
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,15 @@ class TemplateCollectingVisitor {
118118
TemplateCollectingVisitor(this.templates, this.blacklistedClasses,
119119
this.sourceCrawler);
120120

121-
call(CompilationUnitElement cue, String srcPath) {
121+
void call(CompilationUnitElement cue, String srcPath) {
122+
processDeclarations(cue, srcPath);
123+
124+
cue.enclosingElement.parts.forEach((CompilationUnitElement part) {
125+
processDeclarations(part, srcPath);
126+
});
127+
}
128+
129+
void processDeclarations(CompilationUnitElement cue, String srcPath) {
122130
CompilationUnit cu = sourceCrawler.context
123131
.resolveCompilationUnit(cue.source, cue.library);
124132
cu.declarations.forEach((CompilationUnitMember declaration) {
@@ -166,8 +174,7 @@ class TemplateCollectingVisitor {
166174
});
167175
}
168176

169-
bool extractNgTemplateCache(
170-
Annotation ann, List<String> cacheUris) {
177+
bool extractNgTemplateCache(Annotation ann, List<String> cacheUris) {
171178
bool cache = true;
172179
ann.arguments.arguments.forEach((Expression arg) {
173180
if (arg is NamedExpression) {

test/io/test_files/templates/main.dart

+3-23
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,7 @@ library test_files.main;
33
import 'package:angular/core/module.dart';
44
import 'package:angular/tools/template_cache_annotation.dart';
55

6-
@NgComponent(
7-
selector: 'my-component',
8-
templateUrl: '/test/io/test_files/templates/main.html')
9-
@NgTemplateCache()
10-
class MyComponent
11-
{
12-
}
6+
part 'partial.dart';
137

14-
@NgComponent(
15-
selector: 'my-component2',
16-
templateUrl: '/test/io/test_files/templates/dont.html')
17-
@NgTemplateCache(cache: false)
18-
class MyComponent2
19-
{
20-
}
21-
22-
23-
@NgComponent(
24-
selector: 'my-component3',
25-
templateUrl: '/test/io/test_files/templates/dont.html')
26-
@NgTemplateCache(cache: true)
27-
class MyComponent3
28-
{
29-
}
8+
class MainClass {
9+
}
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
part of 'main.dart';
2+
3+
@NgComponent(
4+
selector: 'my-component',
5+
templateUrl: '/test/io/test_files/templates/main.html')
6+
@NgTemplateCache()
7+
class MyComponent
8+
{
9+
}
10+
11+
@NgComponent(
12+
selector: 'my-component2',
13+
templateUrl: '/test/io/test_files/templates/dont.html')
14+
@NgTemplateCache(cache: false)
15+
class MyComponent2
16+
{
17+
}
18+
19+
20+
@NgComponent(
21+
selector: 'my-component3',
22+
templateUrl: '/test/io/test_files/templates/dont.html')
23+
@NgTemplateCache(cache: true)
24+
class MyComponent3
25+
{
26+
}

0 commit comments

Comments
 (0)