Stubs for JetModifierList

This commit is contained in:
Pavel V. Talanov
2014-03-20 14:18:00 +04:00
parent 78c1717eed
commit 97d19d4b16
7 changed files with 144 additions and 6 deletions
@@ -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;
@@ -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<IElementType> tokenConsumer, boolean allowShortAnnotations) {
boolean parseModifierList(IElementType nodeType, @Nullable Consumer<IElementType> 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);
}
@@ -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<PsiJetModifiedListStub> {
public JetModifierList(@NotNull ASTNode node) {
super(node);
}
public JetModifierList(@NotNull PsiJetModifiedListStub stub) {
super(stub, JetStubElementTypes.MODIFIER_LIST);
}
@Override
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
return visitor.visitModifierList(this, data);
@@ -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<JetModifierList> {
}
@@ -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<PsiJetModifiedListStub, JetModifierList> {
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
}
}
@@ -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");
}
@@ -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<JetModifierList> implements PsiJetModifiedListStub {
public PsiJetModifiedListStubImpl(StubElement parent) {
super(parent, JetStubElementTypes.MODIFIER_LIST);
}
}