Search in sources :

Example 6 with NameReference

use of org.eclipse.jdt.internal.compiler.ast.NameReference in project lombok by rzwitserloot.

the class EclipseHandlerUtil method createFieldAccessor.

static Expression createFieldAccessor(EclipseNode field, FieldAccess fieldAccess, ASTNode source, char[] receiver) {
    int pS = source.sourceStart, pE = source.sourceEnd;
    long p = (long) pS << 32 | pE;
    boolean lookForGetter = lookForGetter(field, fieldAccess);
    GetterMethod getter = lookForGetter ? findGetter(field) : null;
    if (getter == null) {
        NameReference ref;
        char[][] tokens = new char[2][];
        tokens[0] = receiver;
        tokens[1] = field.getName().toCharArray();
        long[] poss = { p, p };
        ref = new QualifiedNameReference(tokens, poss, pS, pE);
        setGeneratedBy(ref, source);
        return ref;
    }
    MessageSend call = new MessageSend();
    setGeneratedBy(call, source);
    call.sourceStart = pS;
    call.statementEnd = call.sourceEnd = pE;
    call.receiver = new SingleNameReference(receiver, p);
    setGeneratedBy(call.receiver, source);
    call.selector = getter.name;
    return call;
}
Also used : MessageSend(org.eclipse.jdt.internal.compiler.ast.MessageSend) QualifiedNameReference(org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference) NameReference(org.eclipse.jdt.internal.compiler.ast.NameReference) SingleNameReference(org.eclipse.jdt.internal.compiler.ast.SingleNameReference) SingleNameReference(org.eclipse.jdt.internal.compiler.ast.SingleNameReference) QualifiedNameReference(org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference)

Example 7 with NameReference

use of org.eclipse.jdt.internal.compiler.ast.NameReference 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;
}
Also used : Binding(org.eclipse.jdt.internal.compiler.lookup.Binding) TypeBinding(org.eclipse.jdt.internal.compiler.lookup.TypeBinding) MethodBinding(org.eclipse.jdt.internal.compiler.lookup.MethodBinding) VariableBinding(org.eclipse.jdt.internal.compiler.lookup.VariableBinding) CompletionOnQualifiedNameReference(org.eclipse.jdt.internal.codeassist.complete.CompletionOnQualifiedNameReference) NameReference(org.eclipse.jdt.internal.compiler.ast.NameReference) CompletionOnSingleNameReference(org.eclipse.jdt.internal.codeassist.complete.CompletionOnSingleNameReference) CompletionOnMemberAccess(org.eclipse.jdt.internal.codeassist.complete.CompletionOnMemberAccess) FieldReference(org.eclipse.jdt.internal.compiler.ast.FieldReference) TypeBinding(org.eclipse.jdt.internal.compiler.lookup.TypeBinding) ASTNode(org.eclipse.jdt.internal.compiler.ast.ASTNode) CompletionOnSingleNameReference(org.eclipse.jdt.internal.codeassist.complete.CompletionOnSingleNameReference) CompletionOnQualifiedNameReference(org.eclipse.jdt.internal.codeassist.complete.CompletionOnQualifiedNameReference) VariableBinding(org.eclipse.jdt.internal.compiler.lookup.VariableBinding) SuperReference(org.eclipse.jdt.internal.compiler.ast.SuperReference)

Aggregations

NameReference (org.eclipse.jdt.internal.compiler.ast.NameReference)7 SingleNameReference (org.eclipse.jdt.internal.compiler.ast.SingleNameReference)6 QualifiedNameReference (org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference)5 ArrayList (java.util.ArrayList)3 Expression (org.eclipse.jdt.internal.compiler.ast.Expression)3 MessageSend (org.eclipse.jdt.internal.compiler.ast.MessageSend)3 SuperReference (org.eclipse.jdt.internal.compiler.ast.SuperReference)3 ThisReference (org.eclipse.jdt.internal.compiler.ast.ThisReference)3 EclipseNode (lombok.eclipse.EclipseNode)2 ASTNode (org.eclipse.jdt.internal.compiler.ast.ASTNode)2 Annotation (org.eclipse.jdt.internal.compiler.ast.Annotation)2 Argument (org.eclipse.jdt.internal.compiler.ast.Argument)2 MethodDeclaration (org.eclipse.jdt.internal.compiler.ast.MethodDeclaration)2 ReturnStatement (org.eclipse.jdt.internal.compiler.ast.ReturnStatement)2 Statement (org.eclipse.jdt.internal.compiler.ast.Statement)2 Binding (org.eclipse.jdt.internal.compiler.lookup.Binding)2 MethodBinding (org.eclipse.jdt.internal.compiler.lookup.MethodBinding)2 List (java.util.List)1 EclipseHandlerUtil.createAnnotation (lombok.eclipse.handlers.EclipseHandlerUtil.createAnnotation)1 CompletionOnMemberAccess (org.eclipse.jdt.internal.codeassist.complete.CompletionOnMemberAccess)1