Stub for JetTypeParameterList element

This commit is contained in:
Nikolay Krasko
2012-06-20 15:47:14 +04:00
parent ae885827ba
commit 4b77268b21
12 changed files with 252 additions and 49 deletions
@@ -42,7 +42,7 @@ public interface JetNodeTypes {
JetNodeType ENUM_ENTRY = new JetNodeType("ENUM_ENTRY", JetEnumEntry.class);
JetNodeType ANONYMOUS_INITIALIZER = new JetNodeType("ANONYMOUS_INITIALIZER", JetClassInitializer.class);
JetNodeType TYPE_PARAMETER_LIST = new JetNodeType("TYPE_PARAMETER_LIST", JetTypeParameterList.class);
IElementType TYPE_PARAMETER_LIST = JetStubElementTypes.TYPE_PARAMETER_LIST;
IElementType TYPE_PARAMETER = JetStubElementTypes.TYPE_PARAMETER;
JetNodeType DELEGATION_SPECIFIER_LIST = new JetNodeType("DELEGATION_SPECIFIER_LIST", JetDelegationSpecifierList.class);
JetNodeType DELEGATOR_BY = new JetNodeType("DELEGATOR_BY", JetDelegatorByExpressionSpecifier.class);
@@ -16,7 +16,6 @@
package org.jetbrains.jet.lang.psi;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNameIdentifierOwner;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,7 +26,7 @@ import java.util.List;
/**
* @author max
*/
public interface JetClassOrObject extends PsiElement, PsiNameIdentifierOwner, JetDeclarationContainer {
public interface JetClassOrObject extends PsiNameIdentifierOwner, JetDeclarationContainer {
@Nullable
JetDelegationSpecifierList getDelegationSpecifierList();
@@ -16,11 +16,7 @@
package org.jetbrains.jet.lang.psi;
import com.intellij.extapi.psi.StubBasedPsiElementBase;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.StubBasedPsiElement;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.stubs.StubElement;
import org.jetbrains.annotations.NotNull;
@@ -30,7 +26,7 @@ import org.jetbrains.jet.lexer.JetToken;
/**
* @author Nikolay Krasko
*/
abstract class JetDeclarationStub<T extends StubElement> extends StubBasedPsiElementBase<T> implements JetDeclaration, StubBasedPsiElement<T> {
abstract class JetDeclarationStub<T extends StubElement> extends JetElementImplStub<T> implements JetDeclaration {
public JetDeclarationStub(@NotNull T stub, @NotNull IStubElementType nodeType) {
super(stub, nodeType);
}
@@ -49,40 +45,4 @@ abstract class JetDeclarationStub<T extends StubElement> extends StubBasedPsiEle
JetModifierList modifierList = getModifierList();
return modifierList != null && modifierList.hasModifier(modifier);
}
@Override
public String toString() {
return getNode().getElementType().toString();
}
@Override
public final void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof JetVisitorVoid) {
accept((JetVisitorVoid) visitor);
}
else {
visitor.visitElement(this);
}
}
@Override
public <D> void acceptChildren(@NotNull JetTreeVisitor<D> visitor, D data) {
PsiElement child = getFirstChild();
while (child != null) {
if (child instanceof JetElement) {
((JetElement) child).accept(visitor, data);
}
child = child.getNextSibling();
}
}
@Override
public void accept(@NotNull JetVisitorVoid visitor) {
visitor.visitJetElement(this);
}
@Override
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
return visitor.visitJetElement(this, data);
}
}
@@ -0,0 +1,84 @@
/*
* Copyright 2010-2012 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;
import com.intellij.extapi.psi.StubBasedPsiElementBase;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.StubBasedPsiElement;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.stubs.StubElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.plugin.JetLanguage;
/**
* @author Nikolay Krasko
*/
public class JetElementImplStub<T extends StubElement> extends StubBasedPsiElementBase<T>
implements JetElement, StubBasedPsiElement<T> {
public JetElementImplStub(@NotNull T stub, @NotNull IStubElementType nodeType) {
super(stub, nodeType);
}
public JetElementImplStub(@NotNull ASTNode node) {
super(node);
}
@NotNull
@Override
public Language getLanguage() {
return JetLanguage.INSTANCE;
}
@Override
public String toString() {
return getNode().getElementType().toString();
}
@Override
public final void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof JetVisitorVoid) {
accept((JetVisitorVoid) visitor);
}
else {
visitor.visitElement(this);
}
}
@Override
public <D> void acceptChildren(@NotNull JetTreeVisitor<D> visitor, D data) {
PsiElement child = getFirstChild();
while (child != null) {
if (child instanceof JetElement) {
((JetElement) child).accept(visitor, data);
}
child = child.getNextSibling();
}
}
@Override
public void accept(@NotNull JetVisitorVoid visitor) {
visitor.visitJetElement(this);
}
@Override
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
return visitor.visitJetElement(this, data);
}
}
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.psi;
import com.intellij.lang.ASTNode;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.util.ArrayFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.JetNodeTypes;
@@ -30,6 +31,15 @@ import org.jetbrains.jet.lexer.JetTokens;
* @author max
*/
public class JetTypeParameter extends JetNamedDeclarationStub<PsiJetTypeParameterStub> {
public static final JetTypeParameter[] EMPTY_ARRAY = new JetTypeParameter[0];
public static final ArrayFactory<JetTypeParameter> ARRAY_FACTORY = new ArrayFactory<JetTypeParameter>() {
@Override
public JetTypeParameter[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new JetTypeParameter[count];
}
};
public JetTypeParameter(@NotNull ASTNode node) {
super(node);
}
@@ -17,21 +17,34 @@
package org.jetbrains.jet.lang.psi;
import com.intellij.lang.ASTNode;
import com.intellij.psi.stubs.IStubElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.JetNodeTypes;
import org.jetbrains.jet.lang.psi.stubs.PsiJetTypeParameterListStub;
import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
import java.util.Arrays;
import java.util.List;
/**
* @author max
*/
public class JetTypeParameterList extends JetElementImpl {
public class JetTypeParameterList extends JetElementImplStub<PsiJetTypeParameterListStub> {
public JetTypeParameterList(@NotNull ASTNode node) {
super(node);
}
public JetTypeParameterList(@NotNull PsiJetTypeParameterListStub stub, @NotNull IStubElementType nodeType) {
super(stub, nodeType);
}
public List<JetTypeParameter> getParameters() {
return findChildrenByType(JetNodeTypes.TYPE_PARAMETER);
return Arrays.asList(getStubOrPsiChildren(JetStubElementTypes.TYPE_PARAMETER, JetTypeParameter.ARRAY_FACTORY));
}
@NotNull
@Override
public IStubElementType getElementType() {
return JetStubElementTypes.TYPE_PARAMETER_LIST;
}
@Override
@@ -0,0 +1,26 @@
/*
* Copyright 2010-2012 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.JetTypeParameterList;
/**
* @author Nikolay Krasko
*/
public interface PsiJetTypeParameterListStub extends StubElement<JetTypeParameterList> {
}
@@ -38,7 +38,7 @@ import java.io.IOException;
* @author Nikolay Krasko
*/
public class JetFileElementType extends IStubFileElementType<PsiJetFileStub> {
public static final int STUB_VERSION = 6;
public static final int STUB_VERSION = 8;
public JetFileElementType() {
super("jet.FILE", JetLanguage.INSTANCE);
@@ -26,4 +26,5 @@ public interface JetStubElementTypes {
JetFunctionElementType FUNCTION = new JetFunctionElementType("FUN");
JetTypeParameterElementType TYPE_PARAMETER = new JetTypeParameterElementType("TYPE_PARAMETER");
JetTypeParameterListElementType TYPE_PARAMETER_LIST = new JetTypeParameterListElementType("TYPE_PARAMETER_LIST");
}
@@ -0,0 +1,77 @@
/*
* Copyright 2010-2012 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.lang.LighterAST;
import com.intellij.lang.LighterASTNode;
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.JetTypeParameterList;
import org.jetbrains.jet.lang.psi.stubs.PsiJetTypeParameterListStub;
import org.jetbrains.jet.lang.psi.stubs.impl.PsiJetTypeParameterListStubImpl;
import java.io.IOException;
/**
* @author Nikolay Krasko
*/
public class JetTypeParameterListElementType extends JetStubElementType<PsiJetTypeParameterListStub, JetTypeParameterList> {
public JetTypeParameterListElementType(@NotNull @NonNls String debugName) {
super(debugName);
}
@Override
public JetTypeParameterList createPsiFromAst(@NotNull ASTNode node) {
return new JetTypeParameterList(node);
}
@Override
public PsiJetTypeParameterListStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
return null;
}
@Override
public JetTypeParameterList createPsi(@NotNull PsiJetTypeParameterListStub stub) {
return new JetTypeParameterList(stub, JetStubElementTypes.TYPE_PARAMETER_LIST);
}
@Override
public PsiJetTypeParameterListStub createStub(@NotNull JetTypeParameterList psi, StubElement parentStub) {
return new PsiJetTypeParameterListStubImpl(JetStubElementTypes.TYPE_PARAMETER_LIST, parentStub);
}
@Override
public void serialize(PsiJetTypeParameterListStub stub, StubOutputStream dataStream) throws IOException {
// Do nothing
}
@Override
public PsiJetTypeParameterListStub deserialize(StubInputStream dataStream, StubElement parentStub) throws IOException {
return new PsiJetTypeParameterListStubImpl(JetStubElementTypes.TYPE_PARAMETER_LIST, parentStub);
}
@Override
public void indexStub(PsiJetTypeParameterListStub stub, IndexSink sink) {
// No index
}
}
@@ -0,0 +1,33 @@
/*
* Copyright 2010-2012 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.IStubElementType;
import com.intellij.psi.stubs.StubBase;
import com.intellij.psi.stubs.StubElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetTypeParameterList;
import org.jetbrains.jet.lang.psi.stubs.PsiJetTypeParameterListStub;
/**
* @author Nikolay Krasko
*/
public class PsiJetTypeParameterListStubImpl extends StubBase<JetTypeParameterList> implements PsiJetTypeParameterListStub {
public PsiJetTypeParameterListStubImpl(@NotNull IStubElementType elementType, final StubElement parent) {
super(parent, elementType);
}
}
@@ -57,7 +57,7 @@ public class JetGotoClassContributor implements GotoClassContributor {
final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
PsiClass[] classes = JetCacheManager.getInstance(project).getNamesCache().getClassesByName(name, scope);
HashSet<String> javaQualifiedNames = new HashSet<String>();
Collection<String> javaQualifiedNames = new HashSet<String>();
for (PsiClass aClass : classes) {
String qualifiedName = aClass.getQualifiedName();