Stubs for JetClassBody
This commit is contained in:
@@ -50,7 +50,7 @@ public interface JetNodeTypes {
|
|||||||
IElementType VALUE_PARAMETER_LIST = JetStubElementTypes.VALUE_PARAMETER_LIST;
|
IElementType VALUE_PARAMETER_LIST = JetStubElementTypes.VALUE_PARAMETER_LIST;
|
||||||
IElementType VALUE_PARAMETER = JetStubElementTypes.VALUE_PARAMETER;
|
IElementType VALUE_PARAMETER = JetStubElementTypes.VALUE_PARAMETER;
|
||||||
|
|
||||||
JetNodeType CLASS_BODY = new JetNodeType("CLASS_BODY", JetClassBody.class);
|
IElementType CLASS_BODY = JetStubElementTypes.CLASS_BODY;
|
||||||
JetNodeType IMPORT_LIST = new JetNodeType("IMPORT_LIST", JetImportList.class);
|
JetNodeType IMPORT_LIST = new JetNodeType("IMPORT_LIST", JetImportList.class);
|
||||||
JetNodeType IMPORT_DIRECTIVE = new JetNodeType("IMPORT_DIRECTIVE", JetImportDirective.class);
|
JetNodeType IMPORT_DIRECTIVE = new JetNodeType("IMPORT_DIRECTIVE", JetImportDirective.class);
|
||||||
JetNodeType MODIFIER_LIST = new JetNodeType("MODIFIER_LIST", JetModifierList.class);
|
JetNodeType MODIFIER_LIST = new JetNodeType("MODIFIER_LIST", JetModifierList.class);
|
||||||
|
|||||||
@@ -18,20 +18,27 @@ package org.jetbrains.jet.lang.psi;
|
|||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
import com.intellij.lang.ASTNode;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
|
import com.intellij.psi.stubs.IStubElementType;
|
||||||
|
import com.intellij.psi.stubs.StubElement;
|
||||||
import com.intellij.psi.tree.TokenSet;
|
import com.intellij.psi.tree.TokenSet;
|
||||||
import com.intellij.psi.util.PsiTreeUtil;
|
import com.intellij.psi.util.PsiTreeUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.JetNodeTypes;
|
import org.jetbrains.jet.JetNodeTypes;
|
||||||
|
import org.jetbrains.jet.lang.psi.stubs.PsiJetClassBodyStub;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class JetClassBody extends JetElementImpl implements JetDeclarationContainer {
|
public class JetClassBody extends JetElementImplStub<PsiJetClassBodyStub> implements JetDeclarationContainer {
|
||||||
public JetClassBody(@NotNull ASTNode node) {
|
public JetClassBody(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JetClassBody(@NotNull PsiJetClassBodyStub stub, @NotNull IStubElementType nodeType) {
|
||||||
|
super(stub, nodeType);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<JetDeclaration> getDeclarations() {
|
public List<JetDeclaration> getDeclarations() {
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2013 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.JetClassBody;
|
||||||
|
|
||||||
|
public interface PsiJetClassBodyStub extends StubElement<JetClassBody> {
|
||||||
|
}
|
||||||
+67
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2013 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.JetClassBody;
|
||||||
|
import org.jetbrains.jet.lang.psi.stubs.PsiJetClassBodyStub;
|
||||||
|
import org.jetbrains.jet.lang.psi.stubs.impl.PsiJetClassBodyStubImpl;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class JetClassBodyElementType extends JetStubElementType<PsiJetClassBodyStub, JetClassBody> {
|
||||||
|
public JetClassBodyElementType(@NotNull @NonNls String debugName) {
|
||||||
|
super(debugName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JetClassBody createPsiFromAst(@NotNull ASTNode node) {
|
||||||
|
return new JetClassBody(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JetClassBody createPsi(@NotNull PsiJetClassBodyStub stub) {
|
||||||
|
return new JetClassBody(stub, JetStubElementTypes.CLASS_BODY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PsiJetClassBodyStub createStub(@NotNull JetClassBody psi, StubElement parentStub) {
|
||||||
|
return new PsiJetClassBodyStubImpl(parentStub, JetStubElementTypes.CLASS_BODY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(@NotNull PsiJetClassBodyStub stub, @NotNull StubOutputStream dataStream) throws IOException {
|
||||||
|
//do nothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public PsiJetClassBodyStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
|
||||||
|
return new PsiJetClassBodyStubImpl(parentStub, JetStubElementTypes.CLASS_BODY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void indexStub(@NotNull PsiJetClassBodyStub stub, @NotNull IndexSink sink) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -31,4 +31,5 @@ public interface JetStubElementTypes {
|
|||||||
JetTypeParameterElementType TYPE_PARAMETER = new JetTypeParameterElementType("TYPE_PARAMETER");
|
JetTypeParameterElementType TYPE_PARAMETER = new JetTypeParameterElementType("TYPE_PARAMETER");
|
||||||
JetTypeParameterListElementType TYPE_PARAMETER_LIST = new JetTypeParameterListElementType("TYPE_PARAMETER_LIST");
|
JetTypeParameterListElementType TYPE_PARAMETER_LIST = new JetTypeParameterListElementType("TYPE_PARAMETER_LIST");
|
||||||
JetAnnotationElementType ANNOTATION_ENTRY = new JetAnnotationElementType("ANNOTATION_ENTRY");
|
JetAnnotationElementType ANNOTATION_ENTRY = new JetAnnotationElementType("ANNOTATION_ENTRY");
|
||||||
|
JetClassBodyElementType CLASS_BODY = new JetClassBodyElementType("CLASS_BODY");
|
||||||
}
|
}
|
||||||
|
|||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2013 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.jet.lang.psi.JetClassBody;
|
||||||
|
import org.jetbrains.jet.lang.psi.stubs.PsiJetClassBodyStub;
|
||||||
|
|
||||||
|
public class PsiJetClassBodyStubImpl extends StubBase<JetClassBody> implements PsiJetClassBodyStub {
|
||||||
|
public PsiJetClassBodyStubImpl(StubElement parent, IStubElementType elementType) {
|
||||||
|
super(parent, elementType);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -63,12 +63,13 @@ public class StubIndexServiceImpl implements StubIndexService {
|
|||||||
FqName fqName = stub.getFqName();
|
FqName fqName = stub.getFqName();
|
||||||
|
|
||||||
if (stub.isClassObject()) {
|
if (stub.isClassObject()) {
|
||||||
StubElement parentStub = stub.getParentStub();
|
StubElement parentClassStub = stub.getParentStub().getParentStub();
|
||||||
assert parentStub instanceof PsiJetStubWithFqName<?> : "Something but a class/object is a parent to class object stub: " + parentStub;
|
assert parentClassStub instanceof PsiJetStubWithFqName<?>
|
||||||
|
: "Something but a class/object is a parent to class object stub: " + parentClassStub;
|
||||||
|
|
||||||
name = JvmAbi.CLASS_OBJECT_CLASS_NAME;
|
name = JvmAbi.CLASS_OBJECT_CLASS_NAME;
|
||||||
|
|
||||||
FqName parentFqName = ((PsiJetStubWithFqName<?>) parentStub).getFqName();
|
FqName parentFqName = ((PsiJetStubWithFqName<?>) parentClassStub).getFqName();
|
||||||
if (parentFqName != null) {
|
if (parentFqName != null) {
|
||||||
fqName = parentFqName.child(Name.identifier(name));
|
fqName = parentFqName.child(Name.identifier(name));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,24 +69,28 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
|||||||
"PsiJetFileStubImpl[package=]\n" +
|
"PsiJetFileStubImpl[package=]\n" +
|
||||||
" CLASS:PsiJetClassStubImpl[name=C fqn=C superNames=[]]\n" +
|
" CLASS:PsiJetClassStubImpl[name=C fqn=C superNames=[]]\n" +
|
||||||
" TYPE_PARAMETER_LIST:PsiJetTypeParameterListStubImpl\n" +
|
" TYPE_PARAMETER_LIST:PsiJetTypeParameterListStubImpl\n" +
|
||||||
" TYPE_PARAMETER:PsiJetTypeParameterStubImpl[name=T extendText=null]\n");
|
" TYPE_PARAMETER:PsiJetTypeParameterStubImpl[name=T extendText=null]\n" +
|
||||||
|
" CLASS_BODY:PsiJetClassBodyStubImpl\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testClassObject() {
|
public void testClassObject() {
|
||||||
doBuildTest("class C { class object { fun foo() {} }}",
|
doBuildTest("class C { class object { fun foo() {} }}",
|
||||||
"PsiJetFileStubImpl[package=]\n" +
|
"PsiJetFileStubImpl[package=]\n" +
|
||||||
" CLASS:PsiJetClassStubImpl[name=C fqn=C superNames=[]]\n" +
|
" CLASS:PsiJetClassStubImpl[name=C fqn=C superNames=[]]\n" +
|
||||||
" OBJECT_DECLARATION:PsiJetObjectStubImpl[class-object name=null fqName=null superNames=[]]\n" +
|
" CLASS_BODY:PsiJetClassBodyStubImpl\n" +
|
||||||
" FUN:PsiJetFunctionStubImpl[name=foo]\n" +
|
" OBJECT_DECLARATION:PsiJetObjectStubImpl[class-object name=null fqName=null superNames=[]]\n" +
|
||||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
" CLASS_BODY:PsiJetClassBodyStubImpl\n" +
|
||||||
|
" FUN:PsiJetFunctionStubImpl[name=foo]\n" +
|
||||||
|
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFunctionInNotNamedObject() {
|
public void testFunctionInNotNamedObject() {
|
||||||
doBuildTest("object { fun testing() = 12 }",
|
doBuildTest("object { fun testing() = 12 }",
|
||||||
"PsiJetFileStubImpl[package=]\n" +
|
"PsiJetFileStubImpl[package=]\n" +
|
||||||
" OBJECT_DECLARATION:PsiJetObjectStubImpl[top name=null fqName=null superNames=[]]\n" +
|
" OBJECT_DECLARATION:PsiJetObjectStubImpl[top name=null fqName=null superNames=[]]\n" +
|
||||||
" FUN:PsiJetFunctionStubImpl[name=testing]\n" +
|
" CLASS_BODY:PsiJetClassBodyStubImpl\n" +
|
||||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
" FUN:PsiJetFunctionStubImpl[name=testing]\n" +
|
||||||
|
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFunctionParameters() {
|
public void testFunctionParameters() {
|
||||||
@@ -111,7 +115,8 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
|||||||
"}",
|
"}",
|
||||||
"PsiJetFileStubImpl[package=]\n" +
|
"PsiJetFileStubImpl[package=]\n" +
|
||||||
" CLASS:PsiJetClassStubImpl[name=More fqn=More superNames=[]]\n" +
|
" CLASS:PsiJetClassStubImpl[name=More fqn=More superNames=[]]\n" +
|
||||||
" PROPERTY:PsiJetPropertyStubImpl[val name=test typeText=Int bodyText=11]\n");
|
" CLASS_BODY:PsiJetClassBodyStubImpl\n" +
|
||||||
|
" PROPERTY:PsiJetPropertyStubImpl[val name=test typeText=Int bodyText=11]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNotStorePropertyFromInitializer() {
|
public void testNotStorePropertyFromInitializer() {
|
||||||
@@ -140,18 +145,19 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
|||||||
"PsiJetFileStubImpl[package=]\n" +
|
"PsiJetFileStubImpl[package=]\n" +
|
||||||
" CLASS:PsiJetClassStubImpl[name=Test fqn=Test superNames=[]]\n" +
|
" CLASS:PsiJetClassStubImpl[name=Test fqn=Test superNames=[]]\n" +
|
||||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n" +
|
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n" +
|
||||||
" PROPERTY:PsiJetPropertyStubImpl[val name=test typeText=null bodyText=12]\n" +
|
" CLASS_BODY:PsiJetClassBodyStubImpl\n" +
|
||||||
" FUN:PsiJetFunctionStubImpl[name=more]\n" +
|
" PROPERTY:PsiJetPropertyStubImpl[val name=test typeText=null bodyText=12]\n" +
|
||||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
" FUN:PsiJetFunctionStubImpl[name=more]\n" +
|
||||||
|
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSimpleEnumBuild() {
|
public void testSimpleEnumBuild() {
|
||||||
doBuildTest("enum class Test { First\n Second\n }",
|
doBuildTest("enum class Test { First\n Second\n }",
|
||||||
"PsiJetFileStubImpl[package=]\n" +
|
"PsiJetFileStubImpl[package=]\n" +
|
||||||
" CLASS:PsiJetClassStubImpl[enumClass name=Test fqn=Test superNames=[]]\n" +
|
" CLASS:PsiJetClassStubImpl[enumClass name=Test fqn=Test superNames=[]]\n" +
|
||||||
" ENUM_ENTRY:PsiJetClassStubImpl[enumEntry name=First fqn=Test.First superNames=[]]\n" +
|
" CLASS_BODY:PsiJetClassBodyStubImpl\n" +
|
||||||
" ENUM_ENTRY:PsiJetClassStubImpl[enumEntry name=Second fqn=Test.Second superNames=[]]\n"
|
" ENUM_ENTRY:PsiJetClassStubImpl[enumEntry name=First fqn=Test.First superNames=[]]\n" +
|
||||||
);
|
" ENUM_ENTRY:PsiJetClassStubImpl[enumEntry name=Second fqn=Test.Second superNames=[]]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAnnotationClass() {
|
public void testAnnotationClass() {
|
||||||
@@ -164,7 +170,9 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
|||||||
doBuildTest("class A { inner class B { } }",
|
doBuildTest("class A { inner class B { } }",
|
||||||
"PsiJetFileStubImpl[package=]\n" +
|
"PsiJetFileStubImpl[package=]\n" +
|
||||||
" CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]]\n" +
|
" CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]]\n" +
|
||||||
" CLASS:PsiJetClassStubImpl[inner name=B fqn=A.B superNames=[]]\n");
|
" CLASS_BODY:PsiJetClassBodyStubImpl\n" +
|
||||||
|
" CLASS:PsiJetClassStubImpl[inner name=B fqn=A.B superNames=[]]\n" +
|
||||||
|
" CLASS_BODY:PsiJetClassBodyStubImpl\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLocalClass() {
|
public void testLocalClass() {
|
||||||
@@ -192,7 +200,8 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
|||||||
"PsiJetFileStubImpl[package=]\n" +
|
"PsiJetFileStubImpl[package=]\n" +
|
||||||
" CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]]\n" +
|
" CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]]\n" +
|
||||||
" CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]]\n" +
|
" CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]]\n" +
|
||||||
" OBJECT_DECLARATION:PsiJetObjectStubImpl[top name=Test fqName=Test superNames=[AT]]\n");
|
" OBJECT_DECLARATION:PsiJetObjectStubImpl[top name=Test fqName=Test superNames=[AT]]\n" +
|
||||||
|
" CLASS_BODY:PsiJetClassBodyStubImpl\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLocalNamedObject() {
|
public void testLocalNamedObject() {
|
||||||
@@ -218,7 +227,8 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
|||||||
doBuildTest("Deprecated class Test {}",
|
doBuildTest("Deprecated class Test {}",
|
||||||
"PsiJetFileStubImpl[package=]\n" +
|
"PsiJetFileStubImpl[package=]\n" +
|
||||||
" CLASS:PsiJetClassStubImpl[name=Test fqn=Test superNames=[]]\n" +
|
" CLASS:PsiJetClassStubImpl[name=Test fqn=Test superNames=[]]\n" +
|
||||||
" ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]\n");
|
" ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]\n" +
|
||||||
|
" CLASS_BODY:PsiJetClassBodyStubImpl\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAnnotationOnFunction() {
|
public void testAnnotationOnFunction() {
|
||||||
|
|||||||
Reference in New Issue
Block a user