I’m following JetBrains’ sample website to write a...
# intellij-plugins
j
I’m following JetBrains’ sample website to write a plugin with a
RelatedItemLineMarkerProvider
. I have registered the class in the
plugin.xml
file (as
JAVA
and
kotlin
entries) but I still do not receive calls to either on
collectNavigationMarkers
nor
getLineMarkerInfo
. What am I missing?
b
Can you post the relevant entries in your 
plugin.xml
?
b
When running your plugin, is the line marker provider failing when you're looking at a Java source file, a Kotlin source file, or both?
j
All I see when running
runIde
is a log line for the
ProjectComponent
I have set up to diagnose the issue
I cannot tell if the Line Marker Provider is picked up in either language
b
Sorry, I don't know. I just now tried extending the Custom Language Support Tutorial that I'd recently done to support Kotlin, and I can't get it to work either, although I'm getting different log messages.
d
Everything you did looks fine for me, so I went and built the plugin myself, and actually
LineMarkerProvider
is picked up fine for me: I see multiple lines like
getLineMarkerInfo PsiElement(package)
in my console (from which I’ve run the
runIde
-task) Is the issue reproducible for you on clean build?
j
Running
./gradlew clean runIde
still doesn’t spit these log lines. May I ask, which kind of project are you testing on? Java only, Kotlin only, Java/Kotlin mixed? I tried again with a (very old) mixed Java/Kotlin project and can see the log lines there. Going back to my ‘real-world’ project, they won’t show up. Maybe it is a ‘bad cache’ issue but seems like something specific about my larger Kotlin-only target project?
@dsavvinov I am not super sure what was the reason for my issue before, but maybe I wasn’t just patient enough. The log lines show up after my entire project is processed (and being a large project, that takes a minute or so).
Taking the chance for some extra support here, can I ask another question? Can you point me on to how to iterate over the file indexes filtered by file extension? I want to expose a few targets for my gutter action but believe there must be a faster way than visit every single file in the project. I’m looking specifically for
svg
png
dot
and
dbml
files so far, if that helps
Ok, I found a solution, here’s for others’ reference:
Copy code
val fileType = FileTypeManager.getInstance().getFileTypeByExtension(fileExtension)
With the `FileType`s one can do
Copy code
fileType -> FileTypeIndex.getFiles(fileType, GlobalSearchScope.projectScope(project))
to get the
VirtualFiles
associated with it.
d
Yep, that should do it 👍
j
Follow-up @dsavvinov (sorry for exploring): while writing tests for that LineMarkerProvider, for some reason the annotations in the stub files are not picked up correctly in the PSI tree. Weirdly, when attaching a debugger I see them in PSI but
getAnnotations
on the
UClass
returns an empty
array
. Here is the commit if you wanna have a deeper look: https://github.com/julioz/FloorPlan/pull/46/commits/13e4bd421a985a087e05fb1899db7745e58ca62d
d
A wild guess: can it be that
@Database
annotation (and corresponding import) are unresolved? You can easily verify it by using an annotation, which is declared right in the test-file, like this:
Copy code
annotation class MyDatabaseAnnotation

@MyDatabaseAnnotation
interface MyDatabase
Generally, I’m not familiar enough with UAST, sorry. Maybe @nicolay.mitropolsky can point you in the right direction
j
Yep, that was it. I had to fake the target package but creating a resolution path for the annotation with
Copy code
package androidx.room

annotation class Database
did the trick 👍