| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/services/search/search_engine.dart'; | 7 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
| 9 import 'package:analyzer/src/dart/analysis/driver.dart'; | 9 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| 10 import 'package:analyzer/src/dart/analysis/search.dart'; | 10 import 'package:analyzer/src/dart/analysis/search.dart'; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 | 34 |
| 35 await addSubtypes(type); | 35 await addSubtypes(type); |
| 36 return allSubtypes; | 36 return allSubtypes; |
| 37 } | 37 } |
| 38 | 38 |
| 39 @override | 39 @override |
| 40 Future<List<SearchMatch>> searchMemberDeclarations(String name) async { | 40 Future<List<SearchMatch>> searchMemberDeclarations(String name) async { |
| 41 List<SearchMatch> allDeclarations = []; | 41 List<SearchMatch> allDeclarations = []; |
| 42 RegExp regExp = new RegExp('^$name\$'); | |
| 43 for (AnalysisDriver driver in _drivers) { | 42 for (AnalysisDriver driver in _drivers) { |
| 44 List<Element> elements = await driver.search.classMembers(regExp); | 43 List<Element> elements = await driver.search.classMembers(name); |
| 45 allDeclarations.addAll(elements.map(_SearchMatch.forElement)); | 44 allDeclarations.addAll(elements.map(_SearchMatch.forElement)); |
| 46 } | 45 } |
| 47 return allDeclarations; | 46 return allDeclarations; |
| 48 } | 47 } |
| 49 | 48 |
| 50 @override | 49 @override |
| 51 Future<List<SearchMatch>> searchMemberReferences(String name) async { | 50 Future<List<SearchMatch>> searchMemberReferences(String name) async { |
| 52 List<SearchResult> allResults = []; | 51 List<SearchResult> allResults = []; |
| 53 for (AnalysisDriver driver in _drivers) { | 52 for (AnalysisDriver driver in _drivers) { |
| 54 List<SearchResult> results = | 53 List<SearchResult> results = |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 buffer.write(", range="); | 145 buffer.write(", range="); |
| 147 buffer.write(sourceRange); | 146 buffer.write(sourceRange); |
| 148 buffer.write(", isResolved="); | 147 buffer.write(", isResolved="); |
| 149 buffer.write(isResolved); | 148 buffer.write(isResolved); |
| 150 buffer.write(", isQualified="); | 149 buffer.write(", isQualified="); |
| 151 buffer.write(isQualified); | 150 buffer.write(isQualified); |
| 152 buffer.write(")"); | 151 buffer.write(")"); |
| 153 return buffer.toString(); | 152 return buffer.toString(); |
| 154 } | 153 } |
| 155 | 154 |
| 155 static _SearchMatch forElement(Element element) { |
| 156 return new _SearchMatch( |
| 157 element.source.fullName, |
| 158 element.librarySource, |
| 159 element.source, |
| 160 element.library, |
| 161 element, |
| 162 true, |
| 163 true, |
| 164 MatchKind.DECLARATION, |
| 165 new SourceRange(element.nameOffset, element.nameLength)); |
| 166 } |
| 167 |
| 156 static _SearchMatch forSearchResult(SearchResult result) { | 168 static _SearchMatch forSearchResult(SearchResult result) { |
| 157 Element enclosingElement = result.enclosingElement; | 169 Element enclosingElement = result.enclosingElement; |
| 158 return new _SearchMatch( | 170 return new _SearchMatch( |
| 159 enclosingElement.source.fullName, | 171 enclosingElement.source.fullName, |
| 160 enclosingElement.librarySource, | 172 enclosingElement.librarySource, |
| 161 enclosingElement.source, | 173 enclosingElement.source, |
| 162 enclosingElement.library, | 174 enclosingElement.library, |
| 163 enclosingElement, | 175 enclosingElement, |
| 164 result.isResolved, | 176 result.isResolved, |
| 165 result.isQualified, | 177 result.isQualified, |
| 166 toMatchKind(result.kind), | 178 toMatchKind(result.kind), |
| 167 new SourceRange(result.offset, result.length)); | 179 new SourceRange(result.offset, result.length)); |
| 168 } | 180 } |
| 169 | 181 |
| 170 static _SearchMatch forElement(Element element) { | |
| 171 return new _SearchMatch( | |
| 172 element.source.fullName, | |
| 173 element.librarySource, | |
| 174 element.source, | |
| 175 element.library, | |
| 176 element, | |
| 177 true, | |
| 178 true, | |
| 179 MatchKind.DECLARATION, | |
| 180 new SourceRange(element.nameOffset, element.nameLength)); | |
| 181 } | |
| 182 | |
| 183 static MatchKind toMatchKind(SearchResultKind kind) { | 182 static MatchKind toMatchKind(SearchResultKind kind) { |
| 184 if (kind == SearchResultKind.READ) { | 183 if (kind == SearchResultKind.READ) { |
| 185 return MatchKind.READ; | 184 return MatchKind.READ; |
| 186 } | 185 } |
| 187 if (kind == SearchResultKind.READ_WRITE) { | 186 if (kind == SearchResultKind.READ_WRITE) { |
| 188 return MatchKind.READ_WRITE; | 187 return MatchKind.READ_WRITE; |
| 189 } | 188 } |
| 190 if (kind == SearchResultKind.WRITE) { | 189 if (kind == SearchResultKind.WRITE) { |
| 191 return MatchKind.WRITE; | 190 return MatchKind.WRITE; |
| 192 } | 191 } |
| 193 if (kind == SearchResultKind.INVOCATION) { | 192 if (kind == SearchResultKind.INVOCATION) { |
| 194 return MatchKind.INVOCATION; | 193 return MatchKind.INVOCATION; |
| 195 } | 194 } |
| 196 return MatchKind.REFERENCE; | 195 return MatchKind.REFERENCE; |
| 197 } | 196 } |
| 198 } | 197 } |
| OLD | NEW |