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

Side by Side Diff: pkg/analyzer_experimental/lib/src/generated/engine.dart

Issue 18612009: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 library engine; 3 library engine;
4 import 'dart:collection' show HasNextIterator; 4 import 'dart:collection' show HasNextIterator;
5 import 'java_core.dart'; 5 import 'java_core.dart';
6 import 'java_engine.dart'; 6 import 'java_engine.dart';
7 import 'instrumentation.dart'; 7 import 'instrumentation.dart';
8 import 'error.dart'; 8 import 'error.dart';
9 import 'source.dart'; 9 import 'source.dart';
10 import 'scanner.dart' show Token, CharBufferScanner, StringScanner; 10 import 'scanner.dart' show Token, CharBufferScanner, StringScanner;
(...skipping 2239 matching lines...) Expand 10 before | Expand all | Expand 10 after
2250 return dartEntry.getValue(DartEntry.IMPORTED_LIBRARIES); 2250 return dartEntry.getValue(DartEntry.IMPORTED_LIBRARIES);
2251 } else { 2251 } else {
2252 DartEntryImpl dartCopy = dartEntry.writableCopy; 2252 DartEntryImpl dartCopy = dartEntry.writableCopy;
2253 internalParseCompilationUnit(dartCopy, source); 2253 internalParseCompilationUnit(dartCopy, source);
2254 _sourceMap[source] = dartCopy; 2254 _sourceMap[source] = dartCopy;
2255 return dartCopy.getValue(DartEntry.IMPORTED_LIBRARIES); 2255 return dartCopy.getValue(DartEntry.IMPORTED_LIBRARIES);
2256 } 2256 }
2257 } 2257 }
2258 } 2258 }
2259 SourceKind computeKindOf(Source source) { 2259 SourceKind computeKindOf(Source source) {
2260 { 2260 SourceEntry sourceEntry = getReadableSourceEntry(source);
2261 SourceEntry sourceEntry = getSourceEntry(source); 2261 if (sourceEntry == null) {
2262 if (sourceEntry == null) { 2262 return SourceKind.UNKNOWN;
2263 } else if (sourceEntry is DartEntry) {
2264 try {
2265 return internalGetDartParseData(source, (sourceEntry as DartEntry), Dart Entry.SOURCE_KIND, SourceKind.UNKNOWN);
2266 } on AnalysisException catch (exception) {
2263 return SourceKind.UNKNOWN; 2267 return SourceKind.UNKNOWN;
2264 } else if (sourceEntry is DartEntry) {
2265 DartEntry dartEntry = sourceEntry as DartEntry;
2266 CacheState sourceKindState = dartEntry.getState(DartEntry.SOURCE_KIND);
2267 if (sourceKindState != CacheState.VALID && sourceKindState != CacheState .ERROR) {
2268 internalComputeKindOf(source);
2269 sourceEntry = getSourceEntry(source);
2270 }
2271 } 2268 }
2272 return sourceEntry.kind;
2273 } 2269 }
2270 return sourceEntry.kind;
2274 } 2271 }
2275 LibraryElement computeLibraryElement(Source source) { 2272 LibraryElement computeLibraryElement(Source source) {
2276 { 2273 {
2277 DartEntry dartEntry = getDartEntry(source); 2274 DartEntry dartEntry = getDartEntry(source);
2278 if (dartEntry == null) { 2275 if (dartEntry == null) {
2279 return null; 2276 return null;
2280 } 2277 }
2281 LibraryElement element = dartEntry.getValue(DartEntry.ELEMENT); 2278 LibraryElement element = dartEntry.getValue(DartEntry.ELEMENT);
2282 if (element == null) { 2279 if (element == null) {
2283 LibraryResolver resolver = new LibraryResolver(this); 2280 LibraryResolver resolver = new LibraryResolver(this);
2284 try { 2281 try {
2285 element = resolver.resolveLibrary(source, true); 2282 element = resolver.resolveLibrary(source, true);
2286 recordResolutionResults(resolver); 2283 recordResolutionResults(resolver);
2287 } on AnalysisException catch (exception) { 2284 } on AnalysisException catch (exception) {
2288 DartEntryImpl dartCopy = getDartEntry(source).writableCopy; 2285 DartEntryImpl dartCopy = getDartEntry(source).writableCopy;
2289 dartCopy.setState(DartEntry.RESOLVED_UNIT, CacheState.ERROR); 2286 dartCopy.recordResolutionError();
2290 dartCopy.setState(DartEntry.ELEMENT, CacheState.ERROR);
2291 _sourceMap[source] = dartCopy; 2287 _sourceMap[source] = dartCopy;
2292 AnalysisEngine.instance.logger.logError2("Could not resolve the librar y ${source.fullName}", exception); 2288 AnalysisEngine.instance.logger.logError2("Could not resolve the librar y ${source.fullName}", exception);
2293 } 2289 }
2294 } 2290 }
2295 return element; 2291 return element;
2296 } 2292 }
2297 } 2293 }
2298 LineInfo computeLineInfo(Source source) { 2294 LineInfo computeLineInfo(Source source) {
2299 { 2295 SourceEntry sourceEntry = getReadableSourceEntry(source);
2300 SourceEntry sourceEntry = getSourceEntry(source); 2296 if (sourceEntry is HtmlEntry) {
2301 if (sourceEntry == null) { 2297 return internalGetHtmlParseData(source, SourceEntry.LINE_INFO, null);
2302 return null; 2298 } else if (sourceEntry is DartEntry) {
2303 } 2299 return internalGetDartParseData2(source, SourceEntry.LINE_INFO, null);
2304 LineInfo lineInfo = sourceEntry.getValue(SourceEntry.LINE_INFO);
2305 if (lineInfo == null) {
2306 if (sourceEntry is HtmlEntry) {
2307 parseHtmlUnit(source);
2308 lineInfo = getSourceEntry(source).getValue(SourceEntry.LINE_INFO);
2309 } else if (sourceEntry is DartEntry) {
2310 parseCompilationUnit(source);
2311 lineInfo = getSourceEntry(source).getValue(SourceEntry.LINE_INFO);
2312 }
2313 }
2314 return lineInfo;
2315 } 2300 }
2301 return null;
2316 } 2302 }
2317 CompilationUnit computeResolvableCompilationUnit(Source source) { 2303 CompilationUnit computeResolvableCompilationUnit(Source source) {
2318 { 2304 {
2319 DartEntry dartEntry = getDartEntry(source); 2305 DartEntry dartEntry = getDartEntry(source);
2320 if (dartEntry == null) { 2306 if (dartEntry == null) {
2321 return null; 2307 return null;
2322 } 2308 }
2323 CompilationUnit unit = dartEntry.anyParsedCompilationUnit; 2309 CompilationUnit unit = dartEntry.anyParsedCompilationUnit;
2324 if (unit != null) { 2310 if (unit != null) {
2325 return unit.accept(new ASTCloner()) as CompilationUnit; 2311 return unit.accept(new ASTCloner()) as CompilationUnit;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2401 if (htmlSources.isEmpty) { 2387 if (htmlSources.isEmpty) {
2402 return Source.EMPTY_ARRAY; 2388 return Source.EMPTY_ARRAY;
2403 } 2389 }
2404 return new List.from(htmlSources); 2390 return new List.from(htmlSources);
2405 } 2391 }
2406 } 2392 }
2407 List<Source> get htmlSources => getSources(SourceKind.HTML); 2393 List<Source> get htmlSources => getSources(SourceKind.HTML);
2408 SourceKind getKindOf(Source source) { 2394 SourceKind getKindOf(Source source) {
2409 SourceEntry sourceEntry = getReadableSourceEntry(source); 2395 SourceEntry sourceEntry = getReadableSourceEntry(source);
2410 if (sourceEntry == null) { 2396 if (sourceEntry == null) {
2411 if (AnalysisEngine.isHtmlFileName(source.shortName)) {
2412 return SourceKind.HTML;
2413 }
2414 return SourceKind.UNKNOWN; 2397 return SourceKind.UNKNOWN;
2415 } 2398 }
2416 return sourceEntry.kind; 2399 return sourceEntry.kind;
2417 } 2400 }
2418 List<Source> get launchableClientLibrarySources { 2401 List<Source> get launchableClientLibrarySources {
2419 List<Source> sources = new List<Source>(); 2402 List<Source> sources = new List<Source>();
2420 { 2403 {
2421 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { 2404 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
2422 Source source = entry.getKey(); 2405 Source source = entry.getKey();
2423 SourceEntry sourceEntry = entry.getValue(); 2406 SourceEntry sourceEntry = entry.getValue();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2566 Source newSource = entry.getKey(); 2549 Source newSource = entry.getKey();
2567 SourceEntry existingEntry = getSourceEntry(newSource); 2550 SourceEntry existingEntry = getSourceEntry(newSource);
2568 if (existingEntry == null) { 2551 if (existingEntry == null) {
2569 _sourceMap[newSource] = entry.getValue().writableCopy; 2552 _sourceMap[newSource] = entry.getValue().writableCopy;
2570 } else { 2553 } else {
2571 } 2554 }
2572 } 2555 }
2573 } 2556 }
2574 } 2557 }
2575 CompilationUnit parseCompilationUnit(Source source) { 2558 CompilationUnit parseCompilationUnit(Source source) {
2576 { 2559 DartEntry dartEntry = getReadableDartEntry(source);
2577 accessed(source); 2560 if (dartEntry == null) {
2578 DartEntry dartEntry = getDartEntry(source); 2561 return null;
2579 if (dartEntry == null) { 2562 }
2580 return null; 2563 CompilationUnit unit = dartEntry.anyParsedCompilationUnit;
2564 if (unit == null) {
2565 CacheState state = dartEntry.getState(DartEntry.PARSED_UNIT);
2566 while (state != CacheState.VALID && state != CacheState.ERROR) {
2567 dartEntry = internalParseDart(source);
2568 state = dartEntry.getState(DartEntry.PARSED_UNIT);
2581 } 2569 }
2582 CompilationUnit unit = dartEntry.anyParsedCompilationUnit; 2570 unit = dartEntry.anyParsedCompilationUnit;
2583 if (unit == null) {
2584 DartEntryImpl dartCopy = dartEntry.writableCopy;
2585 unit = internalParseCompilationUnit(dartCopy, source);
2586 _sourceMap[source] = dartCopy;
2587 }
2588 return unit;
2589 } 2571 }
2572 return unit;
2590 } 2573 }
2591 HtmlUnit parseHtmlUnit(Source source) { 2574 HtmlUnit parseHtmlUnit(Source source) => internalGetHtmlParseData(source, Html Entry.PARSED_UNIT, null);
2592 {
2593 accessed(source);
2594 HtmlEntry htmlEntry = getHtmlEntry(source);
2595 if (htmlEntry == null) {
2596 return null;
2597 }
2598 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT);
2599 if (unit == null) {
2600 try {
2601 HtmlParseResult result = new HtmlParser(source).parse(scanHtml(source) );
2602 unit = result.htmlUnit;
2603 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
2604 htmlCopy.setValue(SourceEntry.LINE_INFO, new LineInfo(result.lineStart s));
2605 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit);
2606 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, getLibrarySources2(s ource, unit));
2607 _sourceMap[source] = htmlCopy;
2608 } on AnalysisException catch (exception) {
2609 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
2610 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR);
2611 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR);
2612 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.ERROR);
2613 _sourceMap[source] = htmlCopy;
2614 throw exception;
2615 }
2616 }
2617 return unit;
2618 }
2619 }
2620 List<ChangeNotice> performAnalysisTask() { 2575 List<ChangeNotice> performAnalysisTask() {
2621 { 2576 {
2622 if (!performSingleAnalysisTask() && _pendingNotices.isEmpty) { 2577 if (!performSingleAnalysisTask() && _pendingNotices.isEmpty) {
2623 return null; 2578 return null;
2624 } 2579 }
2625 if (_pendingNotices.isEmpty) { 2580 if (_pendingNotices.isEmpty) {
2626 return ChangeNoticeImpl.EMPTY_ARRAY; 2581 return ChangeNoticeImpl.EMPTY_ARRAY;
2627 } 2582 }
2628 List<ChangeNotice> notices = new List.from(_pendingNotices.values); 2583 List<ChangeNotice> notices = new List.from(_pendingNotices.values);
2629 _pendingNotices.clear(); 2584 _pendingNotices.clear();
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
3110 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { 3065 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
3111 if (identical(entry.getValue().kind, kind2)) { 3066 if (identical(entry.getValue().kind, kind2)) {
3112 sources.add(entry.getKey()); 3067 sources.add(entry.getKey());
3113 } 3068 }
3114 } 3069 }
3115 } 3070 }
3116 return new List.from(sources); 3071 return new List.from(sources);
3117 } 3072 }
3118 3073
3119 /** 3074 /**
3120 * Return `true` if the given compilation unit has a part-of directive but no library 3075 * Given a source for a Dart file, return the data represented by the given de scriptor that is
3121 * directive. 3076 * associated with that source, or the given default value if the source is no t a Dart file. This
3077 * method assumes that the data can be produced by parsing the source if it is not already cached.
3122 * 3078 *
3123 * @param unit the compilation unit being tested 3079 * @param source the source representing the Dart file
3124 * @return `true` if the compilation unit has a part-of directive 3080 * @param dartEntry the cache entry associated with the Dart file
3081 * @param descriptor the descriptor representing the data to be returned
3082 * @param defaultValue the value to be returned if the source is not a Dart fi le
3083 * @return the requested data about the given source
3084 * @throws AnalysisException if data could not be returned because the source could not be parsed
3125 */ 3085 */
3126 bool hasPartOfDirective(CompilationUnit unit) { 3086 Object internalGetDartParseData(Source source, DartEntry dartEntry, DataDescri ptor descriptor, Object defaultValue) {
3127 bool hasPartOf = false; 3087 if (dartEntry == null) {
3128 for (Directive directive in unit.directives) { 3088 return defaultValue;
3129 if (directive is PartOfDirective) {
3130 hasPartOf = true;
3131 } else if (directive is LibraryDirective) {
3132 return false;
3133 }
3134 } 3089 }
3135 return hasPartOf; 3090 CacheState state = dartEntry.getState(descriptor);
3091 while (state != CacheState.ERROR && state != CacheState.VALID) {
3092 dartEntry = internalParseDart(source);
3093 state = dartEntry.getState(descriptor);
3094 }
3095 return dartEntry.getValue(descriptor);
3136 } 3096 }
3137 3097
3138 /** 3098 /**
3139 * Compute the kind of the given source. This method should only be invoked wh en the kind is not 3099 * Given a source for a Dart file, return the data represented by the given de scriptor that is
3140 * already known. 3100 * associated with that source, or the given default value if the source is no t a Dart file. This
3101 * method assumes that the data can be produced by parsing the source if it is not already cached.
3141 * 3102 *
3142 * @param source the source for which a kind is to be computed 3103 * @param source the source representing the Dart file
3143 * @return the new source info that was created to represent the source 3104 * @param descriptor the descriptor representing the data to be returned
3105 * @param defaultValue the value to be returned if the source is not a Dart fi le
3106 * @return the requested data about the given source
3107 * @throws AnalysisException if data could not be returned because the source could not be parsed
3144 */ 3108 */
3145 DartEntry internalComputeKindOf(Source source) { 3109 Object internalGetDartParseData2(Source source, DataDescriptor descriptor, Obj ect defaultValue) => internalGetDartParseData(source, getReadableDartEntry(sourc e), descriptor, defaultValue);
3110
3111 /**
3112 * Given a source for an HTML file, return the data represented by the given d escriptor that is
3113 * associated with that source, or the given default value if the source is no t an HTML file. This
3114 * method assumes that the data can be produced by parsing the source if it is not already cached.
3115 *
3116 * @param source the source representing the Dart file
3117 * @param descriptor the descriptor representing the data to be returned
3118 * @param defaultValue the value to be returned if the source is not a Dart fi le
3119 * @return the requested data about the given source
3120 * @throws AnalysisException if data could not be returned because the source could not be parsed
3121 */
3122 Object internalGetHtmlParseData(Source source, DataDescriptor descriptor, Obje ct defaultValue) {
3123 HtmlEntry htmlEntry = getReadableHtmlEntry(source);
3124 if (htmlEntry == null) {
3125 return defaultValue;
3126 }
3127 CacheState state = htmlEntry.getState(descriptor);
3128 while (state != CacheState.ERROR && state != CacheState.VALID) {
3129 htmlEntry = internalParseHtml(source);
3130 state = htmlEntry.getState(descriptor);
3131 }
3132 return htmlEntry.getValue(descriptor);
3133 }
3134 CompilationUnit internalParseCompilationUnit(DartEntryImpl dartCopy, Source so urce) {
3146 try { 3135 try {
3147 accessed(source); 3136 accessed(source);
3148 RecordingErrorListener errorListener = new RecordingErrorListener(); 3137 RecordingErrorListener errorListener = new RecordingErrorListener();
3149 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorList ener); 3138 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorList ener);
3150 Parser parser = new Parser(source, errorListener); 3139 Parser parser = new Parser(source, errorListener);
3151 CompilationUnit unit = parser.parseCompilationUnit(scanResult._token);
3152 LineInfo lineInfo = new LineInfo(scanResult._lineStarts);
3153 List<AnalysisError> errors = errorListener.getErrors2(source);
3154 unit.parsingErrors = errors;
3155 unit.lineInfo = lineInfo;
3156 DartEntryImpl dartCopy = ((_sourceMap[source] as DartEntry)).writableCopy;
3157 if (hasPartOfDirective(unit)) {
3158 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
3159 } else {
3160 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
3161 }
3162 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo);
3163 dartCopy.setValue(DartEntry.PARSED_UNIT, unit);
3164 dartCopy.setValue(DartEntry.PARSE_ERRORS, errors);
3165 _sourceMap[source] = dartCopy;
3166 return dartCopy;
3167 } on AnalysisException catch (exception) {
3168 DartEntryImpl dartCopy = ((_sourceMap[source] as DartEntry)).writableCopy;
3169 dartCopy.setState(DartEntry.SOURCE_KIND, CacheState.ERROR);
3170 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR);
3171 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.ERROR);
3172 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.ERROR);
3173 _sourceMap[source] = dartCopy;
3174 return dartCopy;
3175 }
3176 }
3177 CompilationUnit internalParseCompilationUnit(DartEntryImpl dartCopy, Source so urce) {
3178 accessed(source);
3179 try {
3180 RecordingErrorListener errorListener = new RecordingErrorListener();
3181 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorList ener);
3182 Parser parser = new Parser(source, errorListener);
3183 CompilationUnit unit = parser.parseCompilationUnit(scanResult._token); 3140 CompilationUnit unit = parser.parseCompilationUnit(scanResult._token);
3184 LineInfo lineInfo = new LineInfo(scanResult._lineStarts); 3141 LineInfo lineInfo = new LineInfo(scanResult._lineStarts);
3185 List<AnalysisError> errors = errorListener.getErrors2(source); 3142 List<AnalysisError> errors = errorListener.getErrors2(source);
3186 bool hasPartOfDirective = false; 3143 bool hasPartOfDirective = false;
3187 bool hasLibraryDirective = false; 3144 bool hasLibraryDirective = false;
3188 Set<Source> exportedSources = new Set<Source>(); 3145 Set<Source> exportedSources = new Set<Source>();
3189 Set<Source> importedSources = new Set<Source>(); 3146 Set<Source> importedSources = new Set<Source>();
3190 Set<Source> includedSources = new Set<Source>(); 3147 Set<Source> includedSources = new Set<Source>();
3191 for (Directive directive in unit.directives) { 3148 for (Directive directive in unit.directives) {
3192 if (directive is ExportDirective) { 3149 if (directive is ExportDirective) {
(...skipping 30 matching lines...) Expand all
3223 dartCopy.setValue(DartEntry.PARSED_UNIT, unit); 3180 dartCopy.setValue(DartEntry.PARSED_UNIT, unit);
3224 dartCopy.setValue(DartEntry.PARSE_ERRORS, errors); 3181 dartCopy.setValue(DartEntry.PARSE_ERRORS, errors);
3225 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, toArray(exportedSources)); 3182 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, toArray(exportedSources));
3226 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, toArray(importedSources)); 3183 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, toArray(importedSources));
3227 dartCopy.setValue(DartEntry.INCLUDED_PARTS, toArray(includedSources)); 3184 dartCopy.setValue(DartEntry.INCLUDED_PARTS, toArray(includedSources));
3228 return unit; 3185 return unit;
3229 } on AnalysisException catch (exception) { 3186 } on AnalysisException catch (exception) {
3230 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR); 3187 dartCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR);
3231 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.ERROR); 3188 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.ERROR);
3232 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.ERROR); 3189 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.ERROR);
3190 dartCopy.setState(DartEntry.EXPORTED_LIBRARIES, CacheState.ERROR);
3191 dartCopy.setState(DartEntry.IMPORTED_LIBRARIES, CacheState.ERROR);
3192 dartCopy.setState(DartEntry.INCLUDED_PARTS, CacheState.ERROR);
3233 throw exception; 3193 throw exception;
3234 } 3194 }
3235 } 3195 }
3196
3197 /**
3198 * Scan and parse the given Dart file, updating the cache as appropriate, and return the updated
3199 * cache entry associated with the source.
3200 *
3201 * @param source the source representing the compilation unit to be parsed
3202 * @return the updated cache entry associated with the source
3203 * @throws AnalysisException if the source does not represent a Dart compilati on unit or if the
3204 * compilation unit cannot be parsed for some reason
3205 */
3206 DartEntry internalParseDart(Source source) {
3207 AnalysisContextImpl_ScanResult scanResult = null;
3208 LineInfo lineInfo = null;
3209 CompilationUnit unit = null;
3210 List<AnalysisError> errors = null;
3211 bool hasPartOfDirective = false;
3212 bool hasLibraryDirective = false;
3213 Set<Source> exportedSources = new Set<Source>();
3214 Set<Source> importedSources = new Set<Source>();
3215 Set<Source> includedSources = new Set<Source>();
3216 AnalysisException thrownException = null;
3217 try {
3218 RecordingErrorListener errorListener = new RecordingErrorListener();
3219 scanResult = internalScan(source, errorListener);
3220 Parser parser = new Parser(source, errorListener);
3221 unit = parser.parseCompilationUnit(scanResult._token);
3222 lineInfo = new LineInfo(scanResult._lineStarts);
3223 errors = errorListener.getErrors2(source);
3224 for (Directive directive in unit.directives) {
3225 if (directive is ExportDirective) {
3226 Source exportSource = resolveSource(source, (directive as ExportDirect ive));
3227 if (exportSource != null) {
3228 javaSetAdd(exportedSources, exportSource);
3229 }
3230 } else if (directive is ImportDirective) {
3231 Source importSource = resolveSource(source, (directive as ImportDirect ive));
3232 if (importSource != null) {
3233 javaSetAdd(importedSources, importSource);
3234 }
3235 } else if (directive is LibraryDirective) {
3236 hasLibraryDirective = true;
3237 } else if (directive is PartDirective) {
3238 Source partSource = resolveSource(source, (directive as PartDirective) );
3239 if (partSource != null) {
3240 javaSetAdd(includedSources, partSource);
3241 }
3242 } else if (directive is PartOfDirective) {
3243 hasPartOfDirective = true;
3244 }
3245 }
3246 unit.parsingErrors = errors;
3247 unit.lineInfo = lineInfo;
3248 } on AnalysisException catch (exception) {
3249 thrownException = exception;
3250 }
3251 DartEntryImpl dartCopy = null;
3252 {
3253 SourceEntry sourceEntry = _sourceMap[source];
3254 if (sourceEntry is! DartEntry) {
3255 throw new AnalysisException.con1("Internal error: attempting to parse no n-Dart file as a Dart file: ${source.fullName}");
3256 }
3257 accessed(source);
3258 int resultTime = scanResult == null ? source.modificationStamp : scanResul t.modificationTime;
3259 if (sourceEntry.modificationTime == resultTime) {
3260 dartCopy = ((sourceEntry as DartEntry)).writableCopy;
3261 if (thrownException == null) {
3262 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo);
3263 if (hasPartOfDirective && !hasLibraryDirective) {
3264 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
3265 } else {
3266 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
3267 }
3268 dartCopy.setValue(DartEntry.PARSED_UNIT, unit);
3269 dartCopy.setValue(DartEntry.PARSE_ERRORS, errors);
3270 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, toArray(exportedSource s));
3271 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, toArray(importedSource s));
3272 dartCopy.setValue(DartEntry.INCLUDED_PARTS, toArray(includedSources));
3273 } else {
3274 dartCopy.recordParseError();
3275 }
3276 _sourceMap[source] = dartCopy;
3277 }
3278 }
3279 if (thrownException != null) {
3280 AnalysisEngine.instance.logger.logError2("Could not parse ${source.fullNam e}", thrownException);
3281 throw thrownException;
3282 }
3283 return dartCopy;
3284 }
3285
3286 /**
3287 * Scan and parse the given HTML file, updating the cache as appropriate, and return the updated
3288 * cache entry associated with the source.
3289 *
3290 * @param source the source representing the HTML file to be parsed
3291 * @return the updated cache entry associated with the source
3292 * @throws AnalysisException if the source does not represent an HTML file or if the file cannot
3293 * be parsed for some reason
3294 */
3295 HtmlEntry internalParseHtml(Source source) {
3296 HtmlParseResult result = null;
3297 LineInfo lineInfo = null;
3298 AnalysisException thrownException = null;
3299 try {
3300 result = new HtmlParser(source).parse(scanHtml(source));
3301 lineInfo = new LineInfo(result.lineStarts);
3302 } on AnalysisException catch (exception) {
3303 thrownException = exception;
3304 }
3305 HtmlEntryImpl htmlCopy = null;
3306 {
3307 SourceEntry sourceEntry = _sourceMap[source];
3308 if (sourceEntry is! HtmlEntry) {
3309 throw new AnalysisException.con1("Internal error: attempting to parse no n-HTML file as a HTML file: ${source.fullName}");
3310 }
3311 accessed(source);
3312 int resultTime = result == null ? source.modificationStamp : result.modifi cationTime;
3313 if (sourceEntry.modificationTime == resultTime) {
3314 htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy;
3315 if (thrownException == null) {
3316 HtmlUnit unit = result.htmlUnit;
3317 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo);
3318 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit);
3319 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, getLibrarySources2(s ource, unit));
3320 } else {
3321 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR);
3322 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR);
3323 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.ERROR);
3324 }
3325 _sourceMap[source] = htmlCopy;
3326 }
3327 }
3328 if (thrownException != null) {
3329 AnalysisEngine.instance.logger.logError2("Could not parse ${source.fullNam e}", thrownException);
3330 throw thrownException;
3331 }
3332 ChangeNoticeImpl notice = getNotice(source);
3333 notice.setErrors(htmlCopy.allErrors, lineInfo);
3334 return htmlCopy;
3335 }
3236 AnalysisContextImpl_ScanResult internalScan(Source source, AnalysisErrorListen er errorListener) { 3336 AnalysisContextImpl_ScanResult internalScan(Source source, AnalysisErrorListen er errorListener) {
3237 AnalysisContextImpl_ScanResult result = new AnalysisContextImpl_ScanResult() ; 3337 AnalysisContextImpl_ScanResult result = new AnalysisContextImpl_ScanResult() ;
3238 Source_ContentReceiver receiver = new Source_ContentReceiver_7(source, error Listener, result); 3338 Source_ContentReceiver receiver = new Source_ContentReceiver_7(source, error Listener, result);
3239 try { 3339 try {
3240 source.getContents(receiver); 3340 source.getContents(receiver);
3241 } catch (exception) { 3341 } catch (exception) {
3242 throw new AnalysisException.con3(exception); 3342 throw new AnalysisException.con3(exception);
3243 } 3343 }
3244 return result; 3344 return result;
3245 } 3345 }
(...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after
4985 } 5085 }
4986 void logError2(String message, Exception exception) { 5086 void logError2(String message, Exception exception) {
4987 } 5087 }
4988 void logError3(Exception exception) { 5088 void logError3(Exception exception) {
4989 } 5089 }
4990 void logInformation(String message) { 5090 void logInformation(String message) {
4991 } 5091 }
4992 void logInformation2(String message, Exception exception) { 5092 void logInformation2(String message, Exception exception) {
4993 } 5093 }
4994 } 5094 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/lib/src/generated/element.dart ('k') | pkg/analyzer_experimental/lib/src/generated/error.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698