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

Commit

Permalink
fix(template_cache_generator): support traversal of partial files
Browse files Browse the repository at this point in the history
Fixes #662
  • Loading branch information
tfortes authored and jbdeboer committed Mar 5, 2014
1 parent 6fe5692 commit f918d4d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 26 deletions.
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
{
}

0 comments on commit f918d4d

Please sign in to comment.