| 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 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 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 CONTEXT_QUERY_PARAM: folder.path, | 705 CONTEXT_QUERY_PARAM: folder.path, |
| 706 SOURCE_QUERY_PARAM: sourceUri | 706 SOURCE_QUERY_PARAM: sourceUri |
| 707 }; | 707 }; |
| 708 List<ResultDescriptor> results = _getExpectedResults(entry); | 708 List<ResultDescriptor> results = _getExpectedResults(entry); |
| 709 results.sort((ResultDescriptor first, ResultDescriptor second) => | 709 results.sort((ResultDescriptor first, ResultDescriptor second) => |
| 710 first.toString().compareTo(second.toString())); | 710 first.toString().compareTo(second.toString())); |
| 711 | 711 |
| 712 buffer.write('<h3>'); | 712 buffer.write('<h3>'); |
| 713 buffer.write(HTML_ESCAPE.convert(entry.target.toString())); | 713 buffer.write(HTML_ESCAPE.convert(entry.target.toString())); |
| 714 buffer.write('</h3>'); | 714 buffer.write('</h3>'); |
| 715 buffer.write('<dl>'); | 715 buffer.write('<p>time</p><blockquote><p>Value</p><blockquote>'); |
| 716 buffer.write('<dt>time</dt><dd>'); | |
| 717 buffer.write(entry.modificationTime); | 716 buffer.write(entry.modificationTime); |
| 718 buffer.write('</dd>'); | 717 buffer.write('</blockquote></blockquote>'); |
| 719 for (ResultDescriptor result in results) { | 718 for (ResultDescriptor result in results) { |
| 719 ResultData data = entry.getResultData(result); |
| 720 CacheState state = entry.getState(result); | 720 CacheState state = entry.getState(result); |
| 721 String descriptorName = HTML_ESCAPE.convert(result.toString()); | 721 String descriptorName = HTML_ESCAPE.convert(result.toString()); |
| 722 String descriptorState = HTML_ESCAPE.convert(state.toString()); | 722 String descriptorState = HTML_ESCAPE.convert(state.toString()); |
| 723 buffer.write('<dt>$descriptorName ($descriptorState)</dt><dd>'); | 723 buffer |
| 724 .write('<p>$descriptorName ($descriptorState)</p><blockquote>'); |
| 724 if (state == CacheState.VALID) { | 725 if (state == CacheState.VALID) { |
| 726 buffer.write('<p>Value</p><blockquote>'); |
| 725 try { | 727 try { |
| 726 _writeValueAsHtml(buffer, entry.getValue(result), linkParameters
); | 728 _writeValueAsHtml( |
| 729 buffer, entry.getValue(result), linkParameters); |
| 727 } catch (exception) { | 730 } catch (exception) { |
| 728 buffer.write('(${HTML_ESCAPE.convert(exception.toString())})'); | 731 buffer.write('(${HTML_ESCAPE.convert(exception.toString())})'); |
| 729 } | 732 } |
| 733 buffer.write('</blockquote>'); |
| 730 } | 734 } |
| 731 buffer.write('</dd>'); | 735 _writeTargetedResults(buffer, 'Depends on', data.dependedOnResults); |
| 736 _writeTargetedResults( |
| 737 buffer, 'Depended on by', data.dependentResults); |
| 738 buffer.write('</blockquote>'); |
| 732 } | 739 } |
| 733 if (entry.exception != null) { | 740 if (entry.exception != null) { |
| 734 buffer.write('<dt>exception</dt><dd>'); | 741 buffer.write('<dt>exception</dt><dd>'); |
| 735 _writeException(buffer, entry.exception); | 742 _writeException(buffer, entry.exception); |
| 736 buffer.write('</dd>'); | 743 buffer.write('</dd>'); |
| 737 } | 744 } |
| 738 buffer.write('</dl>'); | |
| 739 } | 745 } |
| 740 }); | 746 }); |
| 741 }); | 747 }); |
| 742 } | 748 } |
| 743 | 749 |
| 744 /** | 750 /** |
| 745 * Return a response indicating the set of source files in a certain cache | 751 * Return a response indicating the set of source files in a certain cache |
| 746 * state. | 752 * state. |
| 747 */ | 753 */ |
| 748 void _returnCacheState(HttpRequest request) { | 754 void _returnCacheState(HttpRequest request) { |
| (...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1746 */ | 1752 */ |
| 1747 void _writeSubscriptionMap(StringBuffer buffer, List<Enum> allServices, | 1753 void _writeSubscriptionMap(StringBuffer buffer, List<Enum> allServices, |
| 1748 Map<Enum, Set<String>> subscribedServices) { | 1754 Map<Enum, Set<String>> subscribedServices) { |
| 1749 buffer.write('<p><b>Subscriptions</b></p>'); | 1755 buffer.write('<p><b>Subscriptions</b></p>'); |
| 1750 for (Enum service in allServices) { | 1756 for (Enum service in allServices) { |
| 1751 _writeSubscriptionInMap(buffer, service, subscribedServices[service]); | 1757 _writeSubscriptionInMap(buffer, service, subscribedServices[service]); |
| 1752 } | 1758 } |
| 1753 } | 1759 } |
| 1754 | 1760 |
| 1755 /** | 1761 /** |
| 1762 * Write the targeted results returned by iterating over the [results] to the |
| 1763 * given [buffer]. The list will have the given [title] written before it. |
| 1764 */ |
| 1765 void _writeTargetedResults( |
| 1766 StringBuffer buffer, String title, Iterable<TargetedResult> results) { |
| 1767 List<TargetedResult> sortedResults = results.toList(); |
| 1768 sortedResults.sort((TargetedResult first, TargetedResult second) { |
| 1769 int nameOrder = |
| 1770 first.result.toString().compareTo(second.result.toString()); |
| 1771 if (nameOrder != 0) { |
| 1772 return nameOrder; |
| 1773 } |
| 1774 return first.target.toString().compareTo(second.target.toString()); |
| 1775 }); |
| 1776 |
| 1777 buffer.write('<p>'); |
| 1778 buffer.write(title); |
| 1779 buffer.write('</p><blockquote>'); |
| 1780 if (results.isEmpty) { |
| 1781 buffer.write('nothing'); |
| 1782 } else { |
| 1783 for (TargetedResult result in sortedResults) { |
| 1784 buffer.write('<p>'); |
| 1785 buffer.write(result.result.toString()); |
| 1786 buffer.write(' of '); |
| 1787 buffer.write(result.target.toString()); |
| 1788 buffer.write('<p>'); |
| 1789 } |
| 1790 } |
| 1791 buffer.write('</blockquote>'); |
| 1792 } |
| 1793 |
| 1794 /** |
| 1756 * Write two columns of information to the given [buffer], where the | 1795 * Write two columns of information to the given [buffer], where the |
| 1757 * [leftColumn] and [rightColumn] functions are used to generate the content | 1796 * [leftColumn] and [rightColumn] functions are used to generate the content |
| 1758 * of those columns. | 1797 * of those columns. |
| 1759 */ | 1798 */ |
| 1760 void _writeTwoColumns(StringBuffer buffer, HtmlGenerator leftColumn, | 1799 void _writeTwoColumns(StringBuffer buffer, HtmlGenerator leftColumn, |
| 1761 HtmlGenerator rightColumn) { | 1800 HtmlGenerator rightColumn) { |
| 1762 buffer | 1801 buffer |
| 1763 .write('<table class="column"><tr class="column"><td class="column">'); | 1802 .write('<table class="column"><tr class="column"><td class="column">'); |
| 1764 leftColumn(buffer); | 1803 leftColumn(buffer); |
| 1765 buffer.write('</td><td class="column">'); | 1804 buffer.write('</td><td class="column">'); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1808 */ | 1847 */ |
| 1809 static String makeLink( | 1848 static String makeLink( |
| 1810 String path, Map<String, String> params, String innerHtml, | 1849 String path, Map<String, String> params, String innerHtml, |
| 1811 [bool hasError = false]) { | 1850 [bool hasError = false]) { |
| 1812 Uri uri = new Uri(path: path, queryParameters: params); | 1851 Uri uri = new Uri(path: path, queryParameters: params); |
| 1813 String href = HTML_ESCAPE.convert(uri.toString()); | 1852 String href = HTML_ESCAPE.convert(uri.toString()); |
| 1814 String classAttribute = hasError ? ' class="error"' : ''; | 1853 String classAttribute = hasError ? ' class="error"' : ''; |
| 1815 return '<a href="$href"$classAttribute>$innerHtml</a>'; | 1854 return '<a href="$href"$classAttribute>$innerHtml</a>'; |
| 1816 } | 1855 } |
| 1817 } | 1856 } |
| OLD | NEW |