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
017package org.jetbrains.jet.lang.psi;
018
019import com.intellij.extapi.psi.ASTWrapperPsiElement;
020import com.intellij.lang.ASTNode;
021import com.intellij.lang.Language;
022import com.intellij.psi.PsiElement;
023import com.intellij.psi.PsiElementVisitor;
024import org.jetbrains.annotations.NotNull;
025import org.jetbrains.jet.plugin.JetLanguage;
026
027public class JetElementImpl extends ASTWrapperPsiElement implements JetElement {
028    public JetElementImpl(@NotNull ASTNode node) {
029        super(node);
030    }
031
032    @NotNull
033    @Override
034    public Language getLanguage() {
035        return JetLanguage.INSTANCE;
036    }
037
038    @Override
039    public String toString() {
040        return getNode().getElementType().toString();
041    }
042
043    @Override
044    public final void accept(@NotNull PsiElementVisitor visitor) {
045        if (visitor instanceof JetVisitorVoid) {
046            accept((JetVisitorVoid) visitor);
047        }
048        else {
049            visitor.visitElement(this);
050        }
051    }
052
053    @Override
054    public <D> void acceptChildren(@NotNull JetTreeVisitor<D> visitor, D data) {
055        JetPsiUtil.visitChildren(this, visitor, data);
056    }
057
058    @Override
059    public void accept(@NotNull JetVisitorVoid visitor) {
060        visitor.visitJetElement(this);
061    }
062    
063    @Override
064    public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
065        return visitor.visitJetElement(this, data);
066    }
067}