Olaf Gottschalk
11/28/2025, 1:52 PMbeforeCompiling block in refineConfiguration to do some checks in the source.text - but I would need comments already removed from the code snippet... I don't want to reimplement a code parser... đPiotr KrzemiĆski
11/28/2025, 2:00 PMPiotr KrzemiĆski
11/28/2025, 2:00 PMOlaf Gottschalk
11/28/2025, 2:02 PMPiotr KrzemiĆski
11/28/2025, 2:03 PMOlaf Gottschalk
11/28/2025, 2:03 PMOlaf Gottschalk
11/28/2025, 2:05 PMjava.util.Date like this
java.
util.
Date()
This I can still find with a multiline Regex... but...
java. // boo!
util.
Date()
Is impossible to detect without starting to parse completely.Piotr KrzemiĆski
11/28/2025, 2:20 PMOlaf Gottschalk
11/28/2025, 5:05 PMilya.chernikov
12/01/2025, 9:48 AMrefineOnAnnotations. But what I'm implementing is a more generic ability to get a full AST (based on the unresolved FIR) representation in the callback. I think this should help, provided that the refactoring will not end up being blocked by some difficulties.Marc Downie
12/04/2025, 3:56 PMval cs = compiler.state.getCompilationState(compilerConfig)
val env = cs.environment
val project = env.project
val factory = PsiFileFactory.getInstance(project)
val lang = Language.findLanguageByID("kotlin")!!
val instance = factory.createFileFromText(lang, s)
instance.forEachDescendantOfType<PsiElement> { expression ->
when (expression) {
is KtCallExpression -> {
...
Where compilerConfig is the ScriptCompilationConfiguration that I use with my KJvmReplCompilerWithIdeServices
It gets you AST-like things with text ranges. It feels a bit sneaky, but it's been working for a while now.Marc Downie
12/04/2025, 3:59 PM