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 com.intellij.psi.util.PsiTreeUtil; 023 import org.jetbrains.annotations.NotNull; 024 import org.jetbrains.annotations.Nullable; 025 import org.jetbrains.kotlin.JetNodeTypes; 026 import org.jetbrains.kotlin.lexer.JetTokens; 027 028 import java.util.List; 029 030 import static org.jetbrains.kotlin.lexer.JetTokens.*; 031 032 public class JetMultiDeclaration extends JetDeclarationImpl { 033 public JetMultiDeclaration(@NotNull ASTNode node) { 034 super(node); 035 } 036 037 @Override 038 public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) { 039 return visitor.visitMultiDeclaration(this, data); 040 } 041 042 @NotNull 043 public List<JetMultiDeclarationEntry> getEntries() { 044 return findChildrenByType(JetNodeTypes.MULTI_VARIABLE_DECLARATION_ENTRY); 045 } 046 047 @Nullable 048 public JetExpression getInitializer() { 049 ASTNode eqNode = getNode().findChildByType(EQ); 050 if (eqNode == null) { 051 return null; 052 } 053 return PsiTreeUtil.getNextSiblingOfType(eqNode.getPsi(), JetExpression.class); 054 } 055 056 @Nullable 057 public PsiElement getValOrVarKeyword() { 058 return findChildByType(TokenSet.create(VAL_KEYWORD, VAR_KEYWORD)); 059 } 060 061 @Nullable 062 public PsiElement getRPar() { 063 return findChildByType(JetTokens.RPAR); 064 } 065 066 @Nullable 067 public PsiElement getLPar() { 068 return findChildByType(JetTokens.LPAR); 069 } 070 }