Stubs - Extract interface for JetTypeParameterListOwner. Old implementation renamed to JetNotStubbedParameterListOwner.

This commit is contained in:
Nikolay Krasko
2012-06-14 19:03:54 +04:00
parent 7b5c9af33c
commit eb135ee81d
6 changed files with 77 additions and 49 deletions
@@ -38,7 +38,7 @@ import java.util.List;
/**
* @author max
*/
public class JetClass extends JetTypeParameterListOwner
public class JetClass extends JetNotStubbedTypeParameterListOwner
implements JetClassOrObject, JetModifierListOwner, StubBasedPsiElement<PsiJetClassStub> {
private PsiJetClassStub stub;
@@ -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) {
@@ -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<JetTypeConstraint> getTypeConstraints() {
JetTypeConstraintList typeConstraintList = getTypeConstraintList();
if (typeConstraintList == null) {
return Collections.emptyList();
}
return typeConstraintList.getConstraints();
}
@Override
@NotNull
public List<JetTypeParameter> getTypeParameters() {
JetTypeParameterList list = getTypeParameterList();
if (list == null) return Collections.emptyList();
return list.getParameters();
}
}
@@ -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);
}
@@ -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<JetTypeConstraint> getTypeConstraints() {
JetTypeConstraintList typeConstraintList = getTypeConstraintList();
if (typeConstraintList == null) {
return Collections.emptyList();
}
return typeConstraintList.getConstraints();
}
List<JetTypeConstraint> getTypeConstraints();
@NotNull
public List<JetTypeParameter> getTypeParameters() {
JetTypeParameterList list = getTypeParameterList();
if (list == null) return Collections.emptyList();
return list.getParameters();
}
List<JetTypeParameter> getTypeParameters();
}
@@ -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);
}