From dce4d259d9eae2abe052dec02a2ce79e3eb3f36a Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Mon, 7 Apr 2014 19:13:05 +0400 Subject: [PATCH] Stubs for JetTypeConstraint --- .../src/org/jetbrains/jet/JetNodeTypes.java | 2 +- .../jet/lang/psi/JetTypeConstraint.java | 9 +++- .../psi/stubs/PsiJetTypeConstraintStub.java | 24 +++++++++ .../stubs/elements/JetStubElementTypes.java | 2 + .../JetTypeConstraintElementType.java | 51 +++++++++++++++++++ .../stubs/impl/PsiJetTypeConstraintImpl.java | 37 ++++++++++++++ 6 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetTypeConstraintStub.java create mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetTypeConstraintElementType.java create mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetTypeConstraintImpl.java diff --git a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java index 2e930816423..d9a985aaf7d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java +++ b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java @@ -77,7 +77,7 @@ public interface JetNodeTypes { IElementType THIS_CALL = JetStubElementTypes.THIS_CALL; JetNodeType THIS_CONSTRUCTOR_REFERENCE = new JetNodeType("THIS_CONSTRUCTOR_REFERENCE", JetThisReferenceExpression.class); IElementType TYPE_CONSTRAINT_LIST = JetStubElementTypes.TYPE_CONSTRAINT_LIST; - JetNodeType TYPE_CONSTRAINT = new JetNodeType("TYPE_CONSTRAINT", JetTypeConstraint.class); + IElementType TYPE_CONSTRAINT = JetStubElementTypes.TYPE_CONSTRAINT; // TODO: Not sure if we need separate NT for each kind of constants JetNodeType NULL = new JetNodeType("NULL", JetConstantExpression.class); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeConstraint.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeConstraint.java index 24ecb805df2..43a6659ca5a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeConstraint.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeConstraint.java @@ -17,17 +17,24 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; +import com.intellij.psi.stubs.IStubElementType; import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.JetNodeTypes; +import org.jetbrains.jet.lang.psi.stubs.PsiJetTypeConstraintStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; import org.jetbrains.jet.lexer.JetTokens; -public class JetTypeConstraint extends JetElementImpl { +public class JetTypeConstraint extends JetElementImplStub { public JetTypeConstraint(@NotNull ASTNode node) { super(node); } + public JetTypeConstraint(@NotNull PsiJetTypeConstraintStub stub) { + super(stub, JetStubElementTypes.TYPE_CONSTRAINT); + } + @Override public R accept(@NotNull JetVisitor visitor, D data) { return visitor.visitTypeConstraint(this, data); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetTypeConstraintStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetTypeConstraintStub.java new file mode 100644 index 00000000000..80f1dda2e41 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetTypeConstraintStub.java @@ -0,0 +1,24 @@ +/* + * 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.JetTypeConstraint; + +public interface PsiJetTypeConstraintStub extends StubElement { + boolean isClassObjectConstraint(); +} 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 2478beb8e18..60ce7dddc6e 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 @@ -61,6 +61,8 @@ public interface JetStubElementTypes { JetPlaceHolderStubElementType TYPE_CONSTRAINT_LIST = new JetPlaceHolderStubElementType("TYPE_CONSTRAINT_LIST", JetTypeConstraintList.class); + JetTypeConstraintElementType TYPE_CONSTRAINT = new JetTypeConstraintElementType("TYPE_CONSTRAINT"); + JetPlaceHolderStubElementType NULLABLE_TYPE = new JetPlaceHolderStubElementType("NULLABLE_TYPE", JetNullableType.class); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetTypeConstraintElementType.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetTypeConstraintElementType.java new file mode 100644 index 00000000000..3187f758835 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetTypeConstraintElementType.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.JetTypeConstraint; +import org.jetbrains.jet.lang.psi.stubs.PsiJetTypeConstraintStub; +import org.jetbrains.jet.lang.psi.stubs.impl.PsiJetTypeConstraintImpl; + +import java.io.IOException; + +public class JetTypeConstraintElementType extends JetStubElementType { + public JetTypeConstraintElementType(@NotNull @NonNls String debugName) { + super(debugName, JetTypeConstraint.class, PsiJetTypeConstraintStub.class); + } + + @Override + public PsiJetTypeConstraintStub createStub(@NotNull JetTypeConstraint psi, StubElement parentStub) { + return new PsiJetTypeConstraintImpl(parentStub, psi.isClassObjectConstraint()); + } + + @Override + public void serialize(@NotNull PsiJetTypeConstraintStub stub, @NotNull StubOutputStream dataStream) throws IOException { + dataStream.writeBoolean(stub.isClassObjectConstraint()); + } + + @NotNull + @Override + public PsiJetTypeConstraintStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { + boolean isClassObjectConstraint = dataStream.readBoolean(); + return new PsiJetTypeConstraintImpl(parentStub, isClassObjectConstraint); + } +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetTypeConstraintImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetTypeConstraintImpl.java new file mode 100644 index 00000000000..ece3e5b3ad0 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetTypeConstraintImpl.java @@ -0,0 +1,37 @@ +/* + * 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.JetTypeConstraint; +import org.jetbrains.jet.lang.psi.stubs.PsiJetTypeConstraintStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; + +public class PsiJetTypeConstraintImpl extends StubBase implements PsiJetTypeConstraintStub { + private final boolean isClassObjectConstraint; + + public PsiJetTypeConstraintImpl(StubElement parent, boolean isClassObjectConstraint) { + super(parent, JetStubElementTypes.TYPE_CONSTRAINT); + this.isClassObjectConstraint = isClassObjectConstraint; + } + + @Override + public boolean isClassObjectConstraint() { + return isClassObjectConstraint; + } +}