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

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

Issue 841813002: Linter analyzer plumbing. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine; 8 library engine;
9 9
10 import "dart:math" as math; 10 import "dart:math" as math;
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 List<Source> get librarySources => _getSources(SourceKind.LIBRARY); 1185 List<Source> get librarySources => _getSources(SourceKind.LIBRARY);
1186 1186
1187 /** 1187 /**
1188 * Look through the cache for a task that needs to be performed. Return the ta sk that was found, 1188 * Look through the cache for a task that needs to be performed. Return the ta sk that was found,
1189 * or `null` if there is no more work to be done. 1189 * or `null` if there is no more work to be done.
1190 * 1190 *
1191 * @return the next task that needs to be performed 1191 * @return the next task that needs to be performed
1192 */ 1192 */
1193 AnalysisTask get nextAnalysisTask { 1193 AnalysisTask get nextAnalysisTask {
1194 bool hintsEnabled = _options.hint; 1194 bool hintsEnabled = _options.hint;
1195 bool lintsEnabled = _options.lint;
1195 bool hasBlockedTask = false; 1196 bool hasBlockedTask = false;
1196 // 1197 //
1197 // Look for incremental analysis 1198 // Look for incremental analysis
1198 // 1199 //
1199 if (_incrementalAnalysisCache != null && 1200 if (_incrementalAnalysisCache != null &&
1200 _incrementalAnalysisCache.hasWork) { 1201 _incrementalAnalysisCache.hasWork) {
1201 AnalysisTask task = 1202 AnalysisTask task =
1202 new IncrementalAnalysisTask(this, _incrementalAnalysisCache); 1203 new IncrementalAnalysisTask(this, _incrementalAnalysisCache);
1203 _incrementalAnalysisCache = null; 1204 _incrementalAnalysisCache = null;
1204 return task; 1205 return task;
(...skipping 12 matching lines...) Expand all
1217 if (pendingFutures[i].evaluate(sourceEntry)) { 1218 if (pendingFutures[i].evaluate(sourceEntry)) {
1218 pendingFutures.removeAt(i); 1219 pendingFutures.removeAt(i);
1219 } else { 1220 } else {
1220 i++; 1221 i++;
1221 } 1222 }
1222 } 1223 }
1223 if (pendingFutures.isEmpty) { 1224 if (pendingFutures.isEmpty) {
1224 sourcesToRemove.add(source); 1225 sourcesToRemove.add(source);
1225 continue; 1226 continue;
1226 } 1227 }
1227 AnalysisContextImpl_TaskData taskData = 1228 AnalysisContextImpl_TaskData taskData = _getNextAnalysisTaskForSource(
1228 _getNextAnalysisTaskForSource(source, sourceEntry, true, hintsEnable d); 1229 source,
1230 sourceEntry,
1231 true,
1232 hintsEnabled,
1233 lintsEnabled);
1229 task = taskData.task; 1234 task = taskData.task;
1230 if (task != null) { 1235 if (task != null) {
1231 break; 1236 break;
1232 } else if (taskData.isBlocked) { 1237 } else if (taskData.isBlocked) {
1233 hasBlockedTask = true; 1238 hasBlockedTask = true;
1234 } else { 1239 } else {
1235 // There is no more work to do for this task, so forcibly complete 1240 // There is no more work to do for this task, so forcibly complete
1236 // all its pending futures. 1241 // all its pending futures.
1237 for (PendingFuture pendingFuture in pendingFutures) { 1242 for (PendingFuture pendingFuture in pendingFutures) {
1238 pendingFuture.forciblyComplete(); 1243 pendingFuture.forciblyComplete();
1239 } 1244 }
1240 sourcesToRemove.add(source); 1245 sourcesToRemove.add(source);
1241 } 1246 }
1242 } 1247 }
1243 for (Source source in sourcesToRemove) { 1248 for (Source source in sourcesToRemove) {
1244 _pendingFutureSources.remove(source); 1249 _pendingFutureSources.remove(source);
1245 } 1250 }
1246 if (task != null) { 1251 if (task != null) {
1247 return task; 1252 return task;
1248 } 1253 }
1249 } 1254 }
1250 // 1255 //
1251 // Look for a priority source that needs to be analyzed. 1256 // Look for a priority source that needs to be analyzed.
1252 // 1257 //
1253 int priorityCount = _priorityOrder.length; 1258 int priorityCount = _priorityOrder.length;
1254 for (int i = 0; i < priorityCount; i++) { 1259 for (int i = 0; i < priorityCount; i++) {
1255 Source source = _priorityOrder[i]; 1260 Source source = _priorityOrder[i];
1256 AnalysisContextImpl_TaskData taskData = 1261 AnalysisContextImpl_TaskData taskData = _getNextAnalysisTaskForSource(
1257 _getNextAnalysisTaskForSource(source, _cache.get(source), true, hintsE nabled); 1262 source,
1263 _cache.get(source),
1264 true,
1265 hintsEnabled,
1266 lintsEnabled);
1258 AnalysisTask task = taskData.task; 1267 AnalysisTask task = taskData.task;
1259 if (task != null) { 1268 if (task != null) {
1260 return task; 1269 return task;
1261 } else if (taskData.isBlocked) { 1270 } else if (taskData.isBlocked) {
1262 hasBlockedTask = true; 1271 hasBlockedTask = true;
1263 } 1272 }
1264 } 1273 }
1265 if (_neededForResolution != null) { 1274 if (_neededForResolution != null) {
1266 List<Source> sourcesToRemove = new List<Source>(); 1275 List<Source> sourcesToRemove = new List<Source>();
1267 for (Source source in _neededForResolution) { 1276 for (Source source in _neededForResolution) {
(...skipping 22 matching lines...) Expand all
1290 } 1299 }
1291 } 1300 }
1292 // 1301 //
1293 // Look for a non-priority source that needs to be analyzed. 1302 // Look for a non-priority source that needs to be analyzed.
1294 // 1303 //
1295 List<Source> sourcesToRemove = new List<Source>(); 1304 List<Source> sourcesToRemove = new List<Source>();
1296 WorkManager_WorkIterator sources = _workManager.iterator(); 1305 WorkManager_WorkIterator sources = _workManager.iterator();
1297 try { 1306 try {
1298 while (sources.hasNext) { 1307 while (sources.hasNext) {
1299 Source source = sources.next(); 1308 Source source = sources.next();
1300 AnalysisContextImpl_TaskData taskData = 1309 AnalysisContextImpl_TaskData taskData = _getNextAnalysisTaskForSource(
1301 _getNextAnalysisTaskForSource(source, _cache.get(source), false, hin tsEnabled); 1310 source,
1311 _cache.get(source),
1312 false,
1313 hintsEnabled,
1314 lintsEnabled);
1302 AnalysisTask task = taskData.task; 1315 AnalysisTask task = taskData.task;
1303 if (task != null) { 1316 if (task != null) {
1304 return task; 1317 return task;
1305 } else if (taskData.isBlocked) { 1318 } else if (taskData.isBlocked) {
1306 hasBlockedTask = true; 1319 hasBlockedTask = true;
1307 } else { 1320 } else {
1308 sourcesToRemove.add(source); 1321 sourcesToRemove.add(source);
1309 } 1322 }
1310 } 1323 }
1311 } finally { 1324 } finally {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 /** 1388 /**
1376 * Return a list of the sources that would be processed by [performAnalysisTas k]. This 1389 * Return a list of the sources that would be processed by [performAnalysisTas k]. This
1377 * method duplicates, and must therefore be kept in sync with, [getNextAnalysi sTask]. 1390 * method duplicates, and must therefore be kept in sync with, [getNextAnalysi sTask].
1378 * This method is intended to be used for testing purposes only. 1391 * This method is intended to be used for testing purposes only.
1379 * 1392 *
1380 * @return a list of the sources that would be processed by [performAnalysisTa sk] 1393 * @return a list of the sources that would be processed by [performAnalysisTa sk]
1381 */ 1394 */
1382 List<Source> get sourcesNeedingProcessing { 1395 List<Source> get sourcesNeedingProcessing {
1383 HashSet<Source> sources = new HashSet<Source>(); 1396 HashSet<Source> sources = new HashSet<Source>();
1384 bool hintsEnabled = _options.hint; 1397 bool hintsEnabled = _options.hint;
1398 bool lintsEnabled = _options.lint;
1399
1385 // 1400 //
1386 // Look for priority sources that need to be analyzed. 1401 // Look for priority sources that need to be analyzed.
1387 // 1402 //
1388 for (Source source in _priorityOrder) { 1403 for (Source source in _priorityOrder) {
1389 _getSourcesNeedingProcessing( 1404 _getSourcesNeedingProcessing(
1390 source, 1405 source,
1391 _cache.get(source), 1406 _cache.get(source),
1392 true, 1407 true,
1393 hintsEnabled, 1408 hintsEnabled,
1409 lintsEnabled,
1394 sources); 1410 sources);
1395 } 1411 }
1396 // 1412 //
1397 // Look for non-priority sources that need to be analyzed. 1413 // Look for non-priority sources that need to be analyzed.
1398 // 1414 //
1399 WorkManager_WorkIterator iterator = _workManager.iterator(); 1415 WorkManager_WorkIterator iterator = _workManager.iterator();
1400 while (iterator.hasNext) { 1416 while (iterator.hasNext) {
1401 Source source = iterator.next(); 1417 Source source = iterator.next();
1402 _getSourcesNeedingProcessing( 1418 _getSourcesNeedingProcessing(
1403 source, 1419 source,
1404 _cache.get(source), 1420 _cache.get(source),
1405 false, 1421 false,
1406 hintsEnabled, 1422 hintsEnabled,
1423 lintsEnabled,
1407 sources); 1424 sources);
1408 } 1425 }
1409 return new List<Source>.from(sources); 1426 return new List<Source>.from(sources);
1410 } 1427 }
1411 1428
1412 @override 1429 @override
1413 AnalysisContextStatistics get statistics { 1430 AnalysisContextStatistics get statistics {
1414 AnalysisContextStatisticsImpl statistics = 1431 AnalysisContextStatisticsImpl statistics =
1415 new AnalysisContextStatisticsImpl(); 1432 new AnalysisContextStatisticsImpl();
1416 visitCacheItems(statistics._internalPutCacheItem); 1433 visitCacheItems(statistics._internalPutCacheItem);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 return buffer.toString(); 1600 return buffer.toString();
1584 } 1601 }
1585 nameNode = nameNode.parent; 1602 nameNode = nameNode.parent;
1586 } 1603 }
1587 return null; 1604 return null;
1588 } 1605 }
1589 1606
1590 @override 1607 @override
1591 List<AnalysisError> computeErrors(Source source) { 1608 List<AnalysisError> computeErrors(Source source) {
1592 bool enableHints = _options.hint; 1609 bool enableHints = _options.hint;
1610 bool enableLints = _options.lint;
1611
1593 SourceEntry sourceEntry = _getReadableSourceEntry(source); 1612 SourceEntry sourceEntry = _getReadableSourceEntry(source);
1594 if (sourceEntry is DartEntry) { 1613 if (sourceEntry is DartEntry) {
1595 List<AnalysisError> errors = new List<AnalysisError>(); 1614 List<AnalysisError> errors = new List<AnalysisError>();
1596 try { 1615 try {
1597 DartEntry dartEntry = sourceEntry; 1616 DartEntry dartEntry = sourceEntry;
1598 ListUtilities.addAll( 1617 ListUtilities.addAll(
1599 errors, 1618 errors,
1600 _getDartScanData(source, dartEntry, DartEntry.SCAN_ERRORS)); 1619 _getDartScanData(source, dartEntry, DartEntry.SCAN_ERRORS));
1601 dartEntry = _getReadableDartEntry(source); 1620 dartEntry = _getReadableDartEntry(source);
1602 ListUtilities.addAll( 1621 ListUtilities.addAll(
(...skipping 11 matching lines...) Expand all
1614 source, 1633 source,
1615 source, 1634 source,
1616 dartEntry, 1635 dartEntry,
1617 DartEntry.VERIFICATION_ERRORS)); 1636 DartEntry.VERIFICATION_ERRORS));
1618 if (enableHints) { 1637 if (enableHints) {
1619 dartEntry = _getReadableDartEntry(source); 1638 dartEntry = _getReadableDartEntry(source);
1620 ListUtilities.addAll( 1639 ListUtilities.addAll(
1621 errors, 1640 errors,
1622 _getDartHintData(source, source, dartEntry, DartEntry.HINTS)); 1641 _getDartHintData(source, source, dartEntry, DartEntry.HINTS));
1623 } 1642 }
1643 if (enableLints) {
1644 dartEntry = _getReadableDartEntry(source);
1645 ListUtilities.addAll(
1646 errors,
1647 _getDartLintData(source, source, dartEntry, DartEntry.LINTS));
1648 }
1624 } else { 1649 } else {
1625 List<Source> libraries = getLibrariesContaining(source); 1650 List<Source> libraries = getLibrariesContaining(source);
1626 for (Source librarySource in libraries) { 1651 for (Source librarySource in libraries) {
1627 ListUtilities.addAll( 1652 ListUtilities.addAll(
1628 errors, 1653 errors,
1629 _getDartResolutionData( 1654 _getDartResolutionData(
1630 source, 1655 source,
1631 librarySource, 1656 librarySource,
1632 dartEntry, 1657 dartEntry,
1633 DartEntry.RESOLUTION_ERRORS)); 1658 DartEntry.RESOLUTION_ERRORS));
1634 dartEntry = _getReadableDartEntry(source); 1659 dartEntry = _getReadableDartEntry(source);
1635 ListUtilities.addAll( 1660 ListUtilities.addAll(
1636 errors, 1661 errors,
1637 _getDartVerificationData( 1662 _getDartVerificationData(
1638 source, 1663 source,
1639 librarySource, 1664 librarySource,
1640 dartEntry, 1665 dartEntry,
1641 DartEntry.VERIFICATION_ERRORS)); 1666 DartEntry.VERIFICATION_ERRORS));
1642 if (enableHints) { 1667 if (enableHints) {
1643 dartEntry = _getReadableDartEntry(source); 1668 dartEntry = _getReadableDartEntry(source);
1644 ListUtilities.addAll( 1669 ListUtilities.addAll(
1645 errors, 1670 errors,
1646 _getDartHintData(source, librarySource, dartEntry, DartEntry.H INTS)); 1671 _getDartHintData(source, librarySource, dartEntry, DartEntry.H INTS));
1647 } 1672 }
1673 if (enableLints) {
1674 dartEntry = _getReadableDartEntry(source);
1675 ListUtilities.addAll(
1676 errors,
1677 _getDartLintData(source, librarySource, dartEntry, DartEntry.L INTS));
1678 }
1648 } 1679 }
1649 } 1680 }
1650 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { 1681 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) {
1651 AnalysisEngine.instance.logger.logInformation( 1682 AnalysisEngine.instance.logger.logInformation(
1652 "Could not compute errors", 1683 "Could not compute errors",
1653 new CaughtException(exception, stackTrace)); 1684 new CaughtException(exception, stackTrace));
1654 } 1685 }
1655 if (errors.isEmpty) { 1686 if (errors.isEmpty) {
1656 return AnalysisError.NO_ERRORS; 1687 return AnalysisError.NO_ERRORS;
1657 } 1688 }
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
2241 librarySource, 2272 librarySource,
2242 CacheState.FLUSHED); 2273 CacheState.FLUSHED);
2243 dartEntry.setValueInLibrary( 2274 dartEntry.setValueInLibrary(
2244 DartEntry.VERIFICATION_ERRORS, 2275 DartEntry.VERIFICATION_ERRORS,
2245 librarySource, 2276 librarySource,
2246 AnalysisError.NO_ERRORS); 2277 AnalysisError.NO_ERRORS);
2247 dartEntry.setValueInLibrary( 2278 dartEntry.setValueInLibrary(
2248 DartEntry.HINTS, 2279 DartEntry.HINTS,
2249 librarySource, 2280 librarySource,
2250 AnalysisError.NO_ERRORS); 2281 AnalysisError.NO_ERRORS);
2282 dartEntry.setValueInLibrary(
2283 DartEntry.LINTS,
2284 librarySource,
2285 AnalysisError.NO_ERRORS);
2251 } 2286 }
2252 }); 2287 });
2253 } 2288 }
2254 2289
2255 /** 2290 /**
2256 * Record the results produced by performing a [task] and return the cache 2291 * Record the results produced by performing a [task] and return the cache
2257 * entry associated with the results. 2292 * entry associated with the results.
2258 */ 2293 */
2259 DartEntry 2294 DartEntry
2260 recordResolveDartLibraryCycleTaskResults(ResolveDartLibraryCycleTask task) { 2295 recordResolveDartLibraryCycleTaskResults(ResolveDartLibraryCycleTask task) {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
2467 if (_contentsChanged(source, contents)) { 2502 if (_contentsChanged(source, contents)) {
2468 _onSourcesChangedController.add( 2503 _onSourcesChangedController.add(
2469 new SourcesChangedEvent.changedContent(source, contents)); 2504 new SourcesChangedEvent.changedContent(source, contents));
2470 } 2505 }
2471 } 2506 }
2472 2507
2473 @override 2508 @override
2474 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, 2509 void visitCacheItems(void callback(Source source, SourceEntry dartEntry,
2475 DataDescriptor rowDesc, CacheState state)) { 2510 DataDescriptor rowDesc, CacheState state)) {
2476 bool hintsEnabled = _options.hint; 2511 bool hintsEnabled = _options.hint;
2512 bool lintsEnabled = _options.lint;
2477 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); 2513 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
2478 while (iterator.moveNext()) { 2514 while (iterator.moveNext()) {
2479 Source source = iterator.key; 2515 Source source = iterator.key;
2480 SourceEntry sourceEntry = iterator.value; 2516 SourceEntry sourceEntry = iterator.value;
2481 for (DataDescriptor descriptor in sourceEntry.descriptors) { 2517 for (DataDescriptor descriptor in sourceEntry.descriptors) {
2482 if (descriptor == DartEntry.SOURCE_KIND) { 2518 if (descriptor == DartEntry.SOURCE_KIND) {
2483 // The source kind is always valid, so the state isn't interesting. 2519 // The source kind is always valid, so the state isn't interesting.
2484 continue; 2520 continue;
2485 } else if (descriptor == DartEntry.CONTAINING_LIBRARIES) { 2521 } else if (descriptor == DartEntry.CONTAINING_LIBRARIES) {
2486 // The list of containing libraries is always valid, so the state 2522 // The list of containing libraries is always valid, so the state
(...skipping 29 matching lines...) Expand all
2516 for (DataDescriptor descriptor in sourceEntry.libraryDescriptors) { 2552 for (DataDescriptor descriptor in sourceEntry.libraryDescriptors) {
2517 if (descriptor == DartEntry.ANGULAR_ERRORS || 2553 if (descriptor == DartEntry.ANGULAR_ERRORS ||
2518 descriptor == DartEntry.BUILT_ELEMENT || 2554 descriptor == DartEntry.BUILT_ELEMENT ||
2519 descriptor == DartEntry.BUILT_UNIT) { 2555 descriptor == DartEntry.BUILT_UNIT) {
2520 // These values are not currently being computed, so their state 2556 // These values are not currently being computed, so their state
2521 // is not interesting. 2557 // is not interesting.
2522 continue; 2558 continue;
2523 } else if (source.isInSystemLibrary && 2559 } else if (source.isInSystemLibrary &&
2524 !_generateSdkErrors && 2560 !_generateSdkErrors &&
2525 (descriptor == DartEntry.VERIFICATION_ERRORS || 2561 (descriptor == DartEntry.VERIFICATION_ERRORS ||
2526 descriptor == DartEntry.HINTS)) { 2562 descriptor == DartEntry.HINTS ||
2563 descriptor == DartEntry.LINTS)) {
2527 continue; 2564 continue;
2528 } else if (!hintsEnabled && descriptor == DartEntry.HINTS) { 2565 } else if (!hintsEnabled && descriptor == DartEntry.HINTS) {
2529 continue; 2566 continue;
2567 } else if (!lintsEnabled && descriptor == DartEntry.LINTS) {
2568 continue;
2530 } 2569 }
2531 callback( 2570 callback(
2532 librarySource, 2571 librarySource,
2533 sourceEntry, 2572 sourceEntry,
2534 descriptor, 2573 descriptor,
2535 sourceEntry.getStateInLibrary(descriptor, librarySource)); 2574 sourceEntry.getStateInLibrary(descriptor, librarySource));
2536 } 2575 }
2537 } 2576 }
2538 } 2577 }
2539 } 2578 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2626 dartEntry = new GenerateDartHintsTask( 2665 dartEntry = new GenerateDartHintsTask(
2627 this, 2666 this,
2628 units, 2667 units,
2629 getLibraryElement(librarySource)).perform(_resultRecorder) as DartEntr y; 2668 getLibraryElement(librarySource)).perform(_resultRecorder) as DartEntr y;
2630 state = dartEntry.getStateInLibrary(descriptor, librarySource); 2669 state = dartEntry.getStateInLibrary(descriptor, librarySource);
2631 } 2670 }
2632 return dartEntry; 2671 return dartEntry;
2633 } 2672 }
2634 2673
2635 /** 2674 /**
2675 * Given a source for a Dart file and the library that contains it, return a c ache entry in which
2676 * the state of the data represented by the given descriptor is either [CacheS tate.VALID] or
2677 * [CacheStateERROR]. This method assumes that the data can be produced by gen erating hints
danrubel 2015/01/07 20:17:57 hints -> lints
pquitslund 2015/01/08 00:29:52 Done.
2678 * for the library if the data is not already cached.
2679 *
2680 * <b>Note:</b> This method cannot be used in an async environment.
2681 *
2682 * @param unitSource the source representing the Dart file
2683 * @param librarySource the source representing the library containing the Dar t file
2684 * @param dartEntry the cache entry associated with the Dart file
2685 * @param descriptor the descriptor representing the data to be returned
2686 * @return a cache entry containing the required data
2687 * @throws AnalysisException if data could not be returned because the source could not be parsed
2688 */
2689 DartEntry _cacheDartLintData(Source unitSource, Source librarySource,
2690 DartEntry dartEntry, DataDescriptor descriptor) {
2691 //
2692 // Check to see whether we already have the information being requested.
2693 //
2694 CacheState state = dartEntry.getStateInLibrary(descriptor, librarySource);
2695 while (state != CacheState.ERROR && state != CacheState.VALID) {
2696 //
2697 // If not, compute the information.
2698 // Unless the modification date of the source continues to change,
2699 // this loop will eventually terminate.
2700 //
2701 DartEntry libraryEntry = _getReadableDartEntry(librarySource);
2702 libraryEntry = _cacheDartResolutionData(
2703 librarySource,
2704 librarySource,
2705 libraryEntry,
2706 DartEntry.ELEMENT);
2707 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT);
2708 CompilationUnitElement definingUnit =
2709 libraryElement.definingCompilationUnit;
2710 List<CompilationUnitElement> parts = libraryElement.parts;
2711 List<TimestampedData<CompilationUnit>> units =
2712 new List<TimestampedData>(parts.length + 1);
2713 units[0] = _getResolvedUnit(definingUnit, librarySource);
2714 if (units[0] == null) {
2715 Source source = definingUnit.source;
2716 units[0] = new TimestampedData<CompilationUnit>(
2717 getModificationStamp(source),
2718 resolveCompilationUnit(source, libraryElement));
2719 }
2720 for (int i = 0; i < parts.length; i++) {
2721 units[i + 1] = _getResolvedUnit(parts[i], librarySource);
2722 if (units[i + 1] == null) {
2723 Source source = parts[i].source;
2724 units[i +
2725 1] = new TimestampedData<CompilationUnit>(
2726 getModificationStamp(source),
2727 resolveCompilationUnit(source, libraryElement));
2728 }
2729 }
2730 dartEntry = new GenerateDartLintsTask(
Brian Wilkerson 2015/01/07 23:57:54 This is fine for now, but unless you're going to h
pquitslund 2015/01/08 00:29:52 Konstantin and I chatted about this and thought it
2731 this,
2732 units,
2733 getLibraryElement(librarySource)).perform(_resultRecorder) as DartEntr y;
2734 state = dartEntry.getStateInLibrary(descriptor, librarySource);
2735 }
2736 return dartEntry;
2737 }
2738
2739
2740 /**
2636 * Given a source for a Dart file, return a cache entry in which the state of the data represented 2741 * Given a source for a Dart file, return a cache entry in which the state of the data represented
2637 * by the given descriptor is either [CacheState.VALID] or [CacheState.ERROR]. This 2742 * by the given descriptor is either [CacheState.VALID] or [CacheState.ERROR]. This
2638 * method assumes that the data can be produced by parsing the source if it is not already cached. 2743 * method assumes that the data can be produced by parsing the source if it is not already cached.
2639 * 2744 *
2640 * <b>Note:</b> This method cannot be used in an async environment. 2745 * <b>Note:</b> This method cannot be used in an async environment.
2641 * 2746 *
2642 * @param source the source representing the Dart file 2747 * @param source the source representing the Dart file
2643 * @param dartEntry the cache entry associated with the Dart file 2748 * @param dartEntry the cache entry associated with the Dart file
2644 * @param descriptor the descriptor representing the data to be returned 2749 * @param descriptor the descriptor representing the data to be returned
2645 * @return a cache entry containing the required data 2750 * @return a cache entry containing the required data
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
3168 dartEntry.setStateInLibrary( 3273 dartEntry.setStateInLibrary(
3169 DartEntry.HINTS, 3274 DartEntry.HINTS,
3170 librarySource, 3275 librarySource,
3171 CacheState.IN_PROCESS); 3276 CacheState.IN_PROCESS);
3172 return new AnalysisContextImpl_TaskData( 3277 return new AnalysisContextImpl_TaskData(
3173 new GenerateDartHintsTask(this, units, libraryElement), 3278 new GenerateDartHintsTask(this, units, libraryElement),
3174 false); 3279 false);
3175 } 3280 }
3176 3281
3177 /** 3282 /**
3283 * Create a [GenerateDartHintsTask] for the given source, marking the hints as being
danrubel 2015/01/07 20:17:57 hint -> lint in 2 places
pquitslund 2015/01/08 00:29:52 Done.
3284 * in-process.
3285 *
3286 * @param source the source whose content is to be verified
3287 * @param dartEntry the entry for the source
3288 * @param librarySource the source for the library containing the source
3289 * @param libraryEntry the entry for the library
3290 * @return task data representing the created task
3291 */
3292 AnalysisContextImpl_TaskData _createGenerateDartLintsTask(Source source,
3293 DartEntry dartEntry, Source librarySource, DartEntry libraryEntry) {
3294 if (libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID) {
3295 return _createResolveDartLibraryTask(librarySource, libraryEntry);
3296 }
3297 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT);
3298 CompilationUnitElement definingUnit =
3299 libraryElement.definingCompilationUnit;
3300 List<CompilationUnitElement> parts = libraryElement.parts;
3301 List<TimestampedData<CompilationUnit>> units =
3302 new List<TimestampedData>(parts.length + 1);
3303 units[0] = _getResolvedUnit(definingUnit, librarySource);
3304 if (units[0] == null) {
3305 // TODO(brianwilkerson) We should return a ResolveDartUnitTask
3306 // (unless there are multiple ASTs that need to be resolved).
3307 return _createResolveDartLibraryTask(librarySource, libraryEntry);
3308 }
3309 for (int i = 0; i < parts.length; i++) {
3310 units[i + 1] = _getResolvedUnit(parts[i], librarySource);
3311 if (units[i + 1] == null) {
3312 // TODO(brianwilkerson) We should return a ResolveDartUnitTask
3313 // (unless there are multiple ASTs that need to be resolved).
3314 return _createResolveDartLibraryTask(librarySource, libraryEntry);
3315 }
3316 }
3317 dartEntry.setStateInLibrary(
3318 DartEntry.LINTS,
3319 librarySource,
3320 CacheState.IN_PROCESS);
3321 return new AnalysisContextImpl_TaskData(
3322 new GenerateDartLintsTask(this, units, libraryElement),
Brian Wilkerson 2015/01/07 23:57:54 Ditto
pquitslund 2015/01/08 00:29:52 Done.
3323 false);
3324 }
3325
3326
3327
3328 /**
3178 * Create a [GetContentTask] for the given source, marking the content as bein g in-process. 3329 * Create a [GetContentTask] for the given source, marking the content as bein g in-process.
3179 * 3330 *
3180 * @param source the source whose content is to be accessed 3331 * @param source the source whose content is to be accessed
3181 * @param sourceEntry the entry for the source 3332 * @param sourceEntry the entry for the source
3182 * @return task data representing the created task 3333 * @return task data representing the created task
3183 */ 3334 */
3184 AnalysisContextImpl_TaskData _createGetContentTask(Source source, 3335 AnalysisContextImpl_TaskData _createGetContentTask(Source source,
3185 SourceEntry sourceEntry) { 3336 SourceEntry sourceEntry) {
3186 sourceEntry.setState(SourceEntry.CONTENT, CacheState.IN_PROCESS); 3337 sourceEntry.setState(SourceEntry.CONTENT, CacheState.IN_PROCESS);
3187 return new AnalysisContextImpl_TaskData( 3338 return new AnalysisContextImpl_TaskData(
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
3462 DartEntry dartEntry, DataDescriptor descriptor) { 3613 DartEntry dartEntry, DataDescriptor descriptor) {
3463 dartEntry = 3614 dartEntry =
3464 _cacheDartHintData(unitSource, librarySource, dartEntry, descriptor); 3615 _cacheDartHintData(unitSource, librarySource, dartEntry, descriptor);
3465 if (identical(descriptor, DartEntry.ELEMENT)) { 3616 if (identical(descriptor, DartEntry.ELEMENT)) {
3466 return dartEntry.getValue(descriptor); 3617 return dartEntry.getValue(descriptor);
3467 } 3618 }
3468 return dartEntry.getValueInLibrary(descriptor, librarySource); 3619 return dartEntry.getValueInLibrary(descriptor, librarySource);
3469 } 3620 }
3470 3621
3471 /** 3622 /**
3623 * Given a source for a Dart file and the library that contains it, return the data represented by
3624 * the given descriptor that is associated with that source. This method assum es that the data can
3625 * be produced by generating hints for the library if it is not already cached .
danrubel 2015/01/07 20:17:57 hint -> lint
pquitslund 2015/01/08 00:29:52 Done.
3626 *
3627 * <b>Note:</b> This method cannot be used in an async environment.
3628 *
3629 * @param unitSource the source representing the Dart file
3630 * @param librarySource the source representing the library containing the Dar t file
3631 * @param dartEntry the entry representing the Dart file
3632 * @param descriptor the descriptor representing the data to be returned
3633 * @return the requested data about the given source
3634 * @throws AnalysisException if data could not be returned because the source could not be
3635 * resolved
3636 */
3637 Object _getDartLintData(Source unitSource, Source librarySource,
3638 DartEntry dartEntry, DataDescriptor descriptor) {
3639 dartEntry =
3640 _cacheDartLintData(unitSource, librarySource, dartEntry, descriptor);
3641 if (identical(descriptor, DartEntry.ELEMENT)) {
3642 return dartEntry.getValue(descriptor);
3643 }
3644 return dartEntry.getValueInLibrary(descriptor, librarySource);
3645 }
3646
3647 /**
3472 * Given a source for a Dart file, return the data represented by the given de scriptor that is 3648 * Given a source for a Dart file, return the data represented by the given de scriptor that is
3473 * associated with that source. This method assumes that the data can be produ ced by parsing the 3649 * associated with that source. This method assumes that the data can be produ ced by parsing the
3474 * source if it is not already cached. 3650 * source if it is not already cached.
3475 * 3651 *
3476 * <b>Note:</b> This method cannot be used in an async environment. 3652 * <b>Note:</b> This method cannot be used in an async environment.
3477 * 3653 *
3478 * @param source the source representing the Dart file 3654 * @param source the source representing the Dart file
3479 * @param dartEntry the cache entry associated with the Dart file 3655 * @param dartEntry the cache entry associated with the Dart file
3480 * @param descriptor the descriptor representing the data to be returned 3656 * @param descriptor the descriptor representing the data to be returned
3481 * @return the requested data about the given source 3657 * @return the requested data about the given source
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
3739 * Look at the given source to see whether a task needs to be performed relate d to it. Return the 3915 * Look at the given source to see whether a task needs to be performed relate d to it. Return the
3740 * task that should be performed, or `null` if there is no more work to be don e for the 3916 * task that should be performed, or `null` if there is no more work to be don e for the
3741 * source. 3917 * source.
3742 * 3918 *
3743 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 3919 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
3744 * 3920 *
3745 * @param source the source to be checked 3921 * @param source the source to be checked
3746 * @param sourceEntry the cache entry associated with the source 3922 * @param sourceEntry the cache entry associated with the source
3747 * @param isPriority `true` if the source is a priority source 3923 * @param isPriority `true` if the source is a priority source
3748 * @param hintsEnabled `true` if hints are currently enabled 3924 * @param hintsEnabled `true` if hints are currently enabled
3925 * @param lintsEnabled `true` if lints are currently enabled
3749 * @return the next task that needs to be performed for the given source 3926 * @return the next task that needs to be performed for the given source
3750 */ 3927 */
3751 AnalysisContextImpl_TaskData _getNextAnalysisTaskForSource(Source source, 3928 AnalysisContextImpl_TaskData _getNextAnalysisTaskForSource(Source source,
3752 SourceEntry sourceEntry, bool isPriority, bool hintsEnabled) { 3929 SourceEntry sourceEntry, bool isPriority, bool hintsEnabled,
3930 bool lintsEnabled) {
3753 // Refuse to generate tasks for html based files that are above 1500 KB 3931 // Refuse to generate tasks for html based files that are above 1500 KB
3754 if (_isTooBigHtmlSourceEntry(source, sourceEntry)) { 3932 if (_isTooBigHtmlSourceEntry(source, sourceEntry)) {
3755 // TODO (jwren) we still need to report an error of some kind back to the 3933 // TODO (jwren) we still need to report an error of some kind back to the
3756 // client. 3934 // client.
3757 return new AnalysisContextImpl_TaskData(null, false); 3935 return new AnalysisContextImpl_TaskData(null, false);
3758 } 3936 }
3759 if (sourceEntry == null) { 3937 if (sourceEntry == null) {
3760 return new AnalysisContextImpl_TaskData(null, false); 3938 return new AnalysisContextImpl_TaskData(null, false);
3761 } 3939 }
3762 CacheState contentState = sourceEntry.getState(SourceEntry.CONTENT); 3940 CacheState contentState = sourceEntry.getState(SourceEntry.CONTENT);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
3852 dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource); 4030 dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource);
3853 if (hintsState == CacheState.INVALID || 4031 if (hintsState == CacheState.INVALID ||
3854 (isPriority && hintsState == CacheState.FLUSHED)) { 4032 (isPriority && hintsState == CacheState.FLUSHED)) {
3855 return _createGenerateDartHintsTask( 4033 return _createGenerateDartHintsTask(
3856 source, 4034 source,
3857 dartEntry, 4035 dartEntry,
3858 librarySource, 4036 librarySource,
3859 libraryEntry); 4037 libraryEntry);
3860 } 4038 }
3861 } 4039 }
4040 if (lintsEnabled) {
4041 CacheState lintsState =
4042 dartEntry.getStateInLibrary(DartEntry.LINTS, librarySource);
4043 if (lintsState == CacheState.INVALID ||
4044 (isPriority && lintsState == CacheState.FLUSHED)) {
4045 return _createGenerateDartLintsTask(
4046 source,
4047 dartEntry,
4048 librarySource,
4049 libraryEntry);
4050 }
4051 }
3862 } 4052 }
3863 } 4053 }
3864 } 4054 }
3865 } else if (sourceEntry is HtmlEntry) { 4055 } else if (sourceEntry is HtmlEntry) {
3866 HtmlEntry htmlEntry = sourceEntry; 4056 HtmlEntry htmlEntry = sourceEntry;
3867 CacheState parseErrorsState = htmlEntry.getState(HtmlEntry.PARSE_ERRORS); 4057 CacheState parseErrorsState = htmlEntry.getState(HtmlEntry.PARSE_ERRORS);
3868 if (parseErrorsState == CacheState.INVALID || 4058 if (parseErrorsState == CacheState.INVALID ||
3869 (isPriority && parseErrorsState == CacheState.FLUSHED)) { 4059 (isPriority && parseErrorsState == CacheState.FLUSHED)) {
3870 return _createParseHtmlTask(source, htmlEntry); 4060 return _createParseHtmlTask(source, htmlEntry);
3871 } 4061 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
4034 * therefore be kept in sync with, 4224 * therefore be kept in sync with,
4035 * [getNextAnalysisTask]. This method is intended to 4225 * [getNextAnalysisTask]. This method is intended to
4036 * be used for testing purposes only. 4226 * be used for testing purposes only.
4037 * 4227 *
4038 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4228 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
4039 * 4229 *
4040 * @param source the source to be checked 4230 * @param source the source to be checked
4041 * @param sourceEntry the cache entry associated with the source 4231 * @param sourceEntry the cache entry associated with the source
4042 * @param isPriority `true` if the source is a priority source 4232 * @param isPriority `true` if the source is a priority source
4043 * @param hintsEnabled `true` if hints are currently enabled 4233 * @param hintsEnabled `true` if hints are currently enabled
4234 * @param lintsEnabled `true` if lints are currently enabled
4044 * @param sources the set to which sources should be added 4235 * @param sources the set to which sources should be added
4045 */ 4236 */
4046 void _getSourcesNeedingProcessing(Source source, SourceEntry sourceEntry, 4237 void _getSourcesNeedingProcessing(Source source, SourceEntry sourceEntry,
4047 bool isPriority, bool hintsEnabled, HashSet<Source> sources) { 4238 bool isPriority, bool hintsEnabled, bool lintsEnabled,
4239 HashSet<Source> sources) {
4048 if (sourceEntry is DartEntry) { 4240 if (sourceEntry is DartEntry) {
4049 DartEntry dartEntry = sourceEntry; 4241 DartEntry dartEntry = sourceEntry;
4050 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS); 4242 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS);
4051 if (scanErrorsState == CacheState.INVALID || 4243 if (scanErrorsState == CacheState.INVALID ||
4052 (isPriority && scanErrorsState == CacheState.FLUSHED)) { 4244 (isPriority && scanErrorsState == CacheState.FLUSHED)) {
4053 sources.add(source); 4245 sources.add(source);
4054 return; 4246 return;
4055 } 4247 }
4056 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); 4248 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS);
4057 if (parseErrorsState == CacheState.INVALID || 4249 if (parseErrorsState == CacheState.INVALID ||
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4103 if (hintsState == CacheState.INVALID || 4295 if (hintsState == CacheState.INVALID ||
4104 (isPriority && hintsState == CacheState.FLUSHED)) { 4296 (isPriority && hintsState == CacheState.FLUSHED)) {
4105 LibraryElement libraryElement = 4297 LibraryElement libraryElement =
4106 libraryEntry.getValue(DartEntry.ELEMENT); 4298 libraryEntry.getValue(DartEntry.ELEMENT);
4107 if (libraryElement != null) { 4299 if (libraryElement != null) {
4108 sources.add(source); 4300 sources.add(source);
4109 return; 4301 return;
4110 } 4302 }
4111 } 4303 }
4112 } 4304 }
4305 if (lintsEnabled) {
4306 CacheState lintsState =
4307 dartEntry.getStateInLibrary(DartEntry.LINTS, librarySource);
4308 if (lintsState == CacheState.INVALID ||
4309 (isPriority && lintsState == CacheState.FLUSHED)) {
4310 LibraryElement libraryElement =
4311 libraryEntry.getValue(DartEntry.ELEMENT);
4312 if (libraryElement != null) {
4313 sources.add(source);
4314 return;
4315 }
4316 }
4317 }
4113 } 4318 }
4114 } 4319 }
4115 } 4320 }
4116 } else if (sourceEntry is HtmlEntry) { 4321 } else if (sourceEntry is HtmlEntry) {
4117 HtmlEntry htmlEntry = sourceEntry; 4322 HtmlEntry htmlEntry = sourceEntry;
4118 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT); 4323 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT);
4119 if (parsedUnitState == CacheState.INVALID || 4324 if (parsedUnitState == CacheState.INVALID ||
4120 (isPriority && parsedUnitState == CacheState.FLUSHED)) { 4325 (isPriority && parsedUnitState == CacheState.FLUSHED)) {
4121 sources.add(source); 4326 sources.add(source);
4122 return; 4327 return;
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
4592 if (thrownException != null) { 4797 if (thrownException != null) {
4593 throw new AnalysisException('<rethrow>', thrownException); 4798 throw new AnalysisException('<rethrow>', thrownException);
4594 } 4799 }
4595 return libraryEntry; 4800 return libraryEntry;
4596 } 4801 }
4597 4802
4598 /** 4803 /**
4599 * Record the results produced by performing a [task] and return the cache 4804 * Record the results produced by performing a [task] and return the cache
4600 * entry associated with the results. 4805 * entry associated with the results.
4601 */ 4806 */
4807 DartEntry _recordGenerateDartLintsTask(GenerateDartLintsTask task) {
4808 Source librarySource = task.libraryElement.source;
4809 CaughtException thrownException = task.exception;
4810 DartEntry libraryEntry = null;
4811 HashMap<Source, List<AnalysisError>> lintMap = task.lintMap;
4812 if (lintMap == null) {
4813 // We don't have any information about which sources to mark as invalid
4814 // other than the library source.
4815 DartEntry libraryEntry = _cache.get(librarySource);
4816 if (thrownException == null) {
4817 String message =
4818 "GenerateDartHintsTask returned a null lint map "
danrubel 2015/01/07 20:17:57 Hint -> Lint
pquitslund 2015/01/08 00:29:51 Done.
4819 "without throwing an exception: ${librarySource.fullName}";
4820 thrownException =
4821 new CaughtException(new AnalysisException(message), null);
4822 }
4823 libraryEntry.recordLintErrorInLibrary(librarySource, thrownException);
4824 throw new AnalysisException('<rethrow>', thrownException);
4825 }
4826 lintMap.forEach((Source unitSource, List<AnalysisError> lints) {
4827 DartEntry dartEntry = _cache.get(unitSource);
4828 if (unitSource == librarySource) {
4829 libraryEntry = dartEntry;
4830 }
4831 if (thrownException == null) {
4832 dartEntry.setValueInLibrary(DartEntry.LINTS, librarySource, lints);
4833 ChangeNoticeImpl notice = _getNotice(unitSource);
4834 LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO);
4835 notice.setErrors(dartEntry.allErrors, lineInfo);
4836 } else {
4837 dartEntry.recordLintErrorInLibrary(librarySource, thrownException);
4838 }
4839 });
4840 if (thrownException != null) {
4841 throw new AnalysisException('<rethrow>', thrownException);
4842 }
4843 return libraryEntry;
4844 }
4845
4846
4847 /**
4848 * Record the results produced by performing a [task] and return the cache
4849 * entry associated with the results.
4850 */
4602 SourceEntry _recordGetContentsTask(GetContentTask task) { 4851 SourceEntry _recordGetContentsTask(GetContentTask task) {
4603 if (!task.isComplete) { 4852 if (!task.isComplete) {
4604 return null; 4853 return null;
4605 } 4854 }
4606 Source source = task.source; 4855 Source source = task.source;
4607 SourceEntry sourceEntry = _cache.get(source); 4856 SourceEntry sourceEntry = _cache.get(source);
4608 CaughtException thrownException = task.exception; 4857 CaughtException thrownException = task.exception;
4609 if (thrownException != null) { 4858 if (thrownException != null) {
4610 sourceEntry.recordContentError(thrownException); 4859 sourceEntry.recordContentError(thrownException);
4611 _workManager.remove(source); 4860 _workManager.remove(source);
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
5187 5436
5188 @override 5437 @override
5189 DartEntry visitGenerateDartErrorsTask(GenerateDartErrorsTask task) => 5438 DartEntry visitGenerateDartErrorsTask(GenerateDartErrorsTask task) =>
5190 AnalysisContextImpl_this._recordGenerateDartErrorsTask(task); 5439 AnalysisContextImpl_this._recordGenerateDartErrorsTask(task);
5191 5440
5192 @override 5441 @override
5193 DartEntry visitGenerateDartHintsTask(GenerateDartHintsTask task) => 5442 DartEntry visitGenerateDartHintsTask(GenerateDartHintsTask task) =>
5194 AnalysisContextImpl_this._recordGenerateDartHintsTask(task); 5443 AnalysisContextImpl_this._recordGenerateDartHintsTask(task);
5195 5444
5196 @override 5445 @override
5446 DartEntry visitGenerateDartLintsTask(GenerateDartLintsTask task) =>
5447 AnalysisContextImpl_this._recordGenerateDartLintsTask(task);
5448
5449 @override
5197 SourceEntry visitGetContentTask(GetContentTask task) => 5450 SourceEntry visitGetContentTask(GetContentTask task) =>
5198 AnalysisContextImpl_this._recordGetContentsTask(task); 5451 AnalysisContextImpl_this._recordGetContentsTask(task);
5199 5452
5200 @override 5453 @override
5201 DartEntry visitIncrementalAnalysisTask(IncrementalAnalysisTask task) => 5454 DartEntry visitIncrementalAnalysisTask(IncrementalAnalysisTask task) =>
5202 AnalysisContextImpl_this._recordIncrementalAnalysisTaskResults(task); 5455 AnalysisContextImpl_this._recordIncrementalAnalysisTaskResults(task);
5203 5456
5204 @override 5457 @override
5205 DartEntry visitParseDartTask(ParseDartTask task) => 5458 DartEntry visitParseDartTask(ParseDartTask task) =>
5206 AnalysisContextImpl_this._recordParseDartTaskResults(task); 5459 AnalysisContextImpl_this._recordParseDartTaskResults(task);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
5272 DartEntry dartEntry = sourceEntry; 5525 DartEntry dartEntry = sourceEntry;
5273 if (_astIsNeeded(dartEntry)) { 5526 if (_astIsNeeded(dartEntry)) {
5274 return RetentionPriority.MEDIUM; 5527 return RetentionPriority.MEDIUM;
5275 } 5528 }
5276 } 5529 }
5277 return RetentionPriority.LOW; 5530 return RetentionPriority.LOW;
5278 } 5531 }
5279 5532
5280 bool _astIsNeeded(DartEntry dartEntry) => 5533 bool _astIsNeeded(DartEntry dartEntry) =>
5281 dartEntry.hasInvalidData(DartEntry.HINTS) || 5534 dartEntry.hasInvalidData(DartEntry.HINTS) ||
5535 dartEntry.hasInvalidData(DartEntry.HINTS) ||
danrubel 2015/01/07 20:17:57 HINTS -> LINTS Plus perhaps a test?
pquitslund 2015/01/08 00:29:52 Great catch. Thanks! Tests to follow in the next
5282 dartEntry.hasInvalidData(DartEntry.VERIFICATION_ERRORS) || 5536 dartEntry.hasInvalidData(DartEntry.VERIFICATION_ERRORS) ||
5283 dartEntry.hasInvalidData(DartEntry.RESOLUTION_ERRORS); 5537 dartEntry.hasInvalidData(DartEntry.RESOLUTION_ERRORS);
5284 } 5538 }
5285 5539
5286 /** 5540 /**
5287 * Instances of the class `CycleBuilder` are used to construct a list of the lib raries that 5541 * Instances of the class `CycleBuilder` are used to construct a list of the lib raries that
5288 * must be resolved together in order to resolve any one of the libraries. 5542 * must be resolved together in order to resolve any one of the libraries.
5289 */ 5543 */
5290 class AnalysisContextImpl_CycleBuilder { 5544 class AnalysisContextImpl_CycleBuilder {
5291 final AnalysisContextImpl AnalysisContextImpl_this; 5545 final AnalysisContextImpl AnalysisContextImpl_this;
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
6539 */ 6793 */
6540 bool get incrementalApi; 6794 bool get incrementalApi;
6541 6795
6542 /** 6796 /**
6543 * A flag indicating whether validation should be performed after incremental 6797 * A flag indicating whether validation should be performed after incremental
6544 * analysis. 6798 * analysis.
6545 */ 6799 */
6546 bool get incrementalValidation; 6800 bool get incrementalValidation;
6547 6801
6548 /** 6802 /**
6803 * Return `true` if analysis is to generate lint warnings.
6804 *
6805 * @return `true` if analysis is to generate lint warnings
6806 */
6807 bool get lint;
6808
6809 /**
6549 * Return `true` if analysis is to parse comments. 6810 * Return `true` if analysis is to parse comments.
6550 * 6811 *
6551 * @return `true` if analysis is to parse comments 6812 * @return `true` if analysis is to parse comments
6552 */ 6813 */
6553 bool get preserveComments; 6814 bool get preserveComments;
6554 } 6815 }
6555 6816
6556 /** 6817 /**
6557 * Instances of the class `AnalysisOptions` represent a set of analysis options used to 6818 * Instances of the class `AnalysisOptions` represent a set of analysis options used to
6558 * control the behavior of an analysis context. 6819 * control the behavior of an analysis context.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
6640 */ 6901 */
6641 bool incrementalApi = false; 6902 bool incrementalApi = false;
6642 6903
6643 /** 6904 /**
6644 * A flag indicating whether validation should be performed after incremental 6905 * A flag indicating whether validation should be performed after incremental
6645 * analysis. 6906 * analysis.
6646 */ 6907 */
6647 bool incrementalValidation = false; 6908 bool incrementalValidation = false;
6648 6909
6649 /** 6910 /**
6911 * A flag indicating whether analysis is to generate lint warnings.
6912 */
6913 bool lint = false;
6914
6915 /**
6650 * A flag indicating whether analysis is to parse comments. 6916 * A flag indicating whether analysis is to parse comments.
6651 */ 6917 */
6652 bool preserveComments = true; 6918 bool preserveComments = true;
6653 6919
6654 /** 6920 /**
6655 * Initialize a newly created set of analysis options to have their default va lues. 6921 * Initialize a newly created set of analysis options to have their default va lues.
6656 */ 6922 */
6657 AnalysisOptionsImpl(); 6923 AnalysisOptionsImpl();
6658 6924
6659 /** 6925 /**
6660 * Initialize a newly created set of analysis options to have the same values as those in the 6926 * Initialize a newly created set of analysis options to have the same values as those in the
6661 * given set of analysis options. 6927 * given set of analysis options.
6662 * 6928 *
6663 * @param options the analysis options whose values are being copied 6929 * @param options the analysis options whose values are being copied
6664 */ 6930 */
6665 AnalysisOptionsImpl.con1(AnalysisOptions options) { 6931 AnalysisOptionsImpl.con1(AnalysisOptions options) {
6666 analyzeAngular = options.analyzeAngular; 6932 analyzeAngular = options.analyzeAngular;
6667 analyzeFunctionBodies = options.analyzeFunctionBodies; 6933 analyzeFunctionBodies = options.analyzeFunctionBodies;
6668 analyzePolymer = options.analyzePolymer; 6934 analyzePolymer = options.analyzePolymer;
6669 cacheSize = options.cacheSize; 6935 cacheSize = options.cacheSize;
6670 dart2jsHint = options.dart2jsHint; 6936 dart2jsHint = options.dart2jsHint;
6671 enableDeferredLoading = options.enableDeferredLoading; 6937 enableDeferredLoading = options.enableDeferredLoading;
6672 enableEnum = options.enableEnum; 6938 enableEnum = options.enableEnum;
6673 _generateSdkErrors = options.generateSdkErrors; 6939 _generateSdkErrors = options.generateSdkErrors;
6674 hint = options.hint; 6940 hint = options.hint;
6675 incremental = options.incremental; 6941 incremental = options.incremental;
6676 incrementalApi = options.incrementalApi; 6942 incrementalApi = options.incrementalApi;
6677 incrementalValidation = options.incrementalValidation; 6943 incrementalValidation = options.incrementalValidation;
6944 lint = options.lint;
6678 preserveComments = options.preserveComments; 6945 preserveComments = options.preserveComments;
6679 } 6946 }
6680 6947
6681 @override 6948 @override
6682 bool get generateSdkErrors => _generateSdkErrors; 6949 bool get generateSdkErrors => _generateSdkErrors;
6683 6950
6684 /** 6951 /**
6685 * Set whether errors, warnings and hints should be generated for sources in t he SDK to match the 6952 * Set whether errors, warnings and hints should be generated for sources in t he SDK to match the
6686 * given value. 6953 * given value.
6687 * 6954 *
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
6861 /** 7128 /**
6862 * Visit the given [task], returning the result of the visit. This method will 7129 * Visit the given [task], returning the result of the visit. This method will
6863 * throw an AnalysisException if the visitor throws an exception. 7130 * throw an AnalysisException if the visitor throws an exception.
6864 */ 7131 */
6865 E visitGenerateDartHintsTask(GenerateDartHintsTask task); 7132 E visitGenerateDartHintsTask(GenerateDartHintsTask task);
6866 7133
6867 /** 7134 /**
6868 * Visit the given [task], returning the result of the visit. This method will 7135 * Visit the given [task], returning the result of the visit. This method will
6869 * throw an AnalysisException if the visitor throws an exception. 7136 * throw an AnalysisException if the visitor throws an exception.
6870 */ 7137 */
7138 E visitGenerateDartLintsTask(GenerateDartLintsTask task);
7139
7140 /**
7141 * Visit the given [task], returning the result of the visit. This method will
7142 * throw an AnalysisException if the visitor throws an exception.
7143 */
6871 E visitGetContentTask(GetContentTask task); 7144 E visitGetContentTask(GetContentTask task);
6872 7145
6873 /** 7146 /**
6874 * Visit the given [task], returning the result of the visit. This method will 7147 * Visit the given [task], returning the result of the visit. This method will
6875 * throw an AnalysisException if the visitor throws an exception. 7148 * throw an AnalysisException if the visitor throws an exception.
6876 */ 7149 */
6877 E 7150 E
6878 visitIncrementalAnalysisTask(IncrementalAnalysisTask incrementalAnalysisTa sk); 7151 visitIncrementalAnalysisTask(IncrementalAnalysisTask incrementalAnalysisTa sk);
6879 7152
6880 /** 7153 /**
(...skipping 1945 matching lines...) Expand 10 before | Expand all | Expand 10 after
8826 9099
8827 /** 9100 /**
8828 * The data descriptor representing the launchable flag. This data is only 9101 * The data descriptor representing the launchable flag. This data is only
8829 * available for Dart files that are the defining compilation unit of a 9102 * available for Dart files that are the defining compilation unit of a
8830 * library. 9103 * library.
8831 */ 9104 */
8832 static final DataDescriptor<bool> IS_LAUNCHABLE = 9105 static final DataDescriptor<bool> IS_LAUNCHABLE =
8833 new DataDescriptor<bool>("DartEntry.IS_LAUNCHABLE", false); 9106 new DataDescriptor<bool>("DartEntry.IS_LAUNCHABLE", false);
8834 9107
8835 /** 9108 /**
9109 * The data descriptor representing lint warnings resulting from auditing the
9110 * source.
9111 */
9112 static final DataDescriptor<List<AnalysisError>> LINTS =
9113 new DataDescriptor<List<AnalysisError>>(
9114 "DartEntry.LINTS",
9115 AnalysisError.NO_ERRORS);
9116
9117 /**
8836 * The data descriptor representing the errors resulting from parsing the 9118 * The data descriptor representing the errors resulting from parsing the
8837 * source. 9119 * source.
8838 */ 9120 */
8839 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS = 9121 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS =
8840 new DataDescriptor<List<AnalysisError>>( 9122 new DataDescriptor<List<AnalysisError>>(
8841 "DartEntry.PARSE_ERRORS", 9123 "DartEntry.PARSE_ERRORS",
8842 AnalysisError.NO_ERRORS); 9124 AnalysisError.NO_ERRORS);
8843 9125
8844 /** 9126 /**
8845 * The data descriptor representing the parsed AST structure. 9127 * The data descriptor representing the parsed AST structure.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
8918 */ 9200 */
8919 List<AnalysisError> get allErrors { 9201 List<AnalysisError> get allErrors {
8920 List<AnalysisError> errors = new List<AnalysisError>(); 9202 List<AnalysisError> errors = new List<AnalysisError>();
8921 errors.addAll(getValue(SCAN_ERRORS)); 9203 errors.addAll(getValue(SCAN_ERRORS));
8922 errors.addAll(getValue(PARSE_ERRORS)); 9204 errors.addAll(getValue(PARSE_ERRORS));
8923 ResolutionState state = _resolutionState; 9205 ResolutionState state = _resolutionState;
8924 while (state != null) { 9206 while (state != null) {
8925 errors.addAll(state.getValue(RESOLUTION_ERRORS)); 9207 errors.addAll(state.getValue(RESOLUTION_ERRORS));
8926 errors.addAll(state.getValue(VERIFICATION_ERRORS)); 9208 errors.addAll(state.getValue(VERIFICATION_ERRORS));
8927 errors.addAll(state.getValue(HINTS)); 9209 errors.addAll(state.getValue(HINTS));
9210 errors.addAll(state.getValue(LINTS));
8928 state = state._nextState; 9211 state = state._nextState;
8929 } 9212 }
8930 errors.addAll(getValue(ANGULAR_ERRORS)); 9213 errors.addAll(getValue(ANGULAR_ERRORS));
8931 if (errors.length == 0) { 9214 if (errors.length == 0) {
8932 return AnalysisError.NO_ERRORS; 9215 return AnalysisError.NO_ERRORS;
8933 } 9216 }
8934 return errors; 9217 return errors;
8935 } 9218 }
8936 9219
8937 /** 9220 /**
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
9073 * be stored in this SourceEntry. 9356 * be stored in this SourceEntry.
9074 */ 9357 */
9075 List<DataDescriptor> get libraryDescriptors { 9358 List<DataDescriptor> get libraryDescriptors {
9076 return <DataDescriptor>[ 9359 return <DataDescriptor>[
9077 DartEntry.ANGULAR_ERRORS, 9360 DartEntry.ANGULAR_ERRORS,
9078 DartEntry.BUILT_ELEMENT, 9361 DartEntry.BUILT_ELEMENT,
9079 DartEntry.BUILT_UNIT, 9362 DartEntry.BUILT_UNIT,
9080 DartEntry.RESOLUTION_ERRORS, 9363 DartEntry.RESOLUTION_ERRORS,
9081 DartEntry.RESOLVED_UNIT, 9364 DartEntry.RESOLVED_UNIT,
9082 DartEntry.VERIFICATION_ERRORS, 9365 DartEntry.VERIFICATION_ERRORS,
9083 DartEntry.HINTS]; 9366 DartEntry.HINTS,
9367 DartEntry.LINTS];
9084 } 9368 }
9085 9369
9086 /** 9370 /**
9087 * A compilation unit that has not been accessed by any other client and can 9371 * A compilation unit that has not been accessed by any other client and can
9088 * therefore safely be modified by the reconciler, or `null` if the source has 9372 * therefore safely be modified by the reconciler, or `null` if the source has
9089 * not been parsed. 9373 * not been parsed.
9090 */ 9374 */
9091 CompilationUnit get resolvableCompilationUnit { 9375 CompilationUnit get resolvableCompilationUnit {
9092 if (getState(PARSED_UNIT) == CacheState.VALID) { 9376 if (getState(PARSED_UNIT) == CacheState.VALID) {
9093 CompilationUnit unit = getValue(PARSED_UNIT); 9377 CompilationUnit unit = getValue(PARSED_UNIT);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
9248 * @param exception the exception that shows where the error occurred 9532 * @param exception the exception that shows where the error occurred
9249 */ 9533 */
9250 void recordHintErrorInLibrary(Source librarySource, 9534 void recordHintErrorInLibrary(Source librarySource,
9251 CaughtException exception) { 9535 CaughtException exception) {
9252 this.exception = exception; 9536 this.exception = exception;
9253 ResolutionState state = _getOrCreateResolutionState(librarySource); 9537 ResolutionState state = _getOrCreateResolutionState(librarySource);
9254 state.recordHintError(); 9538 state.recordHintError();
9255 } 9539 }
9256 9540
9257 /** 9541 /**
9542 * Record that an error occurred while attempting to generate lints for the
9543 * source represented by this entry. This will set the state of all
9544 * verification information as being in error.
9545 *
9546 * @param librarySource the source of the library in which hints were being ge nerated
danrubel 2015/01/07 20:17:57 hint -> lint
pquitslund 2015/01/08 00:29:52 Done.
9547 * @param exception the exception that shows where the error occurred
9548 */
9549 void recordLintErrorInLibrary(Source librarySource,
9550 CaughtException exception) {
9551 this.exception = exception;
9552 ResolutionState state = _getOrCreateResolutionState(librarySource);
9553 state.recordLintError();
9554 }
9555
9556 /**
9258 * Record that an [exception] occurred while attempting to scan or parse the 9557 * Record that an [exception] occurred while attempting to scan or parse the
9259 * entry represented by this entry. This will set the state of all information , 9558 * entry represented by this entry. This will set the state of all information ,
9260 * including any resolution-based information, as being in error. 9559 * including any resolution-based information, as being in error.
9261 */ 9560 */
9262 void recordParseError(CaughtException exception) { 9561 void recordParseError(CaughtException exception) {
9263 setState(SOURCE_KIND, CacheState.ERROR); 9562 setState(SOURCE_KIND, CacheState.ERROR);
9264 setState(PARSE_ERRORS, CacheState.ERROR); 9563 setState(PARSE_ERRORS, CacheState.ERROR);
9265 setState(PARSED_UNIT, CacheState.ERROR); 9564 setState(PARSED_UNIT, CacheState.ERROR);
9266 setState(EXPORTED_LIBRARIES, CacheState.ERROR); 9565 setState(EXPORTED_LIBRARIES, CacheState.ERROR);
9267 setState(IMPORTED_LIBRARIES, CacheState.ERROR); 9566 setState(IMPORTED_LIBRARIES, CacheState.ERROR);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
9471 9770
9472 /** 9771 /**
9473 * Return `true` if the [descriptor] is valid for this entry when the data is 9772 * Return `true` if the [descriptor] is valid for this entry when the data is
9474 * relative to a library. 9773 * relative to a library.
9475 */ 9774 */
9476 bool _isValidLibraryDescriptor(DataDescriptor descriptor) { 9775 bool _isValidLibraryDescriptor(DataDescriptor descriptor) {
9477 return descriptor == ANGULAR_ERRORS || 9776 return descriptor == ANGULAR_ERRORS ||
9478 descriptor == BUILT_ELEMENT || 9777 descriptor == BUILT_ELEMENT ||
9479 descriptor == BUILT_UNIT || 9778 descriptor == BUILT_UNIT ||
9480 descriptor == HINTS || 9779 descriptor == HINTS ||
9780 descriptor == LINTS ||
9481 descriptor == RESOLUTION_ERRORS || 9781 descriptor == RESOLUTION_ERRORS ||
9482 descriptor == RESOLVED_UNIT || 9782 descriptor == RESOLVED_UNIT ||
9483 descriptor == VERIFICATION_ERRORS; 9783 descriptor == VERIFICATION_ERRORS;
9484 } 9784 }
9485 9785
9486 @override 9786 @override
9487 bool _writeDiffOn(StringBuffer buffer, SourceEntry oldEntry) { 9787 bool _writeDiffOn(StringBuffer buffer, SourceEntry oldEntry) {
9488 bool needsSeparator = super._writeDiffOn(buffer, oldEntry); 9788 bool needsSeparator = super._writeDiffOn(buffer, oldEntry);
9489 if (oldEntry is! DartEntry) { 9789 if (oldEntry is! DartEntry) {
9490 if (needsSeparator) { 9790 if (needsSeparator) {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
9682 9982
9683 /** 9983 /**
9684 * Return `true` if there is analysis information in the given entry that need s to be 9984 * Return `true` if there is analysis information in the given entry that need s to be
9685 * computed, where the computation is dependent on having the AST. 9985 * computed, where the computation is dependent on having the AST.
9686 * 9986 *
9687 * @param dartEntry the entry being tested 9987 * @param dartEntry the entry being tested
9688 * @return `true` if there is analysis information that needs to be computed f rom the AST 9988 * @return `true` if there is analysis information that needs to be computed f rom the AST
9689 */ 9989 */
9690 bool astIsNeeded(DartEntry dartEntry) => 9990 bool astIsNeeded(DartEntry dartEntry) =>
9691 dartEntry.hasInvalidData(DartEntry.HINTS) || 9991 dartEntry.hasInvalidData(DartEntry.HINTS) ||
9992 dartEntry.hasInvalidData(DartEntry.LINTS) ||
9692 dartEntry.hasInvalidData(DartEntry.VERIFICATION_ERRORS) || 9993 dartEntry.hasInvalidData(DartEntry.VERIFICATION_ERRORS) ||
9693 dartEntry.hasInvalidData(DartEntry.RESOLUTION_ERRORS); 9994 dartEntry.hasInvalidData(DartEntry.RESOLUTION_ERRORS);
9694 9995
9695 @override 9996 @override
9696 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) { 9997 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) {
9697 if (sourceEntry is DartEntry) { 9998 if (sourceEntry is DartEntry) {
9698 DartEntry dartEntry = sourceEntry; 9999 DartEntry dartEntry = sourceEntry;
9699 if (astIsNeeded(dartEntry)) { 10000 if (astIsNeeded(dartEntry)) {
9700 return RetentionPriority.MEDIUM; 10001 return RetentionPriority.MEDIUM;
9701 } 10002 }
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
9973 // Store the results. 10274 // Store the results.
9974 // 10275 //
9975 _hintMap = new HashMap<Source, List<AnalysisError>>(); 10276 _hintMap = new HashMap<Source, List<AnalysisError>>();
9976 for (int i = 0; i < unitCount; i++) { 10277 for (int i = 0; i < unitCount; i++) {
9977 Source source = _units[i].data.element.source; 10278 Source source = _units[i].data.element.source;
9978 _hintMap[source] = errorListener.getErrorsForSource(source); 10279 _hintMap[source] = errorListener.getErrorsForSource(source);
9979 } 10280 }
9980 } 10281 }
9981 } 10282 }
9982 10283
10284 /// Generates lint feedback for a single Dart library.
10285 class GenerateDartLintsTask extends AnalysisTask {
10286
10287 ///The compilation units that comprise the library, with the defining
10288 ///compilation unit appearing first in the array.
10289 final List<TimestampedData<CompilationUnit>> _units;
10290
10291 /// The element model for the library being analyzed.
10292 final LibraryElement libraryElement;
10293
10294 /// Initialize a newly created task to perform lint checking over these
10295 /// [_units] belonging to this [libraryElement] within the given [context].
10296 GenerateDartLintsTask(context, this._units, this.libraryElement)
10297 : super(context);
10298
10299 /// A mapping of analyzed sources to their associated lint warnings.
10300 /// May be [null] if the task has not been performed or if analysis did not
10301 /// complete normally.
10302 HashMap<Source, List<AnalysisError>> lintMap;
10303
10304 @override
10305 String get taskDescription {
10306 Source librarySource = libraryElement.source;
10307 return (librarySource == null) ?
10308 "generate Dart lints for library without source" :
10309 "generate Dart lints for ${librarySource.fullName}";
10310 }
10311
10312 @override
10313 accept(AnalysisTaskVisitor visitor) =>
10314 visitor.visitGenerateDartLintsTask(this);
10315
10316 @override
10317 void internalPerform() {
10318
10319 List<CompilationUnit> compilationUnits =
10320 _units.map((TimestampedData<CompilationUnit> unit) => unit.data);
10321 RecordingErrorListener errorListener = new RecordingErrorListener();
10322 LintGenerator lintGenerator =
10323 new LintGenerator(compilationUnits, errorListener);
10324 lintGenerator.generate();
10325
10326 lintMap = new HashMap<Source, List<AnalysisError>>();
10327 compilationUnits.forEach((CompilationUnit unit) {
10328 Source source = unit.element.source;
10329 lintMap[source] = errorListener.getErrorsForSource(source);
10330 });
10331 }
10332 }
10333
10334
9983 /** 10335 /**
9984 * Instances of the class `GetContentTask` get the contents of a source. 10336 * Instances of the class `GetContentTask` get the contents of a source.
9985 */ 10337 */
9986 class GetContentTask extends AnalysisTask { 10338 class GetContentTask extends AnalysisTask {
9987 /** 10339 /**
9988 * The source to be read. 10340 * The source to be read.
9989 */ 10341 */
9990 final Source source; 10342 final Source source;
9991 10343
9992 /** 10344 /**
(...skipping 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after
11791 * The [TimeCounter] for time spent in error verifier. 12143 * The [TimeCounter] for time spent in error verifier.
11792 */ 12144 */
11793 static TimeCounter errors = new TimeCounter(); 12145 static TimeCounter errors = new TimeCounter();
11794 12146
11795 /** 12147 /**
11796 * The [TimeCounter] for time spent in hints generator. 12148 * The [TimeCounter] for time spent in hints generator.
11797 */ 12149 */
11798 static TimeCounter hints = new TimeCounter(); 12150 static TimeCounter hints = new TimeCounter();
11799 12151
11800 /** 12152 /**
12153 * The [TimeCounter] for time spent in linting.
12154 */
12155 static TimeCounter lint = new TimeCounter();
12156
12157 /**
11801 * Reset all of the time counters to zero. 12158 * Reset all of the time counters to zero.
11802 */ 12159 */
11803 static void reset() { 12160 static void reset() {
11804 io = new TimeCounter(); 12161 io = new TimeCounter();
11805 scan = new TimeCounter(); 12162 scan = new TimeCounter();
11806 parse = new TimeCounter(); 12163 parse = new TimeCounter();
11807 resolve = new TimeCounter(); 12164 resolve = new TimeCounter();
11808 angular = new TimeCounter(); 12165 angular = new TimeCounter();
11809 polymer = new TimeCounter(); 12166 polymer = new TimeCounter();
11810 errors = new TimeCounter(); 12167 errors = new TimeCounter();
11811 hints = new TimeCounter(); 12168 hints = new TimeCounter();
12169 lint = new TimeCounter();
11812 } 12170 }
11813 } 12171 }
11814 12172
11815 /** 12173 /**
11816 * Instances of the class `PolymerBuildHtmlTask` build Polymer specific elements . 12174 * Instances of the class `PolymerBuildHtmlTask` build Polymer specific elements .
11817 */ 12175 */
11818 class PolymerBuildHtmlTask extends AnalysisTask { 12176 class PolymerBuildHtmlTask extends AnalysisTask {
11819 /** 12177 /**
11820 * The source to build which Polymer HTML elements for. 12178 * The source to build which Polymer HTML elements for.
11821 */ 12179 */
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
12660 13018
12661 /** 13019 /**
12662 * Invalidate all of the resolution information associated with the compilatio n unit. 13020 * Invalidate all of the resolution information associated with the compilatio n unit.
12663 */ 13021 */
12664 void invalidateAllResolutionInformation() { 13022 void invalidateAllResolutionInformation() {
12665 _nextState = null; 13023 _nextState = null;
12666 _librarySource = null; 13024 _librarySource = null;
12667 setState(DartEntry.BUILT_UNIT, CacheState.INVALID); 13025 setState(DartEntry.BUILT_UNIT, CacheState.INVALID);
12668 setState(DartEntry.BUILT_ELEMENT, CacheState.INVALID); 13026 setState(DartEntry.BUILT_ELEMENT, CacheState.INVALID);
12669 setState(DartEntry.HINTS, CacheState.INVALID); 13027 setState(DartEntry.HINTS, CacheState.INVALID);
13028 setState(DartEntry.LINTS, CacheState.INVALID);
12670 setState(DartEntry.RESOLVED_UNIT, CacheState.INVALID); 13029 setState(DartEntry.RESOLVED_UNIT, CacheState.INVALID);
12671 setState(DartEntry.RESOLUTION_ERRORS, CacheState.INVALID); 13030 setState(DartEntry.RESOLUTION_ERRORS, CacheState.INVALID);
12672 setState(DartEntry.VERIFICATION_ERRORS, CacheState.INVALID); 13031 setState(DartEntry.VERIFICATION_ERRORS, CacheState.INVALID);
12673 } 13032 }
12674 13033
12675 /** 13034 /**
12676 * Record that an exception occurred while attempting to build the element 13035 * Record that an exception occurred while attempting to build the element
12677 * model for the source associated with this state. 13036 * model for the source associated with this state.
12678 */ 13037 */
12679 void recordBuildElementError() { 13038 void recordBuildElementError() {
12680 setState(DartEntry.BUILT_UNIT, CacheState.ERROR); 13039 setState(DartEntry.BUILT_UNIT, CacheState.ERROR);
12681 setState(DartEntry.BUILT_ELEMENT, CacheState.ERROR); 13040 setState(DartEntry.BUILT_ELEMENT, CacheState.ERROR);
12682 recordResolutionError(); 13041 recordResolutionError();
12683 } 13042 }
12684 13043
12685 /** 13044 /**
12686 * Record that an exception occurred while attempting to generate hints for 13045 * Record that an exception occurred while attempting to generate hints for
12687 * the source associated with this entry. This will set the state of all 13046 * the source associated with this entry. This will set the state of all
12688 * verification information as being in error. 13047 * verification information as being in error.
12689 */ 13048 */
12690 void recordHintError() { 13049 void recordHintError() {
12691 setState(DartEntry.HINTS, CacheState.ERROR); 13050 setState(DartEntry.HINTS, CacheState.ERROR);
12692 } 13051 }
12693 13052
12694 /** 13053 /**
13054 * Record that an exception occurred while attempting to generate lints for
13055 * the source associated with this entry. This will set the state of all
13056 * verification information as being in error.
13057 */
13058 void recordLintError() {
13059 setState(DartEntry.LINTS, CacheState.ERROR);
13060 }
13061
13062 /**
12695 * Record that an exception occurred while attempting to resolve the source 13063 * Record that an exception occurred while attempting to resolve the source
12696 * associated with this state. 13064 * associated with this state.
12697 */ 13065 */
12698 void recordResolutionError() { 13066 void recordResolutionError() {
12699 setState(DartEntry.RESOLVED_UNIT, CacheState.ERROR); 13067 setState(DartEntry.RESOLVED_UNIT, CacheState.ERROR);
12700 setState(DartEntry.RESOLUTION_ERRORS, CacheState.ERROR); 13068 setState(DartEntry.RESOLUTION_ERRORS, CacheState.ERROR);
12701 recordVerificationError(); 13069 recordVerificationError();
12702 setState(DartEntry.ANGULAR_ERRORS, CacheState.ERROR); 13070 setState(DartEntry.ANGULAR_ERRORS, CacheState.ERROR);
12703 } 13071 }
12704 13072
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
12793 DartEntry.RESOLUTION_ERRORS, 13161 DartEntry.RESOLUTION_ERRORS,
12794 oldEntry); 13162 oldEntry);
12795 needsSeparator = _writeStateDiffOn( 13163 needsSeparator = _writeStateDiffOn(
12796 buffer, 13164 buffer,
12797 needsSeparator, 13165 needsSeparator,
12798 "verificationErrors", 13166 "verificationErrors",
12799 DartEntry.VERIFICATION_ERRORS, 13167 DartEntry.VERIFICATION_ERRORS,
12800 oldEntry); 13168 oldEntry);
12801 needsSeparator = 13169 needsSeparator =
12802 _writeStateDiffOn(buffer, needsSeparator, "hints", DartEntry.HINTS, oldE ntry); 13170 _writeStateDiffOn(buffer, needsSeparator, "hints", DartEntry.HINTS, oldE ntry);
13171 needsSeparator =
13172 _writeStateDiffOn(buffer, needsSeparator, "lints", DartEntry.LINTS, oldE ntry);
12803 return needsSeparator; 13173 return needsSeparator;
12804 } 13174 }
12805 13175
12806 /** 13176 /**
12807 * Write a textual representation of this state to the given builder. The resu lt will only be 13177 * Write a textual representation of this state to the given builder. The resu lt will only be
12808 * used for debugging purposes. 13178 * used for debugging purposes.
12809 * 13179 *
12810 * @param builder the builder to which the text should be written 13180 * @param builder the builder to which the text should be written
12811 */ 13181 */
12812 void _writeOn(StringBuffer buffer) { 13182 void _writeOn(StringBuffer buffer) {
12813 if (_librarySource != null) { 13183 if (_librarySource != null) {
12814 _writeStateOn(buffer, "builtElement", DartEntry.BUILT_ELEMENT); 13184 _writeStateOn(buffer, "builtElement", DartEntry.BUILT_ELEMENT);
12815 _writeStateOn(buffer, "builtUnit", DartEntry.BUILT_UNIT); 13185 _writeStateOn(buffer, "builtUnit", DartEntry.BUILT_UNIT);
12816 _writeStateOn(buffer, "resolvedUnit", DartEntry.RESOLVED_UNIT); 13186 _writeStateOn(buffer, "resolvedUnit", DartEntry.RESOLVED_UNIT);
12817 _writeStateOn(buffer, "resolutionErrors", DartEntry.RESOLUTION_ERRORS); 13187 _writeStateOn(buffer, "resolutionErrors", DartEntry.RESOLUTION_ERRORS);
12818 _writeStateOn( 13188 _writeStateOn(
12819 buffer, 13189 buffer,
12820 "verificationErrors", 13190 "verificationErrors",
12821 DartEntry.VERIFICATION_ERRORS); 13191 DartEntry.VERIFICATION_ERRORS);
12822 _writeStateOn(buffer, "hints", DartEntry.HINTS); 13192 _writeStateOn(buffer, "hints", DartEntry.HINTS);
13193 _writeStateOn(buffer, "lints", DartEntry.LINTS);
12823 if (_nextState != null) { 13194 if (_nextState != null) {
12824 _nextState._writeOn(buffer); 13195 _nextState._writeOn(buffer);
12825 } 13196 }
12826 } 13197 }
12827 } 13198 }
12828 13199
12829 /** 13200 /**
12830 * Write a textual representation of the difference between the state of the 13201 * Write a textual representation of the difference between the state of the
12831 * value described by the given [descriptor] between the [oldEntry] and this 13202 * value described by the given [descriptor] between the [oldEntry] and this
12832 * entry to the given [buffer]. Return `true` if some difference was written. 13203 * entry to the given [buffer]. Return `true` if some difference was written.
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after
14435 14806
14436 @override 14807 @override
14437 Object visitPolymerTagDartElement(PolymerTagDartElement element) { 14808 Object visitPolymerTagDartElement(PolymerTagDartElement element) {
14438 if (element.name == PolymerHtmlUnitBuilder_this._elementName) { 14809 if (element.name == PolymerHtmlUnitBuilder_this._elementName) {
14439 throw new PolymerHtmlUnitBuilder_FoundTagDartElementError( 14810 throw new PolymerHtmlUnitBuilder_FoundTagDartElementError(
14440 element as PolymerTagDartElementImpl); 14811 element as PolymerTagDartElementImpl);
14441 } 14812 }
14442 return null; 14813 return null;
14443 } 14814 }
14444 } 14815 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/error.dart » ('j') | pkg/analyzer/lib/src/generated/incremental_resolver.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698