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

Side by Side Diff: pkg/analysis_server/lib/src/status/get_handler.dart

Issue 1497083003: Report targets will null entries in status pages (prevents an NPE) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library analysis_server.src.status.get_handler; 5 library analysis_server.src.status.get_handler;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 } 672 }
673 String sourceUri = request.uri.queryParameters[SOURCE_QUERY_PARAM]; 673 String sourceUri = request.uri.queryParameters[SOURCE_QUERY_PARAM];
674 if (sourceUri == null) { 674 if (sourceUri == null) {
675 return _returnFailure( 675 return _returnFailure(
676 request, 'Query parameter $SOURCE_QUERY_PARAM required'); 676 request, 'Query parameter $SOURCE_QUERY_PARAM required');
677 } 677 }
678 678
679 List<Folder> allContexts = <Folder>[]; 679 List<Folder> allContexts = <Folder>[];
680 Map<Folder, List<CacheEntry>> entryMap = 680 Map<Folder, List<CacheEntry>> entryMap =
681 new HashMap<Folder, List<CacheEntry>>(); 681 new HashMap<Folder, List<CacheEntry>>();
682 StringBuffer invalidKeysBuffer = new StringBuffer();
682 analysisServer.folderMap 683 analysisServer.folderMap
683 .forEach((Folder folder, InternalAnalysisContext context) { 684 .forEach((Folder folder, InternalAnalysisContext context) {
684 Source source = context.sourceFactory.forUri(sourceUri); 685 Source source = context.sourceFactory.forUri(sourceUri);
685 if (source != null) { 686 if (source != null) {
686 MapIterator<AnalysisTarget, CacheEntry> iterator = 687 MapIterator<AnalysisTarget, CacheEntry> iterator =
687 context.analysisCache.iterator(); 688 context.analysisCache.iterator();
688 while (iterator.moveNext()) { 689 while (iterator.moveNext()) {
689 if (source == iterator.key.source) { 690 if (source == iterator.key.source) {
690 if (!allContexts.contains(folder)) { 691 if (!allContexts.contains(folder)) {
691 allContexts.add(folder); 692 allContexts.add(folder);
692 } 693 }
693 List<CacheEntry> entries = entryMap[folder]; 694 List<CacheEntry> entries = entryMap[folder];
694 if (entries == null) { 695 if (entries == null) {
695 entries = <CacheEntry>[]; 696 entries = <CacheEntry>[];
696 entryMap[folder] = entries; 697 entryMap[folder] = entries;
697 } 698 }
698 entries.add(iterator.value); 699 CacheEntry value = iterator.value;
700 if (value == null) {
701 if (invalidKeysBuffer.isNotEmpty) {
702 invalidKeysBuffer.write(', ');
703 }
704 invalidKeysBuffer.write(iterator.key.toString());
705 } else {
706 entries.add(value);
707 }
699 } 708 }
700 } 709 }
701 } 710 }
702 }); 711 });
703 allContexts.sort((Folder firstFolder, Folder secondFolder) => 712 allContexts.sort((Folder firstFolder, Folder secondFolder) =>
704 firstFolder.path.compareTo(secondFolder.path)); 713 firstFolder.path.compareTo(secondFolder.path));
705 InternalAnalysisContext context = analysisServer.folderMap[folder]; 714 InternalAnalysisContext context = analysisServer.folderMap[folder];
706 715
707 _writeResponse(request, (StringBuffer buffer) { 716 _writeResponse(request, (StringBuffer buffer) {
708 _writePage(buffer, 'Analysis Server - Cache Entry', 717 _writePage(buffer, 'Analysis Server - Cache Entry',
709 ['Context: $contextFilter', 'File: $sourceUri'], (HttpResponse) { 718 ['Context: $contextFilter', 'File: $sourceUri'], (HttpResponse) {
719 if (invalidKeysBuffer.isNotEmpty) {
720 buffer.write('<h3>Targets with null Entries</h3><p>');
721 buffer.write(invalidKeysBuffer.toString());
722 buffer.write('</p>');
723 }
710 List<CacheEntry> entries = entryMap[folder]; 724 List<CacheEntry> entries = entryMap[folder];
711 buffer.write('<h3>Analyzing Contexts</h3><p>'); 725 buffer.write('<h3>Analyzing Contexts</h3><p>');
712 bool first = true; 726 bool first = true;
713 allContexts.forEach((Folder folder) { 727 allContexts.forEach((Folder folder) {
714 if (first) { 728 if (first) {
715 first = false; 729 first = false;
716 } else { 730 } else {
717 buffer.write('<br>'); 731 buffer.write('<br>');
718 } 732 }
719 InternalAnalysisContext analyzingContext = 733 InternalAnalysisContext analyzingContext =
(...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 */ 2044 */
2031 static String makeLink( 2045 static String makeLink(
2032 String path, Map<String, String> params, String innerHtml, 2046 String path, Map<String, String> params, String innerHtml,
2033 [bool hasError = false]) { 2047 [bool hasError = false]) {
2034 Uri uri = new Uri(path: path, queryParameters: params); 2048 Uri uri = new Uri(path: path, queryParameters: params);
2035 String href = HTML_ESCAPE.convert(uri.toString()); 2049 String href = HTML_ESCAPE.convert(uri.toString());
2036 String classAttribute = hasError ? ' class="error"' : ''; 2050 String classAttribute = hasError ? ' class="error"' : '';
2037 return '<a href="$href"$classAttribute>$innerHtml</a>'; 2051 return '<a href="$href"$classAttribute>$innerHtml</a>';
2038 } 2052 }
2039 } 2053 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698