Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: lib/src/mirror_loader.dart

Issue 888943002: added plugin transformer which initializers can extend to do additional post-processing during tran… (Closed) Base URL: git@github.com:dart-lang/static-init.git@master
Patch Set: update pubspec/changelog Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/plugin_transformer.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 library initialize.mirror_loader; 4 library initialize.mirror_loader;
5 5
6 import 'dart:collection' show Queue; 6 import 'dart:collection' show Queue;
7 import 'dart:mirrors'; 7 import 'dart:mirrors';
8 import 'package:path/path.dart' as path; 8 import 'package:path/path.dart' as path;
9 import 'package:initialize/initialize.dart'; 9 import 'package:initialize/initialize.dart';
10 10
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // TODO(jakemac): Support static class methods. 142 // TODO(jakemac): Support static class methods.
143 throw _TOP_LEVEL_FUNCTIONS_ONLY; 143 throw _TOP_LEVEL_FUNCTIONS_ONLY;
144 } 144 }
145 annotatedValue = (declaration.owner as ObjectMirror) 145 annotatedValue = (declaration.owner as ObjectMirror)
146 .getField(declaration.simpleName).reflectee; 146 .getField(declaration.simpleName).reflectee;
147 } else if (declaration is LibraryMirror) { 147 } else if (declaration is LibraryMirror) {
148 var package; 148 var package;
149 var filePath; 149 var filePath;
150 Uri uri = declaration.uri; 150 Uri uri = declaration.uri;
151 if (uri.scheme == 'file' || uri.scheme.startsWith('http')) { 151 if (uri.scheme == 'file' || uri.scheme.startsWith('http')) {
152 filePath = path.url.relative( 152 filePath = path.url.relative(uri.path,
153 uri.path, from: path.url.dirname(_root.uri.path)); 153 from: path.url.dirname(_root.uri.path));
154 } else if (uri.scheme == 'package') { 154 } else if (uri.scheme == 'package') {
155 var segments = uri.pathSegments; 155 var segments = uri.pathSegments;
156 package = segments[0]; 156 package = segments[0];
157 filePath = path.url.joinAll(segments.getRange(1, segments.length)); 157 filePath = path.url.joinAll(segments.getRange(1, segments.length));
158 } else { 158 } else {
159 throw new UnsupportedError('Unsupported uri scheme ${uri.scheme} for ' 159 throw new UnsupportedError('Unsupported uri scheme ${uri.scheme} for '
160 'library ${declaration}.'); 160 'library ${declaration}.');
161 } 161 }
162 annotatedValue = 162 annotatedValue =
163 new LibraryIdentifier(declaration.qualifiedName, package, filePath); 163 new LibraryIdentifier(declaration.qualifiedName, package, filePath);
(...skipping 21 matching lines...) Expand all
185 return true; 185 return true;
186 } 186 }
187 } 187 }
188 188
189 final _TOP_LEVEL_FUNCTIONS_ONLY = new UnsupportedError( 189 final _TOP_LEVEL_FUNCTIONS_ONLY = new UnsupportedError(
190 'Only top level methods are supported for initializers'); 190 'Only top level methods are supported for initializers');
191 191
192 final _UNSUPPORTED_DECLARATION = new UnsupportedError( 192 final _UNSUPPORTED_DECLARATION = new UnsupportedError(
193 'Initializers are only supported on libraries, classes, and top level ' 193 'Initializers are only supported on libraries, classes, and top level '
194 'methods'); 194 'methods');
OLDNEW
« no previous file with comments | « lib/plugin_transformer.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698