diff --git a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java index c9f11020120..acb819dba22 100644 --- a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java +++ b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java @@ -64,8 +64,7 @@ public interface JetNodeTypes { JetNodeType VALUE_ARGUMENT_NAME = new JetNodeType("VALUE_ARGUMENT_NAME", JetValueArgumentName.class); IElementType TYPE_REFERENCE = JetStubElementTypes.TYPE_REFERENCE; - JetNodeType USER_TYPE = new JetNodeType("USER_TYPE", JetUserType.class); - + IElementType USER_TYPE = JetStubElementTypes.USER_TYPE; JetNodeType FUNCTION_TYPE = new JetNodeType("FUNCTION_TYPE", JetFunctionType.class); JetNodeType FUNCTION_TYPE_RECEIVER = new JetNodeType("FUNCTION_TYPE_RECEIVER", JetFunctionTypeReceiver.class); JetNodeType SELF_TYPE = new JetNodeType("SELF_TYPE", JetSelfType.class); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetUserType.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetUserType.java index 0991d75cf6b..8160b9fc252 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetUserType.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetUserType.java @@ -18,19 +18,26 @@ package org.jetbrains.jet.lang.psi; import com.google.common.collect.Lists; import com.intellij.lang.ASTNode; +import com.intellij.psi.stubs.IStubElementType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.JetNodeTypes; +import org.jetbrains.jet.lang.psi.stubs.PsiJetUserTypeStub; +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 JetUserType extends JetElementImpl implements JetTypeElement { +public class JetUserType extends JetElementImplStub implements JetTypeElement { public JetUserType(@NotNull ASTNode node) { super(node); } + public JetUserType(@NotNull PsiJetUserTypeStub stub) { + super(stub, JetStubElementTypes.USER_TYPE); + } + public boolean isAbsoluteInRootPackage() { return findChildByType(JetTokens.PACKAGE_KEYWORD) != null; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetUserTypeStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetUserTypeStub.java new file mode 100644 index 00000000000..e15759cc793 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetUserTypeStub.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.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetUserType; +import org.jetbrains.jet.lang.resolve.name.Name; + +public interface PsiJetUserTypeStub extends StubElement { + boolean isAbsoluteInRootPackage(); +} 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 d59d74e1d52..5166dbd19a8 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 @@ -53,7 +53,9 @@ public interface JetStubElementTypes { JetPlaceHolderStubElementType NULLABLE_TYPE = new JetPlaceHolderStubElementType("NULLABLE_TYPE", JetNullableType.class); - + JetPlaceHolderStubElementType TYPE_REFERENCE = new JetPlaceHolderStubElementType("TYPE_REFERENCE", JetTypeReference.class);; + + JetUserTypeElementType USER_TYPE = new JetUserTypeElementType("USER_TYPE"); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetUserTypeElementType.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetUserTypeElementType.java new file mode 100644 index 00000000000..3db33a91d9d --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetUserTypeElementType.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.JetUserType; +import org.jetbrains.jet.lang.psi.stubs.PsiJetUserTypeStub; +import org.jetbrains.jet.lang.psi.stubs.impl.PsiJetUserTypeStubImpl; + +import java.io.IOException; + +public class JetUserTypeElementType extends JetStubElementType { + public JetUserTypeElementType(@NotNull @NonNls String debugName) { + super(debugName, JetUserType.class, PsiJetUserTypeStub.class); + } + + @Override + public PsiJetUserTypeStub createStub(@NotNull JetUserType psi, StubElement parentStub) { + return new PsiJetUserTypeStubImpl(parentStub, psi.isAbsoluteInRootPackage()); + } + + @Override + public void serialize(@NotNull PsiJetUserTypeStub stub, @NotNull StubOutputStream dataStream) throws IOException { + dataStream.writeBoolean(stub.isAbsoluteInRootPackage()); + } + + @NotNull + @Override + public PsiJetUserTypeStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { + boolean isAbsoluteInRootPackage = dataStream.readBoolean(); + return new PsiJetUserTypeStubImpl(parentStub, isAbsoluteInRootPackage); + } +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetUserTypeStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetUserTypeStubImpl.java new file mode 100644 index 00000000000..6ce6494daea --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetUserTypeStubImpl.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.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetUserType; +import org.jetbrains.jet.lang.psi.stubs.PsiJetUserTypeStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; +import org.jetbrains.jet.lang.resolve.name.Name; + +public class PsiJetUserTypeStubImpl extends StubBase implements PsiJetUserTypeStub { + private final boolean isAbsoluteInRootPackage; + + public PsiJetUserTypeStubImpl(StubElement parent, boolean isAbsoluteInRootPackage) { + super(parent, JetStubElementTypes.USER_TYPE); + this.isAbsoluteInRootPackage = isAbsoluteInRootPackage; + } + + @Override + public boolean isAbsoluteInRootPackage() { + return isAbsoluteInRootPackage; + } +}