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 = 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_DIRECTIVE = new JetNodeType("IMPORT_DIRECTIVE", JetImportDirective.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.psi.PsiElement;
|
||||
import com.intellij.psi.stubs.IStubElementType;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.lang.psi.stubs.PsiJetClassBodyStub;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JetClassBody extends JetElementImpl implements JetDeclarationContainer {
|
||||
public class JetClassBody extends JetElementImplStub<PsiJetClassBodyStub> implements JetDeclarationContainer {
|
||||
public JetClassBody(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
public JetClassBody(@NotNull PsiJetClassBodyStub stub, @NotNull IStubElementType nodeType) {
|
||||
super(stub, nodeType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
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");
|
||||
JetTypeParameterListElementType TYPE_PARAMETER_LIST = new JetTypeParameterListElementType("TYPE_PARAMETER_LIST");
|
||||
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();
|
||||
|
||||
if (stub.isClassObject()) {
|
||||
StubElement parentStub = stub.getParentStub();
|
||||
assert parentStub instanceof PsiJetStubWithFqName<?> : "Something but a class/object is a parent to class object stub: " + parentStub;
|
||||
StubElement parentClassStub = stub.getParentStub().getParentStub();
|
||||
assert parentClassStub instanceof PsiJetStubWithFqName<?>
|
||||
: "Something but a class/object is a parent to class object stub: " + parentClassStub;
|
||||
|
||||
name = JvmAbi.CLASS_OBJECT_CLASS_NAME;
|
||||
|
||||
FqName parentFqName = ((PsiJetStubWithFqName<?>) parentStub).getFqName();
|
||||
FqName parentFqName = ((PsiJetStubWithFqName<?>) parentClassStub).getFqName();
|
||||
if (parentFqName != null) {
|
||||
fqName = parentFqName.child(Name.identifier(name));
|
||||
}
|
||||
|
||||
@@ -69,24 +69,28 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" CLASS:PsiJetClassStubImpl[name=C fqn=C superNames=[]]\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() {
|
||||
doBuildTest("class C { class object { fun foo() {} }}",
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" CLASS:PsiJetClassStubImpl[name=C fqn=C superNames=[]]\n" +
|
||||
" OBJECT_DECLARATION:PsiJetObjectStubImpl[class-object name=null fqName=null superNames=[]]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[name=foo]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
||||
" CLASS_BODY:PsiJetClassBodyStubImpl\n" +
|
||||
" OBJECT_DECLARATION:PsiJetObjectStubImpl[class-object name=null fqName=null superNames=[]]\n" +
|
||||
" CLASS_BODY:PsiJetClassBodyStubImpl\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[name=foo]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
||||
}
|
||||
|
||||
public void testFunctionInNotNamedObject() {
|
||||
doBuildTest("object { fun testing() = 12 }",
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" OBJECT_DECLARATION:PsiJetObjectStubImpl[top name=null fqName=null superNames=[]]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[name=testing]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
||||
" CLASS_BODY:PsiJetClassBodyStubImpl\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[name=testing]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
||||
}
|
||||
|
||||
public void testFunctionParameters() {
|
||||
@@ -111,7 +115,8 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
"}",
|
||||
"PsiJetFileStubImpl[package=]\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() {
|
||||
@@ -140,18 +145,19 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" CLASS:PsiJetClassStubImpl[name=Test fqn=Test superNames=[]]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n" +
|
||||
" PROPERTY:PsiJetPropertyStubImpl[val name=test typeText=null bodyText=12]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[name=more]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
||||
" CLASS_BODY:PsiJetClassBodyStubImpl\n" +
|
||||
" PROPERTY:PsiJetPropertyStubImpl[val name=test typeText=null bodyText=12]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[name=more]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
||||
}
|
||||
|
||||
public void testSimpleEnumBuild() {
|
||||
doBuildTest("enum class Test { First\n Second\n }",
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" CLASS:PsiJetClassStubImpl[enumClass name=Test fqn=Test superNames=[]]\n" +
|
||||
" ENUM_ENTRY:PsiJetClassStubImpl[enumEntry name=First fqn=Test.First superNames=[]]\n" +
|
||||
" ENUM_ENTRY:PsiJetClassStubImpl[enumEntry name=Second fqn=Test.Second superNames=[]]\n"
|
||||
);
|
||||
" CLASS_BODY:PsiJetClassBodyStubImpl\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() {
|
||||
@@ -164,7 +170,9 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
doBuildTest("class A { inner class B { } }",
|
||||
"PsiJetFileStubImpl[package=]\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() {
|
||||
@@ -192,7 +200,8 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" CLASS:PsiJetClassStubImpl[name=A fqn=A 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() {
|
||||
@@ -218,7 +227,8 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
doBuildTest("Deprecated class Test {}",
|
||||
"PsiJetFileStubImpl[package=]\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() {
|
||||
|
||||
Reference in New Issue
Block a user