blob: cfb68816f08d527981782108833269ba6b7f5f9d [file] [log] [blame]
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library domain.completion;
import 'package:analysis_server/src/analysis_server.dart';
import 'package:analysis_server/src/constants.dart';
import 'package:analysis_server/src/protocol.dart';
/**
* Instances of the class [CompletionDomainHandler] implement a [RequestHandler]
* that handles requests in the search domain.
*/
class CompletionDomainHandler implements RequestHandler {
/**
* The analysis server that is using this handler to process requests.
*/
final AnalysisServer server;
/**
* Initialize a newly created handler to handle requests for the given [server].
*/
CompletionDomainHandler(this.server);
@override
Response handleRequest(Request request) {
try {
String requestName = request.method;
if (requestName == COMPLETION_GET_SUGGESTIONS) {
return getSuggestions(request);
}
} on RequestFailure catch (exception) {
return exception.response;
}
return null;
}
Response getSuggestions(Request request) {
// file
RequestDatum fileDatum = request.getRequiredParameter(FILE);
String file = fileDatum.asString();
// offset
RequestDatum offsetDatum = request.getRequiredParameter(OFFSET);
int offset = offsetDatum.asInt();
// TODO(brianwilkerson) implement
return null;
}
}