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

Side by Side Diff: editor/tools/plugins/com.google.dart.engine.services/src/com/google/dart/engine/services/completion/CompletionEngine.java

Issue 83793016: Issue 13549. Tweaks for arguments list completion. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, the Dart project authors. 2 * Copyright (c) 2013, the Dart project authors.
3 * 3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at 5 * in compliance with the License. You may obtain a copy of the License at
6 * 6 *
7 * http://www.eclipse.org/legal/epl-v10.html 7 * http://www.eclipse.org/legal/epl-v10.html
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
11 * or implied. See the License for the specific language governing permissions a nd limitations under 11 * or implied. See the License for the specific language governing permissions a nd limitations under
12 * the License. 12 * the License.
13 */ 13 */
14 package com.google.dart.engine.services.completion; 14 package com.google.dart.engine.services.completion;
15 15
16 import com.google.common.base.Objects;
16 import com.google.common.collect.Lists; 17 import com.google.common.collect.Lists;
17 import com.google.common.collect.Sets; 18 import com.google.common.collect.Sets;
18 import com.google.dart.engine.ast.ASTNode; 19 import com.google.dart.engine.ast.ASTNode;
19 import com.google.dart.engine.ast.Annotation; 20 import com.google.dart.engine.ast.Annotation;
20 import com.google.dart.engine.ast.ArgumentList; 21 import com.google.dart.engine.ast.ArgumentList;
21 import com.google.dart.engine.ast.AsExpression; 22 import com.google.dart.engine.ast.AsExpression;
22 import com.google.dart.engine.ast.AssertStatement; 23 import com.google.dart.engine.ast.AssertStatement;
23 import com.google.dart.engine.ast.AssignmentExpression; 24 import com.google.dart.engine.ast.AssignmentExpression;
24 import com.google.dart.engine.ast.BinaryExpression; 25 import com.google.dart.engine.ast.BinaryExpression;
25 import com.google.dart.engine.ast.Block; 26 import com.google.dart.engine.ast.Block;
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 ProposalCollector proposalRequestor = new ProposalCollector(requestor) ; 817 ProposalCollector proposalRequestor = new ProposalCollector(requestor) ;
817 try { 818 try {
818 requestor = proposalRequestor; 819 requestor = proposalRequestor;
819 dispatchPrefixAnalysis(invokeNode); 820 dispatchPrefixAnalysis(invokeNode);
820 } finally { 821 } finally {
821 requestor = proposalRequestor.getRequestor(); 822 requestor = proposalRequestor.getRequestor();
822 } 823 }
823 int offset = methodName.getOffset(); 824 int offset = methodName.getOffset();
824 int len = node.getRightParenthesis().getEnd() - offset; 825 int len = node.getRightParenthesis().getEnd() - offset;
825 for (CompletionProposal proposal : proposalRequestor.getProposals()) { 826 for (CompletionProposal proposal : proposalRequestor.getProposals()) {
826 pArgumentList(proposal, offset, len); 827 if (Objects.equal(proposal.getElement(), invokeNode.getStaticElement ())) {
828 pArgumentList(proposal, offset, len);
829 }
827 } 830 }
828 } 831 }
829 analyzeLocalName(new Ident(node)); 832 analyzeLocalName(new Ident(node));
830 } 833 }
831 return null; 834 return null;
832 } 835 }
833 836
834 @Override 837 @Override
835 public Void visitAsExpression(AsExpression node) { 838 public Void visitAsExpression(AsExpression node) {
836 if (isCompletionAfter(node.getAsOperator().getEnd())) { 839 if (isCompletionAfter(node.getAsOperator().getEnd())) {
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 if (name.equals(conflict)) { 2368 if (name.equals(conflict)) {
2366 count += 1; 2369 count += 1;
2367 continue loop; 2370 continue loop;
2368 } 2371 }
2369 } 2372 }
2370 return name; 2373 return name;
2371 } 2374 }
2372 } 2375 }
2373 2376
2374 private void pArgumentList(CompletionProposal proposal, int offset, int len) { 2377 private void pArgumentList(CompletionProposal proposal, int offset, int len) {
2378 // prepare parameters
2379 String[] parameterNames = proposal.getParameterNames();
2380 if (parameterNames.length == 0) {
2381 return;
2382 }
2383 // fill arguments proposal
2375 CompletionProposal prop = createProposal(ProposalKind.ARGUMENT_LIST); 2384 CompletionProposal prop = createProposal(ProposalKind.ARGUMENT_LIST);
2385 prop.setElement(proposal.getElement());
2376 prop.setCompletion(proposal.getCompletion()).setReturnType(proposal.getRetur nType()); 2386 prop.setCompletion(proposal.getCompletion()).setReturnType(proposal.getRetur nType());
2377 prop.setParameterNames(proposal.getParameterNames()); 2387 prop.setParameterNames(parameterNames);
2378 prop.setParameterTypes(proposal.getParameterTypes()); 2388 prop.setParameterTypes(proposal.getParameterTypes());
2379 prop.setParameterStyle( 2389 prop.setParameterStyle(
2380 proposal.getPositionalParameterCount(), 2390 proposal.getPositionalParameterCount(),
2381 proposal.hasNamed(), 2391 proposal.hasNamed(),
2382 proposal.hasPositional()); 2392 proposal.hasPositional());
2383 prop.setReplacementLength(0).setLocation(completionLocation()); 2393 prop.setReplacementLength(0).setLocation(completionLocation());
2384 prop.setRelevance(10); 2394 prop.setRelevance(10);
2385 requestor.accept(prop); 2395 requestor.accept(prop);
2386 } 2396 }
2387 2397
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
2844 return null; 2854 return null;
2845 } 2855 }
2846 Iterator<Type> iter = matches.iterator(); 2856 Iterator<Type> iter = matches.iterator();
2847 Type result = iter.next(); 2857 Type result = iter.next();
2848 while (iter.hasNext()) { 2858 while (iter.hasNext()) {
2849 result = result.getLeastUpperBound(iter.next()); 2859 result = result.getLeastUpperBound(iter.next());
2850 } 2860 }
2851 return result; 2861 return result;
2852 } 2862 }
2853 } 2863 }
OLDNEW
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine.services_test/src/com/google/dart/engine/services/completion/CompletionTests.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698