Add quickfix for unsupported typedef NSFoo Bar.
This commit is contained in:
committed by
SvyatoslavScherbina
parent
e8f97b0436
commit
ffb0d0cfcb
+27
-1
@@ -520,7 +520,17 @@ internal class NativeIndexImpl(val library: NativeLibrary) : NativeIndex() {
|
|||||||
CXCursorKind.CXCursor_ObjCInterfaceDecl ->
|
CXCursorKind.CXCursor_ObjCInterfaceDecl ->
|
||||||
ObjCObjectPointer(getObjCClassAt(declaration), nullability, getProtocols(type))
|
ObjCObjectPointer(getObjCClassAt(declaration), nullability, getProtocols(type))
|
||||||
|
|
||||||
else -> TODO(declarationKind.toString())
|
CXCursorKind.CXCursor_TypedefDecl ->
|
||||||
|
// typedef to Objective-C class itself, e.g. `typedef NSObject Object;`,
|
||||||
|
// (as opposed to `typedef NSObject* Object;`).
|
||||||
|
// Note: it is not yet represented as Kotlin `typealias`.
|
||||||
|
ObjCObjectPointer(
|
||||||
|
getObjCClassAt(getTypedefUnderlyingObjCClass(declaration)),
|
||||||
|
nullability,
|
||||||
|
getProtocols(type)
|
||||||
|
)
|
||||||
|
|
||||||
|
else -> TODO("${declarationKind.toString()} ${clang_getTypeSpelling(type).convertAndDispose()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,6 +546,22 @@ internal class NativeIndexImpl(val library: NativeLibrary) : NativeIndex() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private tailrec fun getTypedefUnderlyingObjCClass(typedefDecl: CValue<CXCursor>): CValue<CXCursor> {
|
||||||
|
assert(typedefDecl.kind == CXCursorKind.CXCursor_TypedefDecl)
|
||||||
|
val underlyingType = clang_getTypedefDeclUnderlyingType(typedefDecl)
|
||||||
|
val underlyingTypeDecl = clang_getTypeDeclaration(underlyingType)
|
||||||
|
|
||||||
|
return when (underlyingTypeDecl.kind) {
|
||||||
|
CXCursorKind.CXCursor_TypedefDecl -> getTypedefUnderlyingObjCClass(underlyingTypeDecl)
|
||||||
|
CXCursorKind.CXCursor_ObjCInterfaceDecl -> underlyingTypeDecl
|
||||||
|
else -> TODO(
|
||||||
|
"""typedef = ${getCursorSpelling(typedefDecl)}
|
||||||
|
|underlying decl kind = ${underlyingTypeDecl.kind}
|
||||||
|
|underlying = ${clang_getTypeSpelling(underlyingType).convertAndDispose()}""".trimMargin()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun getNullability(
|
private fun getNullability(
|
||||||
type: CValue<CXType>, typeAttributes: CValue<CXTypeAttributes>?
|
type: CValue<CXType>, typeAttributes: CValue<CXTypeAttributes>?
|
||||||
): ObjCPointer.Nullability {
|
): ObjCPointer.Nullability {
|
||||||
|
|||||||
@@ -5,8 +5,10 @@
|
|||||||
-(void)print:(const char*)string;
|
-(void)print:(const char*)string;
|
||||||
@end;
|
@end;
|
||||||
|
|
||||||
|
typedef NSString NSStringTypedef;
|
||||||
|
|
||||||
@interface Foo : NSObject
|
@interface Foo : NSObject
|
||||||
@property NSString* name;
|
@property NSStringTypedef* name;
|
||||||
-(void)helloWithPrinter:(id <Printer>)printer;
|
-(void)helloWithPrinter:(id <Printer>)printer;
|
||||||
@end;
|
@end;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user