Ido Flax
06/27/2024, 5:57 PMTypeError: this.y1d_1.n is not a function
details in the thread ->Ido Flax
06/27/2024, 6:07 PMprotoOf($initializeCOROUTINE$4).ta = function () {
var suspendResult = this.ia_1;
$sm: do
try {
var tmp = this.ga_1;
switch (tmp) {
case 0:
this.ha_1 = 5;
var this_0 = Companion_getInstance_7().d1d_1;
if (KmLogging_getInstance().er_1) {
var tmp_0 = true ? this_0.jr_1 : 0;
this_0.kr(tmp_0, toString_0('Initializing vfs rast manager'));
}
this.ga_1 = 1;
suspendResult = await_0(_get_getAllFilePaths__ucd41i_0(this.x1d_1).t1c(), this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 1:
this.y1d_1 = suspendResult;
this.z1d_1 = this.y1d_1.n(); <-- error here
this.ga_1 = 2;
continue $sm;
case 2:
if (!this.z1d_1.o()) {
this.ga_1 = 4;
continue $sm;
}
this.a1e_1 = this.z1d_1.p();
var tmp_1 = this;
tmp_1.b1e_1 = this.a1e_1;
this.ga_1 = 3;
suspendResult = this.x1d_1.c1e(this.b1e_1, this);
if (suspendResult === get_COROUTINE_SUSPENDED()) {
return suspendResult;
}
continue $sm;
case 3:
this.ga_1 = 2;
continue $sm;
case 4:
return Unit_instance;
case 5:
throw this.ja_1;
}
} catch ($p) {
var e = $p;
if (this.ha_1 === 5) {
throw e;
} else {
this.ga_1 = this.ha_1;
this.ja_1 = e;
}
}
while (true);
};
corresponding kotlin code (I think):
fun interface GetAllFilePaths {
operator fun invoke(): Promise<List<String>>
}
class VfsRastManager : ProjectService {
override val project: Project by inject()
private val getAllFilePaths: GetAllFilePaths by inject()
private val getRastForPath: GetRastForPath by inject()
private val fileToRastMap = mutableMapOf<String, VirtualFile>()
operator fun get(uri: String): VirtualFile? = fileToRastMap[uri]
suspend fun fetchAndStore(path: String) {
val rast = getRastForPath(path).await()
LOG.d { "Storing rast for ${path.lastPartAfterSlash}" }
fileToRastMap[path] = VirtualFile(path, rast.asRast())
}
override suspend fun initialize() {
LOG.d { "Initializing vfs rast manager" }
getAllFilePaths().await().forEach { uri ->
fetchAndStore(uri)
}
}
...
}
where the getAllFilePaths is implemented by a TS function:
function getAllRustFiles(): Promise<string[]> {
return vscode.workspace.findFiles('**/*.rs').then(rustFileUris => {
console.debug('Getting all Rust files');
return rustFileUris.map(uri => {
console.debug(`Found Rust file: ${path.basename(uri.fsPath)}`);
return uri.toString();
});
}) as Promise<string[]>;
}
value of this.y1d_1
at runtime:
[
0:"file:///myfilepath/myfile.rs",
...//and many more
]
[[Prototype]]:Array(0)
[[Prototype]]:Object
I guess it’s trying to get the length of the array using .n()
but it doesn’t existEdoardo Luppi
06/27/2024, 6:56 PMgetAllFilePaths
is an external
Kotlin declaration?
Strange that it gets renamed to _get_getAllFilePaths__ucd41i_0
Edoardo Luppi
06/27/2024, 6:57 PMgetAllFilePaths
internally calls the TS function?Ido Flax
06/27/2024, 6:57 PMEdoardo Luppi
06/27/2024, 6:57 PMEdoardo Luppi
06/27/2024, 6:58 PMfun interface GetAllFilePaths {
operator fun invoke(): Promise<List<String>>
}
Ido Flax
06/27/2024, 7:04 PMEdoardo Luppi
06/27/2024, 7:08 PMIdo Flax
06/27/2024, 7:08 PMIdo Flax
06/27/2024, 7:08 PMEdoardo Luppi
06/27/2024, 7:09 PMIdo Flax
06/27/2024, 7:09 PMEdoardo Luppi
06/27/2024, 7:55 PMList
instead of Array
to interface with JS.