| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library domain.search; |
| 6 |
| 7 import 'package:analysis_server/src/analysis_server.dart'; |
| 8 import 'package:analysis_server/src/constants.dart'; |
| 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 |
| 11 /** |
| 12 * Instances of the class [SearchDomainHandler] implement a [RequestHandler] |
| 13 * that handles requests in the search domain. |
| 14 */ |
| 15 class SearchDomainHandler implements RequestHandler { |
| 16 /** |
| 17 * The analysis server that is using this handler to process requests. |
| 18 */ |
| 19 final AnalysisServer server; |
| 20 |
| 21 /** |
| 22 * Initialize a newly created handler to handle requests for the given [server
]. |
| 23 */ |
| 24 SearchDomainHandler(this.server); |
| 25 |
| 26 @override |
| 27 Response handleRequest(Request request) { |
| 28 try { |
| 29 String requestName = request.method; |
| 30 if (requestName == SEARCH_FIND_ELEMENT_REFERENCES) { |
| 31 return findElementReferences(request); |
| 32 } else if (requestName == SEARCH_FIND_MEMBER_DECLARATIONS) { |
| 33 return findMemberDeclarations(request); |
| 34 } else if (requestName == SEARCH_FIND_MEMBER_REFERENCES) { |
| 35 return findMemberReferences(request); |
| 36 } else if (requestName == SEARCH_FIND_TOP_LEVEL_DECLARATIONS) { |
| 37 return findTopLevelDeclarations(request); |
| 38 } |
| 39 } on RequestFailure catch (exception) { |
| 40 return exception.response; |
| 41 } |
| 42 return null; |
| 43 } |
| 44 |
| 45 Response findElementReferences(Request request) { |
| 46 // file |
| 47 RequestDatum fileDatum = request.getRequiredParameter(FILE); |
| 48 String file = fileDatum.asString(); |
| 49 // offset |
| 50 RequestDatum offsetDatum = request.getRequiredParameter(OFFSET); |
| 51 int offset = offsetDatum.asInt(); |
| 52 // includePotential |
| 53 RequestDatum includePotentialDatum = request.getRequiredParameter(LENGTH); |
| 54 bool includePotential = includePotentialDatum.asBool(); |
| 55 // TODO(brianwilkerson) implement |
| 56 return null; |
| 57 } |
| 58 |
| 59 Response findMemberDeclarations(Request request) { |
| 60 // name |
| 61 RequestDatum nameDatum = request.getRequiredParameter(FILE); |
| 62 String name = nameDatum.asString(); |
| 63 // TODO(brianwilkerson) implement |
| 64 return null; |
| 65 } |
| 66 |
| 67 Response findMemberReferences(Request request) { |
| 68 // name |
| 69 RequestDatum nameDatum = request.getRequiredParameter(FILE); |
| 70 String name = nameDatum.asString(); |
| 71 // TODO(brianwilkerson) implement |
| 72 return null; |
| 73 } |
| 74 |
| 75 Response findTopLevelDeclarations(Request request) { |
| 76 // pattern |
| 77 RequestDatum patternDatum = request.getRequiredParameter(FILE); |
| 78 String pattern = patternDatum.asString(); |
| 79 // TODO(brianwilkerson) implement |
| 80 return null; |
| 81 } |
| 82 } |
| OLD | NEW |