diff --git a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java index 53176708714..9f5ef0875a3 100644 --- a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java +++ b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java @@ -53,8 +53,8 @@ public interface JetNodeTypes { IElementType CLASS_BODY = JetStubElementTypes.CLASS_BODY; IElementType IMPORT_LIST = JetStubElementTypes.IMPORT_LIST; IElementType IMPORT_DIRECTIVE = JetStubElementTypes.IMPORT_DIRECTIVE; - JetNodeType MODIFIER_LIST = new JetNodeType("MODIFIER_LIST", JetModifierList.class); - JetNodeType PRIMARY_CONSTRUCTOR_MODIFIER_LIST = new JetNodeType("PRIMARY_CONSTRUCTOR_MODIFIER_LIST", JetModifierList.class); + IElementType MODIFIER_LIST = JetStubElementTypes.MODIFIER_LIST; + IElementType PRIMARY_CONSTRUCTOR_MODIFIER_LIST = JetStubElementTypes.PRIMARY_CONSTRUCTOR_MODIFIER_LIST; JetNodeType ANNOTATION = new JetNodeType("ANNOTATION", JetAnnotation.class); IElementType ANNOTATION_ENTRY = JetStubElementTypes.ANNOTATION_ENTRY; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java index 0ebadcd66c5..d7c35537f8e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java @@ -376,7 +376,7 @@ public class JetParsing extends AbstractJetParsing { /* * (modifier | attribute)* */ - boolean parseModifierList(JetNodeType nodeType, boolean allowShortAnnotations) { + boolean parseModifierList(IElementType nodeType, boolean allowShortAnnotations) { return parseModifierList(nodeType, null, allowShortAnnotations); } @@ -385,7 +385,7 @@ public class JetParsing extends AbstractJetParsing { * * Feeds modifiers (not attributes) into the passed consumer, if it is not null */ - boolean parseModifierList(JetNodeType nodeType, @Nullable Consumer tokenConsumer, boolean allowShortAnnotations) { + boolean parseModifierList(IElementType nodeType, @Nullable Consumer tokenConsumer, boolean allowShortAnnotations) { PsiBuilder.Marker list = mark(); boolean empty = true; while (!eof()) { @@ -1615,7 +1615,7 @@ public class JetParsing extends AbstractJetParsing { return atGT; } - private void parseModifierListWithShortAnnotations(JetNodeType modifierList, TokenSet lookFor, TokenSet stopAt) { + private void parseModifierListWithShortAnnotations(IElementType modifierList, TokenSet lookFor, TokenSet stopAt) { int lastId = findLastBefore(lookFor, stopAt, false); createTruncatedBuilder(lastId).parseModifierList(modifierList, true); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetModifierList.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetModifierList.java index 68b81346d07..5d9ea5a2586 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetModifierList.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetModifierList.java @@ -19,9 +19,12 @@ package org.jetbrains.jet.lang.psi; import com.google.common.collect.Lists; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; +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.PsiJetModifiedListStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; import org.jetbrains.jet.lexer.JetKeywordToken; import org.jetbrains.jet.lexer.JetModifierKeywordToken; import org.jetbrains.jet.lexer.JetToken; @@ -30,11 +33,15 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class JetModifierList extends JetElementImpl { +public class JetModifierList extends JetElementImplStub { public JetModifierList(@NotNull ASTNode node) { super(node); } + public JetModifierList(@NotNull PsiJetModifiedListStub stub) { + super(stub, JetStubElementTypes.MODIFIER_LIST); + } + @Override public R accept(@NotNull JetVisitor visitor, D data) { return visitor.visitModifierList(this, data); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetModifiedListStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetModifiedListStub.java new file mode 100644 index 00000000000..b503198e898 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetModifiedListStub.java @@ -0,0 +1,23 @@ +/* + * 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.JetModifierList; + +public interface PsiJetModifiedListStub extends StubElement { +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetModifierListElementType.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetModifierListElementType.java new file mode 100644 index 00000000000..98e194ffb09 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetModifierListElementType.java @@ -0,0 +1,76 @@ +/* + * 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.lang.ASTNode; +import com.intellij.psi.stubs.IndexSink; +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.JetModifierList; +import org.jetbrains.jet.lang.psi.stubs.PsiJetModifiedListStub; +import org.jetbrains.jet.lang.psi.stubs.impl.PsiJetModifiedListStubImpl; + +import java.io.IOException; + +public class JetModifierListElementType extends JetStubElementType { + public JetModifierListElementType(@NotNull @NonNls String debugName) { + super(debugName); + } + + @Override + public JetModifierList createPsiFromAst(@NotNull ASTNode node) { + return new JetModifierList(node); + } + + @Override + public JetModifierList createPsi(@NotNull PsiJetModifiedListStub stub) { + return new JetModifierList(stub); + } + + @Override + public PsiJetModifiedListStub createStub( + @NotNull JetModifierList psi, StubElement parentStub + ) { + return new PsiJetModifiedListStubImpl(parentStub); + } + + @Override + public void serialize( + @NotNull PsiJetModifiedListStub stub, @NotNull StubOutputStream dataStream + ) throws IOException { + //TODO: + } + + @NotNull + @Override + public PsiJetModifiedListStub deserialize( + @NotNull StubInputStream dataStream, StubElement parentStub + ) throws IOException { + //TODO: + return new PsiJetModifiedListStubImpl(parentStub); + } + + @Override + public void indexStub( + @NotNull PsiJetModifiedListStub stub, @NotNull IndexSink sink + ) { + // do nothing + } +} 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 3b109820f10..cae3e037315 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 @@ -34,4 +34,7 @@ public interface JetStubElementTypes { JetClassBodyElementType CLASS_BODY = new JetClassBodyElementType("CLASS_BODY"); JetImportListElementType IMPORT_LIST = new JetImportListElementType("IMPORT_LIST"); JetImportDirectiveElementType IMPORT_DIRECTIVE = new JetImportDirectiveElementType("IMPORT_DIRECTIVE"); + + JetModifierListElementType MODIFIER_LIST = new JetModifierListElementType("MODIFIER_LIST"); + JetModifierListElementType PRIMARY_CONSTRUCTOR_MODIFIER_LIST = new JetModifierListElementType("PRIMARY_CONSTRUCTOR_MODIFIER_LIST"); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetModifiedListStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetModifiedListStubImpl.java new file mode 100644 index 00000000000..31806ac573a --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetModifiedListStubImpl.java @@ -0,0 +1,29 @@ +/* + * 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.JetModifierList; +import org.jetbrains.jet.lang.psi.stubs.PsiJetModifiedListStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; + +public class PsiJetModifiedListStubImpl extends StubBase implements PsiJetModifiedListStub { + public PsiJetModifiedListStubImpl(StubElement parent) { + super(parent, JetStubElementTypes.MODIFIER_LIST); + } +}