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

Unified Diff: pkg/analysis_server/lib/src/computer/element.dart

Issue 392693002: Initial implementation for 'search.findElementReferences'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add comments Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/lib/src/constants.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/computer/element.dart
diff --git a/pkg/analysis_server/lib/src/computer/element.dart b/pkg/analysis_server/lib/src/computer/element.dart
index 56ede071a6d0d0fd2c861475c7b7f29779390aa0..2ba29901fd93ba6dc556722c2b5a359170bd9c66 100644
--- a/pkg/analysis_server/lib/src/computer/element.dart
+++ b/pkg/analysis_server/lib/src/computer/element.dart
@@ -67,21 +67,35 @@ class Element {
String name = element.displayName;
String elementParameters = _getParametersString(element);
String elementReturnType = _getReturnTypeString(element);
- return new Element(ElementKind.valueOfEngine(element.kind), name,
- new Location.fromElement(element), element.isPrivate, element.isDeprecated,
- parameters: elementParameters, returnType: elementReturnType, isAbstract:
- _isAbstract(element), isConst: _isConst(element), isFinal: _isFinal(element),
+ return new Element(
+ ElementKind.valueOfEngine(element.kind),
+ name,
+ new Location.fromElement(element),
+ element.isPrivate,
+ element.isDeprecated,
+ parameters: elementParameters,
+ returnType: elementReturnType,
+ isAbstract: _isAbstract(element),
+ isConst: _isConst(element),
+ isFinal: _isFinal(element),
isStatic: _isStatic(element));
}
factory Element.fromJson(Map<String, Object> map) {
ElementKind kind = ElementKind.valueOf(map[KIND]);
int flags = map[FLAGS];
- return new Element(kind, map[NAME], new Location.fromJson(map[LOCATION]),
- _hasFlag(flags, FLAG_PRIVATE), _hasFlag(flags, FLAG_DEPRECATED), parameters:
- map[PARAMETERS], returnType: map[RETURN_TYPE], isAbstract: _hasFlag(flags,
- FLAG_ABSTRACT), isConst: _hasFlag(flags, FLAG_CONST), isFinal: _hasFlag(flags,
- FLAG_FINAL), isStatic: _hasFlag(flags, FLAG_STATIC));
+ return new Element(
+ kind,
+ map[NAME],
+ new Location.fromJson(map[LOCATION]),
+ _hasFlag(flags, FLAG_PRIVATE),
+ _hasFlag(flags, FLAG_DEPRECATED),
+ parameters: map[PARAMETERS],
+ returnType: map[RETURN_TYPE],
+ isAbstract: _hasFlag(flags, FLAG_ABSTRACT),
+ isConst: _hasFlag(flags, FLAG_CONST),
+ isFinal: _hasFlag(flags, FLAG_FINAL),
+ isStatic: _hasFlag(flags, FLAG_STATIC));
}
int get flags {
@@ -114,6 +128,10 @@ class Element {
@override
String toString() => toJson().toString();
+ static Map<String, Object> asJson(Element element) {
+ return element.toJson();
+ }
+
static String _getParametersString(engine.Element element) {
// TODO(scheglov) expose the corresponding feature from ExecutableElement
if (element is engine.ExecutableElement) {
@@ -318,12 +336,36 @@ class Location {
startColumn = 1;
}
// done
- return new Location(source.fullName, offset, length, startLine,
+ return new Location(
+ source.fullName,
+ offset,
+ length,
+ startLine,
+ startColumn);
+ }
+
+ factory Location.fromOffset(engine.Element element, int offset, int length) {
+ Source source = element.source;
+ LineInfo lineInfo = element.context.getLineInfo(source);
+ // prepare location
+ LineInfo_Location lineLocation = lineInfo.getLocation(offset);
+ int startLine = lineLocation.lineNumber;
+ int startColumn = lineLocation.columnNumber;
+ // done
+ return new Location(
+ source.fullName,
+ offset,
+ length,
+ startLine,
startColumn);
}
factory Location.fromJson(Map<String, Object> map) {
- return new Location(map[FILE], map[OFFSET], map[LENGTH], map[START_LINE],
+ return new Location(
+ map[FILE],
+ map[OFFSET],
+ map[LENGTH],
+ map[START_LINE],
map[START_COLUMN]);
}
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/lib/src/constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698