Skip to content

Commit 6f8f326

Browse files
committed
predefined std
1 parent 895e676 commit 6f8f326

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2017. tangzx([email protected])
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.tang.intellij.lua.project
18+
19+
import com.intellij.openapi.project.Project
20+
import com.intellij.openapi.vfs.VfsUtil
21+
import com.intellij.openapi.vfs.VirtualFile
22+
import com.intellij.util.indexing.IndexableSetContributor
23+
import com.tang.intellij.lua.psi.LuaFileUtil
24+
import java.io.File
25+
26+
/**
27+
*
28+
* Created by Administrator on 2017/7/5.
29+
*/
30+
class LuaPredefinedLibraryProvider : IndexableSetContributor() {
31+
32+
/*override fun getAdditionalProjectRootsToIndex(project: Project): MutableSet<VirtualFile> {
33+
val dir = LuaFileUtil.getPluginVirtualFile("std")
34+
val file = VfsUtil.findFileByIoFile(File(dir), false)
35+
val list = mutableSetOf<VirtualFile>()
36+
list.add(file!!)
37+
return list
38+
}*/
39+
40+
override fun getAdditionalRootsToIndex(): Set<VirtualFile> {
41+
val dir = LuaFileUtil.getPluginVirtualFile("std")
42+
val file = VfsUtil.findFileByIoFile(File(dir), false)
43+
val set = mutableSetOf<VirtualFile>()
44+
set.add(file!!)
45+
return set
46+
}
47+
}

src/main/java/com/tang/intellij/lua/search/SearchContext.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
import com.intellij.psi.PsiFile;
2222
import com.intellij.psi.search.GlobalSearchScope;
2323
import com.intellij.psi.search.ProjectAndLibrariesScope;
24+
import com.intellij.util.indexing.AdditionalIndexedRootsScope;
2425
import com.tang.intellij.lua.lang.GuessTypeKind;
26+
import com.tang.intellij.lua.project.LuaPredefinedLibraryProvider;
2527

2628
/**
2729
*
@@ -60,7 +62,7 @@ public GlobalSearchScope getScope() {
6062
if (isDumb()) {
6163
scope = GlobalSearchScope.EMPTY_SCOPE;
6264
} else {
63-
scope = new ProjectAndLibrariesScope(project);
65+
scope = new AdditionalIndexedRootsScope(new ProjectAndLibrariesScope(project), LuaPredefinedLibraryProvider.class);
6466
}
6567
}
6668
return scope;

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
<moduleConfigurationEditorProvider implementation="com.tang.intellij.lua.project.LuaModuleConfigurationEditorProvider"/>
8282
<sdkType implementation="com.tang.intellij.lua.project.LuaSdkType"/>
8383
<library.type implementation="com.tang.intellij.lua.project.LuaLibraryType"/>
84+
<indexedRootsProvider implementation="com.tang.intellij.lua.project.LuaPredefinedLibraryProvider"/>
8485
<!-- Add your extensions here -->
8586
<lang.foldingBuilder language="Lua" implementationClass="com.tang.intellij.lua.folding.LuaFoldingBuilder"/>
8687
<lang.braceMatcher language="Lua" implementationClass="com.tang.intellij.lua.braces.LuaBraceMatcher"/>

0 commit comments

Comments
 (0)