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

Unified Diff: pkg/analysis_server/lib/src/services/completion/arglist_computer.dart

Issue 1068483002: rename completion source files to match content (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | « no previous file | pkg/analysis_server/lib/src/services/completion/arglist_contributor.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/completion/arglist_computer.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/arglist_computer.dart b/pkg/analysis_server/lib/src/services/completion/arglist_computer.dart
deleted file mode 100644
index 76f2bff5a51a45bc3a2b238ce3f6115cf4f31fc2..0000000000000000000000000000000000000000
--- a/pkg/analysis_server/lib/src/services/completion/arglist_computer.dart
+++ /dev/null
@@ -1,202 +0,0 @@
-// 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 services.completion.contributor.dart.arglist;
-
-import 'dart:async';
-
-import 'package:analysis_server/src/protocol_server.dart'
- hide Element, ElementKind;
-import 'package:analysis_server/src/services/completion/dart_completion_manager.dart';
-import 'package:analysis_server/src/services/completion/local_declaration_visitor.dart';
-import 'package:analyzer/src/generated/ast.dart';
-import 'package:analyzer/src/generated/scanner.dart';
-
-/**
- * A contributor for calculating `completion.getSuggestions` request results
- * when the cursor position is inside the arguments to a method call.
- */
-class ArgListContributor extends DartCompletionContributor {
- _ArgListSuggestionBuilder builder;
-
- @override
- bool computeFast(DartCompletionRequest request) {
- builder =
- request.target.containingNode.accept(new _ArgListAstVisitor(request));
- return builder == null;
- }
-
- @override
- Future<bool> computeFull(DartCompletionRequest request) {
- if (builder != null) {
- return builder.compute(request.target.containingNode);
- }
- return new Future.value(false);
- }
-}
-
-/**
- * A visitor for determining whether an argument list suggestion is needed
- * and instantiating the builder to create the suggestion.
- */
-class _ArgListAstVisitor
- extends GeneralizingAstVisitor<_ArgListSuggestionBuilder> {
- final DartCompletionRequest request;
-
- _ArgListAstVisitor(this.request);
-
- @override
- _ArgListSuggestionBuilder visitArgumentList(ArgumentList node) {
- Token leftParen = node.leftParenthesis;
- if (leftParen != null && request.offset > leftParen.offset) {
- AstNode parent = node.parent;
- if (parent is MethodInvocation) {
- SimpleIdentifier selector = parent.methodName;
- if (selector != null) {
- String name = selector.name;
- if (name != null && name.length > 0) {
- if (parent.operator == null) {
- /*
- * If a local declaration is found, then return null
- * indicating that suggestions were added
- * and no further action is necessary
- */
- if (new _LocalDeclarationFinder(request, request.offset, name)
- .visit(node)) {
- return null;
- }
- } else {
- // determine target
- }
- }
- }
- }
- return new _ArgListSuggestionBuilder(request);
- }
- return null;
- }
-
- @override
- _ArgListSuggestionBuilder visitNode(AstNode node) {
- return null;
- }
-}
-
-/**
- * A `_ArgListSuggestionBuilder` determines which method or function is being
- * invoked, then builds the argument list suggestion.
- * This operation is instantiated during `computeFast`
- * and calculates the suggestions during `computeFull`.
- */
-class _ArgListSuggestionBuilder {
- final DartCompletionRequest request;
-
- _ArgListSuggestionBuilder(this.request);
-
- Future<bool> compute(ArgumentList node) {
- return new Future.value(false);
- }
-}
-
-/**
- * `_LocalDeclarationFinder` visits an [AstNode] and its parent recursively
- * looking for a matching declaration. If found, it adds the appropriate
- * suggestions and sets finished to `true`.
- */
-class _LocalDeclarationFinder extends LocalDeclarationVisitor {
- final DartCompletionRequest request;
- final String name;
-
- _LocalDeclarationFinder(this.request, int offset, this.name) : super(offset);
-
- @override
- void declaredClass(ClassDeclaration declaration) {}
-
- @override
- void declaredClassTypeAlias(ClassTypeAlias declaration) {}
-
- @override
- void declaredField(FieldDeclaration fieldDecl, VariableDeclaration varDecl) {}
-
- @override
- void declaredFunction(FunctionDeclaration declaration) {
- SimpleIdentifier selector = declaration.name;
- if (selector != null && name == selector.name) {
- _addArgListSuggestion(declaration.functionExpression.parameters);
- finished();
- }
- }
-
- @override
- void declaredFunctionTypeAlias(FunctionTypeAlias declaration) {}
-
- @override
- void declaredLabel(Label label, bool isCaseLabel) {}
-
- @override
- void declaredLocalVar(SimpleIdentifier name, TypeName type) {}
-
- @override
- void declaredMethod(MethodDeclaration declaration) {
- SimpleIdentifier selector = declaration.name;
- if (selector != null && name == selector.name) {
- _addArgListSuggestion(declaration.parameters);
- finished();
- }
- }
-
- @override
- void declaredParam(SimpleIdentifier name, TypeName type) {}
-
- @override
- void declaredTopLevelVar(
- VariableDeclarationList varList, VariableDeclaration varDecl) {}
-
- void _addArgListSuggestion(FormalParameterList parameters) {
- if (parameters.parameters.length == 0) {
- return;
- }
- StringBuffer completion = new StringBuffer('(');
- List<String> paramNames = new List<String>();
- List<String> paramTypes = new List<String>();
- for (FormalParameter param in parameters.parameters) {
- SimpleIdentifier paramId = param.identifier;
- if (paramId != null) {
- String name = paramId.name;
- if (name != null && name.length > 0) {
- if (completion.length > 1) {
- completion.write(', ');
- }
- completion.write(name);
- paramNames.add(name);
- paramTypes.add(_getParamType(param));
- }
- }
- }
- completion.write(')');
- CompletionSuggestion suggestion = new CompletionSuggestion(
- CompletionSuggestionKind.ARGUMENT_LIST, DART_RELEVANCE_HIGH,
- completion.toString(), completion.length, 0, false, false);
- suggestion.parameterNames = paramNames;
- suggestion.parameterTypes = paramTypes;
- request.addSuggestion(suggestion);
- }
-
- String _getParamType(FormalParameter param) {
- TypeName type;
- if (param is SimpleFormalParameter) {
- type = param.type;
- }
- if (type != null) {
- Identifier id = type.name;
- if (id != null) {
- String name = id.name;
- if (name != null && name.length > 0) {
- return name;
- }
- }
- }
- return 'dynamic';
- }
-}
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/arglist_contributor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698