diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClassInitializer.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClassInitializer.java index fdefca96372..c8c1606c15a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClassInitializer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClassInitializer.java @@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull; /** * @author max */ -public class JetClassInitializer extends JetDeclaration implements JetStatementExpression { +public class JetClassInitializer extends JetDeclarationImpl implements JetStatementExpression { public JetClassInitializer(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClassObject.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClassObject.java index 8bb61c8824e..14a3d34d1b6 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClassObject.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClassObject.java @@ -24,7 +24,7 @@ import org.jetbrains.jet.JetNodeTypes; /** * @author max */ -public class JetClassObject extends JetDeclaration implements JetStatementExpression { +public class JetClassObject extends JetDeclarationImpl implements JetStatementExpression { public JetClassObject(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclaration.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclaration.java index 7caa013a3f4..a4df289944c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclaration.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclaration.java @@ -16,29 +16,17 @@ package org.jetbrains.jet.lang.psi; -import com.intellij.lang.ASTNode; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.JetNodeTypes; import org.jetbrains.jet.lexer.JetToken; /** - * @author max + * @author Nikolay Krasko */ -public abstract class JetDeclaration extends JetExpressionImpl implements JetModifierListOwner { - public JetDeclaration(@NotNull ASTNode node) { - super(node); - } - +public interface JetDeclaration extends JetExpression, JetModifierListOwner { @Override @Nullable - public JetModifierList getModifierList() { - return (JetModifierList) findChildByType(JetNodeTypes.MODIFIER_LIST); - } + JetModifierList getModifierList(); @Override - public boolean hasModifier(JetToken modifier) { - JetModifierList modifierList = getModifierList(); - return modifierList != null && modifierList.hasModifier(modifier); - } + boolean hasModifier(JetToken modifier); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclarationImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclarationImpl.java new file mode 100644 index 00000000000..4137aeed119 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclarationImpl.java @@ -0,0 +1,44 @@ +/* + * 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 com.intellij.lang.ASTNode; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.JetNodeTypes; +import org.jetbrains.jet.lexer.JetToken; + +/** + * @author max + */ +abstract class JetDeclarationImpl extends JetExpressionImpl implements JetDeclaration { + public JetDeclarationImpl(@NotNull ASTNode node) { + super(node); + } + + @Override + @Nullable + public JetModifierList getModifierList() { + return (JetModifierList) findChildByType(JetNodeTypes.MODIFIER_LIST); + } + + @Override + public boolean hasModifier(JetToken modifier) { + JetModifierList modifierList = getModifierList(); + return modifierList != null && modifierList.hasModifier(modifier); + } +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetModifiableBlockHelper.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetModifiableBlockHelper.java index 8133034391d..b5834b0a30e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetModifiableBlockHelper.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetModifiableBlockHelper.java @@ -30,7 +30,7 @@ public final class JetModifiableBlockHelper { * Tested in OutOfBlockModificationTest */ public static boolean shouldChangeModificationCount(PsiElement place) { - JetDeclaration declaration = PsiTreeUtil.getParentOfType(place, JetDeclaration.class, true); + JetDeclaration declaration = PsiTreeUtil.getParentOfType(place, JetDeclarationImpl.class, true); if (declaration != null) { if (declaration instanceof JetNamedFunction) { JetNamedFunction function = (JetNamedFunction) declaration; @@ -61,7 +61,7 @@ public final class JetModifiableBlockHelper { } private static boolean takePartInDeclarationTypeInference(PsiElement place) { - JetDeclaration declaration = PsiTreeUtil.getParentOfType(place, JetDeclaration.class, true); + JetDeclaration declaration = PsiTreeUtil.getParentOfType(place, JetDeclarationImpl.class, true); if (declaration != null) { if (declaration instanceof JetNamedFunction) { JetNamedFunction function = (JetNamedFunction) declaration; 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 8ce3419f837..b620b77a769 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedDeclaration.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedDeclaration.java @@ -29,7 +29,7 @@ import org.jetbrains.jet.lexer.JetTokens; /** * @author max */ -public abstract class JetNamedDeclaration extends JetDeclaration implements PsiNameIdentifierOwner, JetStatementExpression, JetNamed { +public abstract class JetNamedDeclaration extends JetDeclarationImpl implements PsiNameIdentifierOwner, JetStatementExpression, JetNamed { public JetNamedDeclaration(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPropertyAccessor.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPropertyAccessor.java index f867190c51c..5b7ec411166 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPropertyAccessor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPropertyAccessor.java @@ -29,7 +29,7 @@ import java.util.List; /** * @author max */ -public class JetPropertyAccessor extends JetDeclaration implements JetDeclarationWithBody, JetModifierListOwner { +public class JetPropertyAccessor extends JetDeclarationImpl implements JetDeclarationWithBody, JetModifierListOwner { public JetPropertyAccessor(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetScript.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetScript.java index dfb61ee3fa2..5aa0a7bff7b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetScript.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetScript.java @@ -25,7 +25,7 @@ import java.util.List; /** * @author Stepan Koltsov */ -public class JetScript extends JetDeclaration { +public class JetScript extends JetDeclarationImpl { public JetScript(@NotNull ASTNode node) { super(node); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetSecondaryConstructor.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetSecondaryConstructor.java index 7874086fba0..61bb31ee91b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetSecondaryConstructor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetSecondaryConstructor.java @@ -28,7 +28,7 @@ import java.util.List; /** * @author max */ -public class JetSecondaryConstructor extends JetDeclaration implements JetDeclarationWithBody, JetStatementExpression { +public class JetSecondaryConstructor extends JetDeclarationImpl implements JetDeclarationWithBody, JetStatementExpression { public JetSecondaryConstructor(@NotNull ASTNode node) { super(node); }