| OLD | NEW |
| 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 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 for (Source source in _priorityOrder) { | 1484 for (Source source in _priorityOrder) { |
| 1485 _getSourcesNeedingProcessing(source, _cache.get(source), true, | 1485 _getSourcesNeedingProcessing(source, _cache.get(source), true, |
| 1486 hintsEnabled, lintsEnabled, sources); | 1486 hintsEnabled, lintsEnabled, sources); |
| 1487 } | 1487 } |
| 1488 // | 1488 // |
| 1489 // Look for non-priority sources that need to be analyzed. | 1489 // Look for non-priority sources that need to be analyzed. |
| 1490 // | 1490 // |
| 1491 WorkManager_WorkIterator iterator = _workManager.iterator(); | 1491 WorkManager_WorkIterator iterator = _workManager.iterator(); |
| 1492 while (iterator.hasNext) { | 1492 while (iterator.hasNext) { |
| 1493 Source source = iterator.next(); | 1493 Source source = iterator.next(); |
| 1494 _getSourcesNeedingProcessing(source, | 1494 _getSourcesNeedingProcessing(source, _cache.get(source), false, |
| 1495 _cache.get(source), false, hintsEnabled, lintsEnabled, sources); | 1495 hintsEnabled, lintsEnabled, sources); |
| 1496 } | 1496 } |
| 1497 return new List<Source>.from(sources); | 1497 return new List<Source>.from(sources); |
| 1498 } | 1498 } |
| 1499 | 1499 |
| 1500 @override | 1500 @override |
| 1501 AnalysisContextStatistics get statistics { | 1501 AnalysisContextStatistics get statistics { |
| 1502 AnalysisContextStatisticsImpl statistics = | 1502 AnalysisContextStatisticsImpl statistics = |
| 1503 new AnalysisContextStatisticsImpl(); | 1503 new AnalysisContextStatisticsImpl(); |
| 1504 visitCacheItems(statistics._internalPutCacheItem); | 1504 visitCacheItems(statistics._internalPutCacheItem); |
| 1505 statistics.partitionData = _cache.partitionData; | 1505 statistics.partitionData = _cache.partitionData; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 // This source is overridden in the content cache, so the change will | 1589 // This source is overridden in the content cache, so the change will |
| 1590 // have no effect. Just ignore it to avoid wasting time doing | 1590 // have no effect. Just ignore it to avoid wasting time doing |
| 1591 // re-analysis. | 1591 // re-analysis. |
| 1592 continue; | 1592 continue; |
| 1593 } | 1593 } |
| 1594 _sourceChanged(source); | 1594 _sourceChanged(source); |
| 1595 } | 1595 } |
| 1596 changeSet.changedContents.forEach((Source key, String value) { | 1596 changeSet.changedContents.forEach((Source key, String value) { |
| 1597 _contentsChanged(key, value, false); | 1597 _contentsChanged(key, value, false); |
| 1598 }); | 1598 }); |
| 1599 changeSet.changedRanges.forEach( | 1599 changeSet.changedRanges |
| 1600 (Source source, ChangeSet_ContentChange change) { | 1600 .forEach((Source source, ChangeSet_ContentChange change) { |
| 1601 _contentRangeChanged(source, change.contents, change.offset, | 1601 _contentRangeChanged(source, change.contents, change.offset, |
| 1602 change.oldLength, change.newLength); | 1602 change.oldLength, change.newLength); |
| 1603 }); | 1603 }); |
| 1604 for (Source source in changeSet.deletedSources) { | 1604 for (Source source in changeSet.deletedSources) { |
| 1605 _sourceDeleted(source); | 1605 _sourceDeleted(source); |
| 1606 } | 1606 } |
| 1607 for (Source source in removedSources) { | 1607 for (Source source in removedSources) { |
| 1608 _sourceRemoved(source); | 1608 _sourceRemoved(source); |
| 1609 } | 1609 } |
| 1610 _onSourcesChangedController.add(new SourcesChangedEvent(changeSet)); | 1610 _onSourcesChangedController.add(new SourcesChangedEvent(changeSet)); |
| 1611 } | 1611 } |
| 1612 | 1612 |
| 1613 @override | 1613 @override |
| 1614 String computeDocumentationComment(Element element) { | 1614 String computeDocumentationComment(Element element) { |
| 1615 if (element == null) { | 1615 if (element == null) { |
| 1616 return null; | 1616 return null; |
| 1617 } | 1617 } |
| 1618 Source source = element.source; | 1618 Source source = element.source; |
| 1619 if (source == null) { | 1619 if (source == null) { |
| 1620 return null; | 1620 return null; |
| 1621 } | 1621 } |
| 1622 CompilationUnit unit = parseCompilationUnit(source); | 1622 CompilationUnit unit = parseCompilationUnit(source); |
| 1623 if (unit == null) { | 1623 if (unit == null) { |
| 1624 return null; | 1624 return null; |
| 1625 } | 1625 } |
| 1626 NodeLocator locator = new NodeLocator.con1(element.nameOffset); | 1626 NodeLocator locator = new NodeLocator.con1(element.nameOffset); |
| 1627 AstNode nameNode = locator.searchWithin(unit); | 1627 AstNode nameNode = locator.searchWithin(unit); |
| 1628 while (nameNode != null) { | 1628 while (nameNode != null) { |
| 1629 if (nameNode is AnnotatedNode) { | 1629 if (nameNode is AnnotatedNode) { |
| 1630 Comment comment = (nameNode as AnnotatedNode).documentationComment; | 1630 Comment comment = nameNode.documentationComment; |
| 1631 if (comment == null) { | 1631 if (comment == null) { |
| 1632 return null; | 1632 return null; |
| 1633 } | 1633 } |
| 1634 StringBuffer buffer = new StringBuffer(); | 1634 StringBuffer buffer = new StringBuffer(); |
| 1635 List<Token> tokens = comment.tokens; | 1635 List<Token> tokens = comment.tokens; |
| 1636 for (int i = 0; i < tokens.length; i++) { | 1636 for (int i = 0; i < tokens.length; i++) { |
| 1637 if (i > 0) { | 1637 if (i > 0) { |
| 1638 buffer.write("\n"); | 1638 buffer.write("\n"); |
| 1639 } | 1639 } |
| 1640 buffer.write(tokens[i].lexeme); | 1640 buffer.write(tokens[i].lexeme); |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2390 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY); | 2390 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY); |
| 2391 dartEntry.setValue(DartEntry.INCLUDED_PARTS, Source.EMPTY_ARRAY); | 2391 dartEntry.setValue(DartEntry.INCLUDED_PARTS, Source.EMPTY_ARRAY); |
| 2392 // DartEntry.IS_CLIENT - set in recordElementData | 2392 // DartEntry.IS_CLIENT - set in recordElementData |
| 2393 // DartEntry.IS_LAUNCHABLE - set in recordElementData | 2393 // DartEntry.IS_LAUNCHABLE - set in recordElementData |
| 2394 dartEntry.setValue(DartEntry.PARSE_ERRORS, AnalysisError.NO_ERRORS); | 2394 dartEntry.setValue(DartEntry.PARSE_ERRORS, AnalysisError.NO_ERRORS); |
| 2395 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); | 2395 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 2396 dartEntry.setState(DartEntry.PUBLIC_NAMESPACE, CacheState.FLUSHED); | 2396 dartEntry.setState(DartEntry.PUBLIC_NAMESPACE, CacheState.FLUSHED); |
| 2397 dartEntry.setValue(DartEntry.SCAN_ERRORS, AnalysisError.NO_ERRORS); | 2397 dartEntry.setValue(DartEntry.SCAN_ERRORS, AnalysisError.NO_ERRORS); |
| 2398 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); | 2398 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); |
| 2399 dartEntry.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED); | 2399 dartEntry.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED); |
| 2400 dartEntry.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, | 2400 dartEntry.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySource, |
| 2401 librarySource, AnalysisError.NO_ERRORS); | 2401 AnalysisError.NO_ERRORS); |
| 2402 dartEntry.setStateInLibrary( | 2402 dartEntry.setStateInLibrary( |
| 2403 DartEntry.RESOLVED_UNIT, librarySource, CacheState.FLUSHED); | 2403 DartEntry.RESOLVED_UNIT, librarySource, CacheState.FLUSHED); |
| 2404 dartEntry.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, | 2404 dartEntry.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, |
| 2405 librarySource, AnalysisError.NO_ERRORS); | 2405 librarySource, AnalysisError.NO_ERRORS); |
| 2406 dartEntry.setValueInLibrary( | 2406 dartEntry.setValueInLibrary( |
| 2407 DartEntry.HINTS, librarySource, AnalysisError.NO_ERRORS); | 2407 DartEntry.HINTS, librarySource, AnalysisError.NO_ERRORS); |
| 2408 dartEntry.setValueInLibrary( | 2408 dartEntry.setValueInLibrary( |
| 2409 DartEntry.LINTS, librarySource, AnalysisError.NO_ERRORS); | 2409 DartEntry.LINTS, librarySource, AnalysisError.NO_ERRORS); |
| 2410 } | 2410 } |
| 2411 }); | 2411 }); |
| (...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3978 * | 3978 * |
| 3979 * @param source the source for which a cache entry is being sought | 3979 * @param source the source for which a cache entry is being sought |
| 3980 * @return the source cache entry associated with the given source | 3980 * @return the source cache entry associated with the given source |
| 3981 */ | 3981 */ |
| 3982 DartEntry _getReadableDartEntry(Source source) { | 3982 DartEntry _getReadableDartEntry(Source source) { |
| 3983 SourceEntry sourceEntry = _cache.get(source); | 3983 SourceEntry sourceEntry = _cache.get(source); |
| 3984 if (sourceEntry == null) { | 3984 if (sourceEntry == null) { |
| 3985 sourceEntry = _createSourceEntry(source, false); | 3985 sourceEntry = _createSourceEntry(source, false); |
| 3986 } | 3986 } |
| 3987 if (sourceEntry is DartEntry) { | 3987 if (sourceEntry is DartEntry) { |
| 3988 return sourceEntry as DartEntry; | 3988 return sourceEntry; |
| 3989 } | 3989 } |
| 3990 return null; | 3990 return null; |
| 3991 } | 3991 } |
| 3992 | 3992 |
| 3993 /** | 3993 /** |
| 3994 * Return the cache entry associated with the given source, or `null` if the s
ource is not | 3994 * Return the cache entry associated with the given source, or `null` if the s
ource is not |
| 3995 * an HTML file. | 3995 * an HTML file. |
| 3996 * | 3996 * |
| 3997 * @param source the source for which a cache entry is being sought | 3997 * @param source the source for which a cache entry is being sought |
| 3998 * @return the source cache entry associated with the given source | 3998 * @return the source cache entry associated with the given source |
| 3999 */ | 3999 */ |
| 4000 HtmlEntry _getReadableHtmlEntry(Source source) { | 4000 HtmlEntry _getReadableHtmlEntry(Source source) { |
| 4001 SourceEntry sourceEntry = _cache.get(source); | 4001 SourceEntry sourceEntry = _cache.get(source); |
| 4002 if (sourceEntry == null) { | 4002 if (sourceEntry == null) { |
| 4003 sourceEntry = _createSourceEntry(source, false); | 4003 sourceEntry = _createSourceEntry(source, false); |
| 4004 } | 4004 } |
| 4005 if (sourceEntry is HtmlEntry) { | 4005 if (sourceEntry is HtmlEntry) { |
| 4006 return sourceEntry as HtmlEntry; | 4006 return sourceEntry; |
| 4007 } | 4007 } |
| 4008 return null; | 4008 return null; |
| 4009 } | 4009 } |
| 4010 | 4010 |
| 4011 /** | 4011 /** |
| 4012 * Return the cache entry associated with the given source, creating it if nec
essary. | 4012 * Return the cache entry associated with the given source, creating it if nec
essary. |
| 4013 * | 4013 * |
| 4014 * @param source the source for which a cache entry is being sought | 4014 * @param source the source for which a cache entry is being sought |
| 4015 * @return the source cache entry associated with the given source | 4015 * @return the source cache entry associated with the given source |
| 4016 */ | 4016 */ |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4873 SourceEntry sourceEntry = _cache.get(source); | 4873 SourceEntry sourceEntry = _cache.get(source); |
| 4874 if (sourceEntry == null) { | 4874 if (sourceEntry == null) { |
| 4875 sourceEntry = _createSourceEntry(source, true); | 4875 sourceEntry = _createSourceEntry(source, true); |
| 4876 } else { | 4876 } else { |
| 4877 _propagateInvalidation(source, sourceEntry); | 4877 _propagateInvalidation(source, sourceEntry); |
| 4878 sourceEntry = _cache.get(source); | 4878 sourceEntry = _cache.get(source); |
| 4879 } | 4879 } |
| 4880 if (sourceEntry is HtmlEntry) { | 4880 if (sourceEntry is HtmlEntry) { |
| 4881 _workManager.add(source, SourcePriority.HTML); | 4881 _workManager.add(source, SourcePriority.HTML); |
| 4882 } else if (sourceEntry is DartEntry) { | 4882 } else if (sourceEntry is DartEntry) { |
| 4883 _workManager.add(source, _computePriority(sourceEntry as DartEntry)); | 4883 _workManager.add(source, _computePriority(sourceEntry)); |
| 4884 } | 4884 } |
| 4885 } | 4885 } |
| 4886 | 4886 |
| 4887 /** | 4887 /** |
| 4888 * Invalidate the [source] that was changed and any sources that referenced | 4888 * Invalidate the [source] that was changed and any sources that referenced |
| 4889 * the source before it existed. | 4889 * the source before it existed. |
| 4890 * | 4890 * |
| 4891 * <b>Note:</b> This method must only be invoked while we are synchronized on | 4891 * <b>Note:</b> This method must only be invoked while we are synchronized on |
| 4892 * [cacheLock]. | 4892 * [cacheLock]. |
| 4893 */ | 4893 */ |
| (...skipping 4093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8987 @override | 8987 @override |
| 8988 accept(AnalysisTaskVisitor visitor) => visitor.visitGetContentTask(this); | 8988 accept(AnalysisTaskVisitor visitor) => visitor.visitGetContentTask(this); |
| 8989 | 8989 |
| 8990 @override | 8990 @override |
| 8991 void internalPerform() { | 8991 void internalPerform() { |
| 8992 _complete = true; | 8992 _complete = true; |
| 8993 try { | 8993 try { |
| 8994 TimestampedData<String> data = context.getContents(source); | 8994 TimestampedData<String> data = context.getContents(source); |
| 8995 _content = data.data; | 8995 _content = data.data; |
| 8996 _modificationTime = data.modificationTime; | 8996 _modificationTime = data.modificationTime; |
| 8997 AnalysisEngine.instance.instrumentationService | 8997 AnalysisEngine.instance.instrumentationService.logFileRead( |
| 8998 .logFileRead(source.fullName, _modificationTime, _content); | 8998 source.fullName, _modificationTime, _content); |
| 8999 } catch (exception, stackTrace) { | 8999 } catch (exception, stackTrace) { |
| 9000 errors.add(new AnalysisError.con1( | 9000 errors.add(new AnalysisError.con1( |
| 9001 source, ScannerErrorCode.UNABLE_GET_CONTENT, [exception])); | 9001 source, ScannerErrorCode.UNABLE_GET_CONTENT, [exception])); |
| 9002 throw new AnalysisException("Could not get contents of $source", | 9002 throw new AnalysisException("Could not get contents of $source", |
| 9003 new CaughtException(exception, stackTrace)); | 9003 new CaughtException(exception, stackTrace)); |
| 9004 } | 9004 } |
| 9005 } | 9005 } |
| 9006 } | 9006 } |
| 9007 | 9007 |
| 9008 /** | 9008 /** |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9482 } | 9482 } |
| 9483 // Only handle small changes | 9483 // Only handle small changes |
| 9484 if (cache.oldLength > 0 || cache.newLength > 30) { | 9484 if (cache.oldLength > 0 || cache.newLength > 30) { |
| 9485 return; | 9485 return; |
| 9486 } | 9486 } |
| 9487 // Produce an updated token stream | 9487 // Produce an updated token stream |
| 9488 CharacterReader reader = new CharSequenceReader(cache.newContents); | 9488 CharacterReader reader = new CharSequenceReader(cache.newContents); |
| 9489 BooleanErrorListener errorListener = new BooleanErrorListener(); | 9489 BooleanErrorListener errorListener = new BooleanErrorListener(); |
| 9490 IncrementalScanner scanner = | 9490 IncrementalScanner scanner = |
| 9491 new IncrementalScanner(cache.source, reader, errorListener); | 9491 new IncrementalScanner(cache.source, reader, errorListener); |
| 9492 scanner.rescan(cache.resolvedUnit.beginToken, cache.offset, | 9492 scanner.rescan(cache.resolvedUnit.beginToken, cache.offset, cache.oldLength, |
| 9493 cache.oldLength, cache.newLength); | 9493 cache.newLength); |
| 9494 if (errorListener.errorReported) { | 9494 if (errorListener.errorReported) { |
| 9495 return; | 9495 return; |
| 9496 } | 9496 } |
| 9497 // Produce an updated AST | 9497 // Produce an updated AST |
| 9498 IncrementalParser parser = new IncrementalParser( | 9498 IncrementalParser parser = new IncrementalParser( |
| 9499 cache.source, scanner.tokenMap, AnalysisErrorListener.NULL_LISTENER); | 9499 cache.source, scanner.tokenMap, AnalysisErrorListener.NULL_LISTENER); |
| 9500 _updatedUnit = parser.reparse(cache.resolvedUnit, scanner.leftToken, | 9500 _updatedUnit = parser.reparse(cache.resolvedUnit, scanner.leftToken, |
| 9501 scanner.rightToken, cache.offset, cache.offset + cache.oldLength); | 9501 scanner.rightToken, cache.offset, cache.offset + cache.oldLength); |
| 9502 // Update the resolution | 9502 // Update the resolution |
| 9503 TypeProvider typeProvider = this.typeProvider; | 9503 TypeProvider typeProvider = this.typeProvider; |
| (...skipping 2715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12219 visitElement(Element element) { | 12219 visitElement(Element element) { |
| 12220 if (element.id == _id) { | 12220 if (element.id == _id) { |
| 12221 result = element; | 12221 result = element; |
| 12222 throw new _ElementByIdFinderException(); | 12222 throw new _ElementByIdFinderException(); |
| 12223 } | 12223 } |
| 12224 super.visitElement(element); | 12224 super.visitElement(element); |
| 12225 } | 12225 } |
| 12226 } | 12226 } |
| 12227 | 12227 |
| 12228 class _ElementByIdFinderException {} | 12228 class _ElementByIdFinderException {} |
| OLD | NEW |