use of org.eclipse.jdt.internal.codeassist.complete.CompletionOnSingleNameReference in project lombok by rzwitserloot.
the class ExtensionMethodCompletionProposal method setMethodBinding.
public void setMethodBinding(final MethodBinding method, final ASTNode node) {
MethodBinding original = method.original();
TypeBinding[] parameters = Arrays.copyOf(method.parameters, method.parameters.length);
method.parameters = Arrays.copyOfRange(method.parameters, 1, method.parameters.length);
TypeBinding[] originalParameters = null;
if (original != method) {
originalParameters = Arrays.copyOf(method.original().parameters, method.original().parameters.length);
method.original().parameters = Arrays.copyOfRange(method.original().parameters, 1, method.original().parameters.length);
}
int length = method.parameters == null ? 0 : method.parameters.length;
char[][] parameterPackageNames = new char[length][];
char[][] parameterTypeNames = new char[length][];
for (int i = 0; i < length; i++) {
TypeBinding type = method.original().parameters[i];
parameterPackageNames[i] = type.qualifiedPackageName();
parameterTypeNames[i] = type.qualifiedSourceName();
}
char[] completion = CharOperation.concat(method.selector, new char[] { '(', ')' });
setDeclarationSignature(CompletionEngine.getSignature(method.declaringClass));
setSignature(CompletionEngine.getSignature(method));
if (original != method) {
setOriginalSignature(CompletionEngine.getSignature(original));
}
setDeclarationPackageName(method.declaringClass.qualifiedPackageName());
setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
setParameterPackageNames(parameterPackageNames);
setParameterTypeNames(parameterTypeNames);
setPackageName(method.returnType.qualifiedPackageName());
setTypeName(method.returnType.qualifiedSourceName());
setName(method.selector);
setCompletion(completion);
setFlags(method.modifiers & (~AccStatic));
int index = node.sourceEnd + 1;
if (node instanceof CompletionOnQualifiedNameReference) {
index -= ((CompletionOnQualifiedNameReference) node).completionIdentifier.length;
}
if (node instanceof CompletionOnMemberAccess) {
index -= ((CompletionOnMemberAccess) node).token.length;
}
if (node instanceof CompletionOnSingleNameReference) {
index -= ((CompletionOnSingleNameReference) node).token.length;
}
setReplaceRange(index, index);
setTokenRange(index, index);
setRelevance(100);
method.parameters = parameters;
if (original != method) {
method.original().parameters = originalParameters;
}
}
use of org.eclipse.jdt.internal.codeassist.complete.CompletionOnSingleNameReference in project lombok by rzwitserloot.
the class PatchExtensionMethodCompletionProposal method getFirstParameterType.
static TypeBinding getFirstParameterType(TypeDeclaration decl, CompletionProposalCollector completionProposalCollector) {
TypeBinding firstParameterType = null;
ASTNode node = getAssistNode(completionProposalCollector);
if (node == null)
return null;
if (!(node instanceof CompletionOnQualifiedNameReference) && !(node instanceof CompletionOnSingleNameReference) && !(node instanceof CompletionOnMemberAccess))
return null;
// Never offer on 'super.<autocomplete>'.
if (node instanceof FieldReference && ((FieldReference) node).receiver instanceof SuperReference)
return null;
if (node instanceof NameReference) {
Binding binding = ((NameReference) node).binding;
/* if ((node instanceof SingleNameReference) && (((SingleNameReference) node).token.length == 0)) {
firstParameterType = decl.binding;
} else */
if (binding instanceof VariableBinding) {
firstParameterType = ((VariableBinding) binding).type;
}
} else if (node instanceof FieldReference) {
firstParameterType = ((FieldReference) node).actualReceiverType;
}
return firstParameterType;
}
Aggregations