mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
package view problem hightlighting speedup
This commit is contained in:
@@ -15,19 +15,24 @@
|
||||
*/
|
||||
package com.intellij.ide.projectView.impl.nodes;
|
||||
|
||||
import com.intellij.ide.projectView.RootsProvider;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiPackage;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Sep 19, 2003
|
||||
* Time: 3:51:02 PM
|
||||
*/
|
||||
public final class PackageElement implements Queryable {
|
||||
public final class PackageElement implements Queryable, RootsProvider {
|
||||
public static final DataKey<PackageElement> DATA_KEY = DataKey.create("package.element");
|
||||
|
||||
private final Module myModule;
|
||||
@@ -48,6 +53,17 @@ public final class PackageElement implements Queryable {
|
||||
return myElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<VirtualFile> getRoots() {
|
||||
Set<VirtualFile> roots= new HashSet<VirtualFile>();
|
||||
final GlobalSearchScope scopeToShow = PackageUtil.getScopeToShow(myModule.getProject(), myModule, isLibraryElement());
|
||||
final PsiDirectory[] dirs = getPackage().getDirectories(scopeToShow);
|
||||
for (PsiDirectory each : dirs) {
|
||||
roots.add(each.getVirtualFile());
|
||||
}
|
||||
return roots;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof PackageElement)) return false;
|
||||
@@ -73,6 +89,8 @@ public final class PackageElement implements Queryable {
|
||||
return myIsLibraryElement;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void putInfo(Map<String, String> info) {
|
||||
PsiPackage pkg = getPackage();
|
||||
if (pkg instanceof Queryable) {
|
||||
|
||||
@@ -51,4 +51,9 @@ public class PackageViewModuleNode extends AbstractModuleNode{
|
||||
return module != null && !module.isDisposed() &&
|
||||
(ModuleUtil.moduleContainsFile(module, file, false) || ModuleUtil.moduleContainsFile(module, file, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean someChildContainsFile(VirtualFile file) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,4 +110,9 @@ public class PackageViewProjectNode extends AbstractProjectNode {
|
||||
throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
|
||||
return createTreeNode(PackageViewModuleGroupNode.class, getProject(), moduleGroup, getSettings());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean someChildContainsFile(VirtualFile file) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,19 +20,19 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.problems.WolfTheProblemSolver;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* A node in the project view tree.
|
||||
@@ -40,7 +40,7 @@ import java.util.List;
|
||||
* @see TreeStructureProvider#modify(com.intellij.ide.util.treeView.AbstractTreeNode, java.util.Collection, com.intellij.ide.projectView.ViewSettings)
|
||||
*/
|
||||
|
||||
public abstract class ProjectViewNode <Value> extends AbstractTreeNode<Value> {
|
||||
public abstract class ProjectViewNode <Value> extends AbstractTreeNode<Value> implements RootsProvider {
|
||||
|
||||
protected static final Logger LOG = Logger.getInstance("#com.intellij.ide.projectView.ProjectViewNode");
|
||||
|
||||
@@ -123,6 +123,22 @@ public abstract class ProjectViewNode <Value> extends AbstractTreeNode<Value> {
|
||||
}
|
||||
|
||||
public boolean someChildContainsFile(final VirtualFile file) {
|
||||
VirtualFile parent = file.getParent();
|
||||
if (parent == null) return false;
|
||||
|
||||
boolean mayContain = false;
|
||||
Collection<VirtualFile> roots = getRoots();
|
||||
for (VirtualFile eachRoot : roots) {
|
||||
if (parent.equals(eachRoot.getParent())) {
|
||||
mayContain = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mayContain) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Collection<? extends AbstractTreeNode> kids = getChildren();
|
||||
for (final AbstractTreeNode kid : kids) {
|
||||
ProjectViewNode node = (ProjectViewNode)kid;
|
||||
@@ -131,6 +147,24 @@ public abstract class ProjectViewNode <Value> extends AbstractTreeNode<Value> {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Collection<VirtualFile> getRoots() {
|
||||
Value value = getValue();
|
||||
|
||||
if (value instanceof RootsProvider) {
|
||||
return ((RootsProvider)value).getRoots();
|
||||
} else if (value instanceof PsiFile) {
|
||||
PsiFile vFile = ((PsiFile)value).getContainingFile();
|
||||
if (vFile != null && vFile.getVirtualFile() != null) {
|
||||
return Collections.singleton(vFile.getVirtualFile());
|
||||
}
|
||||
} else if (value instanceof VirtualFile) {
|
||||
return Collections.singleton(((VirtualFile)value));
|
||||
}
|
||||
|
||||
return EMPTY_ROOTS;
|
||||
}
|
||||
|
||||
|
||||
protected boolean hasProblemFileBeneath() {
|
||||
if (!Registry.is("projectView.showHierarchyErrors")) return false;
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.ide.projectView;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
public interface RootsProvider {
|
||||
|
||||
Set<VirtualFile> EMPTY_ROOTS = new HashSet<VirtualFile>();
|
||||
|
||||
Collection<VirtualFile> getRoots();
|
||||
|
||||
}
|
||||
@@ -29,6 +29,9 @@ import com.intellij.pom.NavigatableWithText;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class AbstractModuleNode extends ProjectViewNode<Module> implements NavigatableWithText {
|
||||
protected AbstractModuleNode(Project project, Module module, ViewSettings viewSettings) {
|
||||
super(project, module, viewSettings);
|
||||
@@ -57,6 +60,11 @@ public abstract class AbstractModuleNode extends ProjectViewNode<Module> impleme
|
||||
return "Module";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<VirtualFile> getRoots() {
|
||||
return Arrays.asList(ModuleRootManager.getInstance(getValue()).getContentRoots());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(@NotNull VirtualFile file) {
|
||||
Module module = getValue();
|
||||
|
||||
+5
@@ -58,4 +58,9 @@ public class StructureViewModuleNode extends AbstractModuleNode {
|
||||
public boolean contains(@NotNull VirtualFile file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean someChildContainsFile(VirtualFile file) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user