| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library services.completion; | 8 library services.completion; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| 11 import 'package:analyzer/src/generated/java_core.dart' hide StringUtils; | 11 import 'package:analyzer/src/generated/java_core.dart' hide StringUtils; |
| 12 import 'package:analyzer/src/generated/java_engine.dart'; | 12 import 'package:analyzer/src/generated/java_engine.dart'; |
| 13 import 'package:analyzer/src/generated/java_io.dart'; | 13 import 'package:analyzer/src/generated/java_io.dart'; |
| 14 import 'package:analyzer/src/generated/ast.dart'; | 14 import 'package:analyzer/src/generated/ast.dart'; |
| 15 import 'package:analyzer/src/generated/element.dart'; | 15 import 'package:analyzer/src/generated/element.dart'; |
| 16 import 'package:analyzer/src/generated/engine.dart'; | 16 import 'package:analyzer/src/generated/engine.dart'; |
| 17 import 'package:analyzer/src/generated/error.dart'; | 17 import 'package:analyzer/src/generated/error.dart'; |
| 18 import 'package:analyzer/src/generated/resolver.dart'; | 18 import 'package:analyzer/src/generated/resolver.dart'; |
| 19 import 'package:analyzer/src/generated/scanner.dart'; | 19 import 'package:analyzer/src/generated/scanner.dart'; |
| 20 import 'package:analyzer/src/generated/sdk.dart'; | 20 import 'package:analyzer/src/generated/sdk.dart'; |
| 21 import 'package:analyzer/src/generated/source_io.dart'; | 21 import 'package:analyzer/src/generated/source_io.dart'; |
| 22 import 'package:analyzer/src/generated/utilities_dart.dart'; | 22 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 23 import 'stubs.dart'; | 23 import 'stubs.dart'; |
| 24 import 'util.dart'; | 24 import 'util.dart'; |
| 25 | 25 |
| 26 import '../../completion/completion_suggestion.dart'; |
| 27 |
| 26 class AstNodeClassifier_CompletionEngine_typeOf extends CompletionEngine_AstNode
Classifier { | 28 class AstNodeClassifier_CompletionEngine_typeOf extends CompletionEngine_AstNode
Classifier { |
| 27 final CompletionEngine CompletionEngine_this; | 29 final CompletionEngine CompletionEngine_this; |
| 28 | 30 |
| 29 List<DartType> result; | 31 List<DartType> result; |
| 30 | 32 |
| 31 AstNodeClassifier_CompletionEngine_typeOf(this.CompletionEngine_this, this.res
ult) : super(); | 33 AstNodeClassifier_CompletionEngine_typeOf(this.CompletionEngine_this, this.res
ult) : super(); |
| 32 | 34 |
| 33 @override | 35 @override |
| 34 Object visitPrefixedIdentifier(PrefixedIdentifier node) => visitSimpleIdentifi
er(node.identifier); | 36 Object visitPrefixedIdentifier(PrefixedIdentifier node) => visitSimpleIdentifi
er(node.identifier); |
| 35 | 37 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 154 } |
| 153 | 155 |
| 154 void _analyzeDeclarationName(VariableDeclaration varDecl) { | 156 void _analyzeDeclarationName(VariableDeclaration varDecl) { |
| 155 // We might want to propose multiple names for a declaration based on types
someday. | 157 // We might want to propose multiple names for a declaration based on types
someday. |
| 156 // For now, just use whatever is already there. | 158 // For now, just use whatever is already there. |
| 157 SimpleIdentifier identifier = varDecl.name; | 159 SimpleIdentifier identifier = varDecl.name; |
| 158 _filter = _createFilter(identifier); | 160 _filter = _createFilter(identifier); |
| 159 VariableDeclarationList varList = varDecl.parent as VariableDeclarationList; | 161 VariableDeclarationList varList = varDecl.parent as VariableDeclarationList; |
| 160 TypeName type = varList.type; | 162 TypeName type = varList.type; |
| 161 if (identifier.length > 0) { | 163 if (identifier.length > 0) { |
| 162 _pName3(identifier.name, ProposalKind.VARIABLE); | 164 _pName3(identifier.name, CompletionSuggestionKind.VARIABLE); |
| 163 } | 165 } |
| 164 if (type == null) { | 166 if (type == null) { |
| 165 if (varList.keyword == null) { | 167 if (varList.keyword == null) { |
| 166 // Interpret as the type name of a typed variable declaration { DivE!; } | 168 // Interpret as the type name of a typed variable declaration { DivE!; } |
| 167 _analyzeLocalName(identifier); | 169 _analyzeLocalName(identifier); |
| 168 } | 170 } |
| 169 } else { | 171 } else { |
| 170 _pParamName(type.name.name.toLowerCase()); | 172 _pParamName(type.name.name.toLowerCase()); |
| 171 } | 173 } |
| 172 } | 174 } |
| 173 | 175 |
| 174 void _analyzeDirectAccess(DartType receiverType, SimpleIdentifier completionNo
de) { | 176 void _analyzeDirectAccess(DartType receiverType, SimpleIdentifier completionNo
de) { |
| 175 if (receiverType != null) { | 177 if (receiverType != null) { |
| 176 // Complete this.!y where this is absent | 178 // Complete this.!y where this is absent |
| 177 Element rcvrTypeElem = receiverType.element; | 179 Element rcvrTypeElem = receiverType.element; |
| 178 if (receiverType.isDynamic) { | 180 if (receiverType.isDynamic) { |
| 179 rcvrTypeElem = objectClassElement; | 181 rcvrTypeElem = objectClassElement; |
| 180 } | 182 } |
| 181 if (rcvrTypeElem is ClassElement) { | 183 if (rcvrTypeElem is ClassElement) { |
| 182 _directAccess(rcvrTypeElem as ClassElement, completionNode); | 184 _directAccess(rcvrTypeElem as ClassElement, completionNode); |
| 183 } | 185 } |
| 184 } | 186 } |
| 185 } | 187 } |
| 186 | 188 |
| 187 void _analyzeImmediateField(SimpleIdentifier fieldName) { | 189 void _analyzeImmediateField(SimpleIdentifier fieldName) { |
| 188 _filter = _createFilter(fieldName); | 190 _filter = _createFilter(fieldName); |
| 189 ClassDeclaration classDecl = fieldName.getAncestor((node) => node is ClassDe
claration); | 191 ClassDeclaration classDecl = fieldName.getAncestor((node) => node is ClassDe
claration); |
| 190 ClassElement classElement = classDecl.element; | 192 ClassElement classElement = classDecl.element; |
| 191 for (FieldElement field in classElement.fields) { | 193 for (FieldElement field in classElement.fields) { |
| 192 _pName3(field.displayName, ProposalKind.FIELD); | 194 _pName3(field.displayName, CompletionSuggestionKind.FIELD); |
| 193 } | 195 } |
| 194 } | 196 } |
| 195 | 197 |
| 196 void _analyzeLiteralReference(BooleanLiteral literal) { | 198 void _analyzeLiteralReference(BooleanLiteral literal) { |
| 197 // state.setContext(literal); | 199 // state.setContext(literal); |
| 198 Ident ident = _createIdent(literal.parent); | 200 Ident ident = _createIdent(literal.parent); |
| 199 ident.token = literal.literal; | 201 ident.token = literal.literal; |
| 200 _filter = _createFilter(ident); | 202 _filter = _createFilter(ident); |
| 201 _analyzeLocalName(ident); | 203 _analyzeLocalName(ident); |
| 202 } | 204 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // filter by name | 264 // filter by name |
| 263 if (_filterDisallows(parameterElement)) { | 265 if (_filterDisallows(parameterElement)) { |
| 264 continue; | 266 continue; |
| 265 } | 267 } |
| 266 // may be already used | 268 // may be already used |
| 267 String parameterName = parameterElement.name; | 269 String parameterName = parameterElement.name; |
| 268 if (usedNames.contains(parameterName)) { | 270 if (usedNames.contains(parameterName)) { |
| 269 continue; | 271 continue; |
| 270 } | 272 } |
| 271 // OK, add proposal | 273 // OK, add proposal |
| 272 CompletionProposal prop = _createProposal4(ProposalKind.NAMED_ARGUMENT); | 274 CompletionProposal prop = _createProposal4(CompletionSuggestionKind.NAMED_
ARGUMENT); |
| 273 prop.setCompletion(parameterName); | 275 prop.setCompletion(parameterName); |
| 274 prop.setParameterName(parameterName); | 276 prop.setParameterName(parameterName); |
| 275 prop.setParameterType(parameterElement.type.displayName); | 277 prop.setParameterType(parameterElement.type.displayName); |
| 276 prop.setLocation(identifier.offset); | 278 prop.setLocation(identifier.offset); |
| 277 prop.setReplacementLength(identifier.length); | 279 prop.setReplacementLength(identifier.length); |
| 278 prop.setRelevance(CompletionProposal.RELEVANCE_HIGH); | 280 prop.setRelevance(CompletionProposal.RELEVANCE_HIGH); |
| 279 _requestor.accept(prop); | 281 _requestor.accept(prop); |
| 280 } | 282 } |
| 281 } | 283 } |
| 282 | 284 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 312 } | 314 } |
| 313 // show current parameter | 315 // show current parameter |
| 314 int argIndex = args.arguments.indexOf(identifier); | 316 int argIndex = args.arguments.indexOf(identifier); |
| 315 if (argIndex == -1) { | 317 if (argIndex == -1) { |
| 316 argIndex = 0; | 318 argIndex = 0; |
| 317 } | 319 } |
| 318 if (argIndex >= 0 && argIndex < parameters.length) { | 320 if (argIndex >= 0 && argIndex < parameters.length) { |
| 319 ParameterElement parameter = parameters[argIndex]; | 321 ParameterElement parameter = parameters[argIndex]; |
| 320 if (parameter.parameterKind != ParameterKind.NAMED) { | 322 if (parameter.parameterKind != ParameterKind.NAMED) { |
| 321 String parameterName = parameter.displayName; | 323 String parameterName = parameter.displayName; |
| 322 CompletionProposal prop = _createProposal4(ProposalKind.OPTIONAL_ARGUMEN
T); | 324 CompletionProposal prop = _createProposal4(CompletionSuggestionKind.OPTI
ONAL_ARGUMENT); |
| 323 prop.setCompletion(parameterName); | 325 prop.setCompletion(parameterName); |
| 324 prop.setParameterName(parameterName); | 326 prop.setParameterName(parameterName); |
| 325 prop.setParameterType(parameter.type.displayName); | 327 prop.setParameterType(parameter.type.displayName); |
| 326 prop.setLocation(identifier.offset); | 328 prop.setLocation(identifier.offset); |
| 327 prop.setReplacementLength(identifier.length); | 329 prop.setReplacementLength(identifier.length); |
| 328 prop.setRelevance(CompletionProposal.RELEVANCE_HIGH); | 330 prop.setRelevance(CompletionProposal.RELEVANCE_HIGH); |
| 329 _requestor.accept(prop); | 331 _requestor.accept(prop); |
| 330 } | 332 } |
| 331 } | 333 } |
| 332 } | 334 } |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 } | 582 } |
| 581 } | 583 } |
| 582 } | 584 } |
| 583 } | 585 } |
| 584 } | 586 } |
| 585 // add known package: URIs | 587 // add known package: URIs |
| 586 for (String uri in packageUris) { | 588 for (String uri in packageUris) { |
| 587 if (_filterDisallows2(uri)) { | 589 if (_filterDisallows2(uri)) { |
| 588 continue; | 590 continue; |
| 589 } | 591 } |
| 590 CompletionProposal prop = _createProposal4(ProposalKind.IMPORT); | 592 CompletionProposal prop = _createProposal4(CompletionSuggestionKind.IMPORT
); |
| 591 prop.setCompletion(uri); | 593 prop.setCompletion(uri); |
| 592 // put "lib" before "lib/src" | 594 // put "lib" before "lib/src" |
| 593 if (!uri.contains("/src/")) { | 595 if (!uri.contains("/src/")) { |
| 594 prop.setRelevance(CompletionProposal.RELEVANCE_HIGH); | 596 prop.setRelevance(CompletionProposal.RELEVANCE_HIGH); |
| 595 } | 597 } |
| 596 // done | 598 // done |
| 597 _requestor.accept(prop); | 599 _requestor.accept(prop); |
| 598 } | 600 } |
| 599 } | 601 } |
| 600 | 602 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 if (library.isImplementation) { | 663 if (library.isImplementation) { |
| 662 continue; | 664 continue; |
| 663 } | 665 } |
| 664 // standard libraries name name starting with "dart:" | 666 // standard libraries name name starting with "dart:" |
| 665 name = StringUtils.removeStart(name, "dart:"); | 667 name = StringUtils.removeStart(name, "dart:"); |
| 666 // ignore private libraries | 668 // ignore private libraries |
| 667 if (Identifier.isPrivateName(name)) { | 669 if (Identifier.isPrivateName(name)) { |
| 668 continue; | 670 continue; |
| 669 } | 671 } |
| 670 // add with "dart:" prefix | 672 // add with "dart:" prefix |
| 671 _pName3("dart:${name}", ProposalKind.IMPORT); | 673 _pName3("dart:${name}", CompletionSuggestionKind.IMPORT); |
| 672 } | 674 } |
| 673 } | 675 } |
| 674 | 676 |
| 675 void _operatorAccess(Expression expr, SimpleIdentifier identifier) { | 677 void _operatorAccess(Expression expr, SimpleIdentifier identifier) { |
| 676 _state._requiresOperators(); | 678 _state._requiresOperators(); |
| 677 _analyzePrefixedAccess(expr, identifier); | 679 _analyzePrefixedAccess(expr, identifier); |
| 678 } | 680 } |
| 679 | 681 |
| 680 void _prefixedAccess(InterfaceType type, bool forSuper, SimpleIdentifier ident
ifier) { | 682 void _prefixedAccess(InterfaceType type, bool forSuper, SimpleIdentifier ident
ifier) { |
| 681 // Complete identifier when it refers to field or method in classElement. | 683 // Complete identifier when it refers to field or method in classElement. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 if (type != null) { | 765 if (type != null) { |
| 764 prop.setReturnType(type.name); | 766 prop.setReturnType(type.name); |
| 765 } | 767 } |
| 766 if (identifier != null) { | 768 if (identifier != null) { |
| 767 prop.setReplacementLengthIdentifier(identifier.length); | 769 prop.setReplacementLengthIdentifier(identifier.length); |
| 768 } | 770 } |
| 769 return prop; | 771 return prop; |
| 770 } | 772 } |
| 771 | 773 |
| 772 CompletionProposal _createProposal3(Element element, String completion) { | 774 CompletionProposal _createProposal3(Element element, String completion) { |
| 773 ProposalKind kind = _proposalKindOf(element); | 775 CompletionSuggestionKind kind = _proposalKindOf(element); |
| 774 CompletionProposal prop = _createProposal4(kind); | 776 CompletionProposal prop = _createProposal4(kind); |
| 775 prop.setElement(element); | 777 prop.setElement(element); |
| 776 prop.setCompletion(completion); | 778 prop.setCompletion(completion); |
| 777 prop.setDeprecated(_isDeprecated(element)); | 779 prop.setDeprecated(_isDeprecated(element)); |
| 778 if (_isPrivate(element)) { | 780 if (_isPrivate(element)) { |
| 779 prop.setRelevance(CompletionProposal.RELEVANCE_LOW); | 781 prop.setRelevance(CompletionProposal.RELEVANCE_LOW); |
| 780 } | 782 } |
| 781 if (_filter._isSameCasePrefix(element.name)) { | 783 if (_filter._isSameCasePrefix(element.name)) { |
| 782 prop.incRelevance(); | 784 prop.incRelevance(); |
| 783 } | 785 } |
| 784 return prop; | 786 return prop; |
| 785 } | 787 } |
| 786 | 788 |
| 787 CompletionProposal _createProposal4(ProposalKind kind) => _factory.createCompl
etionProposal(kind, _completionTokenOffset()); | 789 CompletionProposal _createProposal4(CompletionSuggestionKind kind) => _factory
.createCompletionProposal(kind, _completionTokenOffset()); |
| 788 | 790 |
| 789 List<LibraryElement> _currentLibraryList() { | 791 List<LibraryElement> _currentLibraryList() { |
| 790 Set<LibraryElement> libraries = new Set<LibraryElement>(); | 792 Set<LibraryElement> libraries = new Set<LibraryElement>(); |
| 791 LibraryElement curLib = currentLibrary; | 793 LibraryElement curLib = currentLibrary; |
| 792 libraries.add(curLib); | 794 libraries.add(curLib); |
| 793 Queue<LibraryElement> queue = new Queue<LibraryElement>(); | 795 Queue<LibraryElement> queue = new Queue<LibraryElement>(); |
| 794 queue.addAll(curLib.importedLibraries); | 796 queue.addAll(curLib.importedLibraries); |
| 795 _currentLibraryLister(queue, libraries); | 797 _currentLibraryLister(queue, libraries); |
| 796 return new List.from(libraries); | 798 return new List.from(libraries); |
| 797 } | 799 } |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 } | 1002 } |
| 1001 } | 1003 } |
| 1002 | 1004 |
| 1003 void _pArgumentList(CompletionProposal proposal, int offset, int len) { | 1005 void _pArgumentList(CompletionProposal proposal, int offset, int len) { |
| 1004 // prepare parameters | 1006 // prepare parameters |
| 1005 List<String> parameterNames = proposal.parameterNames; | 1007 List<String> parameterNames = proposal.parameterNames; |
| 1006 if (parameterNames.length == 0) { | 1008 if (parameterNames.length == 0) { |
| 1007 return; | 1009 return; |
| 1008 } | 1010 } |
| 1009 // fill arguments proposal | 1011 // fill arguments proposal |
| 1010 CompletionProposal prop = _createProposal4(ProposalKind.ARGUMENT_LIST); | 1012 CompletionProposal prop = _createProposal4(CompletionSuggestionKind.ARGUMENT
_LIST); |
| 1011 prop.setElement(proposal.element); | 1013 prop.setElement(proposal.element); |
| 1012 prop.setCompletion(proposal.completion).setReturnType(proposal.returnType); | 1014 prop.setCompletion(proposal.completion).setReturnType(proposal.returnType); |
| 1013 prop.setParameterNames(parameterNames); | 1015 prop.setParameterNames(parameterNames); |
| 1014 prop.setParameterTypes(proposal.parameterTypes); | 1016 prop.setParameterTypes(proposal.parameterTypes); |
| 1015 prop.setParameterStyle(proposal.positionalParameterCount, proposal.hasNamed,
proposal.hasPositional); | 1017 prop.setParameterStyle(proposal.positionalParameterCount, proposal.hasNamed,
proposal.hasPositional); |
| 1016 prop.setReplacementLength(0).setLocation(_completionLocation()); | 1018 prop.setReplacementLength(0).setLocation(_completionLocation()); |
| 1017 prop.setRelevance(CompletionProposal.RELEVANCE_HIGH); | 1019 prop.setRelevance(CompletionProposal.RELEVANCE_HIGH); |
| 1018 _requestor.accept(prop); | 1020 _requestor.accept(prop); |
| 1019 } | 1021 } |
| 1020 | 1022 |
| 1021 void _pDynamic() { | 1023 void _pDynamic() { |
| 1022 _pWord(_C_DYNAMIC, ProposalKind.VARIABLE); | 1024 _pWord(_C_DYNAMIC, CompletionSuggestionKind.VARIABLE); |
| 1023 } | 1025 } |
| 1024 | 1026 |
| 1025 void _pExecutable(Element element, FunctionType functionType, SimpleIdentifier
identifier, bool isPotentialMatch) { | 1027 void _pExecutable(Element element, FunctionType functionType, SimpleIdentifier
identifier, bool isPotentialMatch) { |
| 1026 // Create a completion proposal for the element: function, method, getter, s
etter, constructor. | 1028 // Create a completion proposal for the element: function, method, getter, s
etter, constructor. |
| 1027 String name = element.displayName; | 1029 String name = element.displayName; |
| 1028 if (name.isEmpty) { | 1030 if (name.isEmpty) { |
| 1029 return; | 1031 return; |
| 1030 } | 1032 } |
| 1031 if (_filterDisallows(element)) { | 1033 if (_filterDisallows(element)) { |
| 1032 return; | 1034 return; |
| 1033 } | 1035 } |
| 1034 if (!_isVisible(element)) { | 1036 if (!_isVisible(element)) { |
| 1035 return; | 1037 return; |
| 1036 } | 1038 } |
| 1037 // May be we are in argument of function type parameter, propose function re
ference. | 1039 // May be we are in argument of function type parameter, propose function re
ference. |
| 1038 if (_state._targetParameter != null) { | 1040 if (_state._targetParameter != null) { |
| 1039 DartType parameterType = _state._targetParameter.type; | 1041 DartType parameterType = _state._targetParameter.type; |
| 1040 if (parameterType is FunctionType) { | 1042 if (parameterType is FunctionType) { |
| 1041 if (functionType.isAssignableTo(parameterType)) { | 1043 if (functionType.isAssignableTo(parameterType)) { |
| 1042 _pName2(name, element, CompletionProposal.RELEVANCE_HIGH, ProposalKind
.METHOD_NAME); | 1044 _pName2(name, element, CompletionProposal.RELEVANCE_HIGH, CompletionSu
ggestionKind.METHOD_NAME); |
| 1043 } | 1045 } |
| 1044 } | 1046 } |
| 1045 } | 1047 } |
| 1046 CompletionProposal prop = _createProposal(element); | 1048 CompletionProposal prop = _createProposal(element); |
| 1047 prop.setPotentialMatch(isPotentialMatch); | 1049 prop.setPotentialMatch(isPotentialMatch); |
| 1048 if (isPotentialMatch) { | 1050 if (isPotentialMatch) { |
| 1049 prop.setRelevance(CompletionProposal.RELEVANCE_LOW); | 1051 prop.setRelevance(CompletionProposal.RELEVANCE_LOW); |
| 1050 } | 1052 } |
| 1051 _setParameterInfo(functionType, prop); | 1053 _setParameterInfo(functionType, prop); |
| 1052 prop.setCompletion(name).setReturnType(functionType.returnType.displayName); | 1054 prop.setCompletion(name).setReturnType(functionType.returnType.displayName); |
| 1053 // If there is already argument list, then update only method name. | 1055 // If there is already argument list, then update only method name. |
| 1054 if (identifier.parent is MethodInvocation && (identifier.parent as MethodInv
ocation).argumentList != null) { | 1056 if (identifier.parent is MethodInvocation && (identifier.parent as MethodInv
ocation).argumentList != null) { |
| 1055 prop.setKind(ProposalKind.METHOD_NAME); | 1057 prop.setKind(CompletionSuggestionKind.METHOD_NAME); |
| 1056 } | 1058 } |
| 1057 Element container = element.enclosingElement; | 1059 Element container = element.enclosingElement; |
| 1058 if (container != null) { | 1060 if (container != null) { |
| 1059 prop.setDeclaringType(container.displayName); | 1061 prop.setDeclaringType(container.displayName); |
| 1060 } | 1062 } |
| 1061 _requestor.accept(prop); | 1063 _requestor.accept(prop); |
| 1062 } | 1064 } |
| 1063 | 1065 |
| 1064 void _pExecutable2(ExecutableElement element, SimpleIdentifier identifier, boo
l isPotentialMatch) { | 1066 void _pExecutable2(ExecutableElement element, SimpleIdentifier identifier, boo
l isPotentialMatch) { |
| 1065 _pExecutable(element, element.type, identifier, isPotentialMatch); | 1067 _pExecutable(element, element.type, identifier, isPotentialMatch); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1079 if (container != null) { | 1081 if (container != null) { |
| 1080 prop.setDeclaringType(container.displayName); | 1082 prop.setDeclaringType(container.displayName); |
| 1081 } | 1083 } |
| 1082 if (identifier != null) { | 1084 if (identifier != null) { |
| 1083 prop.setReplacementLengthIdentifier(identifier.length); | 1085 prop.setReplacementLengthIdentifier(identifier.length); |
| 1084 } | 1086 } |
| 1085 _requestor.accept(prop); | 1087 _requestor.accept(prop); |
| 1086 } | 1088 } |
| 1087 | 1089 |
| 1088 void _pFalse() { | 1090 void _pFalse() { |
| 1089 _pWord(_C_FALSE, ProposalKind.VARIABLE); | 1091 _pWord(_C_FALSE, CompletionSuggestionKind.VARIABLE); |
| 1090 } | 1092 } |
| 1091 | 1093 |
| 1092 void _pField(FieldElement element, SimpleIdentifier identifier, ClassElement c
lassElement) { | 1094 void _pField(FieldElement element, SimpleIdentifier identifier, ClassElement c
lassElement) { |
| 1093 // Create a completion proposal for the element: field only. | 1095 // Create a completion proposal for the element: field only. |
| 1094 if (_filterDisallows(element)) { | 1096 if (_filterDisallows(element)) { |
| 1095 return; | 1097 return; |
| 1096 } | 1098 } |
| 1097 CompletionProposal prop = _createProposal(element); | 1099 CompletionProposal prop = _createProposal(element); |
| 1098 Element container = element.enclosingElement; | 1100 Element container = element.enclosingElement; |
| 1099 prop.setDeclaringType(container.displayName); | 1101 prop.setDeclaringType(container.displayName); |
| 1100 _requestor.accept(prop); | 1102 _requestor.accept(prop); |
| 1101 } | 1103 } |
| 1102 | 1104 |
| 1103 /** | 1105 /** |
| 1104 * Proposes URI with the given scheme for the given [NamespaceDirective]. | 1106 * Proposes URI with the given scheme for the given [NamespaceDirective]. |
| 1105 */ | 1107 */ |
| 1106 void _pImportUriWithScheme(NamespaceDirective node, String uriScheme) { | 1108 void _pImportUriWithScheme(NamespaceDirective node, String uriScheme) { |
| 1107 String newUri = "${uriScheme}${new String.fromCharCode(CompletionProposal.CU
RSOR_MARKER)}"; | 1109 String newUri = "${uriScheme}${new String.fromCharCode(CompletionProposal.CU
RSOR_MARKER)}"; |
| 1108 if (node.uri.isSynthetic) { | 1110 if (node.uri.isSynthetic) { |
| 1109 newUri = "'${newUri}'"; | 1111 newUri = "'${newUri}'"; |
| 1110 if (node.semicolon == null || node.semicolon.isSynthetic) { | 1112 if (node.semicolon == null || node.semicolon.isSynthetic) { |
| 1111 newUri += ";"; | 1113 newUri += ";"; |
| 1112 } | 1114 } |
| 1113 } | 1115 } |
| 1114 if (_context.selectionOffset == node.keyword.end) { | 1116 if (_context.selectionOffset == node.keyword.end) { |
| 1115 newUri = " ${newUri}"; | 1117 newUri = " ${newUri}"; |
| 1116 } | 1118 } |
| 1117 _pName3(newUri, ProposalKind.IMPORT); | 1119 _pName3(newUri, CompletionSuggestionKind.IMPORT); |
| 1118 } | 1120 } |
| 1119 | 1121 |
| 1120 void _pKeyword(Token keyword) { | 1122 void _pKeyword(Token keyword) { |
| 1121 _filter = new Filter.con2(keyword.lexeme, keyword.offset, _completionLocatio
n()); | 1123 _filter = new Filter.con2(keyword.lexeme, keyword.offset, _completionLocatio
n()); |
| 1122 // This isn't as useful as it might seem. It only works in the case that com
pletion | 1124 // This isn't as useful as it might seem. It only works in the case that com
pletion |
| 1123 // is requested on an existing recognizable keyword. | 1125 // is requested on an existing recognizable keyword. |
| 1124 // TODO: Add keyword proposal kind | 1126 // TODO: Add keyword proposal kind |
| 1125 CompletionProposal prop = _createProposal4(ProposalKind.LIBRARY_PREFIX); | 1127 CompletionProposal prop = _createProposal4(CompletionSuggestionKind.LIBRARY_
PREFIX); |
| 1126 prop.setCompletion(keyword.lexeme); | 1128 prop.setCompletion(keyword.lexeme); |
| 1127 _requestor.accept(prop); | 1129 _requestor.accept(prop); |
| 1128 } | 1130 } |
| 1129 | 1131 |
| 1130 void _pName(Element element, SimpleIdentifier identifier) { | 1132 void _pName(Element element, SimpleIdentifier identifier) { |
| 1131 CompletionProposal prop = _createProposal2(element, identifier); | 1133 CompletionProposal prop = _createProposal2(element, identifier); |
| 1132 if (prop != null) { | 1134 if (prop != null) { |
| 1133 _requestor.accept(prop); | 1135 _requestor.accept(prop); |
| 1134 } | 1136 } |
| 1135 } | 1137 } |
| 1136 | 1138 |
| 1137 void _pName2(String name, Element element, int relevance, ProposalKind kind) { | 1139 void _pName2(String name, Element element, int relevance, CompletionSuggestion
Kind kind) { |
| 1138 if (_filterDisallows2(name)) { | 1140 if (_filterDisallows2(name)) { |
| 1139 return; | 1141 return; |
| 1140 } | 1142 } |
| 1141 CompletionProposal prop = _createProposal4(kind); | 1143 CompletionProposal prop = _createProposal4(kind); |
| 1142 prop.setRelevance(relevance); | 1144 prop.setRelevance(relevance); |
| 1143 prop.setCompletion(name); | 1145 prop.setCompletion(name); |
| 1144 prop.setElement(element); | 1146 prop.setElement(element); |
| 1145 _requestor.accept(prop); | 1147 _requestor.accept(prop); |
| 1146 } | 1148 } |
| 1147 | 1149 |
| 1148 void _pName3(String name, ProposalKind kind) { | 1150 void _pName3(String name, CompletionSuggestionKind kind) { |
| 1149 if (_filterDisallows2(name)) { | 1151 if (_filterDisallows2(name)) { |
| 1150 return; | 1152 return; |
| 1151 } | 1153 } |
| 1152 CompletionProposal prop = _createProposal4(kind); | 1154 CompletionProposal prop = _createProposal4(kind); |
| 1153 prop.setCompletion(name); | 1155 prop.setCompletion(name); |
| 1154 _requestor.accept(prop); | 1156 _requestor.accept(prop); |
| 1155 } | 1157 } |
| 1156 | 1158 |
| 1157 void _pNamedConstructor(ClassElement classElement, ConstructorElement element,
SimpleIdentifier identifier) { | 1159 void _pNamedConstructor(ClassElement classElement, ConstructorElement element,
SimpleIdentifier identifier) { |
| 1158 // Create a completion proposal for the named constructor. | 1160 // Create a completion proposal for the named constructor. |
| 1159 String name = classElement.displayName; | 1161 String name = classElement.displayName; |
| 1160 if (!element.displayName.isEmpty) { | 1162 if (!element.displayName.isEmpty) { |
| 1161 name += ".${element.displayName}"; | 1163 name += ".${element.displayName}"; |
| 1162 } | 1164 } |
| 1163 if (_filterDisallows2(name)) { | 1165 if (_filterDisallows2(name)) { |
| 1164 return; | 1166 return; |
| 1165 } | 1167 } |
| 1166 CompletionProposal prop = _createProposal3(element, name); | 1168 CompletionProposal prop = _createProposal3(element, name); |
| 1167 _setParameterInfo(element.type, prop); | 1169 _setParameterInfo(element.type, prop); |
| 1168 prop.setReturnType(element.type.returnType.name); | 1170 prop.setReturnType(element.type.returnType.name); |
| 1169 Element container = element.enclosingElement; | 1171 Element container = element.enclosingElement; |
| 1170 prop.setDeclaringType(container.displayName); | 1172 prop.setDeclaringType(container.displayName); |
| 1171 if (identifier != null) { | 1173 if (identifier != null) { |
| 1172 prop.setReplacementLengthIdentifier(identifier.length); | 1174 prop.setReplacementLengthIdentifier(identifier.length); |
| 1173 } | 1175 } |
| 1174 _requestor.accept(prop); | 1176 _requestor.accept(prop); |
| 1175 } | 1177 } |
| 1176 | 1178 |
| 1177 void _pNull() { | 1179 void _pNull() { |
| 1178 _pWord(_C_NULL, ProposalKind.VARIABLE); | 1180 _pWord(_C_NULL, CompletionSuggestionKind.VARIABLE); |
| 1179 } | 1181 } |
| 1180 | 1182 |
| 1181 void _pParamName(String name) { | 1183 void _pParamName(String name) { |
| 1182 if (_filterDisallows2(name)) { | 1184 if (_filterDisallows2(name)) { |
| 1183 return; | 1185 return; |
| 1184 } | 1186 } |
| 1185 CompletionProposal prop = _createProposal4(ProposalKind.PARAMETER); | 1187 CompletionProposal prop = _createProposal4(CompletionSuggestionKind.PARAMETE
R); |
| 1186 prop.setCompletion(name); | 1188 prop.setCompletion(name); |
| 1187 _requestor.accept(prop); | 1189 _requestor.accept(prop); |
| 1188 } | 1190 } |
| 1189 | 1191 |
| 1190 ProposalKind _proposalKindOf(Element element) { | 1192 CompletionSuggestionKind _proposalKindOf(Element element) { |
| 1191 ProposalKind kind; | 1193 CompletionSuggestionKind kind; |
| 1192 while (true) { | 1194 while (true) { |
| 1193 if (element.kind == ElementKind.CONSTRUCTOR) { | 1195 if (element.kind == ElementKind.CONSTRUCTOR) { |
| 1194 kind = ProposalKind.CONSTRUCTOR; | 1196 kind = CompletionSuggestionKind.CONSTRUCTOR; |
| 1195 } else if (element.kind == ElementKind.FUNCTION) { | 1197 } else if (element.kind == ElementKind.FUNCTION) { |
| 1196 kind = ProposalKind.FUNCTION; | 1198 kind = CompletionSuggestionKind.FUNCTION; |
| 1197 } else if (element.kind == ElementKind.METHOD) { | 1199 } else if (element.kind == ElementKind.METHOD) { |
| 1198 kind = ProposalKind.METHOD; | 1200 kind = CompletionSuggestionKind.METHOD; |
| 1199 } else if (element.kind == ElementKind.GETTER) { | 1201 } else if (element.kind == ElementKind.GETTER) { |
| 1200 kind = ProposalKind.GETTER; | 1202 kind = CompletionSuggestionKind.GETTER; |
| 1201 } else if (element.kind == ElementKind.SETTER) { | 1203 } else if (element.kind == ElementKind.SETTER) { |
| 1202 kind = ProposalKind.SETTER; | 1204 kind = CompletionSuggestionKind.SETTER; |
| 1203 } else if (element.kind == ElementKind.CLASS) { | 1205 } else if (element.kind == ElementKind.CLASS) { |
| 1204 kind = ProposalKind.CLASS; | 1206 kind = CompletionSuggestionKind.CLASS; |
| 1205 } else if (element.kind == ElementKind.FIELD) { | 1207 } else if (element.kind == ElementKind.FIELD) { |
| 1206 kind = ProposalKind.FIELD; | 1208 kind = CompletionSuggestionKind.FIELD; |
| 1207 } else if (element.kind == ElementKind.IMPORT) { | 1209 } else if (element.kind == ElementKind.IMPORT) { |
| 1208 kind = ProposalKind.IMPORT; | 1210 kind = CompletionSuggestionKind.IMPORT; |
| 1209 } else if (element.kind == ElementKind.PARAMETER) { | 1211 } else if (element.kind == ElementKind.PARAMETER) { |
| 1210 kind = ProposalKind.PARAMETER; | 1212 kind = CompletionSuggestionKind.PARAMETER; |
| 1211 } else if (element.kind == ElementKind.PREFIX) { | 1213 } else if (element.kind == ElementKind.PREFIX) { |
| 1212 kind = ProposalKind.LIBRARY_PREFIX; | 1214 kind = CompletionSuggestionKind.LIBRARY_PREFIX; |
| 1213 } else if (element.kind == ElementKind.FUNCTION_TYPE_ALIAS) { | 1215 } else if (element.kind == ElementKind.FUNCTION_TYPE_ALIAS) { |
| 1214 kind = ProposalKind.CLASS_ALIAS; | 1216 kind = CompletionSuggestionKind.CLASS_ALIAS; |
| 1215 } else if (element.kind == ElementKind.TYPE_PARAMETER) { | 1217 } else if (element.kind == ElementKind.TYPE_PARAMETER) { |
| 1216 kind = ProposalKind.TYPE_PARAMETER; | 1218 kind = CompletionSuggestionKind.TYPE_PARAMETER; |
| 1217 } else if (element.kind == ElementKind.LOCAL_VARIABLE || element.kind == E
lementKind.TOP_LEVEL_VARIABLE) { | 1219 } else if (element.kind == ElementKind.LOCAL_VARIABLE || element.kind == E
lementKind.TOP_LEVEL_VARIABLE) { |
| 1218 kind = ProposalKind.VARIABLE; | 1220 kind = CompletionSuggestionKind.VARIABLE; |
| 1219 } else { | 1221 } else { |
| 1220 throw new IllegalArgumentException(); | 1222 throw new IllegalArgumentException(); |
| 1221 } | 1223 } |
| 1222 break; | 1224 break; |
| 1223 } | 1225 } |
| 1224 return kind; | 1226 return kind; |
| 1225 } | 1227 } |
| 1226 | 1228 |
| 1227 void _proposeCombinator(Combinator node, SimpleIdentifier identifier) { | 1229 void _proposeCombinator(Combinator node, SimpleIdentifier identifier) { |
| 1228 _filter = _createFilter(identifier); | 1230 _filter = _createFilter(identifier); |
| 1229 NamespaceDirective directive = node.parent as NamespaceDirective; | 1231 NamespaceDirective directive = node.parent as NamespaceDirective; |
| 1230 LibraryElement libraryElement = directive.uriElement; | 1232 LibraryElement libraryElement = directive.uriElement; |
| 1231 if (libraryElement != null) { | 1233 if (libraryElement != null) { |
| 1232 // prepare Elements with unique names | 1234 // prepare Elements with unique names |
| 1233 CompletionEngine_NameCollector nameCollector = _createNameCollector(); | 1235 CompletionEngine_NameCollector nameCollector = _createNameCollector(); |
| 1234 Iterable<Element> elements = CorrectionUtils.getExportNamespace2(libraryEl
ement).values; | 1236 Iterable<Element> elements = CorrectionUtils.getExportNamespace2(libraryEl
ement).values; |
| 1235 for (Element element in elements) { | 1237 for (Element element in elements) { |
| 1236 if (_filterDisallows(element)) { | 1238 if (_filterDisallows(element)) { |
| 1237 continue; | 1239 continue; |
| 1238 } | 1240 } |
| 1239 nameCollector._mergeName(element); | 1241 nameCollector._mergeName(element); |
| 1240 } | 1242 } |
| 1241 // propose each Element | 1243 // propose each Element |
| 1242 for (Element element in nameCollector.uniqueElements) { | 1244 for (Element element in nameCollector.uniqueElements) { |
| 1243 CompletionProposal proposal = _createProposal(element); | 1245 CompletionProposal proposal = _createProposal(element); |
| 1244 if (proposal.kind == ProposalKind.FUNCTION) { | 1246 if (proposal.kind == CompletionSuggestionKind.FUNCTION) { |
| 1245 proposal.setKind(ProposalKind.METHOD_NAME); | 1247 proposal.setKind(CompletionSuggestionKind.METHOD_NAME); |
| 1246 } | 1248 } |
| 1247 _requestor.accept(proposal); | 1249 _requestor.accept(proposal); |
| 1248 } | 1250 } |
| 1249 } | 1251 } |
| 1250 } | 1252 } |
| 1251 | 1253 |
| 1252 void _proposeName(Element element, SimpleIdentifier identifier, CompletionEngi
ne_NameCollector names) { | 1254 void _proposeName(Element element, SimpleIdentifier identifier, CompletionEngi
ne_NameCollector names) { |
| 1253 while (true) { | 1255 while (true) { |
| 1254 if (element.kind == ElementKind.FUNCTION || element.kind == ElementKind.GE
TTER || element.kind == ElementKind.METHOD || element.kind == ElementKind.SETTER
) { | 1256 if (element.kind == ElementKind.FUNCTION || element.kind == ElementKind.GE
TTER || element.kind == ElementKind.METHOD || element.kind == ElementKind.SETTER
) { |
| 1255 ExecutableElement candidate = element as ExecutableElement; | 1257 ExecutableElement candidate = element as ExecutableElement; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1270 } | 1272 } |
| 1271 } | 1273 } |
| 1272 | 1274 |
| 1273 void _proposeNames(CompletionEngine_NameCollector names, SimpleIdentifier iden
tifier) { | 1275 void _proposeNames(CompletionEngine_NameCollector names, SimpleIdentifier iden
tifier) { |
| 1274 for (Element element in names.uniqueElements) { | 1276 for (Element element in names.uniqueElements) { |
| 1275 _proposeName(element, identifier, names); | 1277 _proposeName(element, identifier, names); |
| 1276 } | 1278 } |
| 1277 } | 1279 } |
| 1278 | 1280 |
| 1279 void _pTrue() { | 1281 void _pTrue() { |
| 1280 _pWord(_C_TRUE, ProposalKind.VARIABLE); | 1282 _pWord(_C_TRUE, CompletionSuggestionKind.VARIABLE); |
| 1281 } | 1283 } |
| 1282 | 1284 |
| 1283 void _pVar() { | 1285 void _pVar() { |
| 1284 _pWord(_C_VAR, ProposalKind.VARIABLE); | 1286 _pWord(_C_VAR, CompletionSuggestionKind.VARIABLE); |
| 1285 } | 1287 } |
| 1286 | 1288 |
| 1287 void _pVoid() { | 1289 void _pVoid() { |
| 1288 _pWord(_C_VOID, ProposalKind.VARIABLE); | 1290 _pWord(_C_VOID, CompletionSuggestionKind.VARIABLE); |
| 1289 } | 1291 } |
| 1290 | 1292 |
| 1291 void _pWord(String word, ProposalKind kind) { | 1293 void _pWord(String word, CompletionSuggestionKind kind) { |
| 1292 if (_filterDisallows2(word)) { | 1294 if (_filterDisallows2(word)) { |
| 1293 return; | 1295 return; |
| 1294 } | 1296 } |
| 1295 CompletionProposal prop = _createProposal4(kind); | 1297 CompletionProposal prop = _createProposal4(kind); |
| 1296 prop.setCompletion(word); | 1298 prop.setCompletion(word); |
| 1297 _requestor.accept(prop); | 1299 _requestor.accept(prop); |
| 1298 } | 1300 } |
| 1299 | 1301 |
| 1300 void _removeNotMatchingFilter(List<Element> elements) { | 1302 void _removeNotMatchingFilter(List<Element> elements) { |
| 1301 if (_filter == null) { | 1303 if (_filter == null) { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 | 1468 |
| 1467 @override | 1469 @override |
| 1468 Object visitComment(Comment node) { | 1470 Object visitComment(Comment node) { |
| 1469 node.parent.accept(this); | 1471 node.parent.accept(this); |
| 1470 // propose names | 1472 // propose names |
| 1471 for (Element element in _names.uniqueElements) { | 1473 for (Element element in _names.uniqueElements) { |
| 1472 CompletionProposal proposal = CompletionEngine_this._createProposal2(eleme
nt, _identifier); | 1474 CompletionProposal proposal = CompletionEngine_this._createProposal2(eleme
nt, _identifier); |
| 1473 if (proposal != null) { | 1475 if (proposal != null) { |
| 1474 // we don't want to add arguments, just names | 1476 // we don't want to add arguments, just names |
| 1475 if (element is MethodElement || element is FunctionElement) { | 1477 if (element is MethodElement || element is FunctionElement) { |
| 1476 proposal.setKind(ProposalKind.METHOD_NAME); | 1478 proposal.setKind(CompletionSuggestionKind.METHOD_NAME); |
| 1477 } | 1479 } |
| 1478 // elevate priority for local elements | 1480 // elevate priority for local elements |
| 1479 if (_enclosingElements.contains(element.enclosingElement)) { | 1481 if (_enclosingElements.contains(element.enclosingElement)) { |
| 1480 proposal.setRelevance(CompletionProposal.RELEVANCE_HIGH); | 1482 proposal.setRelevance(CompletionProposal.RELEVANCE_HIGH); |
| 1481 } | 1483 } |
| 1482 // propose | 1484 // propose |
| 1483 CompletionEngine_this._requestor.accept(proposal); | 1485 CompletionEngine_this._requestor.accept(proposal); |
| 1484 } | 1486 } |
| 1485 } | 1487 } |
| 1486 // done | 1488 // done |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1583 Object visitCommentReference(CommentReference node) { | 1585 Object visitCommentReference(CommentReference node) { |
| 1584 AstNode comment = node.parent; | 1586 AstNode comment = node.parent; |
| 1585 CompletionEngine_CommentReferenceCompleter visitor = new CompletionEngine_Co
mmentReferenceCompleter(CompletionEngine_this, _completionNode); | 1587 CompletionEngine_CommentReferenceCompleter visitor = new CompletionEngine_Co
mmentReferenceCompleter(CompletionEngine_this, _completionNode); |
| 1586 return comment.accept(visitor); | 1588 return comment.accept(visitor); |
| 1587 } | 1589 } |
| 1588 | 1590 |
| 1589 @override | 1591 @override |
| 1590 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 1592 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 1591 if (identical(node.returnType, _completionNode)) { | 1593 if (identical(node.returnType, _completionNode)) { |
| 1592 CompletionEngine_this._filter = CompletionEngine_this._createFilter(_compl
etionNode); | 1594 CompletionEngine_this._filter = CompletionEngine_this._createFilter(_compl
etionNode); |
| 1593 CompletionEngine_this._pName3(_completionNode.name, ProposalKind.CONSTRUCT
OR); | 1595 CompletionEngine_this._pName3(_completionNode.name, CompletionSuggestionKi
nd.CONSTRUCTOR); |
| 1594 } | 1596 } |
| 1595 return null; | 1597 return null; |
| 1596 } | 1598 } |
| 1597 | 1599 |
| 1598 @override | 1600 @override |
| 1599 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { | 1601 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
| 1600 // { A() : this.!x = 1; } | 1602 // { A() : this.!x = 1; } |
| 1601 if (identical(node.fieldName, _completionNode)) { | 1603 if (identical(node.fieldName, _completionNode)) { |
| 1602 ClassElement classElement = (node.parent as ConstructorDeclaration).elemen
t.enclosingElement; | 1604 ClassElement classElement = (node.parent as ConstructorDeclaration).elemen
t.enclosingElement; |
| 1603 CompletionEngine_this._fieldReference(classElement, node.fieldName); | 1605 CompletionEngine_this._fieldReference(classElement, node.fieldName); |
| (...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2842 } | 2844 } |
| 2843 } | 2845 } |
| 2844 | 2846 |
| 2845 /** | 2847 /** |
| 2846 * The factory class used to create completion proposals. | 2848 * The factory class used to create completion proposals. |
| 2847 */ | 2849 */ |
| 2848 class CompletionFactory { | 2850 class CompletionFactory { |
| 2849 /** | 2851 /** |
| 2850 * Create a completion proposal of the given kind. | 2852 * Create a completion proposal of the given kind. |
| 2851 */ | 2853 */ |
| 2852 CompletionProposal createCompletionProposal(ProposalKind kind, int insertionPo
int) { | 2854 CompletionProposal createCompletionProposal(CompletionSuggestionKind kind, int
insertionPoint) { |
| 2853 CompletionProposalImpl prop = new CompletionProposalImpl(); | 2855 CompletionProposalImpl prop = new CompletionProposalImpl(); |
| 2854 prop.setKind(kind); | 2856 prop.setKind(kind); |
| 2855 prop.setLocation(insertionPoint); | 2857 prop.setLocation(insertionPoint); |
| 2856 return prop; | 2858 return prop; |
| 2857 } | 2859 } |
| 2858 } | 2860 } |
| 2859 | 2861 |
| 2860 abstract class CompletionProposal { | 2862 abstract class CompletionProposal { |
| 2861 static final int RELEVANCE_LOW = 0; | 2863 static final int RELEVANCE_LOW = 0; |
| 2862 | 2864 |
| 2863 static final int RELEVANCE_DEFAULT = 10; | 2865 static final int RELEVANCE_DEFAULT = 10; |
| 2864 | 2866 |
| 2865 static final int RELEVANCE_HIGH = 20; | 2867 static final int RELEVANCE_HIGH = 20; |
| 2866 | 2868 |
| 2867 /** | 2869 /** |
| 2868 * This character is used to specify location of the cursor after completion. | 2870 * This character is used to specify location of the cursor after completion. |
| 2869 */ | 2871 */ |
| 2870 static final int CURSOR_MARKER = 0x2758; | 2872 static final int CURSOR_MARKER = 0x2758; |
| 2871 | 2873 |
| 2872 void applyPartitionOffset(int partitionOffset); | 2874 void applyPartitionOffset(int partitionOffset); |
| 2873 | 2875 |
| 2874 String get completion; | 2876 String get completion; |
| 2875 | 2877 |
| 2876 String get declaringType; | 2878 String get declaringType; |
| 2877 | 2879 |
| 2878 Element get element; | 2880 Element get element; |
| 2879 | 2881 |
| 2880 ProposalKind get kind; | 2882 CompletionSuggestionKind get kind; |
| 2881 | 2883 |
| 2882 int get location; | 2884 int get location; |
| 2883 | 2885 |
| 2884 String get parameterName; | 2886 String get parameterName; |
| 2885 | 2887 |
| 2886 List<String> get parameterNames; | 2888 List<String> get parameterNames; |
| 2887 | 2889 |
| 2888 String get parameterType; | 2890 String get parameterType; |
| 2889 | 2891 |
| 2890 List<String> get parameterTypes; | 2892 List<String> get parameterTypes; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2910 bool get isPotentialMatch; | 2912 bool get isPotentialMatch; |
| 2911 | 2913 |
| 2912 CompletionProposal setCompletion(String x); | 2914 CompletionProposal setCompletion(String x); |
| 2913 | 2915 |
| 2914 CompletionProposal setDeclaringType(String name); | 2916 CompletionProposal setDeclaringType(String name); |
| 2915 | 2917 |
| 2916 CompletionProposal setDeprecated(bool deprecated); | 2918 CompletionProposal setDeprecated(bool deprecated); |
| 2917 | 2919 |
| 2918 CompletionProposal setElement(Element element); | 2920 CompletionProposal setElement(Element element); |
| 2919 | 2921 |
| 2920 CompletionProposal setKind(ProposalKind x); | 2922 CompletionProposal setKind(CompletionSuggestionKind x); |
| 2921 | 2923 |
| 2922 CompletionProposal setLocation(int x); | 2924 CompletionProposal setLocation(int x); |
| 2923 | 2925 |
| 2924 CompletionProposal setParameterName(String paramName); | 2926 CompletionProposal setParameterName(String paramName); |
| 2925 | 2927 |
| 2926 CompletionProposal setParameterNames(List<String> paramNames); | 2928 CompletionProposal setParameterNames(List<String> paramNames); |
| 2927 | 2929 |
| 2928 CompletionProposal setParameterStyle(int count, bool named, bool positional); | 2930 CompletionProposal setParameterStyle(int count, bool named, bool positional); |
| 2929 | 2931 |
| 2930 CompletionProposal setParameterType(String paramType); | 2932 CompletionProposal setParameterType(String paramType); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2952 String _declaringType = ""; | 2954 String _declaringType = ""; |
| 2953 | 2955 |
| 2954 List<String> _parameterNames = StringUtilities.EMPTY_ARRAY; | 2956 List<String> _parameterNames = StringUtilities.EMPTY_ARRAY; |
| 2955 | 2957 |
| 2956 List<String> _parameterTypes = StringUtilities.EMPTY_ARRAY; | 2958 List<String> _parameterTypes = StringUtilities.EMPTY_ARRAY; |
| 2957 | 2959 |
| 2958 String _parameterName; | 2960 String _parameterName; |
| 2959 | 2961 |
| 2960 String _parameterType; | 2962 String _parameterType; |
| 2961 | 2963 |
| 2962 ProposalKind _kind = ProposalKind.NONE; | 2964 CompletionSuggestionKind _kind = null; |
| 2963 | 2965 |
| 2964 int _location = 0; | 2966 int _location = 0; |
| 2965 | 2967 |
| 2966 int _replacementLength = 0; | 2968 int _replacementLength = 0; |
| 2967 | 2969 |
| 2968 int _replacementLength2 = 0; | 2970 int _replacementLength2 = 0; |
| 2969 | 2971 |
| 2970 int _positionalParameterCount = 0; | 2972 int _positionalParameterCount = 0; |
| 2971 | 2973 |
| 2972 bool _named = false; | 2974 bool _named = false; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2987 @override | 2989 @override |
| 2988 String get completion => _completion; | 2990 String get completion => _completion; |
| 2989 | 2991 |
| 2990 @override | 2992 @override |
| 2991 String get declaringType => _declaringType; | 2993 String get declaringType => _declaringType; |
| 2992 | 2994 |
| 2993 @override | 2995 @override |
| 2994 Element get element => _element; | 2996 Element get element => _element; |
| 2995 | 2997 |
| 2996 @override | 2998 @override |
| 2997 ProposalKind get kind => _kind; | 2999 CompletionSuggestionKind get kind => _kind; |
| 2998 | 3000 |
| 2999 @override | 3001 @override |
| 3000 int get location => _location; | 3002 int get location => _location; |
| 3001 | 3003 |
| 3002 @override | 3004 @override |
| 3003 String get parameterName => _parameterName; | 3005 String get parameterName => _parameterName; |
| 3004 | 3006 |
| 3005 @override | 3007 @override |
| 3006 List<String> get parameterNames => _parameterNames; | 3008 List<String> get parameterNames => _parameterNames; |
| 3007 | 3009 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3065 return this; | 3067 return this; |
| 3066 } | 3068 } |
| 3067 | 3069 |
| 3068 @override | 3070 @override |
| 3069 CompletionProposal setElement(Element element) { | 3071 CompletionProposal setElement(Element element) { |
| 3070 this._element = element; | 3072 this._element = element; |
| 3071 return this; | 3073 return this; |
| 3072 } | 3074 } |
| 3073 | 3075 |
| 3074 @override | 3076 @override |
| 3075 CompletionProposal setKind(ProposalKind x) { | 3077 CompletionProposal setKind(CompletionSuggestionKind x) { |
| 3076 _kind = x; | 3078 _kind = x; |
| 3077 return this; | 3079 return this; |
| 3078 } | 3080 } |
| 3079 | 3081 |
| 3080 @override | 3082 @override |
| 3081 CompletionProposal setLocation(int x) { | 3083 CompletionProposal setLocation(int x) { |
| 3082 _location = x; | 3084 _location = x; |
| 3083 return this; | 3085 return this; |
| 3084 } | 3086 } |
| 3085 | 3087 |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3660 } | 3662 } |
| 3661 | 3663 |
| 3662 @override | 3664 @override |
| 3663 void endReporting() { | 3665 void endReporting() { |
| 3664 requestor.endReporting(); | 3666 requestor.endReporting(); |
| 3665 } | 3667 } |
| 3666 | 3668 |
| 3667 List<CompletionProposal> get proposals => _proposals; | 3669 List<CompletionProposal> get proposals => _proposals; |
| 3668 } | 3670 } |
| 3669 | 3671 |
| 3670 /** | |
| 3671 * The various kinds of completion proposals. Each specifies the kind of complet
ion to be created, | |
| 3672 * corresponding to different syntactical elements. | |
| 3673 */ | |
| 3674 class ProposalKind extends Enum<ProposalKind> { | |
| 3675 static const ProposalKind NONE = const ProposalKind('NONE', 0); | |
| 3676 | |
| 3677 static const ProposalKind CLASS = const ProposalKind('CLASS', 1); | |
| 3678 | |
| 3679 static const ProposalKind CLASS_ALIAS = const ProposalKind('CLASS_ALIAS', 2); | |
| 3680 | |
| 3681 static const ProposalKind CONSTRUCTOR = const ProposalKind('CONSTRUCTOR', 3); | |
| 3682 | |
| 3683 static const ProposalKind FIELD = const ProposalKind('FIELD', 4); | |
| 3684 | |
| 3685 static const ProposalKind FUNCTION = const ProposalKind('FUNCTION', 5); | |
| 3686 | |
| 3687 static const ProposalKind FUNCTION_ALIAS = const ProposalKind('FUNCTION_ALIAS'
, 6); | |
| 3688 | |
| 3689 static const ProposalKind GETTER = const ProposalKind('GETTER', 7); | |
| 3690 | |
| 3691 static const ProposalKind IMPORT = const ProposalKind('IMPORT', 8); | |
| 3692 | |
| 3693 static const ProposalKind LIBRARY_PREFIX = const ProposalKind('LIBRARY_PREFIX'
, 9); | |
| 3694 | |
| 3695 static const ProposalKind METHOD = const ProposalKind('METHOD', 10); | |
| 3696 | |
| 3697 static const ProposalKind METHOD_NAME = const ProposalKind('METHOD_NAME', 11); | |
| 3698 | |
| 3699 static const ProposalKind PARAMETER = const ProposalKind('PARAMETER', 12); | |
| 3700 | |
| 3701 static const ProposalKind SETTER = const ProposalKind('SETTER', 13); | |
| 3702 | |
| 3703 static const ProposalKind VARIABLE = const ProposalKind('VARIABLE', 14); | |
| 3704 | |
| 3705 static const ProposalKind TYPE_PARAMETER = const ProposalKind('TYPE_PARAMETER'
, 15); | |
| 3706 | |
| 3707 static const ProposalKind ARGUMENT_LIST = const ProposalKind('ARGUMENT_LIST',
16); | |
| 3708 | |
| 3709 static const ProposalKind OPTIONAL_ARGUMENT = const ProposalKind('OPTIONAL_ARG
UMENT', 17); | |
| 3710 | |
| 3711 static const ProposalKind NAMED_ARGUMENT = const ProposalKind('NAMED_ARGUMENT'
, 18); | |
| 3712 | |
| 3713 static const List<ProposalKind> values = const [ | |
| 3714 NONE, | |
| 3715 CLASS, | |
| 3716 CLASS_ALIAS, | |
| 3717 CONSTRUCTOR, | |
| 3718 FIELD, | |
| 3719 FUNCTION, | |
| 3720 FUNCTION_ALIAS, | |
| 3721 GETTER, | |
| 3722 IMPORT, | |
| 3723 LIBRARY_PREFIX, | |
| 3724 METHOD, | |
| 3725 METHOD_NAME, | |
| 3726 PARAMETER, | |
| 3727 SETTER, | |
| 3728 VARIABLE, | |
| 3729 TYPE_PARAMETER, | |
| 3730 ARGUMENT_LIST, | |
| 3731 OPTIONAL_ARGUMENT, | |
| 3732 NAMED_ARGUMENT]; | |
| 3733 | |
| 3734 const ProposalKind(String name, int ordinal) : super(name, ordinal); | |
| 3735 } | |
| 3736 | |
| 3737 class SearchFilter_CompletionEngine_allSubtypes implements SearchFilter { | 3672 class SearchFilter_CompletionEngine_allSubtypes implements SearchFilter { |
| 3738 ClassElement classElement; | 3673 ClassElement classElement; |
| 3739 | 3674 |
| 3740 SearchFilter_CompletionEngine_allSubtypes(this.classElement); | 3675 SearchFilter_CompletionEngine_allSubtypes(this.classElement); |
| 3741 | 3676 |
| 3742 @override | 3677 @override |
| 3743 bool passes(SearchMatch match) { | 3678 bool passes(SearchMatch match) { |
| 3744 Element element = match.element; | 3679 Element element = match.element; |
| 3745 if (element is ClassElement) { | 3680 if (element is ClassElement) { |
| 3746 ClassElement clElem = element; | 3681 ClassElement clElem = element; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3761 | 3696 |
| 3762 class TopLevelNamesKind extends Enum<TopLevelNamesKind> { | 3697 class TopLevelNamesKind extends Enum<TopLevelNamesKind> { |
| 3763 static const TopLevelNamesKind DECLARED_AND_IMPORTS = const TopLevelNamesKind(
'DECLARED_AND_IMPORTS', 0); | 3698 static const TopLevelNamesKind DECLARED_AND_IMPORTS = const TopLevelNamesKind(
'DECLARED_AND_IMPORTS', 0); |
| 3764 | 3699 |
| 3765 static const TopLevelNamesKind DECLARED_AND_EXPORTS = const TopLevelNamesKind(
'DECLARED_AND_EXPORTS', 1); | 3700 static const TopLevelNamesKind DECLARED_AND_EXPORTS = const TopLevelNamesKind(
'DECLARED_AND_EXPORTS', 1); |
| 3766 | 3701 |
| 3767 static const List<TopLevelNamesKind> values = const [DECLARED_AND_IMPORTS, DEC
LARED_AND_EXPORTS]; | 3702 static const List<TopLevelNamesKind> values = const [DECLARED_AND_IMPORTS, DEC
LARED_AND_EXPORTS]; |
| 3768 | 3703 |
| 3769 const TopLevelNamesKind(String name, int ordinal) : super(name, ordinal); | 3704 const TopLevelNamesKind(String name, int ordinal) : super(name, ordinal); |
| 3770 } | 3705 } |
| OLD | NEW |