diff --git a/idea/src/org/jetbrains/jet/JetNodeTypes.java b/idea/src/org/jetbrains/jet/JetNodeTypes.java index 254532d789d..ac24cca8159 100644 --- a/idea/src/org/jetbrains/jet/JetNodeTypes.java +++ b/idea/src/org/jetbrains/jet/JetNodeTypes.java @@ -22,13 +22,14 @@ public interface JetNodeTypes { JetNodeType CLASS_OBJECT = new JetNodeType("CLASS_OBJECT", JetClassObject.class); JetNodeType CONSTRUCTOR = new JetNodeType("CONSTRUCTOR", JetConstructor.class); + JetNodeType ENUM_ENTRY = new JetNodeType("ENUM_ENTRY", JetEnumEntry.class); TokenSet DECLARATIONS = TokenSet.create( NAMESPACE, CLASS, PROPERTY, FUN, EXTENSION, - TYPEDEF, DECOMPOSER, CLASS_OBJECT, CONSTRUCTOR); + TYPEDEF, DECOMPOSER, CLASS_OBJECT, CONSTRUCTOR, ENUM_ENTRY); - JetNodeType TYPE_PARAMETER_LIST = new JetNodeType("TYPE_PARAMETER_LIST"); - JetNodeType TYPE_PARAMETER = new JetNodeType("TYPE_PARAMETER"); + JetNodeType TYPE_PARAMETER_LIST = new JetNodeType("TYPE_PARAMETER_LIST", JetTypeParameterList.class); + JetNodeType TYPE_PARAMETER = new JetNodeType("TYPE_PARAMETER", JetTypeParameter.class); JetNodeType PRIMARY_CONSTRUCTOR_PARAMETERS_LIST = new JetNodeType("PRIMARY_CONSTRUCTOR_PARAMETERS_LIST"); JetNodeType PRIMARY_CONSTRUCTOR_PARAMETER = new JetNodeType("PRIMARY_CONSTRUCTOR_PARAMETER"); JetNodeType DELEGATION_SPECIFIER_LIST = new JetNodeType("DELEGATION_SPECIFIER_LIST"); @@ -41,7 +42,7 @@ public interface JetNodeTypes { JetNodeType CLASS_BODY = new JetNodeType("CLASS_BODY", JetClassBody.class); JetNodeType IMPORT_DIRECTIVE = new JetNodeType("IMPORT_DIRECTIVE", JetImportDirective.class); JetNodeType IMPORTED = new JetNodeType("IMPORTED"); - JetNodeType NAMESPACE_BODY = new JetNodeType("NAMESPACE_BODY"); + JetNodeType NAMESPACE_BODY = new JetNodeType("NAMESPACE_BODY", JetNamespaceBody.class); JetNodeType MODIFIER_LIST = new JetNodeType("MODIFIER_LIST", JetModifierList.class); JetNodeType ATTRIBUTE_ANNOTATION = new JetNodeType("ATTRIBUTE_ANNOTATION", JetAttributeAnnotation.class); JetNodeType ATTRIBUTE = new JetNodeType("ATTRIBUTE", JetAttribute.class); @@ -63,7 +64,6 @@ public interface JetNodeTypes { JetNodeType BLOCK = new JetNodeType("BLOCK"); JetNodeType TYPE_CONSTRAINT_LIST = new JetNodeType("TYPE_CONSTRAINT_LIST"); JetNodeType TYPE_CONSTRAINT = new JetNodeType("TYPE_CONSTRAINT"); - JetNodeType ENUM_ENTRY = new JetNodeType("ENUM_ENTRY"); JetNodeType NULL = new JetNodeType("NULL"); JetNodeType BOOLEAN_CONSTANT = new JetNodeType("BOOLEAN_CONSTANT"); JetNodeType FLOAT_CONSTANT = new JetNodeType("FLOAT_CONSTANT"); diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetClass.java b/idea/src/org/jetbrains/jet/lang/psi/JetClass.java index b9c5a013225..9d7ebee292f 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetClass.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetClass.java @@ -2,6 +2,7 @@ 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; @@ -10,7 +11,7 @@ import java.util.List; /** * @author max */ -public class JetClass extends JetNamedDeclaration{ +public class JetClass extends JetTypeParameterListOwner { public JetClass(@NotNull ASTNode node) { super(node); } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetEnumEntry.java b/idea/src/org/jetbrains/jet/lang/psi/JetEnumEntry.java new file mode 100644 index 00000000000..680d0862823 --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/psi/JetEnumEntry.java @@ -0,0 +1,18 @@ +package org.jetbrains.jet.lang.psi; + +import com.intellij.lang.ASTNode; +import org.jetbrains.annotations.NotNull; + +/** + * @author max + */ +public class JetEnumEntry extends JetClass { + public JetEnumEntry(@NotNull ASTNode node) { + super(node); + } + + @Override + public void accept(@NotNull JetVisitor visitor) { + visitor.visitEnumEntry(this); + } +} diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetExtension.java b/idea/src/org/jetbrains/jet/lang/psi/JetExtension.java index 1eabdb817dd..11cc8343aee 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetExtension.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetExtension.java @@ -10,7 +10,7 @@ import java.util.List; /** * @author max */ -public class JetExtension extends JetNamedDeclaration { +public class JetExtension extends JetTypeParameterListOwner { public JetExtension(@NotNull ASTNode node) { super(node); } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetFunction.java b/idea/src/org/jetbrains/jet/lang/psi/JetFunction.java index ad232a0680a..d332f49e3c7 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetFunction.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetFunction.java @@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull; /** * @author max */ -public class JetFunction extends JetNamedDeclaration { +public class JetFunction extends JetTypeParameterListOwner { public JetFunction(@NotNull ASTNode node) { super(node); } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetNamespaceBody.java b/idea/src/org/jetbrains/jet/lang/psi/JetNamespaceBody.java new file mode 100644 index 00000000000..fe45025ab3a --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/psi/JetNamespaceBody.java @@ -0,0 +1,25 @@ +package org.jetbrains.jet.lang.psi; + +import com.intellij.lang.ASTNode; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.JetNodeTypes; + +import java.util.List; + +/** + * @author max + */ +public class JetNamespaceBody extends JetElement { + public JetNamespaceBody(@NotNull ASTNode node) { + super(node); + } + + public List getDeclarations() { + return findChildrenByType(JetNodeTypes.DECLARATIONS); + } + + @Override + public void accept(@NotNull JetVisitor visitor) { + visitor.visitNamespaceBody(this); + } +} diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetTypeParameter.java b/idea/src/org/jetbrains/jet/lang/psi/JetTypeParameter.java new file mode 100644 index 00000000000..566df104b0d --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/psi/JetTypeParameter.java @@ -0,0 +1,18 @@ +package org.jetbrains.jet.lang.psi; + +import com.intellij.lang.ASTNode; +import org.jetbrains.annotations.NotNull; + +/** + * @author max + */ +public class JetTypeParameter extends JetNamedDeclaration { + public JetTypeParameter(@NotNull ASTNode node) { + super(node); + } + + @Override + public void accept(JetVisitor visitor) { + visitor.visitTypeParameter(this); + } +} diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetTypeParameterList.java b/idea/src/org/jetbrains/jet/lang/psi/JetTypeParameterList.java new file mode 100644 index 00000000000..8f32e66e2ae --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/psi/JetTypeParameterList.java @@ -0,0 +1,25 @@ +package org.jetbrains.jet.lang.psi; + +import com.intellij.lang.ASTNode; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.JetNodeTypes; + +import java.util.List; + +/** + * @author max + */ +public class JetTypeParameterList extends JetElement { + public JetTypeParameterList(@NotNull ASTNode node) { + super(node); + } + + public List getParameters() { + return findChildrenByType(JetNodeTypes.TYPE_PARAMETER); + } + + @Override + public void accept(JetVisitor visitor) { + visitor.visitTypeParameterList(this); + } +} diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetTypeParameterListOwner.java b/idea/src/org/jetbrains/jet/lang/psi/JetTypeParameterListOwner.java new file mode 100644 index 00000000000..9ae6667409e --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/psi/JetTypeParameterListOwner.java @@ -0,0 +1,30 @@ +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 + */ +public class JetTypeParameterListOwner extends JetNamedDeclaration { + public JetTypeParameterListOwner(@NotNull ASTNode node) { + super(node); + } + + @Nullable + public JetTypeParameterList getTypeParameterList() { + return (JetTypeParameterList) findChildByType(JetNodeTypes.TYPE_PARAMETER_LIST); + } + + public List getTypeParameters() { + JetTypeParameterList list = getTypeParameterList(); + if (list == null) return Collections.emptyList(); + + return list.getParameters(); + } +} diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetTypedef.java b/idea/src/org/jetbrains/jet/lang/psi/JetTypedef.java index 62a01d380d9..4f9e9625490 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetTypedef.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetTypedef.java @@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull; /** * @author max */ -public class JetTypedef extends JetNamedDeclaration { +public class JetTypedef extends JetTypeParameterListOwner { public JetTypedef(@NotNull ASTNode node) { super(node); } diff --git a/idea/src/org/jetbrains/jet/lang/psi/JetVisitor.java b/idea/src/org/jetbrains/jet/lang/psi/JetVisitor.java index 3dd525d433a..70a2900516b 100644 --- a/idea/src/org/jetbrains/jet/lang/psi/JetVisitor.java +++ b/idea/src/org/jetbrains/jet/lang/psi/JetVisitor.java @@ -62,6 +62,10 @@ public class JetVisitor extends PsiElementVisitor { visitJetElement(classBody); } + public void visitNamespaceBody(JetNamespaceBody body) { + visitJetElement(body); + } + public void visitModifierList(JetModifierList list) { visitJetElement(list); } @@ -73,4 +77,16 @@ public class JetVisitor extends PsiElementVisitor { public void visitAttribute(JetAttribute attribute) { visitJetElement(attribute); } + + public void visitTypeParameterList(JetTypeParameterList list) { + visitJetElement(list); + } + + public void visitTypeParameter(JetTypeParameter parameter) { + visitDeclaration(parameter); + } + + public void visitEnumEntry(JetEnumEntry enumEntry) { + visitClass(enumEntry); + } }