| Index: editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/engine/MainEngine.java
|
| diff --git a/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/engine/MainEngine.java b/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/engine/MainEngine.java
|
| index 8bb1473afe8d61796858d2c137184e9a7e1f0055..12bf47b013b27142026cdff0f57cb870d032942b 100644
|
| --- a/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/engine/MainEngine.java
|
| +++ b/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/engine/MainEngine.java
|
| @@ -323,6 +323,8 @@ public class MainEngine {
|
| " * Helper for measuring how much time is spent doing some operation.",
|
| " */",
|
| "class TimeCounter {",
|
| + " static final int NANOS_PER_MILLI = 1000 * 1000;",
|
| + " static final int NANOS_PER_MICRO = 1000;",
|
| " static TimeCounter _current = null;",
|
| " final Stopwatch _sw = new Stopwatch();",
|
| "",
|
| @@ -346,6 +348,7 @@ public class MainEngine {
|
| " */",
|
| "class TimeCounter_TimeCounterHandle {",
|
| " final TimeCounter _counter;",
|
| + " int _startMicros;",
|
| " TimeCounter _prev;",
|
| "",
|
| " TimeCounter_TimeCounterHandle(this._counter) {",
|
| @@ -356,21 +359,27 @@ public class MainEngine {
|
| " }",
|
| " TimeCounter._current = _counter;",
|
| " // start this counter",
|
| + " _startMicros = _counter._sw.elapsedMicroseconds;",
|
| " _counter._sw.start();",
|
| " }",
|
| "",
|
| " /**",
|
| " * Stops counting time and updates counter.",
|
| " */",
|
| - " void stop() {",
|
| + " int stop() {",
|
| " _counter._sw.stop();",
|
| + " int elapsed = (_counter._sw.elapsedMicroseconds - _startMicros) *",
|
| + " TimeCounter.NANOS_PER_MICRO;",
|
| " // restore previous counter and resume it",
|
| " TimeCounter._current = _prev;",
|
| " if (_prev != null) {",
|
| " _prev._sw.start();",
|
| " }",
|
| + " // done",
|
| + " return elapsed;",
|
| " }",
|
| - "}");
|
| + "}",
|
| + "");
|
| Files.write(source, new File(targetFolder + "/utilities_general.dart"), Charsets.UTF_8);
|
| }
|
| {
|
| @@ -528,10 +537,13 @@ public class MainEngine {
|
| }
|
| {
|
| CompilationUnit library = buildResolverTestLibrary();
|
| - Files.write(
|
| - getFormattedSource(library),
|
| - new File(targetTestFolder + "/resolver_test.dart"),
|
| - Charsets.UTF_8);
|
| + String source = getFormattedSource(library);
|
| + // TODO(scheglov) restore this test once TestSource is not file based
|
| + source = replaceSourceFragment(
|
| + source,
|
| + "AnalysisDeltaTest.dartSuite();",
|
| + "//AnalysisDeltaTest.dartSuite();");
|
| + Files.write(source, new File(targetTestFolder + "/resolver_test.dart"), Charsets.UTF_8);
|
| }
|
| {
|
| String projectFolder = new File(targetFolder).getParentFile().getParentFile().getParent();
|
| @@ -544,8 +556,7 @@ public class MainEngine {
|
| List<CompilationUnitMember> members) {
|
| for (CompilationUnitMember member : members) {
|
| // may be removed
|
| - CompilationUnit memberUnit = (CompilationUnit) member.getParent();
|
| - if (memberUnit == null || !memberUnit.getDeclarations().contains(member)) {
|
| + if (isRemoved(member)) {
|
| continue;
|
| }
|
| // OK, add this member
|
| @@ -1072,6 +1083,9 @@ public class MainEngine {
|
| || isEngineTestPath(file, "internal/scope/")) {
|
| List<CompilationUnitMember> unitMembers = entry.getValue();
|
| for (CompilationUnitMember unitMember : unitMembers) {
|
| + if (isRemoved(unitMember)) {
|
| + continue;
|
| + }
|
| boolean isTestSuite = EngineSemanticProcessor.gatherTestSuites(mainStatements, unitMember);
|
| if (!isTestSuite) {
|
| unit.getDeclarations().add(unitMember);
|
| @@ -1207,6 +1221,7 @@ public class MainEngine {
|
| unit.getDirectives().add(importDirective("java_core.dart", null));
|
| unit.getDirectives().add(importDirective("java_io.dart", null));
|
| unit.getDirectives().add(importDirective("utilities_general.dart", null));
|
| + unit.getDirectives().add(importDirective("instrumentation.dart", null));
|
| unit.getDirectives().add(importDirective("engine.dart", null));
|
| unit.getDirectives().add(exportDirective("source.dart"));
|
| for (Entry<File, List<CompilationUnitMember>> entry : context.getFileToMembers().entrySet()) {
|
| @@ -1447,6 +1462,11 @@ public class MainEngine {
|
| engineTestFolder.getAbsolutePath() + "/com/google/dart/engine/" + enginePackage);
|
| }
|
|
|
| + private static boolean isRemoved(CompilationUnitMember member) {
|
| + CompilationUnit memberUnit = (CompilationUnit) member.getParent();
|
| + return memberUnit == null || !memberUnit.getDeclarations().contains(member);
|
| + }
|
| +
|
| private static String makeSource(String... lines) {
|
| return Joiner.on("\n").join(lines);
|
| }
|
|
|