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.tree.TokenSet;
021    import org.jetbrains.annotations.NotNull;
022    import org.jetbrains.annotations.Nullable;
023    import org.jetbrains.jet.JetNodeTypes;
024    import org.jetbrains.jet.lang.resolve.name.FqName;
025    import org.jetbrains.jet.lexer.JetTokens;
026    
027    import static org.jetbrains.jet.lexer.JetTokens.VAL_KEYWORD;
028    import static org.jetbrains.jet.lexer.JetTokens.VAR_KEYWORD;
029    
030    public class JetMultiDeclarationEntry extends JetNamedDeclarationNotStubbed implements JetVariableDeclaration {
031        public JetMultiDeclarationEntry(@NotNull ASTNode node) {
032            super(node);
033        }
034    
035        @Override
036        public JetTypeReference getTypeRef() {
037            return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE);
038        }
039    
040        @Override
041        public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
042            return visitor.visitMultiDeclarationEntry(this, data);
043        }
044    
045        @Override
046        public boolean isVar() {
047            return getParentNode().findChildByType(JetTokens.VAR_KEYWORD) != null;
048        }
049    
050        @Nullable
051        @Override
052        public JetExpression getInitializer() {
053            return null;
054        }
055    
056        @Override
057        public boolean hasInitializer() {
058            return false;
059        }
060    
061        @NotNull
062        private ASTNode getParentNode() {
063            ASTNode parent = getNode().getTreeParent();
064            assert parent.getElementType() == JetNodeTypes.MULTI_VARIABLE_DECLARATION;
065            return parent;
066        }
067    
068        @Override
069        public ASTNode getValOrVarNode() {
070            return getParentNode().findChildByType(TokenSet.create(VAL_KEYWORD, VAR_KEYWORD));
071        }
072    
073        @Nullable
074        @Override
075        public FqName getFqName() {
076            return null;
077        }
078    }