Introduced JetNamed to unify named functions and properties

This commit is contained in:
Andrey Breslav
2012-05-30 21:58:18 +04:00
parent 22be8ad49a
commit 173904d606
3 changed files with 31 additions and 4 deletions
@@ -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();
}
@@ -22,14 +22,13 @@ import com.intellij.psi.PsiNameIdentifierOwner;
import com.intellij.util.IncorrectOperationException; import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.jet.lexer.JetTokens;
/** /**
* @author max * @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) { public JetNamedDeclaration(@NotNull ASTNode node) {
super(node); super(node);
} }
@@ -46,7 +45,7 @@ public abstract class JetNamedDeclaration extends JetDeclaration implements PsiN
} }
} }
@Nullable @Override
public Name getNameAsName() { public Name getNameAsName() {
String name = getName(); String name = getName();
return name != null ? Name.identifier(name) : null; return name != null ? Name.identifier(name) : null;
@@ -32,7 +32,7 @@ import org.jetbrains.jet.lexer.JetTokens;
/** /**
* @author max * @author max
*/ */
public class JetNamedFunction extends JetFunction implements StubBasedPsiElement<PsiJetFunctionStub<?>> { public class JetNamedFunction extends JetFunction implements StubBasedPsiElement<PsiJetFunctionStub<?>>, JetNamed {
public JetNamedFunction(@NotNull ASTNode node) { public JetNamedFunction(@NotNull ASTNode node) {
super(node); super(node);
} }