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

Side by Side Diff: pkg/analysis_server/lib/src/computer/computer_hover.dart

Issue 1513943005: Tweaks for hover. (Closed) Base URL: git@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 | pkg/analysis_server/test/analysis/get_hover_test.dart » ('j') | 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 computer.hover; 5 library computer.hover;
6 6
7 import 'package:analysis_server/plugin/protocol/protocol.dart' 7 import 'package:analysis_server/plugin/protocol/protocol.dart'
8 show HoverInformation; 8 show HoverInformation;
9 import 'package:analyzer/src/generated/ast.dart'; 9 import 'package:analyzer/src/generated/ast.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 95 }
96 // description 96 // description
97 hover.elementDescription = element.toString(); 97 hover.elementDescription = element.toString();
98 hover.elementKind = element.kind.displayName; 98 hover.elementKind = element.kind.displayName;
99 // not local element 99 // not local element
100 if (element.enclosingElement is! ExecutableElement) { 100 if (element.enclosingElement is! ExecutableElement) {
101 // containing class 101 // containing class
102 ClassElement containingClass = 102 ClassElement containingClass =
103 element.getAncestor((e) => e is ClassElement); 103 element.getAncestor((e) => e is ClassElement);
104 if (containingClass != null) { 104 if (containingClass != null) {
105 hover.containingClassDescription = containingClass.toString(); 105 hover.containingClassDescription = containingClass.displayName;
106 } 106 }
107 // containing library 107 // containing library
108 LibraryElement library = element.library; 108 LibraryElement library = element.library;
109 if (library != null) { 109 if (library != null) {
110 hover.containingLibraryName = library.name; 110 hover.containingLibraryName = library.name;
111 hover.containingLibraryPath = library.source.fullName; 111 hover.containingLibraryPath = library.source.fullName;
112 } 112 }
113 } 113 }
114 // documentation 114 // documentation
115 hover.dartdoc = _computeDocumentation(element); 115 hover.dartdoc = _computeDocumentation(element);
116 } 116 }
117 // parameter 117 // parameter
118 hover.parameter = _safeToString(expression.bestParameterElement); 118 hover.parameter = _safeToString(expression.bestParameterElement);
119 // types 119 // types
120 hover.staticType = _safeToString(expression.staticType); 120 if (element == null || element is VariableElement) {
121 hover.staticType = _safeToString(expression.staticType);
122 }
121 hover.propagatedType = _safeToString(expression.propagatedType); 123 hover.propagatedType = _safeToString(expression.propagatedType);
122 // done 124 // done
123 return hover; 125 return hover;
124 } 126 }
125 // not an expression 127 // not an expression
126 return null; 128 return null;
127 } 129 }
128 130
129 String _computeDocumentation(Element element) { 131 String _computeDocumentation(Element element) {
130 if (element is ParameterElement) { 132 if (element is ParameterElement) {
131 element = element.enclosingElement; 133 element = element.enclosingElement;
132 } 134 }
133 String dartDoc = element.computeDocumentationComment(); 135 String dartDoc = element.computeDocumentationComment();
134 return _removeDartDocDelimiters(dartDoc); 136 return _removeDartDocDelimiters(dartDoc);
135 } 137 }
136 138
137 static _safeToString(obj) => obj != null ? obj.toString() : null; 139 static _safeToString(obj) => obj != null ? obj.toString() : null;
138 } 140 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis/get_hover_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698