PsiJetStubWithFqName interface extracted

This commit is contained in:
Andrey Breslav
2013-02-15 17:50:13 +04:00
parent 179456cd0b
commit bf62bc0261
11 changed files with 53 additions and 29 deletions
@@ -30,6 +30,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.JetNodeTypes;
import org.jetbrains.jet.lang.psi.stubs.PsiJetClassStub;
import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lexer.JetTokens;
import java.util.ArrayList;
@@ -197,7 +198,8 @@ public class JetClass extends JetTypeParameterListOwnerStub<PsiJetClassStub> imp
private String getQualifiedName() {
PsiJetClassStub stub = getStub();
if (stub != null) {
return stub.getQualifiedName();
FqName fqName = stub.getFqName();
return fqName == null ? null : fqName.getFqName();
}
List<String> parts = new ArrayList<String>();
@@ -66,7 +66,7 @@ public class JetObjectDeclaration extends JetNamedDeclarationStub<PsiJetObjectSt
public FqName getFqName() {
PsiJetObjectStub stub = getStub();
if (stub != null) {
return stub.getFQName();
return stub.getFqName();
}
return JetPsiUtil.getFQName(this);
@@ -16,18 +16,12 @@
package org.jetbrains.jet.lang.psi.stubs;
import com.intellij.psi.stubs.NamedStub;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.psi.JetClass;
import java.util.List;
public interface PsiJetClassStub extends NamedStub<JetClass> {
@NonNls
@Nullable
String getQualifiedName();
public interface PsiJetClassStub extends PsiJetStubWithFqName<JetClass> {
boolean isTrait();
@@ -16,14 +16,9 @@
package org.jetbrains.jet.lang.psi.stubs;
import com.intellij.psi.stubs.NamedStub;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
import org.jetbrains.jet.lang.resolve.name.FqName;
public interface PsiJetObjectStub extends NamedStub<JetObjectDeclaration> {
@Nullable
FqName getFQName();
public interface PsiJetObjectStub extends PsiJetStubWithFqName<JetObjectDeclaration> {
boolean isTopLevel();
boolean isClassObject();
}
@@ -0,0 +1,27 @@
/*
* 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.PsiNamedElement;
import com.intellij.psi.stubs.NamedStub;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.name.FqName;
public interface PsiJetStubWithFqName<T extends PsiNamedElement> extends NamedStub<T> {
@Nullable
FqName getFqName();
}
@@ -61,7 +61,8 @@ public class JetClassElementType extends JetStubElementType<PsiJetClassStub, Jet
@Override
public void serialize(PsiJetClassStub stub, StubOutputStream dataStream) throws IOException {
dataStream.writeName(stub.getName());
dataStream.writeName(stub.getQualifiedName());
FqName fqName = stub.getFqName();
dataStream.writeName(fqName == null ? null : fqName.getFqName());
dataStream.writeBoolean(stub.isTrait());
dataStream.writeBoolean(stub.isEnumClass());
dataStream.writeBoolean(stub.isEnumEntry());
@@ -35,7 +35,7 @@ import org.jetbrains.jet.plugin.JetLanguage;
import java.io.IOException;
public class JetFileElementType extends IStubFileElementType<PsiJetFileStub> {
public static final int STUB_VERSION = 22;
public static final int STUB_VERSION = 23;
public JetFileElementType() {
super("jet.FILE", JetLanguage.INSTANCE);
@@ -71,7 +71,7 @@ public class JetObjectElementType extends JetStubElementType<PsiJetObjectStub, J
@Override
public void serialize(PsiJetObjectStub stub, StubOutputStream dataStream) throws IOException {
dataStream.writeName(stub.getName());
FqName fqName = stub.getFQName();
FqName fqName = stub.getFqName();
dataStream.writeName(fqName != null ? fqName.toString() : null);
dataStream.writeBoolean(stub.isTopLevel());
dataStream.writeBoolean(stub.isClassObject());
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.psi.JetClass;
import org.jetbrains.jet.lang.psi.stubs.PsiJetClassStub;
import org.jetbrains.jet.lang.psi.stubs.elements.JetClassElementType;
import org.jetbrains.jet.lang.resolve.name.FqName;
import java.util.ArrayList;
import java.util.List;
@@ -82,8 +83,12 @@ public class PsiJetClassStubImpl extends StubBase<JetClass> implements PsiJetCla
}
@Override
public String getQualifiedName() {
return StringRef.toString(qualifiedName);
public FqName getFqName() {
String stringRef = StringRef.toString(qualifiedName);
if (stringRef == null) {
return null;
}
return new FqName(stringRef);
}
@Override
@@ -152,7 +157,7 @@ public class PsiJetClassStubImpl extends StubBase<JetClass> implements PsiJetCla
}
builder.append("name=").append(getName());
builder.append(" fqn=").append(getQualifiedName());
builder.append(" fqn=").append(getFqName());
builder.append(" superNames=").append("[").append(StringUtil.join(ArrayUtil.toStringArray(getSuperNames()))).append("]");
builder.append("]");
@@ -65,7 +65,7 @@ public class PsiJetObjectStubImpl extends StubBase<JetObjectDeclaration> impleme
@Nullable
@Override
public FqName getFQName() {
public FqName getFqName() {
return fqName;
}
@@ -48,9 +48,9 @@ public class StubIndexServiceImpl implements StubIndexService {
sink.occurrence(JetShortClassNameIndex.getInstance().getKey(), name);
}
String fqn = stub.getQualifiedName();
FqName fqn = stub.getFqName();
if (fqn != null) {
sink.occurrence(JetFullClassNameIndex.getInstance().getKey(), fqn);
sink.occurrence(JetFullClassNameIndex.getInstance().getKey(), fqn.getFqName());
}
for (String superName : stub.getSuperNames()) {
@@ -63,17 +63,17 @@ public class StubIndexServiceImpl implements StubIndexService {
@Override
public void indexObject(PsiJetObjectStub stub, IndexSink sink) {
String name = stub.getName();
FqName fqName = stub.getFQName();
FqName fqName = stub.getFqName();
if (stub.isClassObject()) {
StubElement parentStub = stub.getParentStub();
assert parentStub instanceof PsiJetClassStub : "Something but a class is a parent to class object stub: " + parentStub;
assert parentStub instanceof PsiJetStubWithFqName<?> : "Something but a class/object is a parent to class object stub: " + parentStub;
name = JvmAbi.CLASS_OBJECT_CLASS_NAME;
String qualifiedName = ((PsiJetClassStub) parentStub).getQualifiedName();
if (qualifiedName != null) {
fqName = new FqName(qualifiedName).child(Name.identifier(name));
FqName parentFqName = ((PsiJetStubWithFqName<?>) parentStub).getFqName();
if (parentFqName != null) {
fqName = parentFqName.child(Name.identifier(name));
}
}
else {