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.psi.typeRefHelpers.TypeRefHelpersPackage;
025 import org.jetbrains.jet.lang.resolve.name.FqName;
026 import org.jetbrains.jet.lexer.JetTokens;
027
028 import java.util.Collections;
029 import java.util.List;
030
031 import static org.jetbrains.jet.lexer.JetTokens.VAL_KEYWORD;
032 import static org.jetbrains.jet.lexer.JetTokens.VAR_KEYWORD;
033
034 public class JetMultiDeclarationEntry extends JetNamedDeclarationNotStubbed implements JetVariableDeclaration {
035 public JetMultiDeclarationEntry(@NotNull ASTNode node) {
036 super(node);
037 }
038
039 @Override
040 public JetTypeReference getTypeReference() {
041 return TypeRefHelpersPackage.getTypeReference(this);
042 }
043
044 @Override
045 @Nullable
046 public JetTypeReference setTypeReference(@Nullable JetTypeReference typeRef) {
047 return TypeRefHelpersPackage.setTypeReference(this, getNameIdentifier(), typeRef);
048 }
049
050 @Nullable
051 @Override
052 public JetParameterList getValueParameterList() {
053 return null;
054 }
055
056 @Nullable
057 @Override
058 public JetTypeReference getReceiverTypeReference() {
059 return null;
060 }
061
062 @NotNull
063 @Override
064 public List<JetTypeConstraint> getTypeConstraints() {
065 return Collections.emptyList();
066 }
067
068 @NotNull
069 @Override
070 public List<JetTypeParameter> getTypeParameters() {
071 return Collections.emptyList();
072 }
073
074 @Override
075 public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
076 return visitor.visitMultiDeclarationEntry(this, data);
077 }
078
079 @Override
080 public boolean isVar() {
081 return getParentNode().findChildByType(JetTokens.VAR_KEYWORD) != null;
082 }
083
084 @Nullable
085 @Override
086 public JetExpression getInitializer() {
087 return null;
088 }
089
090 @Override
091 public boolean hasInitializer() {
092 return false;
093 }
094
095 @NotNull
096 private ASTNode getParentNode() {
097 ASTNode parent = getNode().getTreeParent();
098 assert parent.getElementType() == JetNodeTypes.MULTI_VARIABLE_DECLARATION;
099 return parent;
100 }
101
102 @Override
103 public ASTNode getValOrVarNode() {
104 return getParentNode().findChildByType(TokenSet.create(VAL_KEYWORD, VAR_KEYWORD));
105 }
106
107 @Nullable
108 @Override
109 public FqName getFqName() {
110 return null;
111 }
112 }