1 11 package org.eclipse.jdt.internal.codeassist.complete; 12 13 import org.eclipse.jdt.internal.compiler.ast.MessageSend; 14 import org.eclipse.jdt.internal.compiler.ast.NameReference; 15 import org.eclipse.jdt.internal.compiler.lookup.BlockScope; 16 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; 17 18 public class CompletionOnMessageSendName extends MessageSend { 19 public CompletionOnMessageSendName(char[] selector, int start, int end) { 20 super(); 21 this.selector = selector; 22 this.sourceStart = start; 23 this.sourceEnd = end; 24 this.nameSourcePosition = end; 25 } 26 27 public TypeBinding resolveType(BlockScope scope) { 28 29 if (receiver.isImplicitThis()) 30 throw new CompletionNodeFound(); 31 32 this.actualReceiverType = receiver.resolveType(scope); 33 if (this.actualReceiverType == null || this.actualReceiverType.isBaseType() || this.actualReceiverType.isArrayType()) 34 throw new CompletionNodeFound(); 35 36 if (this.typeArguments != null) { 38 int length = this.typeArguments.length; 39 this.genericTypeArguments = new TypeBinding[length]; 40 for (int i = 0; i < length; i++) { 41 this.genericTypeArguments[i] = this.typeArguments[i].resolveType(scope, true ); 42 } 43 } 44 45 if(this.receiver instanceof NameReference) { 46 throw new CompletionNodeFound(this, ((NameReference)this.receiver).binding, scope); 47 } else if(this.receiver instanceof MessageSend) { 48 throw new CompletionNodeFound(this, ((MessageSend)this.receiver).binding, scope); 49 } 50 throw new CompletionNodeFound(this, this.actualReceiverType, scope); 51 } 52 53 public StringBuffer printExpression(int indent, StringBuffer output) { 54 55 output.append("<CompleteOnMessageSendName:"); if (!receiver.isImplicitThis()) receiver.printExpression(0, output).append('.'); 57 if (this.typeArguments != null) { 58 output.append('<'); 59 int max = typeArguments.length - 1; 60 for (int j = 0; j < max; j++) { 61 typeArguments[j].print(0, output); 62 output.append(", "); } 64 typeArguments[max].print(0, output); 65 output.append('>'); 66 } 67 output.append(selector).append('('); 68 return output.append(")>"); } 70 } 71 | Popular Tags |