From eb135ee81dbb226c7b1a60b568390cbd55c24418 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Thu, 14 Jun 2012 19:03:54 +0400 Subject: [PATCH] Stubs - Extract interface for JetTypeParameterListOwner. Old implementation renamed to JetNotStubbedParameterListOwner. --- .../org/jetbrains/jet/lang/psi/JetClass.java | 2 +- .../jetbrains/jet/lang/psi/JetFunction.java | 2 +- .../JetNotStubbedTypeParameterListOwner.java | 66 +++++++++++++++++++ .../jetbrains/jet/lang/psi/JetProperty.java | 2 +- .../lang/psi/JetTypeParameterListOwner.java | 52 ++------------- .../jetbrains/jet/lang/psi/JetTypedef.java | 2 +- 6 files changed, 77 insertions(+), 49 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNotStubbedTypeParameterListOwner.java diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClass.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClass.java index 1084227ab8c..e637c6b9a79 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClass.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClass.java @@ -38,7 +38,7 @@ import java.util.List; /** * @author max */ -public class JetClass extends JetTypeParameterListOwner +public class JetClass extends JetNotStubbedTypeParameterListOwner implements JetClassOrObject, JetModifierListOwner, StubBasedPsiElement { private PsiJetClassStub stub; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunction.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunction.java index e10c256c82c..08e38b6df7e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunction.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunction.java @@ -30,7 +30,7 @@ import java.util.List; /** * @author abreslav */ -abstract public class JetFunction extends JetTypeParameterListOwner +abstract public class JetFunction extends JetNotStubbedTypeParameterListOwner implements JetDeclarationWithBody, JetModifierListOwner { public JetFunction(@NotNull ASTNode node) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNotStubbedTypeParameterListOwner.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNotStubbedTypeParameterListOwner.java new file mode 100644 index 00000000000..7a0fb034082 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNotStubbedTypeParameterListOwner.java @@ -0,0 +1,66 @@ +/* + * 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 java.util.Collections; +import java.util.List; + +/** + * @author max + */ +@Deprecated +class JetNotStubbedTypeParameterListOwner extends JetNotStubbedNamedDeclaration implements JetTypeParameterListOwner { + public JetNotStubbedTypeParameterListOwner(@NotNull ASTNode node) { + super(node); + } + + @Override + @Nullable + public JetTypeParameterList getTypeParameterList() { + return (JetTypeParameterList) findChildByType(JetNodeTypes.TYPE_PARAMETER_LIST); + } + + @Override + @Nullable + public JetTypeConstraintList getTypeConstraintList() { + return (JetTypeConstraintList) findChildByType(JetNodeTypes.TYPE_CONSTRAINT_LIST); + } + + @Override + @NotNull + public List getTypeConstraints() { + JetTypeConstraintList typeConstraintList = getTypeConstraintList(); + if (typeConstraintList == null) { + return Collections.emptyList(); + } + return typeConstraintList.getConstraints(); + } + + @Override + @NotNull + public List getTypeParameters() { + JetTypeParameterList list = getTypeParameterList(); + if (list == null) return Collections.emptyList(); + + return list.getParameters(); + } +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetProperty.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetProperty.java index 28b1aa3c6ae..924be214f79 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetProperty.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetProperty.java @@ -36,7 +36,7 @@ import static org.jetbrains.jet.lexer.JetTokens.*; /** * @author max */ -public class JetProperty extends JetTypeParameterListOwner implements JetModifierListOwner { +public class JetProperty extends JetNotStubbedTypeParameterListOwner implements JetModifierListOwner { public JetProperty(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeParameterListOwner.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeParameterListOwner.java index 3e32b92e6f1..06234fa1725 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeParameterListOwner.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeParameterListOwner.java @@ -1,61 +1,23 @@ -/* - * 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 java.util.Collections; import java.util.List; /** - * @author max + * @author Nikolay Krasko */ -public class JetTypeParameterListOwner extends JetNotStubbedNamedDeclaration { - public JetTypeParameterListOwner(@NotNull ASTNode node) { - super(node); - } +public interface JetTypeParameterListOwner extends JetNamedDeclaration { + @Nullable + JetTypeParameterList getTypeParameterList(); @Nullable - public JetTypeParameterList getTypeParameterList() { - return (JetTypeParameterList) findChildByType(JetNodeTypes.TYPE_PARAMETER_LIST); - } - - @Nullable - public JetTypeConstraintList getTypeConstraintList() { - return (JetTypeConstraintList) findChildByType(JetNodeTypes.TYPE_CONSTRAINT_LIST); - } + JetTypeConstraintList getTypeConstraintList(); @NotNull - public List getTypeConstraints() { - JetTypeConstraintList typeConstraintList = getTypeConstraintList(); - if (typeConstraintList == null) { - return Collections.emptyList(); - } - return typeConstraintList.getConstraints(); - } + List getTypeConstraints(); @NotNull - public List getTypeParameters() { - JetTypeParameterList list = getTypeParameterList(); - if (list == null) return Collections.emptyList(); - - return list.getParameters(); - } + List getTypeParameters(); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypedef.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypedef.java index 5483c29a803..823d36de1e5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypedef.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypedef.java @@ -24,7 +24,7 @@ import org.jetbrains.jet.JetNodeTypes; /** * @author max */ -public class JetTypedef extends JetTypeParameterListOwner { +public class JetTypedef extends JetNotStubbedTypeParameterListOwner { public JetTypedef(@NotNull ASTNode node) { super(node); }