diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetStubbedPsiUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetStubbedPsiUtil.java index 329d716da32..f5e6d71ca39 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetStubbedPsiUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetStubbedPsiUtil.java @@ -18,7 +18,9 @@ package org.jetbrains.jet.lang.psi; import com.intellij.psi.PsiElement; import com.intellij.psi.stubs.StubElement; +import com.intellij.psi.tree.TokenSet; import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.util.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -52,6 +54,19 @@ public final class JetStubbedPsiUtil { return PsiTreeUtil.getParentOfType(element, declarationClass, strict); } + @Nullable + public static T getStubOrPsiChild( + @NotNull JetElementImplStub element, + @NotNull TokenSet types, + @NotNull ArrayFactory factory + ) { + T[] typeElements = element.getStubOrPsiChildren(types, factory); + if (typeElements.length == 0) { + return null; + } + return typeElements[0]; + } + private JetStubbedPsiUtil() { } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeElement.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeElement.java index b645f8da9d2..d1fb79dd5ca 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeElement.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeElement.java @@ -16,11 +16,22 @@ package org.jetbrains.jet.lang.psi; +import com.intellij.util.ArrayFactory; import org.jetbrains.annotations.NotNull; import java.util.List; public interface JetTypeElement extends JetElement { + JetTypeElement[] EMPTY_ARRAY = new JetTypeElement[0]; + + ArrayFactory ARRAY_FACTORY = new ArrayFactory() { + @NotNull + @Override + public JetTypeElement[] create(int count) { + return count == 0 ? EMPTY_ARRAY : new JetTypeElement[count]; + } + }; + @NotNull List getTypeArgumentsAsTypes(); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeReference.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeReference.java index f68f8452977..47b52bdc32f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeReference.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeReference.java @@ -17,11 +17,9 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; -import com.intellij.psi.tree.TokenSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.psi.stubs.PsiJetPlaceHolderStub; -import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementType; import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; import java.util.ArrayList; @@ -36,9 +34,6 @@ import static org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes.ANNO */ public class JetTypeReference extends JetElementImplStub> { - public static final TokenSet TYPE_ELEMENTS - = TokenSet.create(JetStubElementTypes.USER_TYPE, JetStubElementTypes.NULLABLE_TYPE, JetStubElementTypes.FUNCTION_TYPE); - public JetTypeReference(@NotNull ASTNode node) { super(node); } @@ -59,12 +54,7 @@ public class JetTypeReference extends JetElementImplStub getAnnotations() { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetStubElementTypes.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetStubElementTypes.java index ac0ce0f7f27..47210f3f0ea 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetStubElementTypes.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetStubElementTypes.java @@ -100,4 +100,6 @@ public interface JetStubElementTypes { TokenSet.create(CLASS, OBJECT_DECLARATION, CLASS_OBJECT, FUNCTION, PROPERTY, ANONYMOUS_INITIALIZER, ENUM_ENTRY); TokenSet DELEGATION_SPECIFIER_TYPES = TokenSet.create(DELEGATOR_BY, DELEGATOR_SUPER_CALL, DELEGATOR_SUPER_CLASS, THIS_CALL); + + TokenSet TYPE_ELEMENT_TYPES = TokenSet.create(USER_TYPE, NULLABLE_TYPE, FUNCTION_TYPE); }