OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 4 |
5 package com.google.dart.compiler.parser; | 5 package com.google.dart.compiler.parser; |
6 | 6 |
7 import com.google.dart.compiler.DartCompilationError; | 7 import com.google.dart.compiler.DartCompilationError; |
8 import com.google.dart.compiler.DartCompilerListenerTest; | 8 import com.google.dart.compiler.DartCompilerListenerTest; |
9 import com.google.dart.compiler.DartSourceTest; | 9 import com.google.dart.compiler.DartSourceTest; |
10 import com.google.dart.compiler.ast.DartUnit; | 10 import com.google.dart.compiler.ast.DartUnit; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 /** | 70 /** |
71 * Parse source code in the background | 71 * Parse source code in the background |
72 */ | 72 */ |
73 @Override | 73 @Override |
74 public void run() { | 74 public void run() { |
75 while (true) { | 75 while (true) { |
76 DartSourceTest src; | 76 DartSourceTest src; |
77 ParserContext context; | |
78 synchronized (lock) { | 77 synchronized (lock) { |
79 while (state == ParseState.INIT) { | 78 while (state == ParseState.INIT) { |
80 try { | 79 try { |
81 lock.wait(); | 80 lock.wait(); |
82 } catch (InterruptedException e) { | 81 } catch (InterruptedException e) { |
83 // Fall through | 82 // Fall through |
84 } | 83 } |
85 } | 84 } |
86 if (state == ParseState.STOP) { | 85 if (state == ParseState.STOP) { |
87 return; | 86 return; |
88 } | 87 } |
89 src = new DartSourceTest(srcName, srcCode, null); | 88 src = new DartSourceTest(srcName, srcCode, null); |
90 context = makeParserContext(src, srcCode, listener); | |
91 } | 89 } |
92 DartUnit unit = makeParser(context).parseUnit(src); | 90 DartUnit unit = makeParser(src, srcCode, listener).parseUnit(); |
93 synchronized (lock) { | 91 synchronized (lock) { |
94 if (state == ParseState.STOP) { | 92 if (state == ParseState.STOP) { |
95 return; | 93 return; |
96 } | 94 } |
97 state = ParseState.INIT; | 95 state = ParseState.INIT; |
98 result = unit; | 96 result = unit; |
99 lock.notifyAll(); | 97 lock.notifyAll(); |
100 } | 98 } |
101 } | 99 } |
102 } | 100 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // System.out.println(); | 153 // System.out.println(); |
156 fail("Failed to finish parsing " + srcName + "\n" + modifiedSrcCode); | 154 fail("Failed to finish parsing " + srcName + "\n" + modifiedSrcCode); |
157 } | 155 } |
158 // System.out.print('.'); | 156 // System.out.print('.'); |
159 } | 157 } |
160 thread.stopParsing(); | 158 thread.stopParsing(); |
161 // System.out.println(); | 159 // System.out.println(); |
162 return thread.result; | 160 return thread.result; |
163 } | 161 } |
164 } | 162 } |
OLD | NEW |