Stubs for JetTypeProjection

This commit is contained in:
Pavel V. Talanov
2014-03-31 14:09:17 +04:00
parent f9a051e71e
commit b4ec9a5d1a
6 changed files with 126 additions and 2 deletions
@@ -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);
@@ -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<PsiJetTypeProjectionStub> 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);
@@ -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<JetTypeProjection> {
JetProjectionKind getProjectionKind();
}
@@ -65,6 +65,9 @@ public interface JetStubElementTypes {
JetPlaceHolderStubElementType<JetFunctionType> FUNCTION_TYPE =
new JetPlaceHolderStubElementType<JetFunctionType>("FUNCTION_TYPE", JetFunctionType.class);
JetTypeProjectionElementType TYPE_PROJECTION = new JetTypeProjectionElementType("TYPE_PROJECTION");
JetPlaceHolderStubElementType<JetFunctionTypeReceiver> FUNCTION_TYPE_RECEIVER =
new JetPlaceHolderStubElementType<JetFunctionTypeReceiver>("FUNCTION_TYPE_RECEIVER", JetFunctionTypeReceiver.class);
@@ -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<PsiJetTypeProjectionStub, JetTypeProjection> {
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);
}
}
@@ -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<JetTypeProjection> 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];
}
}