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.search.LocalSearchScope;
022 import com.intellij.psi.search.SearchScope;
023 import org.jetbrains.annotations.NotNull;
024 import org.jetbrains.annotations.Nullable;
025 import org.jetbrains.kotlin.lexer.KtTokens;
026 import org.jetbrains.kotlin.name.FqName;
027
028 public class KtFunctionLiteral extends KtFunctionNotStubbed {
029 public KtFunctionLiteral(@NotNull ASTNode node) {
030 super(node);
031 }
032
033 @Override
034 public boolean hasBlockBody() {
035 return false;
036 }
037
038 @Override
039 public String getName() {
040 return "<anonymous>";
041 }
042
043 @Override
044 public PsiElement getNameIdentifier() {
045 return null;
046 }
047
048 public boolean hasParameterSpecification() {
049 return findChildByType(KtTokens.ARROW) != null;
050 }
051
052 @Override
053 public KtBlockExpression getBodyExpression() {
054 return (KtBlockExpression) super.getBodyExpression();
055 }
056
057 @Nullable
058 @Override
059 public PsiElement getEqualsToken() {
060 return null;
061 }
062
063 @NotNull
064 public PsiElement getLBrace() {
065 return findChildByType(KtTokens.LBRACE);
066 }
067
068 @Nullable
069 @IfNotParsed
070 public PsiElement getRBrace() {
071 return findChildByType(KtTokens.RBRACE);
072 }
073
074 @Nullable
075 public PsiElement getArrow() {
076 return findChildByType(KtTokens.ARROW);
077 }
078
079 @Nullable
080 @Override
081 public FqName getFqName() {
082 return null;
083 }
084
085 @Override
086 public boolean hasBody() {
087 return getBodyExpression() != null;
088 }
089
090 @NotNull
091 @Override
092 public SearchScope getUseScope() {
093 return new LocalSearchScope(this);
094 }
095 }