From 173904d6063cf0fc425cc232bcfd37809e10a5fe Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Wed, 30 May 2012 21:58:18 +0400 Subject: [PATCH] Introduced JetNamed to unify named functions and properties --- .../org/jetbrains/jet/lang/psi/JetNamed.java | 28 +++++++++++++++++++ .../jet/lang/psi/JetNamedDeclaration.java | 5 ++-- .../jet/lang/psi/JetNamedFunction.java | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamed.java diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamed.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamed.java new file mode 100644 index 00000000000..d6bfa96311f --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamed.java @@ -0,0 +1,28 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.lang.psi; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.resolve.name.Name; + +/** + * @author abreslav + */ +public interface JetNamed { + @Nullable + Name getNameAsName(); +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedDeclaration.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedDeclaration.java index 48635e73052..6a705be80f1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedDeclaration.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedDeclaration.java @@ -22,14 +22,13 @@ import com.intellij.psi.PsiNameIdentifierOwner; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lexer.JetTokens; /** * @author max */ -public abstract class JetNamedDeclaration extends JetDeclaration implements PsiNameIdentifierOwner, JetStatementExpression { +public abstract class JetNamedDeclaration extends JetDeclaration implements PsiNameIdentifierOwner, JetStatementExpression, JetNamed { public JetNamedDeclaration(@NotNull ASTNode node) { super(node); } @@ -46,7 +45,7 @@ public abstract class JetNamedDeclaration extends JetDeclaration implements PsiN } } - @Nullable + @Override public Name getNameAsName() { String name = getName(); return name != null ? Name.identifier(name) : null; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedFunction.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedFunction.java index 3835e71c4bf..98981725c84 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedFunction.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedFunction.java @@ -32,7 +32,7 @@ import org.jetbrains.jet.lexer.JetTokens; /** * @author max */ -public class JetNamedFunction extends JetFunction implements StubBasedPsiElement> { +public class JetNamedFunction extends JetFunction implements StubBasedPsiElement>, JetNamed { public JetNamedFunction(@NotNull ASTNode node) { super(node); }