REVIEW: JetClassBody#getDeclarations() by stub
This commit is contained in:
@@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.psi;
|
|||||||
import com.intellij.lang.ASTNode;
|
import com.intellij.lang.ASTNode;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.tree.TokenSet;
|
import com.intellij.psi.tree.TokenSet;
|
||||||
import com.intellij.psi.util.PsiTreeUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.JetNodeTypes;
|
import org.jetbrains.jet.JetNodeTypes;
|
||||||
@@ -27,9 +26,14 @@ import org.jetbrains.jet.lang.psi.stubs.PsiJetPlaceHolderStub;
|
|||||||
import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
|
import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class JetClassBody extends JetElementImplStub<PsiJetPlaceHolderStub<JetClassBody>> implements JetDeclarationContainer {
|
public class JetClassBody extends JetElementImplStub<PsiJetPlaceHolderStub<JetClassBody>> implements JetDeclarationContainer {
|
||||||
|
private static final TokenSet DECLARATION_TYPES =
|
||||||
|
TokenSet.create(JetStubElementTypes.CLASS, JetStubElementTypes.OBJECT_DECLARATION, JetStubElementTypes.CLASS_OBJECT,
|
||||||
|
JetStubElementTypes.FUNCTION, JetStubElementTypes.PROPERTY);
|
||||||
|
|
||||||
public JetClassBody(@NotNull ASTNode node) {
|
public JetClassBody(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -41,7 +45,7 @@ public class JetClassBody extends JetElementImplStub<PsiJetPlaceHolderStub<JetCl
|
|||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<JetDeclaration> getDeclarations() {
|
public List<JetDeclaration> getDeclarations() {
|
||||||
return PsiTreeUtil.getChildrenOfTypeAsList(this, JetDeclaration.class);
|
return Arrays.asList(getStubOrPsiChildren(DECLARATION_TYPES, JetDeclaration.ARRAY_FACTORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -16,5 +16,17 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.lang.psi;
|
package org.jetbrains.jet.lang.psi;
|
||||||
|
|
||||||
|
import com.intellij.util.ArrayFactory;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public interface JetDeclaration extends JetExpression, JetModifierListOwner {
|
public interface JetDeclaration extends JetExpression, JetModifierListOwner {
|
||||||
|
JetDeclaration[] EMPTY_ARRAY = new JetDeclaration[0];
|
||||||
|
|
||||||
|
ArrayFactory<JetDeclaration> ARRAY_FACTORY = new ArrayFactory<JetDeclaration>() {
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public JetDeclaration[] create(int count) {
|
||||||
|
return count == 0 ? EMPTY_ARRAY : new JetDeclaration[count];
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user