11package com.tang.intellij.lua.editor
22
3+ import com.cppcxy.ide.lsp.GutterInfo
34import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer
45import com.intellij.openapi.Disposable
56import com.intellij.openapi.application.ApplicationManager
@@ -20,14 +21,15 @@ import com.intellij.openapi.vfs.VirtualFileManager
2021import com.intellij.openapi.vfs.newvfs.BulkFileListener
2122import com.intellij.openapi.vfs.newvfs.events.VFileEvent
2223import com.intellij.psi.PsiManager
24+ import com.tang.intellij.lua.lang.LuaFileType
2325import com.tang.intellij.lua.psi.LuaPsiFile
2426import java.util.concurrent.ConcurrentHashMap
2527
2628/* *
2729 * Manager to handle gutter cache and trigger updates
2830 */
2931object LuaGutterCacheManager {
30- private val gutterCache = ConcurrentHashMap <String , List <com.cppcxy.ide.lsp. GutterInfo >>()
32+ private val gutterCache = ConcurrentHashMap <String , List <GutterInfo >>()
3133 private val cacheTimestamps = ConcurrentHashMap <String , Long >()
3234
3335 fun clearCache (uri : String ) {
@@ -40,11 +42,11 @@ object LuaGutterCacheManager {
4042 cacheTimestamps.clear()
4143 }
4244
43- fun getCache (uri : String ): List <com.cppcxy.ide.lsp. GutterInfo >? {
45+ fun getCache (uri : String ): List <GutterInfo >? {
4446 return gutterCache[uri]
4547 }
4648
47- fun setCache (uri : String , infos : List <com.cppcxy.ide.lsp. GutterInfo >) {
49+ fun setCache (uri : String , infos : List <GutterInfo >) {
4850 gutterCache[uri] = infos
4951 cacheTimestamps[uri] = System .currentTimeMillis()
5052 }
@@ -70,7 +72,7 @@ class LuaDocumentListener(private val project: Project) : DocumentListener {
7072 val document = event.document
7173 val file = FileDocumentManager .getInstance().getFile(document) ? : return
7274
73- if (file.extension != " lua " ) return
75+ if (file.fileType != = LuaFileType . INSTANCE ) return
7476
7577 // Clear cache immediately for instant refresh
7678 LuaGutterCacheManager .clearCache(file.url)
@@ -123,7 +125,7 @@ class LuaDocumentListener(private val project: Project) : DocumentListener {
123125 */
124126class LuaFileEditorListener (private val project : Project ) : FileEditorManagerListener {
125127 override fun fileOpened (source : FileEditorManager , file : VirtualFile ) {
126- if (file.extension == " lua " ) {
128+ if (file.fileType == = LuaFileType . INSTANCE ) {
127129 // Clear cache for newly opened file to ensure fresh data
128130 LuaGutterCacheManager .clearCache(file.url)
129131
@@ -167,7 +169,7 @@ class LuaGutterCacheStartupActivity : ProjectActivity {
167169 override fun after (events : List <VFileEvent >) {
168170 for (event in events) {
169171 val file = event.file
170- if (file != null && file.extension == " lua " ) {
172+ if (file != null && file.fileType == = LuaFileType . INSTANCE ) {
171173 // Clear cache when file changes externally
172174 LuaGutterCacheManager .clearCache(file.url)
173175
0 commit comments