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

Commit

Permalink
fix(generator): Avoid compile-time filter map querying when generatin…
Browse files Browse the repository at this point in the history
…g static parser.

This fixes #432.

Also consistenly load libraries through the package root to avoid getting in
trouble if the same library is loaded through different URIs.
  • Loading branch information
Kasper Lund committed Jan 27, 2014
1 parent 73b0dca commit 522ba49
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 26 deletions.
8 changes: 0 additions & 8 deletions bin/parser_generator_for_spec.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import 'dart:io';
import 'package:di/di.dart';
import 'package:di/dynamic_injector.dart';
import 'package:angular/core/module.dart';
import 'package:angular/core/parser/parser.dart';
import 'package:angular/tools/parser_generator/generator.dart';
import 'package:angular/tools/parser_getter_setter/generator.dart';

class NullFilterMap implements FilterMap {
call(name) => null;
Type operator[](annotation) => null;
forEach(fn) { }
annotationsFor(type) => null;
}

main(arguments) {
var isGetter = !arguments.isEmpty;

Expand Down
4 changes: 2 additions & 2 deletions lib/core/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import 'package:angular/core/parser/parser.dart';
import 'package:angular/core/parser/lexer.dart';
import 'package:angular/utils.dart';

import 'service.dart';
export 'service.dart';
import 'package:angular/core/service.dart';
export 'package:angular/core/service.dart';

part "cache.dart";
part "directive.dart";
Expand Down
2 changes: 1 addition & 1 deletion lib/playback/playback_http.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:angular/core_dom/module.dart';
import 'package:angular/core/service.dart';
import 'package:angular/mock/module.dart' as mock;

import 'playback_data.dart' as playback_data;
import 'package:angular/playback/playback_data.dart' as playback_data;

@NgInjectableService()
class PlaybackHttpBackendConfig {
Expand Down
11 changes: 7 additions & 4 deletions lib/tools/expression_extractor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import 'package:angular/tools/common.dart';

import 'package:di/di.dart';
import 'package:di/dynamic_injector.dart';
import 'package:angular/tools/parser_generator/generator.dart';

import 'package:angular/core/module.dart';
import 'package:angular/core/parser/parser.dart';
import 'package:angular/tools/parser_generator/generator.dart';

main(args) {
if (args.length < 5) {
Expand Down Expand Up @@ -50,9 +52,10 @@ main(args) {

printer.printSrc('// Found ${expressions.length} expressions');
Module module = new Module()
..type(Parser, implementedBy: DynamicParser)
..type(ParserBackend, implementedBy: DynamicParserBackend)
..value(SourcePrinter, printer);
..type(Parser, implementedBy: DynamicParser)
..type(ParserBackend, implementedBy: DynamicParserBackend)
..type(FilterMap, implementedBy: NullFilterMap)
..value(SourcePrinter, printer);
Injector injector =
new DynamicInjector(modules: [module], allowImplicitInjection: true);

Expand Down
6 changes: 3 additions & 3 deletions lib/tools/html_extractor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ library angular.html_parser;
import 'package:html5lib/parser.dart';
import 'package:html5lib/dom.dart';

import 'selector.dart';
import 'io.dart';
import 'common.dart';
import 'package:angular/tools/selector.dart';
import 'package:angular/tools/io.dart';
import 'package:angular/tools/common.dart';

typedef NodeVisitor(Node node);

Expand Down
2 changes: 1 addition & 1 deletion lib/tools/io_impl.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
library angular.io_impl;

import 'dart:io';
import 'io.dart';
import 'package:angular/tools/io.dart';

class IoServiceImpl implements IoService {

Expand Down
12 changes: 10 additions & 2 deletions lib/tools/parser_generator/generator.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
library generator;

import 'dart_code_gen.dart';
import '../../core/parser/parser.dart';
import 'package:angular/core/module.dart';
import 'package:angular/core/parser/parser.dart';
import 'package:angular/tools/parser_generator/dart_code_gen.dart';

class NullFilterMap implements FilterMap {
call(name) => null;
Type operator[](annotation) => null;
forEach(fn) { }
annotationsFor(type) => null;
}

class SourcePrinter {
printSrc(src) {
Expand Down
2 changes: 1 addition & 1 deletion lib/tools/source_crawler_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library angular.source_crawler_impl;

import 'dart:io';
import 'package:analyzer/analyzer.dart';
import 'source_crawler.dart';
import 'package:angular/tools/source_crawler.dart';

const String PACKAGE_PREFIX = 'package:';

Expand Down
6 changes: 3 additions & 3 deletions lib/tools/source_metadata_extractor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ library angular.source_metadata_extractor ;

import 'package:analyzer/src/generated/ast.dart';

import 'source_crawler.dart';
import '../utils.dart';
import 'common.dart';
import 'package:angular/tools/source_crawler.dart';
import 'package:angular/tools/common.dart';
import 'package:angular/utils.dart';

const String _COMPONENT = '-component';
const String _DIRECTIVE = '-directive';
Expand Down
2 changes: 1 addition & 1 deletion lib/tools/template_cache_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'dart:async';
import 'dart:collection';

import 'package:analyzer/src/generated/ast.dart';
import 'source_crawler_impl.dart';
import 'package:angular/tools/source_crawler_impl.dart';

const String PACKAGE_PREFIX = 'package:';
const String DART_PACKAGE_PREFIX = 'dart:';
Expand Down

0 comments on commit 522ba49

Please sign in to comment.