Skip to content

Commit

Permalink
format with dart_style 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
John Messerly committed Jul 31, 2015
1 parent cd1fbf5 commit c5f4228
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 62 deletions.
15 changes: 8 additions & 7 deletions pkg/dev_compiler/bin/devrun.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import 'dart:io';

import 'package:dev_compiler/src/compiler.dart' show validateOptions, compile;
import 'package:dev_compiler/src/options.dart';
import 'package:dev_compiler/src/runner/runtime_utils.dart' show
listOutputFiles, getMainModuleName;
import 'package:dev_compiler/src/runner/runtime_utils.dart'
show listOutputFiles, getMainModuleName;
import 'package:dev_compiler/src/runner/v8_runner.dart' show V8Runner;

import 'package:path/path.dart';


void _showUsageAndExit() {
print('usage: dartdevrun [<options>] <file.dart>\n');
print('<file.dart> is a single Dart file to run.\n');
Expand All @@ -26,7 +25,9 @@ void _showUsageAndExit() {
}

main(List<String> args) async {
args = []..add('--arrow-fn-bind-this')..addAll(args);
args = []
..add('--arrow-fn-bind-this')
..addAll(args);

CompilerOptions options = validateOptions(args, forceOutDir: true);
if (options == null || options.help) {
Expand Down Expand Up @@ -55,8 +56,8 @@ main(List<String> args) async {
}

/// Generates an HTML file that can be used to run the output with Chrome Dev.
_writeHtmlRunner(CompilerOptions options, List<File> files,
String startStatement) async {
_writeHtmlRunner(
CompilerOptions options, List<File> files, String startStatement) async {
String outputDir = options.codegenOptions.outputDir;
String htmlOutput = join(outputDir, "run.html");
await new File(htmlOutput).writeAsString('''
Expand All @@ -67,7 +68,7 @@ _writeHtmlRunner(CompilerOptions options, List<File> files,
<script>$startStatement</script>
</body></html>
''');

stderr.writeln(
'Wrote $htmlOutput. It can be opened in Chrome Dev with the following flags:\n'
'--js-flags="--harmony-arrow-functions '
Expand Down
11 changes: 4 additions & 7 deletions pkg/dev_compiler/lib/src/codegen/html_codegen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,10 @@ String generateEntryHtml(HtmlSourceNode root, AbstractCompiler compiler) {

var libraries = [];
var resources = new Set();
visitInPostOrder(
root,
(n) {
if (n is DartSourceNode) libraries.add(n);
if (n is ResourceSourceNode) resources.add(n);
},
includeParts: false);
visitInPostOrder(root, (n) {
if (n is DartSourceNode) libraries.add(n);
if (n is ResourceSourceNode) resources.add(n);
}, includeParts: false);

root.htmlResourceNodes.forEach((element, resource) {
// Make sure we don't try and add this node again.
Expand Down
13 changes: 7 additions & 6 deletions pkg/dev_compiler/lib/src/runner/runtime_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const _ALIASED_RUNTIME_FILES = const {
/// returns null.
String getRuntimeFileAlias(CompilerOptions options, File file) =>
file.absolute.path.startsWith(_getRuntimeDir(options).absolute.path)
? _ALIASED_RUNTIME_FILES[basename(file.path)] : null;
? _ALIASED_RUNTIME_FILES[basename(file.path)]
: null;

Directory _getRuntimeDir(CompilerOptions options) => new Directory(
join(options.codegenOptions.outputDir, 'dev_compiler', 'runtime'));
Expand All @@ -44,11 +45,11 @@ Future<List<File>> listOutputFiles(CompilerOptions options) async {
int i = defaultRuntimeFiles.indexOf(basename(file.path));
return i < 0 ? maxIndex : i;
}
return files..sort((File a, File b) {
int pa = getPriorityIndex(a),
pb = getPriorityIndex(b);
return pa != pb ? (pa - pb) : a.path.compareTo(b.path);
});
return files
..sort((File a, File b) {
int pa = getPriorityIndex(a), pb = getPriorityIndex(b);
return pa != pb ? (pa - pb) : a.path.compareTo(b.path);
});
}

/// TODO(ochafik): Split / reuse [AbstractCompiler.getModuleName].
Expand Down
13 changes: 8 additions & 5 deletions pkg/dev_compiler/lib/src/runner/v8_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ abstract class V8Runner {
String get _v8Binary => _options.runnerOptions.v8Binary;

Future<Process> start(List<File> files, String startStatement) =>
Process.start(_v8Binary,
Process.start(
_v8Binary,
[
"--harmony_arrow_functions",
"--harmony_classes",
Expand All @@ -59,7 +60,8 @@ abstract class V8Runner {
"--harmony_object_literals",
"--harmony_rest_parameters",
"--harmony_spreadcalls",
"-e", _GLOBALS + _getLoadStatements(files).join() + startStatement
"-e",
_GLOBALS + _getLoadStatements(files).join() + startStatement
],
workingDirectory: _options.codegenOptions.outputDir);

Expand Down Expand Up @@ -100,7 +102,8 @@ class _NodeRunner extends V8Runner {

@override
_getLoadStatements(List<File> files) => files.map((file) {
String alias = getRuntimeFileAlias(_options, file);
return (alias != null ? 'var $alias = ' : '') + 'require("${file.path}");';
});
String alias = getRuntimeFileAlias(_options, file);
return (alias != null ? 'var $alias = ' : '') +
'require("${file.path}");';
});
}
47 changes: 22 additions & 25 deletions pkg/dev_compiler/lib/src/server/dependency_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -459,31 +459,28 @@ rebuild(SourceNode start, bool build(SourceNode node)) {
.any((i) => apiChangeDetected.contains(i));
}

visitInPostOrder(
start,
(n) {
if (n.structureChanged) htmlNeedsRebuild = true;
if (shouldBuildNode(n)) {
var oldHash = n.cachingHash;
if (build(n)) apiChangeDetected.add(n);
if (oldHash != n.cachingHash) htmlNeedsRebuild = true;
} else if (n is DartSourceNode &&
n.exports.any((e) => apiChangeDetected.contains(e))) {
apiChangeDetected.add(n);
}
n.needsRebuild = false;
n.structureChanged = false;
if (n is DartSourceNode) {
// Note: clearing out flags in the parts could be a problem if someone
// tries to use a file both as a part and a library at the same time.
// In that case, we might not correctly propagate changes in the
// places where it is used as a library.
// Technically it's not allowed to have a file as a part and a library
// at once, and the analyzer should report an error in that case.
n.parts.forEach((p) => p.needsRebuild = p.structureChanged = false);
}
},
includeParts: false);
visitInPostOrder(start, (n) {
if (n.structureChanged) htmlNeedsRebuild = true;
if (shouldBuildNode(n)) {
var oldHash = n.cachingHash;
if (build(n)) apiChangeDetected.add(n);
if (oldHash != n.cachingHash) htmlNeedsRebuild = true;
} else if (n is DartSourceNode &&
n.exports.any((e) => apiChangeDetected.contains(e))) {
apiChangeDetected.add(n);
}
n.needsRebuild = false;
n.structureChanged = false;
if (n is DartSourceNode) {
// Note: clearing out flags in the parts could be a problem if someone
// tries to use a file both as a part and a library at the same time.
// In that case, we might not correctly propagate changes in the
// places where it is used as a library.
// Technically it's not allowed to have a file as a part and a library
// at once, and the analyzer should report an error in that case.
n.parts.forEach((p) => p.needsRebuild = p.structureChanged = false);
}
}, includeParts: false);
}

/// Helper that runs [action] on nodes reachable from [start] in pre-order.
Expand Down
2 changes: 1 addition & 1 deletion pkg/dev_compiler/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dev_dependencies:
# We pin a specific version to ensure everyone is formatting the code exactly
# the same way. This is because any change in dart_style, even non-breaking
# changes, may change the output format.
dart_style: 0.2.0-rc.3
dart_style: 0.2.0
pub_semver: ^1.1.0
test: ^0.12.0
environment:
Expand Down
11 changes: 4 additions & 7 deletions pkg/dev_compiler/test/checker/self_host_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ import 'package:test/test.dart';
import '../testing.dart' show testDirectory, realSdkContext;

void main() {
test(
'checker can run on itself ',
() {
new BatchCompiler(realSdkContext, new CompilerOptions())
.compileFromUriString('$testDirectory/all_tests.dart');
},
skip: 'test is very slow');
test('checker can run on itself ', () {
new BatchCompiler(realSdkContext, new CompilerOptions())
.compileFromUriString('$testDirectory/all_tests.dart');
}, skip: 'test is very slow');
}
10 changes: 6 additions & 4 deletions pkg/dev_compiler/test/testing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ void testChecker(Map<String, String> testFiles,
var provider = createTestResourceProvider(testFiles);
var uriResolver = new TestUriResolver(provider);
var context = AnalysisEngine.instance.createAnalysisContext();
context.sourceFactory = createSourceFactory(new SourceResolverOptions(
customUrlMappings: customUrlMappings,
useMockSdk: sdkDir == null,
dartSdkPath: sdkDir), fileResolvers: [uriResolver]);
context.sourceFactory = createSourceFactory(
new SourceResolverOptions(
customUrlMappings: customUrlMappings,
useMockSdk: sdkDir == null,
dartSdkPath: sdkDir),
fileResolvers: [uriResolver]);

var checker = new StrongChecker(
context,
Expand Down

0 comments on commit c5f4228

Please sign in to comment.