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

fix(template_cache_generator): support traversal of partial files #663

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/tools/template_cache_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,15 @@ class TemplateCollectingVisitor {
TemplateCollectingVisitor(this.templates, this.blacklistedClasses,
this.sourceCrawler);

call(CompilationUnitElement cue, String srcPath) {
void call(CompilationUnitElement cue, String srcPath) {
processDeclarations(cue, srcPath);

cue.enclosingElement.parts.forEach((CompilationUnitElement part) {
processDeclarations(part, srcPath);
});
}

void processDeclarations(CompilationUnitElement cue, String srcPath) {
CompilationUnit cu = sourceCrawler.context
.resolveCompilationUnit(cue.source, cue.library);
cu.declarations.forEach((CompilationUnitMember declaration) {
Expand Down Expand Up @@ -166,8 +174,7 @@ class TemplateCollectingVisitor {
});
}

bool extractNgTemplateCache(
Annotation ann, List<String> cacheUris) {
bool extractNgTemplateCache(Annotation ann, List<String> cacheUris) {
bool cache = true;
ann.arguments.arguments.forEach((Expression arg) {
if (arg is NamedExpression) {
Expand Down
26 changes: 3 additions & 23 deletions test/io/test_files/templates/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,7 @@ library test_files.main;
import 'package:angular/core/module.dart';
import 'package:angular/tools/template_cache_annotation.dart';

@NgComponent(
selector: 'my-component',
templateUrl: '/test/io/test_files/templates/main.html')
@NgTemplateCache()
class MyComponent
{
}
part 'partial.dart';

@NgComponent(
selector: 'my-component2',
templateUrl: '/test/io/test_files/templates/dont.html')
@NgTemplateCache(cache: false)
class MyComponent2
{
}


@NgComponent(
selector: 'my-component3',
templateUrl: '/test/io/test_files/templates/dont.html')
@NgTemplateCache(cache: true)
class MyComponent3
{
}
class MainClass {
}
26 changes: 26 additions & 0 deletions test/io/test_files/templates/partial.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
part of 'main.dart';

@NgComponent(
selector: 'my-component',
templateUrl: '/test/io/test_files/templates/main.html')
@NgTemplateCache()
class MyComponent
{
}

@NgComponent(
selector: 'my-component2',
templateUrl: '/test/io/test_files/templates/dont.html')
@NgTemplateCache(cache: false)
class MyComponent2
{
}


@NgComponent(
selector: 'my-component3',
templateUrl: '/test/io/test_files/templates/dont.html')
@NgTemplateCache(cache: true)
class MyComponent3
{
}