don't resolve from android classes to android source (IDEA-141587)

This commit is contained in:
peter
2015-07-12 23:25:21 +02:00
parent 6089157d9c
commit 93be085a46
3 changed files with 31 additions and 31 deletions
@@ -22,12 +22,9 @@ package com.intellij.psi.impl.search;
import com.intellij.ide.highlighter.JavaClassFileType;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.JdkOrderEntry;
import com.intellij.openapi.roots.OrderEntry;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.SdkResolveScopeProvider;
import com.intellij.psi.search.DelegatingGlobalSearchScope;
import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NotNull;
@@ -66,27 +63,8 @@ public class JavaSourceFilterScope extends DelegatingGlobalSearchScope {
return myIndex.isInLibraryClasses(file);
}
if (myIndex.isInSourceContent(file)) {
return true;
}
final Project project = getProject();
if (project != null) {
for (OrderEntry entry : myIndex.getOrderEntriesForFile(file)) {
if (entry instanceof JdkOrderEntry) {
final JdkOrderEntry jdkOrderEntry = (JdkOrderEntry)entry;
for (SdkResolveScopeProvider provider : SdkResolveScopeProvider.EP_NAME.getExtensions()) {
final GlobalSearchScope scope = provider.getScope(project, jdkOrderEntry);
if (scope != null && scope.contains(file)) {
return true;
}
}
}
}
}
return false;
return myIndex.isInSourceContent(file) ||
myBaseScope.isForceSearchingInLibrarySources() && myIndex.isInLibrarySource(file);
}
}
@@ -9,6 +9,8 @@ import org.jetbrains.annotations.Nullable;
/**
* @author Eugene.Kudelevsky
* @deprecated todo remove in IDEA 16
* use com.intellij.psi.ResolveScopeProvider
*/
public abstract class SdkResolveScopeProvider {
public static final ExtensionPointName<SdkResolveScopeProvider> EP_NAME =
@@ -19,28 +19,48 @@ package com.intellij.openapi.module.impl.scopes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.JdkOrderEntry;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.vfs.VirtualFile;
import java.util.Arrays;
/**
* @author max
*/
public class JdkScope extends LibraryScopeBase {
private final VirtualFile[] myClasses;
private final VirtualFile[] mySources;
private final String myJdkName;
public JdkScope(Project project, JdkOrderEntry jdk) {
super(project, jdk.getRootFiles(OrderRootType.CLASSES), jdk.getRootFiles(OrderRootType.SOURCES));
myJdkName = jdk.getJdkName();
public JdkScope(Project project, JdkOrderEntry entry) {
this(project, entry.getRootFiles(OrderRootType.CLASSES), entry.getRootFiles(OrderRootType.SOURCES), entry.getJdkName());
}
public JdkScope(Project project,
VirtualFile[] classes,
VirtualFile[] sources,
String jdkName) {
super(project, classes, sources);
myClasses = classes;
mySources = sources;
myJdkName = jdkName;
}
@Override
public int hashCode() {
return myJdkName.hashCode();
int result = Arrays.hashCode(myClasses);
result = 31 * result + Arrays.hashCode(mySources);
result = 31 * result + myJdkName.hashCode();
return result;
}
@Override
public boolean equals(Object object) {
if (object == this) return true;
if (object == null) return false;
if (object.getClass() != JdkScope.class) return false;
if (object.getClass() != getClass()) return false;
final JdkScope that = (JdkScope)object;
return that.myJdkName.equals(myJdkName);
return myJdkName.equals(that.myJdkName) &&
Arrays.equals(myClasses, that.myClasses) &&
Arrays.equals(mySources, that.mySources);
}
}