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

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

Issue 1392173002: Show UsedLocalElements and parts ASTs on the status pages. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
« 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 12 matching lines...) Expand all
23 import 'package:analysis_server/src/socket_server.dart'; 23 import 'package:analysis_server/src/socket_server.dart';
24 import 'package:analysis_server/src/status/ast_writer.dart'; 24 import 'package:analysis_server/src/status/ast_writer.dart';
25 import 'package:analysis_server/src/status/element_writer.dart'; 25 import 'package:analysis_server/src/status/element_writer.dart';
26 import 'package:analyzer/file_system/file_system.dart'; 26 import 'package:analyzer/file_system/file_system.dart';
27 import 'package:analyzer/src/context/cache.dart'; 27 import 'package:analyzer/src/context/cache.dart';
28 import 'package:analyzer/src/generated/ast.dart'; 28 import 'package:analyzer/src/generated/ast.dart';
29 import 'package:analyzer/src/generated/element.dart'; 29 import 'package:analyzer/src/generated/element.dart';
30 import 'package:analyzer/src/generated/engine.dart' 30 import 'package:analyzer/src/generated/engine.dart'
31 hide AnalysisCache, AnalysisContextImpl, AnalysisTask; 31 hide AnalysisCache, AnalysisContextImpl, AnalysisTask;
32 import 'package:analyzer/src/generated/java_engine.dart'; 32 import 'package:analyzer/src/generated/java_engine.dart';
33 import 'package:analyzer/src/generated/resolver.dart';
33 import 'package:analyzer/src/generated/source.dart'; 34 import 'package:analyzer/src/generated/source.dart';
34 import 'package:analyzer/src/generated/utilities_collection.dart'; 35 import 'package:analyzer/src/generated/utilities_collection.dart';
35 import 'package:analyzer/src/generated/utilities_general.dart'; 36 import 'package:analyzer/src/generated/utilities_general.dart';
36 import 'package:analyzer/src/task/dart.dart'; 37 import 'package:analyzer/src/task/dart.dart';
37 import 'package:analyzer/src/task/html.dart'; 38 import 'package:analyzer/src/task/html.dart';
38 import 'package:analyzer/task/dart.dart'; 39 import 'package:analyzer/task/dart.dart';
39 import 'package:analyzer/task/general.dart'; 40 import 'package:analyzer/task/general.dart';
40 import 'package:analyzer/task/html.dart'; 41 import 'package:analyzer/task/html.dart';
41 import 'package:analyzer/task/model.dart'; 42 import 'package:analyzer/task/model.dart';
42 import 'package:plugin/plugin.dart'; 43 import 'package:plugin/plugin.dart';
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 InternalAnalysisContext context = analysisServer.folderMap[folder]; 572 InternalAnalysisContext context = analysisServer.folderMap[folder];
572 573
573 _writeResponse(request, (StringBuffer buffer) { 574 _writeResponse(request, (StringBuffer buffer) {
574 _writePage(buffer, 'Analysis Server - AST Structure', 575 _writePage(buffer, 'Analysis Server - AST Structure',
575 ['Context: $contextFilter', 'File: $sourceUri'], (HttpResponse) { 576 ['Context: $contextFilter', 'File: $sourceUri'], (HttpResponse) {
576 Source source = context.sourceFactory.forUri(sourceUri); 577 Source source = context.sourceFactory.forUri(sourceUri);
577 if (source == null) { 578 if (source == null) {
578 buffer.write('<p>Not found.</p>'); 579 buffer.write('<p>Not found.</p>');
579 return; 580 return;
580 } 581 }
581 CacheEntry entry = context.analysisCache.get(source); 582 List<Source> libraries = context.getLibrariesContaining(source);
582 if (entry == null) { 583 for (Source library in libraries) {
583 buffer.write('<p>Not found.</p>'); 584 AnalysisTarget target = new LibrarySpecificUnit(library, source);
584 return; 585 CacheEntry entry = context.analysisCache.get(target);
585 } 586 buffer.write('<b>$target</b><br>');
586 CompilationUnit ast = _getAnyAst(entry); 587 if (entry == null) {
587 if (ast == null) { 588 buffer.write('<p>Not found.</p>');
588 buffer.write('<p>null</p>'); 589 return;
Brian Wilkerson 2015/10/08 04:12:31 I think we want to "continue" rather than "return"
589 return; 590 }
590 } 591 CompilationUnit ast = _getAnyAst(entry);
591 AstWriter writer = new AstWriter(buffer); 592 if (ast == null) {
592 ast.accept(writer); 593 buffer.write('<p>null</p>');
593 if (writer.exceptions.isNotEmpty) { 594 return;
594 buffer.write('<h3>Exceptions while creating page</h3>'); 595 }
595 for (CaughtException exception in writer.exceptions) { 596 AstWriter writer = new AstWriter(buffer);
596 _writeException(buffer, exception); 597 ast.accept(writer);
598 if (writer.exceptions.isNotEmpty) {
599 buffer.write('<h3>Exceptions while creating page</h3>');
600 for (CaughtException exception in writer.exceptions) {
601 _writeException(buffer, exception);
602 }
597 } 603 }
598 } 604 }
599 }); 605 });
600 }); 606 });
601 } 607 }
602 608
603 /** 609 /**
604 * Return a response containing information about a single source file in the 610 * Return a response containing information about a single source file in the
605 * cache. 611 * cache.
606 */ 612 */
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 } 1830 }
1825 buffer.write('</ul>'); 1831 buffer.write('</ul>');
1826 } else if (value is AstNode) { 1832 } else if (value is AstNode) {
1827 String link = 1833 String link =
1828 makeLink(AST_PATH, linkParameters, value.runtimeType.toString()); 1834 makeLink(AST_PATH, linkParameters, value.runtimeType.toString());
1829 buffer.write('<i>$link</i>'); 1835 buffer.write('<i>$link</i>');
1830 } else if (value is Element) { 1836 } else if (value is Element) {
1831 String link = 1837 String link =
1832 makeLink(ELEMENT_PATH, linkParameters, value.runtimeType.toString()); 1838 makeLink(ELEMENT_PATH, linkParameters, value.runtimeType.toString());
1833 buffer.write('<i>$link</i>'); 1839 buffer.write('<i>$link</i>');
1840 } else if (value is UsedLocalElements) {
1841 buffer.write('<ul>');
1842 {
1843 HashSet<Element> elements = value.elements;
Brian Wilkerson 2015/10/08 04:12:31 Is it worth sorting the list?
1844 buffer.write('List "elements" containing ${elements.length} entries');
1845 buffer.write('<ul>');
1846 for (Element element in elements) {
1847 buffer.write('<li>');
1848 buffer.write('<i>${element.runtimeType}</i> $element');
1849 buffer.write('</li>');
1850 }
1851 buffer.write('</ul>');
1852 }
1853 {
1854 List<String> members = value.members.toList();
1855 members.sort((String a, String b) {
1856 a = a.toLowerCase();
1857 b = b.toLowerCase();
1858 return a.compareTo(b);
1859 });
1860 buffer.write('List "members" containing ${members.length} entries');
1861 buffer.write('<ul>');
1862 for (String member in members) {
1863 buffer.write('<li>');
1864 buffer.write(member);
1865 buffer.write('</li>');
1866 }
1867 buffer.write('</ul>');
1868 }
1869 {
1870 List<String> readMembers = value.readMembers.toList();
Brian Wilkerson 2015/10/08 04:12:31 Duplicated code. Consider creating a method to wri
1871 readMembers.sort((String a, String b) {
1872 a = a.toLowerCase();
Brian Wilkerson 2015/10/08 04:12:31 Unless the "toLowerCase" is important, you could j
1873 b = b.toLowerCase();
1874 return a.compareTo(b);
1875 });
1876 buffer.write(
1877 'List "readMembers" containing ${readMembers.length} entries');
1878 buffer.write('<ul>');
1879 for (String readMember in readMembers) {
1880 buffer.write('<li>');
1881 buffer.write(readMember);
1882 buffer.write('</li>');
1883 }
1884 buffer.write('</ul>');
1885 }
1886 buffer.write('</ul>');
1834 } else { 1887 } else {
1835 buffer.write(HTML_ESCAPE.convert(value.toString())); 1888 buffer.write(HTML_ESCAPE.convert(value.toString()));
1836 buffer.write(' <i>(${value.runtimeType.toString()})</i>'); 1889 buffer.write(' <i>(${value.runtimeType.toString()})</i>');
1837 } 1890 }
1838 } 1891 }
1839 1892
1840 /** 1893 /**
1841 * Create a link to [path] with query parameters [params], with inner HTML 1894 * Create a link to [path] with query parameters [params], with inner HTML
1842 * [innerHtml]. If [hasError] is `true`, then the link will have the class 1895 * [innerHtml]. If [hasError] is `true`, then the link will have the class
1843 * 'error'. 1896 * 'error'.
1844 */ 1897 */
1845 static String makeLink( 1898 static String makeLink(
1846 String path, Map<String, String> params, String innerHtml, 1899 String path, Map<String, String> params, String innerHtml,
1847 [bool hasError = false]) { 1900 [bool hasError = false]) {
1848 Uri uri = new Uri(path: path, queryParameters: params); 1901 Uri uri = new Uri(path: path, queryParameters: params);
1849 String href = HTML_ESCAPE.convert(uri.toString()); 1902 String href = HTML_ESCAPE.convert(uri.toString());
1850 String classAttribute = hasError ? ' class="error"' : ''; 1903 String classAttribute = hasError ? ' class="error"' : '';
1851 return '<a href="$href"$classAttribute>$innerHtml</a>'; 1904 return '<a href="$href"$classAttribute>$innerHtml</a>';
1852 } 1905 }
1853 } 1906 }
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