001    /*
002     * Copyright 2010-2013 JetBrains s.r.o.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.jetbrains.jet.lang.psi;
018    
019    import com.intellij.lang.ASTNode;
020    import com.intellij.psi.stubs.IStubElementType;
021    import org.jetbrains.annotations.NotNull;
022    import org.jetbrains.annotations.Nullable;
023    import org.jetbrains.jet.JetNodeTypes;
024    import org.jetbrains.jet.lang.psi.stubs.PsiJetPlaceHolderStub;
025    import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
026    
027    import java.util.Collections;
028    import java.util.List;
029    
030    public class JetDelegatorToThisCall extends JetDelegationSpecifier implements JetCallElement {
031    
032        public JetDelegatorToThisCall(@NotNull ASTNode node) {
033            super(node);
034        }
035    
036        public JetDelegatorToThisCall(@NotNull PsiJetPlaceHolderStub<? extends JetDelegationSpecifier> stub) {
037            super(stub, JetStubElementTypes.THIS_CALL);
038        }
039    
040        @Override
041        public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
042            return visitor.visitDelegationToThisCall(this, data);
043        }
044    
045        @Override
046        public JetExpression getCalleeExpression() {
047            return getThisReference();
048        }
049    
050        @Nullable
051        public JetValueArgumentList getValueArgumentList() {
052            return (JetValueArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST);
053        }
054    
055        @NotNull
056        public List<? extends ValueArgument> getValueArguments() {
057            JetValueArgumentList list = getValueArgumentList();
058            return list != null ? list.getArguments() : Collections.<JetValueArgument>emptyList();
059        }
060    
061        @NotNull
062        @Override
063        public List<JetExpression> getFunctionLiteralArguments() {
064            return Collections.emptyList();
065        }
066    
067        @NotNull
068        @Override
069        public List<JetTypeProjection> getTypeArguments() {
070            return Collections.emptyList();
071        }
072    
073        @Override
074        public JetTypeArgumentList getTypeArgumentList() {
075            return null;
076        }
077    
078        public JetReferenceExpression getThisReference() {
079            return findChildByClass(JetThisReferenceExpression.class);
080        }
081    }