Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
47d96d10
Commit
47d96d10
authored
6 years ago
by
Dmitry Trofimov
Committed by
Mikhail Golubev
6 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Filter should accept roots
parent
21c65b39
Branches unavailable
Tags unavailable
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
+4
-19
...pl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
platform/lang-impl/src/com/intellij/util/indexing/IndexLibraryManager.kt
+28
-5
...mpl/src/com/intellij/util/indexing/IndexLibraryManager.kt
with
32 additions
and
24 deletions
+32
-24
platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
+
4
-
19
View file @
47d96d10
...
...
@@ -3,7 +3,6 @@
package
com.intellij.util.indexing
;
import
com.google.common.annotations.VisibleForTesting
;
import
com.google.common.collect.Lists
;
import
com.intellij.AppTopics
;
import
com.intellij.history.LocalHistory
;
import
com.intellij.ide.plugins.PluginManager
;
...
...
@@ -38,7 +37,10 @@ import com.intellij.openapi.util.*;
import
com.intellij.openapi.util.io.FileUtil
;
import
com.intellij.openapi.util.registry.Registry
;
import
com.intellij.openapi.util.text.StringUtil
;
import
com.intellij.openapi.vfs.*
;
import
com.intellij.openapi.vfs.LocalFileSystem
;
import
com.intellij.openapi.vfs.VirtualFile
;
import
com.intellij.openapi.vfs.VirtualFileManager
;
import
com.intellij.openapi.vfs.VirtualFileWithId
;
import
com.intellij.openapi.vfs.newvfs.ManagingFS
;
import
com.intellij.openapi.vfs.newvfs.NewVirtualFile
;
import
com.intellij.openapi.vfs.newvfs.events.VFileEvent
;
...
...
@@ -95,8 +97,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import
java.util.function.Predicate
;
import
java.util.stream.Stream
;
import
static
com
.
intellij
.
util
.
FileContentUtilCore
.
reparseFiles
;
/**
* @author Eugene Zhuravlev
*/
...
...
@@ -280,21 +280,6 @@ public class FileBasedIndexImpl extends FileBasedIndex implements BaseComponent,
}
}
//TODO: move to a better place
public
void
forceReindex
(
VirtualFile
file
)
{
List
<
VirtualFile
>
filesToReindex
=
Lists
.
newArrayList
();
VfsUtilCore
.
visitChildrenRecursively
(
file
,
new
VirtualFileVisitor
()
{
@Override
public
boolean
visitFile
(
@NotNull
VirtualFile
file
)
{
filesToReindex
.
add
(
file
);
return
true
;
}
});
reparseFiles
(
filesToReindex
);
}
boolean
processChangedFiles
(
@NotNull
Project
project
,
@NotNull
Processor
<?
super
VirtualFile
>
processor
)
{
// avoid missing files when events are processed concurrently
return
Stream
.
concat
(
myChangedFilesCollector
.
myVfsEventsMerger
.
getChangedFiles
(),
...
...
This diff is collapsed.
Click to expand it.
platform/lang-impl/src/com/intellij/util/indexing/IndexLibraryManager.kt
+
28
-
5
View file @
47d96d10
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package
com.intellij.util.indexing
import
com.intellij.openapi.application.ApplicationManager
import
com.intellij.openapi.components.ProjectComponent
import
com.intellij.openapi.module.ModuleManager
import
com.intellij.openapi.project.Project
import
com.intellij.openapi.project.ProjectManager
import
com.intellij.openapi.roots.
ProjectFileIndex
import
com.intellij.openapi.roots.ProjectRootManager
import
com.intellij.openapi.roots.
*
import
com.intellij.openapi.roots.
ex.
ProjectRootManager
Ex
import
com.intellij.openapi.vfs.VfsUtil
import
com.intellij.openapi.vfs.VirtualFile
...
...
@@ -14,6 +16,7 @@ class IndexLibraryManager(val project: Project) : ProjectComponent {
val
rootsToIndex
=
HashSet
<
VirtualFile
>()
fun
updateNames
(
names
:
Collection
<
String
>)
{
var
flag
=
false
for
(
name
in
names
)
{
if
(!
nameSet
.
contains
(
name
))
{
...
...
@@ -23,16 +26,20 @@ class IndexLibraryManager(val project: Project) : ProjectComponent {
val
libFile
=
canonicalFile
.
findChild
(
name
)
if
(
libFile
!=
null
)
{
rootsToIndex
.
add
(
libFile
)
(
FileBasedIndex
.
getInstance
()
as
FileBasedIndexImpl
).
forceReindex
(
libFile
)
flag
=
true
}
}
}
}
}
nameSet
.
clear
()
nameSet
.
addAll
(
names
)
if
(
flag
)
{
ApplicationManager
.
getApplication
().
invokeLater
{
ProjectRootManagerEx
.
getInstanceEx
(
project
).
makeRootsChange
({},
false
,
true
)
}
}
}
fun
isUnusedLibrary
(
file
:
VirtualFile
):
Boolean
{
...
...
@@ -40,6 +47,22 @@ class IndexLibraryManager(val project: Project) : ProjectComponent {
return
false
}
for
(
module
in
ModuleManager
.
getInstance
(
project
).
modules
)
{
val
orderEntries
=
ModuleRootManager
.
getInstance
(
module
).
orderEntries
for
(
orderEntry
in
orderEntries
)
{
if
(
orderEntry
is
LibraryOrSdkOrderEntry
)
{
if
(
orderEntry
.
isValid
())
{
for
(
root
in
orderEntry
.
getRootFiles
(
OrderRootType
.
SOURCES
)
+
orderEntry
.
getRootFiles
(
OrderRootType
.
CLASSES
))
{
if
(
root
==
file
)
{
return
false
}
}
}
}
}
}
for
(
root
in
rootsToIndex
)
{
if
(
VfsUtil
.
isAncestor
(
root
,
file
,
false
))
{
return
false
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help