Skip to content

Commit d4d8ad1

Browse files
committed
bug fix #61
1 parent 7b95dcf commit d4d8ad1

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ sourceSets {
2626
main {
2727
java.srcDirs 'gen'
2828
resources {
29-
exclude "debugger/**", "std/**"
29+
exclude "debugger/**"
3030
}
3131
}
3232
}
@@ -45,6 +45,6 @@ task copyAttachDebugger(dependsOn:["debugger:attach:windows:buildProduct"], type
4545
}
4646

4747
//buildPlugin.dependsOn(copyAttachDebugger)
48-
buildPlugin.from(fileTree(dir:"${RES_DIR}", includes:['std/**', 'debugger/**'])) {
48+
buildPlugin.from(fileTree(dir:"${RES_DIR}", includes:['debugger/**'])) {
4949
into "/${project.name}/classes/"
5050
}

src/main/java/com/tang/intellij/lua/project/LuaPredefinedLibraryProvider.kt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ package com.tang.intellij.lua.project
1818

1919
import com.intellij.openapi.vfs.VfsUtil
2020
import com.intellij.openapi.vfs.VirtualFile
21+
import com.intellij.util.PathUtil
2122
import com.intellij.util.indexing.IndexableSetContributor
23+
import com.intellij.util.io.URLUtil
2224
import com.tang.intellij.lua.psi.LuaFileUtil
2325
import java.io.File
2426

@@ -28,21 +30,19 @@ import java.io.File
2830
*/
2931
class LuaPredefinedLibraryProvider : IndexableSetContributor() {
3032

31-
/*override fun getAdditionalProjectRootsToIndex(project: Project): MutableSet<VirtualFile> {
32-
val dir = LuaFileUtil.getPluginVirtualFile("std")
33-
val file = VfsUtil.findFileByIoFile(File(dir), false)
34-
val list = mutableSetOf<VirtualFile>()
35-
list.add(file!!)
36-
return list
37-
}*/
38-
3933
private val predefined: Set<VirtualFile> by lazy {
40-
val dir = LuaFileUtil.getPluginVirtualFile("std")
41-
val file = VfsUtil.findFileByIoFile(File(dir), false)
34+
val jarPath = PathUtil.getJarPathForClass(LuaPredefinedLibraryProvider::class.java)
35+
val dir = if (jarPath.endsWith(".jar")) {
36+
VfsUtil.findFileByURL(URLUtil.getJarEntryURL(File(jarPath), "std"))
37+
} else
38+
VfsUtil.findFileByIoFile(File("$jarPath/std"), true)
39+
4240
val set = mutableSetOf<VirtualFile>()
43-
if (file != null) {
44-
file.children.forEach { it.putUserData(LuaFileUtil.PREDEFINED_KEY, true) }
45-
set.add(file)
41+
if (dir != null) {
42+
dir.children.forEach {
43+
it.putUserData(LuaFileUtil.PREDEFINED_KEY, true)
44+
}
45+
set.add(dir)
4646
}
4747
set
4848
}

0 commit comments

Comments
 (0)