From abda0deac8549484f7a7eb23bccdeba458024db8 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Wed, 9 Apr 2014 16:16:59 +0400 Subject: [PATCH] Stubs for JetPropertyAccessor --- .../src/org/jetbrains/jet/JetNodeTypes.java | 2 +- .../jet/lang/psi/JetPropertyAccessor.java | 8 ++- .../psi/stubs/PsiJetPropertyAccessorStub.java | 26 +++++++++ .../JetPropertyAccessorElementType.java | 55 +++++++++++++++++++ .../stubs/elements/JetStubElementTypes.java | 2 + .../impl/PsiJetPropertyAccessorStubImpl.java | 51 +++++++++++++++++ 6 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetPropertyAccessorStub.java create mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetPropertyAccessorElementType.java create mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetPropertyAccessorStubImpl.java diff --git a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java index d9a985aaf7d..bedf24ca1c2 100644 --- a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java +++ b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java @@ -72,7 +72,7 @@ public interface JetNodeTypes { IElementType TYPE_PROJECTION = JetStubElementTypes.TYPE_PROJECTION; // TODO: review - JetNodeType PROPERTY_ACCESSOR = new JetNodeType("PROPERTY_ACCESSOR", JetPropertyAccessor.class); + IElementType PROPERTY_ACCESSOR = JetStubElementTypes.PROPERTY_ACCESSOR; JetNodeType INITIALIZER_LIST = new JetNodeType("INITIALIZER_LIST", JetInitializerList.class); IElementType THIS_CALL = JetStubElementTypes.THIS_CALL; JetNodeType THIS_CONSTRUCTOR_REFERENCE = new JetNodeType("THIS_CONSTRUCTOR_REFERENCE", JetThisReferenceExpression.class); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPropertyAccessor.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPropertyAccessor.java index 454273deb48..eedfbd6d5f2 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPropertyAccessor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPropertyAccessor.java @@ -22,17 +22,23 @@ import com.intellij.psi.util.PsiTreeUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.JetNodeTypes; +import org.jetbrains.jet.lang.psi.stubs.PsiJetPropertyAccessorStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; import org.jetbrains.jet.lexer.JetTokens; import java.util.Collections; import java.util.List; -public class JetPropertyAccessor extends JetDeclarationImpl +public class JetPropertyAccessor extends JetDeclarationStub implements JetDeclarationWithBody, JetModifierListOwner, JetWithExpressionInitializer { public JetPropertyAccessor(@NotNull ASTNode node) { super(node); } + public JetPropertyAccessor(@NotNull PsiJetPropertyAccessorStub stub) { + super(stub, JetStubElementTypes.PROPERTY_ACCESSOR); + } + @Override public R accept(@NotNull JetVisitor visitor, D data) { return visitor.visitPropertyAccessor(this, data); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetPropertyAccessorStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetPropertyAccessorStub.java new file mode 100644 index 00000000000..fba117ed5f0 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetPropertyAccessorStub.java @@ -0,0 +1,26 @@ +/* + * 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.JetPropertyAccessor; + +public interface PsiJetPropertyAccessorStub extends StubElement { + boolean isGetter(); + boolean hasBody(); + boolean hasBlockBody(); +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetPropertyAccessorElementType.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetPropertyAccessorElementType.java new file mode 100644 index 00000000000..1c8bd2dcfdc --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetPropertyAccessorElementType.java @@ -0,0 +1,55 @@ +/* + * 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.JetPropertyAccessor; +import org.jetbrains.jet.lang.psi.stubs.PsiJetPropertyAccessorStub; +import org.jetbrains.jet.lang.psi.stubs.impl.PsiJetPropertyAccessorStubImpl; + +import java.io.IOException; + +public class JetPropertyAccessorElementType extends JetStubElementType { + public JetPropertyAccessorElementType(@NotNull @NonNls String debugName) { + super(debugName, JetPropertyAccessor.class, PsiJetPropertyAccessorStub.class); + } + + @Override + public PsiJetPropertyAccessorStub createStub(@NotNull JetPropertyAccessor psi, StubElement parentStub) { + return new PsiJetPropertyAccessorStubImpl(parentStub, psi.isGetter(), psi.hasBody(), psi.hasBlockBody()); + } + + @Override + public void serialize(@NotNull PsiJetPropertyAccessorStub stub, @NotNull StubOutputStream dataStream) throws IOException { + dataStream.writeBoolean(stub.isGetter()); + dataStream.writeBoolean(stub.hasBody()); + dataStream.writeBoolean(stub.hasBlockBody()); + } + + @NotNull + @Override + public PsiJetPropertyAccessorStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { + boolean isGetter = dataStream.readBoolean(); + boolean hasBody = dataStream.readBoolean(); + boolean hasBlockBody = dataStream.readBoolean(); + return new PsiJetPropertyAccessorStubImpl(parentStub, isGetter, hasBody, hasBlockBody); + } +} 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 60ce7dddc6e..c5b6d137616 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 @@ -25,6 +25,8 @@ public interface JetStubElementTypes { JetClassElementType CLASS = new JetClassElementType("CLASS"); JetFunctionElementType FUNCTION = new JetFunctionElementType("FUN"); JetPropertyElementType PROPERTY = new JetPropertyElementType("PROPERTY"); + JetPropertyAccessorElementType PROPERTY_ACCESSOR = new JetPropertyAccessorElementType("PROPERTY_ACCESSOR"); + JetClassElementType ENUM_ENTRY = new JetClassElementType("ENUM_ENTRY"); JetObjectElementType OBJECT_DECLARATION = new JetObjectElementType("OBJECT_DECLARATION"); JetPlaceHolderStubElementType CLASS_OBJECT = diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetPropertyAccessorStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetPropertyAccessorStubImpl.java new file mode 100644 index 00000000000..22b46a7edd0 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetPropertyAccessorStubImpl.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.impl; + +import com.intellij.psi.stubs.StubBase; +import com.intellij.psi.stubs.StubElement; +import org.jetbrains.jet.lang.psi.JetPropertyAccessor; +import org.jetbrains.jet.lang.psi.stubs.PsiJetPropertyAccessorStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; + +public class PsiJetPropertyAccessorStubImpl extends StubBase implements PsiJetPropertyAccessorStub { + private final boolean isGetter; + private final boolean hasBody; + private final boolean hasBlockBody; + + public PsiJetPropertyAccessorStubImpl(StubElement parent, boolean isGetter, boolean hasBody, boolean hasBlockBody) { + super(parent, JetStubElementTypes.PROPERTY_ACCESSOR); + this.isGetter = isGetter; + this.hasBody = hasBody; + this.hasBlockBody = hasBlockBody; + } + + @Override + public boolean isGetter() { + return isGetter; + } + + @Override + public boolean hasBody() { + return hasBody; + } + + @Override + public boolean hasBlockBody() { + return hasBlockBody; + } +}