001    /*
002     * Copyright 2010-2015 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.kotlin.psi;
018    
019    import com.intellij.lang.ASTNode;
020    import com.intellij.psi.PsiElement;
021    import com.intellij.psi.tree.TokenSet;
022    import org.jetbrains.annotations.NotNull;
023    import org.jetbrains.annotations.Nullable;
024    import org.jetbrains.kotlin.JetNodeTypes;
025    import org.jetbrains.kotlin.lexer.JetTokens;
026    import org.jetbrains.kotlin.name.FqName;
027    import org.jetbrains.kotlin.psi.typeRefHelpers.TypeRefHelpersPackage;
028    
029    import java.util.Collections;
030    import java.util.List;
031    
032    import static org.jetbrains.kotlin.lexer.JetTokens.VAL_KEYWORD;
033    import static org.jetbrains.kotlin.lexer.JetTokens.VAR_KEYWORD;
034    
035    public class JetMultiDeclarationEntry extends JetNamedDeclarationNotStubbed implements JetVariableDeclaration {
036        public JetMultiDeclarationEntry(@NotNull ASTNode node) {
037            super(node);
038        }
039    
040        @Override
041        public JetTypeReference getTypeReference() {
042            return TypeRefHelpersPackage.getTypeReference(this);
043        }
044    
045        @Override
046        @Nullable
047        public JetTypeReference setTypeReference(@Nullable JetTypeReference typeRef) {
048            return TypeRefHelpersPackage.setTypeReference(this, getNameIdentifier(), typeRef);
049        }
050    
051        @Nullable
052        @Override
053        public PsiElement getColon() {
054            return findChildByType(JetTokens.COLON);
055        }
056    
057        @Nullable
058        @Override
059        public JetParameterList getValueParameterList() {
060            return null;
061        }
062    
063        @NotNull
064        @Override
065        public List<JetParameter> getValueParameters() {
066            return Collections.emptyList();
067        }
068    
069        @Nullable
070        @Override
071        public JetTypeReference getReceiverTypeReference() {
072            return null;
073        }
074    
075        @Nullable
076        @Override
077        public JetTypeParameterList getTypeParameterList() {
078            return null;
079        }
080    
081        @Nullable
082        @Override
083        public JetTypeConstraintList getTypeConstraintList() {
084            return null;
085        }
086    
087        @NotNull
088        @Override
089        public List<JetTypeConstraint> getTypeConstraints() {
090            return Collections.emptyList();
091        }
092    
093        @NotNull
094        @Override
095        public List<JetTypeParameter> getTypeParameters() {
096            return Collections.emptyList();
097        }
098    
099        @Override
100        public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
101            return visitor.visitMultiDeclarationEntry(this, data);
102        }
103    
104        @Override
105        public boolean isVar() {
106            return getParentNode().findChildByType(JetTokens.VAR_KEYWORD) != null;
107        }
108    
109        @Nullable
110        @Override
111        public JetExpression getInitializer() {
112            return null;
113        }
114    
115        @Override
116        public boolean hasInitializer() {
117            return false;
118        }
119    
120        @NotNull
121        private ASTNode getParentNode() {
122            ASTNode parent = getNode().getTreeParent();
123            assert parent.getElementType() == JetNodeTypes.MULTI_VARIABLE_DECLARATION;
124            return parent;
125        }
126    
127        @Override
128        public ASTNode getValOrVarNode() {
129            return getParentNode().findChildByType(TokenSet.create(VAL_KEYWORD, VAR_KEYWORD));
130        }
131    
132        @Nullable
133        @Override
134        public FqName getFqName() {
135            return null;
136        }
137    }