fix tests: imported FQ name of an import directive is nullable
This commit is contained in:
@@ -66,7 +66,7 @@ public interface KotlinFunctionStub : KotlinCallableStubBase<JetNamedFunction> {
|
||||
public interface KotlinImportDirectiveStub : StubElement<JetImportDirective> {
|
||||
public fun isAbsoluteInRootPackage(): Boolean
|
||||
public fun isAllUnder(): Boolean
|
||||
public fun getImportedFqName(): FqName
|
||||
public fun getImportedFqName(): FqName?
|
||||
public fun getAliasName(): String?
|
||||
public fun isValid(): Boolean
|
||||
}
|
||||
|
||||
+5
-2
@@ -22,6 +22,7 @@ import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.psi.JetImportDirective;
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinImportDirectiveStub;
|
||||
import org.jetbrains.kotlin.psi.stubs.impl.KotlinImportDirectiveStubImpl;
|
||||
@@ -35,7 +36,8 @@ public class JetImportDirectiveElementType extends JetStubElementType<KotlinImpo
|
||||
|
||||
@Override
|
||||
public KotlinImportDirectiveStub createStub(@NotNull JetImportDirective psi, StubElement parentStub) {
|
||||
StringRef fqName = StringRef.fromString(psi.getImportedFqName().asString());
|
||||
FqName importedFqName = psi.getImportedFqName();
|
||||
StringRef fqName = StringRef.fromString(importedFqName == null ? null : importedFqName.asString());
|
||||
StringRef aliasName = StringRef.fromString(psi.getAliasName());
|
||||
return new KotlinImportDirectiveStubImpl(parentStub, psi.isAbsoluteInRootPackage(), psi.isAllUnder(),
|
||||
fqName, aliasName, psi.isValidImport());
|
||||
@@ -45,7 +47,8 @@ public class JetImportDirectiveElementType extends JetStubElementType<KotlinImpo
|
||||
public void serialize(@NotNull KotlinImportDirectiveStub stub, @NotNull StubOutputStream dataStream) throws IOException {
|
||||
dataStream.writeBoolean(stub.isAbsoluteInRootPackage());
|
||||
dataStream.writeBoolean(stub.isAllUnder());
|
||||
dataStream.writeName(stub.getImportedFqName().asString());
|
||||
FqName importedFqName = stub.getImportedFqName();
|
||||
dataStream.writeName(importedFqName != null ? importedFqName.asString() : null);
|
||||
dataStream.writeName(stub.getAliasName());
|
||||
dataStream.writeBoolean(stub.isValid());
|
||||
}
|
||||
|
||||
+7
-2
@@ -28,13 +28,18 @@ public class KotlinImportDirectiveStubImpl(
|
||||
parent: StubElement<PsiElement>,
|
||||
private val isAbsoluteInRootPackage: Boolean,
|
||||
private val isAllUnder: Boolean,
|
||||
private val importedFqName: StringRef,
|
||||
private val importedFqName: StringRef?,
|
||||
private val aliasName: StringRef?,
|
||||
private val isValid: Boolean) : KotlinStubBaseImpl<JetImportDirective>(parent, JetStubElementTypes.IMPORT_DIRECTIVE), KotlinImportDirectiveStub {
|
||||
|
||||
override fun isAbsoluteInRootPackage(): Boolean = isAbsoluteInRootPackage
|
||||
override fun isAllUnder(): Boolean = isAllUnder
|
||||
override fun getImportedFqName(): FqName = FqName(StringRef.toString(importedFqName)!!)
|
||||
|
||||
override fun getImportedFqName(): FqName? {
|
||||
val fqNameString = StringRef.toString(importedFqName)
|
||||
return if (fqNameString != null) FqName(fqNameString) else null
|
||||
}
|
||||
|
||||
override fun getAliasName(): String? = StringRef.toString(aliasName)
|
||||
override fun isValid(): Boolean = isValid
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user