2 more indices not needed anymore

This commit is contained in:
Valentin Kipyatkov
2014-11-28 20:41:13 +03:00
parent 2a2fa5d4f2
commit 2daeaa38d9
5 changed files with 11 additions and 120 deletions
@@ -1,50 +0,0 @@
/*
* Copyright 2010-2013 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 org.jetbrains.jet.plugin.stubindex;
import com.intellij.openapi.project.Project;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.stubs.StringStubIndexExtension;
import com.intellij.psi.stubs.StubIndexKey;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetNamedFunction;
import java.util.Collection;
public class JetTopLevelNonExtensionFunctionShortNameIndex extends StringStubIndexExtension<JetNamedFunction> {
private static final StubIndexKey<String, JetNamedFunction> KEY = KotlinIndexUtil.createIndexKey(JetTopLevelNonExtensionFunctionShortNameIndex.class);
private static final JetTopLevelNonExtensionFunctionShortNameIndex ourInstance = new JetTopLevelNonExtensionFunctionShortNameIndex();
@NotNull
public static JetTopLevelNonExtensionFunctionShortNameIndex getInstance() {
return ourInstance;
}
private JetTopLevelNonExtensionFunctionShortNameIndex() {}
@NotNull
@Override
public StubIndexKey<String, JetNamedFunction> getKey() {
return KEY;
}
@Override
public Collection<JetNamedFunction> get(String s, Project project, @NotNull GlobalSearchScope scope) {
return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project));
}
}
@@ -1,51 +0,0 @@
/*
* Copyright 2010-2014 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 org.jetbrains.jet.plugin.stubindex;
import com.intellij.openapi.project.Project;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.stubs.StringStubIndexExtension;
import com.intellij.psi.stubs.StubIndexKey;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetProperty;
import java.util.Collection;
public class JetTopLevelNonExtensionPropertyShortNameIndex extends StringStubIndexExtension<JetProperty> {
private static final StubIndexKey<String, JetProperty> KEY = KotlinIndexUtil.createIndexKey(JetTopLevelNonExtensionPropertyShortNameIndex.class);
private static final JetTopLevelNonExtensionPropertyShortNameIndex ourInstance = new JetTopLevelNonExtensionPropertyShortNameIndex();
@NotNull
public static JetTopLevelNonExtensionPropertyShortNameIndex getInstance() {
return ourInstance;
}
private JetTopLevelNonExtensionPropertyShortNameIndex() {}
@NotNull
@Override
public StubIndexKey<String, JetProperty> getKey() {
return KEY;
}
@NotNull
@Override
public Collection<JetProperty> get(String s, Project project, @NotNull GlobalSearchScope scope) {
return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project));
}
}
@@ -96,11 +96,6 @@ public class StubIndexServiceImpl implements StubIndexService {
public void indexFunction(KotlinFunctionStub stub, IndexSink sink) {
String name = stub.getName();
if (name != null) {
if (stub.isTopLevel()) {
if (!stub.isExtension()) {
sink.occurrence(JetTopLevelNonExtensionFunctionShortNameIndex.getInstance().getKey(), name);
}
}
sink.occurrence(JetFunctionShortNameIndex.getInstance().getKey(), name);
if (stub.isProbablyNothingType()) {
@@ -122,13 +117,6 @@ public class StubIndexServiceImpl implements StubIndexService {
public void indexProperty(KotlinPropertyStub stub, IndexSink sink) {
String name = stub.getName();
if (name != null) {
if (stub.isTopLevel()) {
// Collection only top level functions as only they are expected in completion without explicit import
if (!stub.hasReceiverTypeRef()) {
sink.occurrence(JetTopLevelNonExtensionPropertyShortNameIndex.getInstance().getKey(), name);
}
}
sink.occurrence(JetPropertyShortNameIndex.getInstance().getKey(), name);
if (stub.isProbablyNothingType()) {
-2
View File
@@ -399,8 +399,6 @@
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetTopLevelPropertyByPackageIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetClassShortNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetFullClassNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetTopLevelNonExtensionFunctionShortNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetTopLevelNonExtensionPropertyShortNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetPropertyShortNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetFunctionShortNameIndex"/>
<stubIndex implementation="org.jetbrains.jet.plugin.stubindex.JetSuperClassIndex"/>
@@ -58,15 +58,21 @@ public class KotlinIndicesHelper(
}
}
JetTopLevelNonExtensionFunctionShortNameIndex.getInstance().get(name, project, scope)
.mapTo(result) { resolutionFacade.resolveToDescriptor(it) as CallableDescriptor }
JetTopLevelNonExtensionPropertyShortNameIndex.getInstance().get(name, project, scope)
.mapTo(result) { resolutionFacade.resolveToDescriptor(it) as CallableDescriptor }
result.addTopLevelNonExtensionCallablesByName(JetFunctionShortNameIndex.getInstance(), name)
result.addTopLevelNonExtensionCallablesByName(JetPropertyShortNameIndex.getInstance(), name)
return result.filter(visibilityFilter)
}
private fun MutableSet<CallableDescriptor>.addTopLevelNonExtensionCallablesByName(
index: StringStubIndexExtension<out JetCallableDeclaration>,
name: String
) {
index.get(name, project, scope)
.filter { it.getParent() is JetFile && it.getReceiverTypeReference() == null }
.mapTo(this) { resolutionFacade.resolveToDescriptor(it) as CallableDescriptor }
}
public fun getTopLevelCallables(nameFilter: (String) -> Boolean, context: JetExpression /*TODO: to be dropped*/): Collection<CallableDescriptor> {
val sourceNames = JetTopLevelFunctionFqnNameIndex.getInstance().getAllKeys(project).stream() + JetTopLevelPropertyFqnNameIndex.getInstance().getAllKeys(project).stream()
val allFqNames = sourceNames.map { FqName(it) } + JetFromJavaDescriptorHelper.getTopLevelCallableFqNames(project, scope, false).stream()