diff --git a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java index bf5481870b4..fcdace2ad75 100644 --- a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java +++ b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java @@ -69,7 +69,7 @@ public interface JetNodeTypes { IElementType FUNCTION_TYPE_RECEIVER = JetStubElementTypes.FUNCTION_TYPE_RECEIVER; JetNodeType SELF_TYPE = new JetNodeType("SELF_TYPE", JetSelfType.class); IElementType NULLABLE_TYPE = JetStubElementTypes.NULLABLE_TYPE; - JetNodeType TYPE_PROJECTION = new JetNodeType("TYPE_PROJECTION", JetTypeProjection.class); + IElementType TYPE_PROJECTION = JetStubElementTypes.TYPE_PROJECTION; // TODO: review JetNodeType PROPERTY_ACCESSOR = new JetNodeType("PROPERTY_ACCESSOR", JetPropertyAccessor.class); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeProjection.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeProjection.java index c9689d661bc..b6371481aa5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeProjection.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeProjection.java @@ -21,17 +21,23 @@ import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.JetNodeTypes; +import org.jetbrains.jet.lang.psi.stubs.PsiJetTypeProjectionStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; import org.jetbrains.jet.lexer.JetModifierKeywordToken; import org.jetbrains.jet.lexer.JetTokens; import java.util.Collections; import java.util.List; -public class JetTypeProjection extends JetElementImpl implements JetModifierListOwner { +public class JetTypeProjection extends JetElementImplStub implements JetModifierListOwner { public JetTypeProjection(@NotNull ASTNode node) { super(node); } + public JetTypeProjection(@NotNull PsiJetTypeProjectionStub stub) { + super(stub, JetStubElementTypes.TYPE_PROJECTION); + } + @Override public JetModifierList getModifierList() { return (JetModifierList) findChildByType(JetNodeTypes.MODIFIER_LIST); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetTypeProjectionStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetTypeProjectionStub.java new file mode 100644 index 00000000000..5a6d3941658 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetTypeProjectionStub.java @@ -0,0 +1,25 @@ +/* + * Copyright 2010-2014 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.stubs; + +import com.intellij.psi.stubs.StubElement; +import org.jetbrains.jet.lang.psi.JetProjectionKind; +import org.jetbrains.jet.lang.psi.JetTypeProjection; + +public interface PsiJetTypeProjectionStub extends StubElement { + JetProjectionKind getProjectionKind(); +} 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 5e00d60dc8c..fa6a5a2d762 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 @@ -65,6 +65,9 @@ public interface JetStubElementTypes { JetPlaceHolderStubElementType FUNCTION_TYPE = new JetPlaceHolderStubElementType("FUNCTION_TYPE", JetFunctionType.class); + + JetTypeProjectionElementType TYPE_PROJECTION = new JetTypeProjectionElementType("TYPE_PROJECTION"); + JetPlaceHolderStubElementType FUNCTION_TYPE_RECEIVER = new JetPlaceHolderStubElementType("FUNCTION_TYPE_RECEIVER", JetFunctionTypeReceiver.class); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetTypeProjectionElementType.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetTypeProjectionElementType.java new file mode 100644 index 00000000000..87c57ac35d3 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetTypeProjectionElementType.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010-2014 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.stubs.elements; + +import com.intellij.psi.stubs.StubElement; +import com.intellij.psi.stubs.StubInputStream; +import com.intellij.psi.stubs.StubOutputStream; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetTypeProjection; +import org.jetbrains.jet.lang.psi.stubs.PsiJetTypeProjectionStub; +import org.jetbrains.jet.lang.psi.stubs.impl.PsiJetTypeProjectionStubImpl; + +import java.io.IOException; + +public class JetTypeProjectionElementType extends JetStubElementType { + public JetTypeProjectionElementType(@NotNull @NonNls String debugName) { + super(debugName, JetTypeProjection.class, PsiJetTypeProjectionStub.class); + } + + @Override + public PsiJetTypeProjectionStub createStub(@NotNull JetTypeProjection psi, StubElement parentStub) { + return new PsiJetTypeProjectionStubImpl(parentStub, psi.getProjectionKind().ordinal()); + } + + @Override + public void serialize(@NotNull PsiJetTypeProjectionStub stub, @NotNull StubOutputStream dataStream) throws IOException { + dataStream.writeVarInt(stub.getProjectionKind().ordinal()); + } + + @NotNull + @Override + public PsiJetTypeProjectionStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { + int projectionKindOrdinal = dataStream.readVarInt(); + return new PsiJetTypeProjectionStubImpl(parentStub, projectionKindOrdinal); + } +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetTypeProjectionStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetTypeProjectionStubImpl.java new file mode 100644 index 00000000000..3cd51bffee3 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetTypeProjectionStubImpl.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2014 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.stubs.impl; + +import com.intellij.psi.stubs.StubBase; +import com.intellij.psi.stubs.StubElement; +import org.jetbrains.jet.lang.psi.JetProjectionKind; +import org.jetbrains.jet.lang.psi.JetTypeProjection; +import org.jetbrains.jet.lang.psi.stubs.PsiJetTypeProjectionStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; + +public class PsiJetTypeProjectionStubImpl extends StubBase implements PsiJetTypeProjectionStub { + + private final int projectionKindOrdinal; + + public PsiJetTypeProjectionStubImpl(StubElement parent, int projectionKindOrdinal) { + super(parent, JetStubElementTypes.TYPE_PROJECTION); + this.projectionKindOrdinal = projectionKindOrdinal; + } + + @Override + public JetProjectionKind getProjectionKind() { + return JetProjectionKind.values()[projectionKindOrdinal]; + } +}