Minor: fix nullability warnings and extract method
This commit is contained in:
+35
-31
@@ -44,7 +44,7 @@ import java.util.List;
|
||||
public class IdeStubIndexService extends StubIndexService {
|
||||
|
||||
@Override
|
||||
public void indexFile(KotlinFileStub stub, IndexSink sink) {
|
||||
public void indexFile(@NotNull KotlinFileStub stub, @NotNull IndexSink sink) {
|
||||
FqName packageFqName = stub.getPackageFqName();
|
||||
|
||||
sink.occurrence(KotlinExactPackagesIndex.getInstance().getKey(), packageFqName.asString());
|
||||
@@ -70,27 +70,15 @@ public class IdeStubIndexService extends StubIndexService {
|
||||
if (partSimpleName == null) {
|
||||
continue;
|
||||
}
|
||||
FqName multifileClassPartFqName = packageFqName.child(Name.identifier(partSimpleName));
|
||||
sink.occurrence(KotlinMultifileClassPartIndex.INSTANCE.getKey(), multifileClassPartFqName.asString());
|
||||
FqName multiFileClassPartFqName = packageFqName.child(Name.identifier(partSimpleName));
|
||||
sink.occurrence(KotlinMultifileClassPartIndex.INSTANCE.getKey(), multiFileClassPartFqName.asString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void indexClass(KotlinClassStub stub, IndexSink sink) {
|
||||
String name = stub.getName();
|
||||
if (name != null) {
|
||||
sink.occurrence(KotlinClassShortNameIndex.getInstance().getKey(), name);
|
||||
}
|
||||
|
||||
FqName fqName = stub.getFqName();
|
||||
if (fqName != null) {
|
||||
sink.occurrence(KotlinFullClassNameIndex.getInstance().getKey(), fqName.asString());
|
||||
|
||||
if (stub.isTopLevel()) {
|
||||
sink.occurrence(KotlinTopLevelClassByPackageIndex.getInstance().getKey(), fqName.parent().asString());
|
||||
}
|
||||
}
|
||||
public void indexClass(@NotNull KotlinClassStub stub, @NotNull IndexSink sink) {
|
||||
processNames(sink, stub.getName(), stub.getFqName(), stub.isTopLevel());
|
||||
|
||||
if (stub.isInterface()) {
|
||||
sink.occurrence(KotlinClassShortNameIndex.getInstance().getKey(), JvmAbi.DEFAULT_IMPLS_CLASS_NAME);
|
||||
@@ -100,22 +88,28 @@ public class IdeStubIndexService extends StubIndexService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void indexObject(KotlinObjectStub stub, IndexSink sink) {
|
||||
String name = stub.getName();
|
||||
if (name != null) {
|
||||
sink.occurrence(KotlinClassShortNameIndex.getInstance().getKey(), name);
|
||||
public void indexObject(@NotNull KotlinObjectStub stub, @NotNull IndexSink sink) {
|
||||
processNames(sink, stub.getName(), stub.getFqName(), stub.isTopLevel());
|
||||
|
||||
indexSuperNames(stub, sink);
|
||||
}
|
||||
|
||||
private static void processNames(
|
||||
@NotNull IndexSink sink,
|
||||
String shortName,
|
||||
FqName fqName,
|
||||
boolean level) {
|
||||
if (shortName != null) {
|
||||
sink.occurrence(KotlinClassShortNameIndex.getInstance().getKey(), shortName);
|
||||
}
|
||||
|
||||
FqName fqName = stub.getFqName();
|
||||
if (fqName != null) {
|
||||
sink.occurrence(KotlinFullClassNameIndex.getInstance().getKey(), fqName.asString());
|
||||
|
||||
if (stub.isTopLevel()) {
|
||||
if (level) {
|
||||
sink.occurrence(KotlinTopLevelClassByPackageIndex.getInstance().getKey(), fqName.parent().asString());
|
||||
}
|
||||
}
|
||||
|
||||
indexSuperNames(stub, sink);
|
||||
}
|
||||
|
||||
private static void indexSuperNames(KotlinClassOrObjectStub<? extends KtClassOrObject> stub, IndexSink sink) {
|
||||
@@ -138,6 +132,9 @@ public class IdeStubIndexService extends StubIndexService {
|
||||
}
|
||||
}
|
||||
|
||||
// Drop suppression and fix warning after abandoning 173 branch
|
||||
// BUNCH: 173
|
||||
@SuppressWarnings({"ConstantConditions", "CastCanBeRemovedNarrowingVariableType"})
|
||||
@Nullable
|
||||
private static KotlinModifierListStub getModifierListStub(@NotNull KotlinClassOrObjectStub<? extends KtClassOrObject> stub) {
|
||||
StubElement<?> childStub = stub.findChildStubByType(KtStubElementTypes.MODIFIER_LIST);
|
||||
@@ -148,7 +145,7 @@ public class IdeStubIndexService extends StubIndexService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void indexFunction(KotlinFunctionStub stub, IndexSink sink) {
|
||||
public void indexFunction(@NotNull KotlinFunctionStub stub, @NotNull IndexSink sink) {
|
||||
String name = stub.getName();
|
||||
if (name != null) {
|
||||
sink.occurrence(KotlinFunctionShortNameIndex.getInstance().getKey(), name);
|
||||
@@ -176,7 +173,7 @@ public class IdeStubIndexService extends StubIndexService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void indexTypeAlias(KotlinTypeAliasStub stub, IndexSink sink) {
|
||||
public void indexTypeAlias(@NotNull KotlinTypeAliasStub stub, @NotNull IndexSink sink) {
|
||||
String name = stub.getName();
|
||||
if (name != null) {
|
||||
sink.occurrence(KotlinTypeAliasShortNameIndex.getInstance().getKey(), name);
|
||||
@@ -194,7 +191,7 @@ public class IdeStubIndexService extends StubIndexService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void indexProperty(KotlinPropertyStub stub, IndexSink sink) {
|
||||
public void indexProperty(@NotNull KotlinPropertyStub stub, @NotNull IndexSink sink) {
|
||||
String name = stub.getName();
|
||||
if (name != null) {
|
||||
sink.occurrence(KotlinPropertyShortNameIndex.getInstance().getKey(), name);
|
||||
@@ -226,7 +223,7 @@ public class IdeStubIndexService extends StubIndexService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void indexAnnotation(KotlinAnnotationEntryStub stub, IndexSink sink) {
|
||||
public void indexAnnotation(@NotNull KotlinAnnotationEntryStub stub, @NotNull IndexSink sink) {
|
||||
String name = stub.getShortName();
|
||||
if (name == null) {
|
||||
return;
|
||||
@@ -237,7 +234,10 @@ public class IdeStubIndexService extends StubIndexService {
|
||||
if (fileStub != null) {
|
||||
List<KotlinImportDirectiveStub> aliasImportStubs = fileStub.findImportsByAlias(name);
|
||||
for (KotlinImportDirectiveStub importStub : aliasImportStubs) {
|
||||
sink.occurrence(KotlinAnnotationsIndex.getInstance().getKey(), importStub.getImportedFqName().shortName().asString());
|
||||
FqName importedFqName = importStub.getImportedFqName();
|
||||
if (importedFqName != null) {
|
||||
sink.occurrence(KotlinAnnotationsIndex.getInstance().getKey(), importedFqName.shortName().asString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -298,11 +298,15 @@ public class IdeStubIndexService extends StubIndexService {
|
||||
@Override
|
||||
public KotlinFileStub deserializeFileStub(@NotNull StubInputStream dataStream) throws IOException {
|
||||
StringRef packageFqNameAsString = dataStream.readName();
|
||||
if (packageFqNameAsString == null) {
|
||||
throw new IllegalStateException("Can't read package fqname from stream");
|
||||
}
|
||||
|
||||
boolean isScript = dataStream.readBoolean();
|
||||
StringRef facadeStringRef = dataStream.readName();
|
||||
StringRef partSimpleName = dataStream.readName();
|
||||
int numPartNames = dataStream.readInt();
|
||||
List<StringRef> facadePartNames = new ArrayList<StringRef>();
|
||||
List<StringRef> facadePartNames = new ArrayList<>();
|
||||
for (int i = 0; i < numPartNames; ++i) {
|
||||
StringRef partNameRef = dataStream.readName();
|
||||
facadePartNames.add(partNameRef);
|
||||
|
||||
Reference in New Issue
Block a user