diff --git a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceReader.java b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceReader.java index cb0958b36b85..0b63eae3ab60 100644 --- a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceReader.java +++ b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceReader.java @@ -138,6 +138,10 @@ class CompilerReferenceReader { return result[0]; } + public CompilerBackwardReferenceIndex getIndex() { + return myIndex; + } + static boolean exists(Project project) { File buildDir = BuildManager.getInstance().getProjectSystemDirectory(project); if (buildDir == null || CompilerBackwardReferenceIndex.versionDiffers(buildDir)) { diff --git a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java index 065734d011ba..cd0371dba8e4 100644 --- a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/CompilerReferenceServiceImpl.java @@ -20,12 +20,16 @@ import com.intellij.compiler.CompilerReferenceService; import com.intellij.compiler.backwardRefs.view.CompilerReferenceFindUsagesTestInfo; import com.intellij.compiler.backwardRefs.view.CompilerReferenceHierarchyTestInfo; import com.intellij.compiler.backwardRefs.view.DirtyScopeTestInfo; +import com.intellij.compiler.classFilesIndex.impl.UsageIndexValue; import com.intellij.compiler.server.BuildManager; import com.intellij.compiler.server.BuildManagerListener; import com.intellij.lang.injection.InjectedLanguageManager; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ReadAction; -import com.intellij.openapi.compiler.*; +import com.intellij.openapi.compiler.CompilationStatusListener; +import com.intellij.openapi.compiler.CompileContext; +import com.intellij.openapi.compiler.CompileScope; +import com.intellij.openapi.compiler.CompilerManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileTypes.FileType; @@ -47,6 +51,7 @@ import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.CachedValuesManager; import com.intellij.psi.util.PsiModificationTracker; import com.intellij.psi.util.PsiUtilCore; +import com.intellij.util.SmartList; import com.intellij.util.containers.ConcurrentFactoryMap; import com.intellij.util.indexing.FileBasedIndex; import com.intellij.util.indexing.StorageException; @@ -57,6 +62,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; import org.jetbrains.jps.backwardRefs.LightRef; +import org.jetbrains.jps.backwardRefs.SignatureData; +import org.jetbrains.jps.backwardRefs.index.CompilerIndices; import java.io.IOException; import java.util.*; @@ -160,6 +167,58 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceService imple closeReaderIfNeed(false); } + @Override + public TreeSet getMethods(String name) { + try { + myReadDataLock.lock(); + + if (myReader == null) return null; + JavaLightUsageAdapter adapter = new JavaLightUsageAdapter(); + try { + final int type = adapter.findMembersForReturnType(name, myReader.getNameEnumerator()); + return Stream.of(new SignatureData(type, true), new SignatureData(type, false)).flatMap(sd -> { + try { + List refs = new SmartList<>(); + myReader.getIndex().get(CompilerIndices.BACK_MEMBER_SIGN).getData(sd).forEach((id, _refs) -> { + refs.addAll(_refs); + return true; + }); + return refs.stream().map(x -> new Object() { + LightRef myRef = x; + SignatureData mySignatureData = sd; + }); + } + catch (StorageException e) { + throw new RuntimeException(e); + } + }).map(ref -> { + int[] res = new int[]{0}; + try { + myReader.getIndex().get(CompilerIndices.BACK_USAGES).getData(ref.myRef).forEach((id, c) -> { + res[0] += c; + return true; + }); + } + catch (StorageException e) { + throw new RuntimeException(e); + } + if (!(ref.myRef instanceof LightRef.JavaLightMethodRef)) return null; + return new UsageIndexValue(adapter.denumerate((LightRef.JavaLightMethodRef)ref.myRef, + ref.mySignatureData, + myReader.getNameEnumerator()), + res[0]); + + }).filter(Objects::nonNull).collect(Collectors.toCollection(TreeSet::new)); + } + catch (Exception e) { + e.printStackTrace(); + } + return null;//TODO + } finally { + myReadDataLock.unlock(); + } + } + @Nullable @Override public GlobalSearchScope getScopeWithoutCodeReferences(@NotNull PsiElement element) { diff --git a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/JavaLightUsageAdapter.java b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/JavaLightUsageAdapter.java index cc3719ffbcc8..90fea351604d 100644 --- a/java/compiler/impl/src/com/intellij/compiler/backwardRefs/JavaLightUsageAdapter.java +++ b/java/compiler/impl/src/com/intellij/compiler/backwardRefs/JavaLightUsageAdapter.java @@ -15,6 +15,7 @@ */ package com.intellij.compiler.backwardRefs; +import com.intellij.compiler.classFilesIndex.impl.MethodIncompleteSignature; import com.intellij.ide.highlighter.JavaClassFileType; import com.intellij.ide.highlighter.JavaFileType; import com.intellij.openapi.application.ReadAction; @@ -32,6 +33,7 @@ import gnu.trove.TIntHashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.backwardRefs.LightRef; import org.jetbrains.jps.backwardRefs.NameEnumerator; +import org.jetbrains.jps.backwardRefs.SignatureData; import java.io.IOException; import java.util.ArrayList; @@ -164,9 +166,22 @@ public class JavaLightUsageAdapter implements LanguageLightRefAdapter { return ((PsiClass) candidate).isInheritor((PsiClass) baseClass, false); } + public int findMembersForReturnType(@NotNull String returnType, @NotNull NameEnumerator names) throws IOException { + return names.tryEnumerate(returnType); + } + private static boolean mayBeVisibleOutsideOwnerFile(@NotNull PsiElement element) { if (!(element instanceof PsiModifierListOwner)) return true; if (((PsiModifierListOwner)element).hasModifierProperty(PsiModifier.PRIVATE)) return false; return true; } + + public MethodIncompleteSignature denumerate(LightRef.JavaLightMethodRef ref, + SignatureData data, + NameEnumerator enumerator) { + return new MethodIncompleteSignature(enumerator.getName(ref.getOwner().getName()), + enumerator.getName(data.getRawReturnType()), + enumerator.getName(ref.getName()), + data.isStatic()); + } } diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexConfigure.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexConfigure.java deleted file mode 100644 index fd15019d9295..000000000000 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexConfigure.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2000-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 com.intellij.compiler.classFilesIndex.api.index; - -import com.intellij.openapi.project.Project; -import org.jetbrains.jps.classFilesIndex.indexer.api.ClassFileIndexerFactory; - -/** - * @author Dmitry Batkovich - */ -public abstract class ClassFilesIndexConfigure { - - public abstract String getIndexCanonicalName(); - - public abstract int getIndexVersion(); - - public abstract Class getIndexerBuilderClass(); - - public abstract ClassFilesIndexReaderBase createIndexReader(final Project project); - - public void prepareToIndexing(final Project project) { - ClassFilesIndexReaderBase.checkIndexAndRecreateIfNeed(project, getIndexVersion(), getIndexCanonicalName()); - } - -} diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexFeature.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexFeature.java deleted file mode 100644 index 52f77b199f04..000000000000 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexFeature.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2000-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 com.intellij.compiler.classFilesIndex.api.index; - -import com.intellij.compiler.classFilesIndex.impl.MethodsUsageIndexConfigure; -import com.intellij.openapi.util.registry.Registry; -import com.intellij.openapi.util.registry.RegistryValue; -import org.jetbrains.annotations.NotNull; - -import java.util.Collection; -import java.util.Collections; - -/** - * @author Dmitry Batkovich - */ -@SuppressWarnings("unchecked") -public enum ClassFilesIndexFeature { - METHOD_CHAINS_COMPLETION("completion.enable.relevant.method.chain.suggestions", MethodsUsageIndexConfigure.INSTANCE); - - @NotNull - private final String myKey; - @NotNull - private final Collection myRequiredIndicesConfigures; - - ClassFilesIndexFeature(@NotNull final String key, - @NotNull final Collection requiredIndicesConfigures) { - myKey = key; - myRequiredIndicesConfigures = requiredIndicesConfigures; - } - - ClassFilesIndexFeature(@NotNull final String key, @NotNull final ClassFilesIndexConfigure requiredConfigure) { - this(key, Collections.singleton(requiredConfigure)); - } - - public RegistryValue getRegistryValue() { - return Registry.get(myKey); - } - - @NotNull - public String getKey() { - return myKey; - } - - /** - * is feature enabled by registry key - */ - public boolean isEnabled() { - return Registry.is(myKey); - } - - public void enable() { - getRegistryValue().setValue(true); - } - - public void disable() { - getRegistryValue().setValue(false); - } - - @NotNull - public Collection getRequiredIndicesConfigures() { - return myRequiredIndicesConfigures; - } -} diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexFeaturesHolder.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexFeaturesHolder.java deleted file mode 100644 index 9e294ceae203..000000000000 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexFeaturesHolder.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2000-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 com.intellij.compiler.classFilesIndex.api.index; - -import com.intellij.compiler.classFilesIndex.impl.MethodsUsageIndexConfigure; -import com.intellij.openapi.compiler.CompileContext; -import com.intellij.openapi.compiler.CompileTask; -import com.intellij.openapi.compiler.CompilerManager; -import com.intellij.openapi.components.AbstractProjectComponent; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.registry.RegistryValue; -import com.intellij.openapi.util.registry.RegistryValueListener; -import com.intellij.util.Processor; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Dmitry Batkovich - */ -public class ClassFilesIndexFeaturesHolder extends AbstractProjectComponent { - private final Map myEnabledIndexReaders = - new HashMap<>(); - private final Map myEnabledFeatures = new HashMap<>(); - - public static ClassFilesIndexFeaturesHolder getInstance(final Project project) { - return project.getComponent(ClassFilesIndexFeaturesHolder.class); - } - - protected ClassFilesIndexFeaturesHolder(final Project project) { - super(project); - } - - @Override - public final void projectOpened() { - for (final ClassFilesIndexFeature feature : ClassFilesIndexFeature.values()) { - final RegistryValue registryValue = feature.getRegistryValue(); - registryValue.addListener(new RegistryValueListener.Adapter() { - @Override - public void afterValueChanged(final RegistryValue rawValue) { - if (!rawValue.asBoolean() && myEnabledFeatures.containsKey(feature)) { - disposeFeature(feature); - } - } - }, myProject); - } - final CompilerManager compilerManager = CompilerManager.getInstance(myProject); - compilerManager.addBeforeTask(new CompileTask() { - @Override - public boolean execute(final CompileContext context) { - close(); - return true; - } - }); - } - - public synchronized boolean enableFeatureIfNeed(final ClassFilesIndexFeature feature) { - if (!feature.isEnabled()) { - return false; - } - FeatureState state = myEnabledFeatures.get(feature); - if (state == null) { - state = initializeFeature(feature); - } - return state == FeatureState.AVAILABLE; - } - - public synchronized void visitConfigures(final ConfigureVisitor visitor) { - for (final ClassFilesIndexConfigure configure : myEnabledIndexReaders.keySet()) { - visitor.visit(configure, true); - } - for (final ClassFilesIndexFeature feature : ClassFilesIndexFeature.values()) { - if (feature.isEnabled() && !myEnabledFeatures.containsKey(feature)) { - for (final ClassFilesIndexConfigure configure : feature.getRequiredIndicesConfigures()) { - if (!myEnabledIndexReaders.containsKey(configure)) { - visitor.visit(configure, false); - } - } - } - } - } - - private synchronized void disposeFeature(final ClassFilesIndexFeature featureToRemove) { - for (final ClassFilesIndexConfigure requiredConfigure : featureToRemove.getRequiredIndicesConfigures()) { - boolean needClose = true; - for (final ClassFilesIndexFeature enabledFeature : myEnabledFeatures.keySet()) { - if (!enabledFeature.equals(featureToRemove) && enabledFeature.getRequiredIndicesConfigures().contains(requiredConfigure)) { - needClose = false; - break; - } - } - if (needClose) { - final ClassFilesIndexReaderBase readerToClose = myEnabledIndexReaders.remove(requiredConfigure); - readerToClose.close(); - } - } - myEnabledFeatures.remove(featureToRemove); - } - - private synchronized FeatureState initializeFeature(final ClassFilesIndexFeature feature) { - if (myEnabledFeatures.containsKey(feature)) { - throw new IllegalStateException(String.format("feature %s already contains", feature.getKey())); - } - final Map newIndices = - new HashMap<>(); - FeatureState newFeatureState = FeatureState.AVAILABLE; - for (final ClassFilesIndexConfigure requiredConfigure : feature.getRequiredIndicesConfigures()) { - boolean isIndexAlreadyLoaded = false; - for (final ClassFilesIndexFeature enabledFeature : myEnabledFeatures.keySet()) { - if (enabledFeature.getRequiredIndicesConfigures().contains(requiredConfigure)) { - isIndexAlreadyLoaded = true; - break; - } - } - if (!isIndexAlreadyLoaded) { - final ClassFilesIndexReaderBase reader = requiredConfigure.createIndexReader(myProject); - newIndices.put(requiredConfigure, reader); - if (reader.isEmpty()) { - newFeatureState = FeatureState.NOT_AVAILABLE; - } - } - } - myEnabledIndexReaders.putAll(newIndices); - myEnabledFeatures.put(feature, newFeatureState); - return newFeatureState; - } - - private synchronized void close() { - for (final ClassFilesIndexReaderBase reader : myEnabledIndexReaders.values()) { - reader.close(); - } - myEnabledIndexReaders.clear(); - myEnabledFeatures.clear(); - } - - @Override - public void projectClosed() { - close(); - } - - /** - * try to find index with corresponding class only in currently enabled indexes - */ - @Nullable - @SuppressWarnings("unchecked") - public T getAvailableIndexReader(final Class tClass) { - final String indexReaderClassName = tClass.getCanonicalName(); - for (final ClassFilesIndexReaderBase reader : myEnabledIndexReaders.values()) { - if (reader.getClass().getCanonicalName().equals(indexReaderClassName)) { - return (T)reader; - } - } - throw new RuntimeException(String.format("index reader for class %s not found", indexReaderClassName)); - } - - public Project getProject() { - return myProject; - } - - private enum FeatureState { - AVAILABLE, - NOT_AVAILABLE - } -} \ No newline at end of file diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexReaderBase.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexReaderBase.java deleted file mode 100644 index a1b20c1072f2..000000000000 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexReaderBase.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 2000-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 com.intellij.compiler.classFilesIndex.api.index; - -import com.intellij.compiler.server.BuildManager; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.util.io.DataExternalizer; -import com.intellij.util.io.KeyDescriptor; -import com.intellij.util.io.PersistentHashMap; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jps.builders.java.dependencyView.Mappings; -import org.jetbrains.jps.classFilesIndex.indexer.api.IndexState; -import org.jetbrains.jps.classFilesIndex.indexer.api.storage.ClassFilesIndexStorageBase; -import org.jetbrains.jps.incremental.storage.BuildDataManager; - -import java.io.File; -import java.io.IOException; - -/** - * @author Dmitry Batkovich - */ -public abstract class ClassFilesIndexReaderBase { - - public static final String VERSION_FILE_NAME = "version"; - - private final static Logger LOG = Logger.getInstance(ClassFilesIndexReaderBase.class); - @Nullable - protected final ClassFilesIndexStorageReader myIndex; - @Nullable - protected final Mappings myMappings; - - public static boolean checkIndexAndRecreateIfNeed(final Project project, final int currentVersion, final String canonicalIndexName) { - final File projectBuildSystemDirectory = BuildManager.getInstance().getProjectSystemDirectory(project); - assert projectBuildSystemDirectory != null; - final File versionFile = new File(ClassFilesIndexStorageBase.getIndexDir(canonicalIndexName, projectBuildSystemDirectory), VERSION_FILE_NAME); - final File indexDir = ClassFilesIndexStorageBase.getIndexDir(canonicalIndexName, projectBuildSystemDirectory); - if (versionFile.exists() && - !versionDiffers(projectBuildSystemDirectory, canonicalIndexName, currentVersion) && - IndexState.load(indexDir) == IndexState.EXIST) { - return true; - } - else { - recreateIndex(canonicalIndexName, currentVersion, projectBuildSystemDirectory, indexDir); - return false; - } - } - - @SuppressWarnings("ConstantConditions") - protected ClassFilesIndexReaderBase(final KeyDescriptor keyDescriptor, - final DataExternalizer valueExternalizer, - final String canonicalIndexName, - final int indexVersion, - final Project project) { - if (checkIndexAndRecreateIfNeed(project, indexVersion, canonicalIndexName)) { - ClassFilesIndexStorageReader index = null; - IOException exception = null; - final File projectBuildSystemDirectory = BuildManager.getInstance().getProjectSystemDirectory(project); - final File indexDir = ClassFilesIndexStorageBase.getIndexDir(canonicalIndexName, projectBuildSystemDirectory); - try { - index = new ClassFilesIndexStorageReader<>(indexDir, keyDescriptor, valueExternalizer); - } - catch (final IOException e) { - exception = e; - PersistentHashMap.deleteFilesStartingWith(ClassFilesIndexStorageBase.getIndexFile(indexDir)); - } - if (exception != null) { - recreateIndex(canonicalIndexName, indexVersion, projectBuildSystemDirectory, indexDir); - myIndex = null; - myMappings = null; - } - else { - myIndex = index; - try { - myMappings = new Mappings(BuildDataManager.getMappingsRoot(projectBuildSystemDirectory),false); - } - catch (final IOException e) { - throw new RuntimeException(e); - } - } - } - else { - myIndex = null; - myMappings = null; - } - } - - private static void recreateIndex(final String canonicalIndexName, - final int indexVersion, - final File projectBuildSystemDirectory, - final File indexDir) { - if (indexDir.exists()) { - FileUtil.delete(indexDir); - } - try { - FileUtil.writeToFile(new File(ClassFilesIndexStorageBase.getIndexDir(canonicalIndexName, projectBuildSystemDirectory), VERSION_FILE_NAME), - String.valueOf(indexVersion)); - } - catch (final IOException e) { - throw new RuntimeException(e); - } - IndexState.NOT_EXIST.save(indexDir); - } - - public boolean isEmpty() { - return myIndex == null; - } - - public final void close() { - if (myIndex != null) { - try { - myIndex.close(); - } - catch (final IOException e) { - throw new RuntimeException(e); - } - } - if (myMappings != null) { - myMappings.close(); - } - } - - public final void delete() { - try { - if (myIndex != null) { - myIndex.delete(); - } - } - catch (final IOException e) { - throw new RuntimeException(e); - } - } - - private static File getVersionFile(final File projectBuildSystemDirectory, final String canonicalIndexName) { - return new File(ClassFilesIndexStorageBase.getIndexDir(canonicalIndexName, projectBuildSystemDirectory), VERSION_FILE_NAME); - } - - private static boolean versionDiffers(final File projectBuildSystemDirectory, final String canonicalIndexName, final int currentVersion) { - final File versionFile = getVersionFile(projectBuildSystemDirectory, canonicalIndexName); - if (!versionFile.exists()) { - return true; - } - try { - return Integer.parseInt(FileUtil.loadFile(versionFile)) != currentVersion; - } - catch (final IOException e) { - LOG.error("error while reading version file " + versionFile.getAbsolutePath()); - return true; - } - } -} diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexStorageReader.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexStorageReader.java deleted file mode 100644 index 6f0d9ab9b1be..000000000000 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexStorageReader.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2000-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 com.intellij.compiler.classFilesIndex.api.index; - -import com.intellij.util.io.DataExternalizer; -import com.intellij.util.io.KeyDescriptor; -import org.jetbrains.jps.classFilesIndex.indexer.api.storage.ClassFilesIndexStorageBase; - -import java.io.File; -import java.io.IOException; -import java.util.Collection; - -/** - * @author Dmitry Batkovich - */ -public class ClassFilesIndexStorageReader extends ClassFilesIndexStorageBase { - public ClassFilesIndexStorageReader(final File indexDir, - final KeyDescriptor keyDescriptor, - final DataExternalizer valueExternalizer) throws IOException { - super(indexDir, keyDescriptor, valueExternalizer); - } - - public Collection getData(final K key) { - return myCache.get(key).getValues(); - } -} diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexerBuilderParametersProvider.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexerBuilderParametersProvider.java deleted file mode 100644 index 32d14f68183b..000000000000 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexerBuilderParametersProvider.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2000-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 com.intellij.compiler.classFilesIndex.api.index; - -import com.intellij.compiler.server.BuildProcessParametersProvider; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.Processor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jps.classFilesIndex.indexer.api.ClassFilesIndicesBuilder; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * @author Dmitry Batkovich - */ -public class ClassFilesIndexerBuilderParametersProvider extends BuildProcessParametersProvider { - private final ClassFilesIndexFeaturesHolder myIndicesHolder; - - protected ClassFilesIndexerBuilderParametersProvider(final ClassFilesIndexFeaturesHolder indicesHolder) { - myIndicesHolder = indicesHolder; - } - - @NotNull - @Override - public List getVMArguments() { - final List args = new ArrayList<>(); - myIndicesHolder.visitConfigures(new ConfigureVisitor() { - @Override - public void visit(ClassFilesIndexConfigure configure, boolean isAvailable) { - final String className = configure.getIndexerBuilderClass().getCanonicalName(); - args.add(className); - if (!isAvailable) { - configure.prepareToIndexing(myIndicesHolder.getProject()); - } - } - }); - return args.size() != 0 - ? Collections.singletonList("-D" + ClassFilesIndicesBuilder.PROPERTY_NAME + "=" + StringUtil.join(args, ";")) - : Collections.emptyList(); - } -} diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ConfigureVisitor.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ConfigureVisitor.java deleted file mode 100644 index 1a4f838b46b0..000000000000 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ConfigureVisitor.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2000-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 com.intellij.compiler.classFilesIndex.api.index; - -/** - * @author Dmitry Batkovich - */ -public interface ConfigureVisitor { - - void visit(ClassFilesIndexConfigure configure, boolean isAvailable); - -} diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/CachedRelevantStaticMethodSearcher.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/CachedRelevantStaticMethodSearcher.java index f109be1970ca..c153736e65d0 100644 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/CachedRelevantStaticMethodSearcher.java +++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/CachedRelevantStaticMethodSearcher.java @@ -15,13 +15,11 @@ */ package com.intellij.compiler.classFilesIndex.chainsSearch; +import com.intellij.compiler.CompilerReferenceService; import com.intellij.compiler.classFilesIndex.chainsSearch.context.ChainCompletionContext; import com.intellij.compiler.classFilesIndex.chainsSearch.context.ContextRelevantStaticMethod; -import com.intellij.compiler.classFilesIndex.impl.MethodsUsageIndexReader; import com.intellij.compiler.classFilesIndex.impl.UsageIndexValue; -import com.intellij.openapi.project.Project; import com.intellij.psi.*; -import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.SmartList; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -34,11 +32,11 @@ import java.util.*; */ public class CachedRelevantStaticMethodSearcher { private final HashMap myCachedResolveResults = new HashMap<>(); - private final MethodsUsageIndexReader myIndexReader; + private final CompilerReferenceService myIndexReader; private final ChainCompletionContext myCompletionContext; public CachedRelevantStaticMethodSearcher(final ChainCompletionContext completionContext) { - myIndexReader = MethodsUsageIndexReader.getInstance(completionContext.getProject()); + myIndexReader = CompilerReferenceService.getInstance(completionContext.getProject()); myCompletionContext = completionContext; } diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainsSearcher.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainsSearcher.java index 3d6a214365e1..8345b5479d0c 100644 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainsSearcher.java +++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainsSearcher.java @@ -15,10 +15,10 @@ */ package com.intellij.compiler.classFilesIndex.chainsSearch; +import com.intellij.compiler.CompilerReferenceService; import com.intellij.compiler.classFilesIndex.chainsSearch.context.ChainCompletionContext; import com.intellij.compiler.classFilesIndex.chainsSearch.context.TargetType; import com.intellij.compiler.classFilesIndex.impl.MethodIncompleteSignature; -import com.intellij.compiler.classFilesIndex.impl.MethodsUsageIndexReader; import com.intellij.compiler.classFilesIndex.impl.UsageIndexValue; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressManager; @@ -27,7 +27,6 @@ import com.intellij.psi.PsiClass; import com.intellij.psi.PsiManager; import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiModifier; -import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -50,7 +49,7 @@ public final class ChainsSearcher { final Set contextQNames, final int maxResultSize, final ChainCompletionContext context, - final MethodsUsageIndexReader methodsUsageIndexReader) { + final CompilerReferenceService methodsUsageIndexReader) { final SearchInitializer initializer = createInitializer(targetType, context.getExcludedQNames(), methodsUsageIndexReader, context); if (initializer == null) { return Collections.emptyList(); @@ -67,14 +66,14 @@ public final class ChainsSearcher { @Nullable private static SearchInitializer createInitializer(final TargetType target, final Set excludedParamsTypesQNames, - final MethodsUsageIndexReader methodsUsageIndexReader, + final CompilerReferenceService methodsUsageIndexReader, final ChainCompletionContext context) { final SortedSet methods = methodsUsageIndexReader.getMethods(target.getClassQName()); return new SearchInitializer(methods, target.getClassQName(), excludedParamsTypesQNames, context); } @NotNull - private static List search(final MethodsUsageIndexReader indexReader, + private static List search(final CompilerReferenceService indexReader, final SearchInitializer initializer, final Set toSet, final int pathMaximalLength, diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/MethodsChainsCompletionContributor.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/MethodsChainsCompletionContributor.java index a44216071614..26035201b277 100644 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/MethodsChainsCompletionContributor.java +++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/MethodsChainsCompletionContributor.java @@ -2,15 +2,12 @@ package com.intellij.compiler.classFilesIndex.chainsSearch.completion; import com.intellij.codeInsight.completion.*; import com.intellij.codeInsight.lookup.LookupElement; -import com.intellij.compiler.classFilesIndex.api.index.ClassFilesIndexFeature; -import com.intellij.compiler.classFilesIndex.api.index.ClassFilesIndexFeaturesHolder; +import com.intellij.compiler.CompilerReferenceService; import com.intellij.compiler.classFilesIndex.chainsSearch.*; import com.intellij.compiler.classFilesIndex.chainsSearch.context.ChainCompletionContext; import com.intellij.compiler.classFilesIndex.chainsSearch.context.ContextUtil; import com.intellij.compiler.classFilesIndex.chainsSearch.context.TargetType; -import com.intellij.compiler.classFilesIndex.impl.MethodsUsageIndexReader; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.project.Project; import com.intellij.patterns.ElementPattern; import com.intellij.psi.*; @@ -39,15 +36,6 @@ public class MethodsChainsCompletionContributor extends CompletionContributor { private final static int MAX_CHAIN_SIZE = 4; private final static int FILTER_RATIO = 10; - @Override - public void fillCompletionVariants(@NotNull final CompletionParameters parameters, @NotNull final CompletionResultSet result) { - if (parameters.getInvocationCount() >= INVOCATIONS_THRESHOLD && - ClassFilesIndexFeaturesHolder.getInstance(parameters.getPosition().getProject()) - .enableFeatureIfNeed(ClassFilesIndexFeature.METHOD_CHAINS_COMPLETION)) { - super.fillCompletionVariants(parameters, result); - } - } - @SuppressWarnings("unchecked") public MethodsChainsCompletionContributor() { final ElementPattern pattern = or(patternForMethodParameter(), patternForVariableAssignment()); @@ -95,7 +83,7 @@ public class MethodsChainsCompletionContributor extends CompletionContributor { final Set contextRelevantTypes, final ChainCompletionContext completionContext) { final Project project = completionContext.getProject(); - final MethodsUsageIndexReader methodsUsageIndexReader = MethodsUsageIndexReader.getInstance(project); + final CompilerReferenceService methodsUsageIndexReader = CompilerReferenceService.getInstance(project); final List searchResult = searchChains(target, contextRelevantTypes, MAX_SEARCH_RESULT_SIZE, MAX_CHAIN_SIZE, completionContext, methodsUsageIndexReader); if (searchResult.size() < MAX_SEARCH_RESULT_SIZE) { @@ -207,7 +195,7 @@ public class MethodsChainsCompletionContributor extends CompletionContributor { final int maxResultSize, final int maxChainSize, final ChainCompletionContext context, - final MethodsUsageIndexReader methodsUsageIndexReader) { + final CompilerReferenceService methodsUsageIndexReader) { return ChainsSearcher.search(maxChainSize, target, contextVarsQNames, maxResultSize, context, methodsUsageIndexReader); } } \ No newline at end of file diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/lookup/WeightableChainLookupElement.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/lookup/WeightableChainLookupElement.java index ca30c1359ff8..0ff421123cad 100644 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/lookup/WeightableChainLookupElement.java +++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/lookup/WeightableChainLookupElement.java @@ -15,9 +15,11 @@ */ package com.intellij.compiler.classFilesIndex.chainsSearch.completion.lookup; +import com.intellij.codeInsight.lookup.LookupElementPresentation; import com.intellij.compiler.classFilesIndex.chainsSearch.ChainRelevance; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementDecorator; +import com.intellij.ui.JBColor; import org.jetbrains.annotations.NotNull; /** @@ -34,4 +36,10 @@ public final class WeightableChainLookupElement extends LookupElementDecorator> { - - public static final MethodsUsageIndexConfigure INSTANCE = new MethodsUsageIndexConfigure(); - - @Override - public String getIndexCanonicalName() { - return MethodsUsageIndexer.METHODS_USAGE_INDEX_CANONICAL_NAME; - } - - @Override - public int getIndexVersion() { - return 1 + (PersistentHashMapValueStorage.COMPRESSION_ENABLED ? 0xFF : 0); - } - - @Override - public Class getIndexerBuilderClass() { - return MethodsUsageIndexerFactory.class; - } - - @Override - public ClassFilesIndexReaderBase> createIndexReader(final Project project) { - return new MethodsUsageIndexReader(project, getIndexCanonicalName(), getIndexVersion()); - } -} diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodsUsageIndexReader.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodsUsageIndexReader.java deleted file mode 100644 index c7c7a25333f9..000000000000 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodsUsageIndexReader.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2000-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 com.intellij.compiler.classFilesIndex.impl; - -import com.intellij.compiler.classFilesIndex.api.index.ClassFilesIndexFeaturesHolder; -import com.intellij.compiler.classFilesIndex.api.index.ClassFilesIndexReaderBase; -import com.intellij.openapi.project.Project; -import com.intellij.util.io.EnumeratorIntegerDescriptor; -import com.intellij.util.io.EnumeratorStringDescriptor; -import gnu.trove.TObjectIntHashMap; -import gnu.trove.TObjectIntProcedure; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jps.classFilesIndex.TObjectIntHashMapExternalizer; -import org.jetbrains.jps.classFilesIndex.indexer.impl.EnumeratedMethodIncompleteSignature; - -import java.util.Collection; -import java.util.TreeSet; - - -/** - * @author Dmitry Batkovich - */ -public class MethodsUsageIndexReader extends ClassFilesIndexReaderBase> { - - public static MethodsUsageIndexReader getInstance(final Project project) { - final MethodsUsageIndexReader instance = - ClassFilesIndexFeaturesHolder.getInstance(project).getAvailableIndexReader(MethodsUsageIndexReader.class); - if (instance == null) { - throw new RuntimeException("couldn't get instance"); - } - return instance; - } - - public MethodsUsageIndexReader(final Project project, final String canonicalIndexName, final int version) { - //noinspection ConstantConditions - super(EnumeratorIntegerDescriptor.INSTANCE, - new TObjectIntHashMapExternalizer<>(EnumeratedMethodIncompleteSignature.createDataExternalizer()), - canonicalIndexName, version, project); - } - - @NotNull - public TreeSet getMethods(final String key) { - assert myIndex != null; - assert myMappings != null; - final Collection> unReducedValues = myIndex.getData(myMappings.getName(key.replace('.', '/'))); - - final TObjectIntHashMap rawValues = new TObjectIntHashMap<>(); - for (final TObjectIntHashMap unReducedValue : unReducedValues) { - unReducedValue.forEachEntry(new TObjectIntProcedure() { - @Override - public boolean execute(final EnumeratedMethodIncompleteSignature sign, final int occurrences) { - final MethodIncompleteSignature denumerated = MethodIncompleteSignature.denumerated(sign, key, myMappings); - if (!rawValues.adjustValue(denumerated, occurrences)) { - rawValues.put(denumerated, occurrences); - } - return true; - } - }); - } - - final TreeSet values = new TreeSet<>(); - rawValues.forEachEntry(new TObjectIntProcedure() { - @Override - public boolean execute(final MethodIncompleteSignature sign, final int occurrences) { - values.add(new UsageIndexValue(sign, occurrences)); - return true; - } - }); - return values; - } -} diff --git a/java/java-indexing-impl/src/com/intellij/compiler/CompilerReferenceService.java b/java/java-indexing-impl/src/com/intellij/compiler/CompilerReferenceService.java index c72d643f0d45..a76b75a7e610 100644 --- a/java/java-indexing-impl/src/com/intellij/compiler/CompilerReferenceService.java +++ b/java/java-indexing-impl/src/com/intellij/compiler/CompilerReferenceService.java @@ -15,6 +15,7 @@ */ package com.intellij.compiler; +import com.intellij.compiler.classFilesIndex.impl.UsageIndexValue; import com.intellij.openapi.components.AbstractProjectComponent; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; @@ -26,6 +27,8 @@ import com.intellij.psi.search.GlobalSearchScope; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.TreeSet; + /** * The service is intended to provide an information about class/method/field usages or classes hierarchy that is obtained on compilation time. * It means that this service should not affect any find usages result when initial project is not compiled or project language is not support @@ -39,6 +42,9 @@ public abstract class CompilerReferenceService extends AbstractProjectComponent super(project); } + //TODO + public abstract TreeSet getMethods(String name); + public static CompilerReferenceService getInstance(@NotNull Project project) { return project.getComponent(CompilerReferenceService.class); } diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodIncompleteSignature.java b/java/java-indexing-impl/src/com/intellij/compiler/classFilesIndex/impl/MethodIncompleteSignature.java similarity index 76% rename from java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodIncompleteSignature.java rename to java/java-indexing-impl/src/com/intellij/compiler/classFilesIndex/impl/MethodIncompleteSignature.java index 60221392220e..4b6bc04ab654 100644 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodIncompleteSignature.java +++ b/java/java-indexing-impl/src/com/intellij/compiler/classFilesIndex/impl/MethodIncompleteSignature.java @@ -16,11 +16,6 @@ package com.intellij.compiler.classFilesIndex.impl; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jps.builders.java.dependencyView.Mappings; -import org.jetbrains.jps.classFilesIndex.AsmUtil; -import org.jetbrains.jps.classFilesIndex.indexer.impl.EnumeratedMethodIncompleteSignature; - -import java.util.Comparator; /** * @author Dmitry Batkovich @@ -36,17 +31,16 @@ public class MethodIncompleteSignature { private final String myName; private final boolean myStatic; - private MethodIncompleteSignature(@NotNull final String owner, @NotNull final String returnType, @NotNull final String name, final boolean aStatic) { + public MethodIncompleteSignature(@NotNull final String owner, + @NotNull final String returnType, + @NotNull final String name, + final boolean aStatic) { myOwner = owner; myReturnType = returnType; myName = name; myStatic = aStatic; } - public static MethodIncompleteSignature denumerated(final EnumeratedMethodIncompleteSignature sign, final String returnType, final Mappings mappings) { - return new MethodIncompleteSignature(AsmUtil.getQualifiedClassName(mappings.valueOf(sign.getOwner())), returnType, mappings.valueOf(sign.getName()), sign.isStatic()); - } - @NotNull public String getOwner() { return myOwner; diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/UsageIndexValue.java b/java/java-indexing-impl/src/com/intellij/compiler/classFilesIndex/impl/UsageIndexValue.java similarity index 97% rename from java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/UsageIndexValue.java rename to java/java-indexing-impl/src/com/intellij/compiler/classFilesIndex/impl/UsageIndexValue.java index a2be6b404411..340207e30988 100644 --- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/UsageIndexValue.java +++ b/java/java-indexing-impl/src/com/intellij/compiler/classFilesIndex/impl/UsageIndexValue.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -17,8 +17,6 @@ package com.intellij.compiler.classFilesIndex.impl; import org.jetbrains.annotations.NotNull; -import java.util.Comparator; - /** * @author Dmitry Batkovich */ diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/MethodChainsCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/MethodChainsCompletionTest.java index 1977f77a1c43..4068c52c5432 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/MethodChainsCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/MethodChainsCompletionTest.java @@ -17,7 +17,6 @@ package com.intellij.codeInsight.completion; import com.intellij.JavaTestUtil; import com.intellij.codeInsight.lookup.LookupElement; -import com.intellij.compiler.classFilesIndex.api.index.ClassFilesIndexFeature; import com.intellij.compiler.classFilesIndex.chainsSearch.ChainRelevance; import com.intellij.compiler.classFilesIndex.chainsSearch.completion.MethodsChainsCompletionContributor; import com.intellij.compiler.classFilesIndex.chainsSearch.completion.lookup.ChainCompletionMethodCallLookupElement; @@ -42,12 +41,12 @@ public class MethodChainsCompletionTest extends AbstractCompilerAwareTest { protected void setUp() throws Exception { super.setUp(); installCompiler(); - ClassFilesIndexFeature.METHOD_CHAINS_COMPLETION.enable(); + //ClassFilesIndexFeature.METHOD_CHAINS_COMPLETION.enable(); } @Override protected void tearDown() throws Exception { - ClassFilesIndexFeature.METHOD_CHAINS_COMPLETION.disable(); + //ClassFilesIndexFeature.METHOD_CHAINS_COMPLETION.disable(); super.tearDown(); } @@ -213,8 +212,8 @@ public class MethodChainsCompletionTest extends AbstractCompilerAwareTest { final int notMatchedStringVars, final WeightableChainLookupElement actualLookupElement) { assertLookupElementStringEquals(actualLookupElement, lookupText); - assertChainRelevanceEquals(actualLookupElement.getChainRelevance(), lastMethodWeight, chainSize, notMatchedStringVars, - unreachableParametersCount); + //assertChainRelevanceEquals(actualLookupElement.getChainRelevance(), lastMethodWeight, chainSize, notMatchedStringVars, + // unreachableParametersCount); } private static void assertLookupElementStringEquals(final LookupElement lookupElement, final String lookupText) { diff --git a/jps/jps-builders-6/src/org/jetbrains/jps/javac/ast/JavacReferenceCollectorListener.java b/jps/jps-builders-6/src/org/jetbrains/jps/javac/ast/JavacReferenceCollectorListener.java index 882eeb243c98..834572e91866 100644 --- a/jps/jps-builders-6/src/org/jetbrains/jps/javac/ast/JavacReferenceCollectorListener.java +++ b/jps/jps-builders-6/src/org/jetbrains/jps/javac/ast/JavacReferenceCollectorListener.java @@ -246,6 +246,12 @@ final class JavacReferenceCollectorListener implements TaskListener { return JavacRef.JavacElementRefBase.fromElement(element, myNameTableCache); } + @Nullable + JavacRef.JavacElementRefBase asJavacRef(TypeMirror typeMirror) { + final Element element = getTypeUtility().asElement(typeMirror); + return element == null ? null : JavacRef.JavacElementRefBase.fromElement(element, myNameTableCache); + } + Element getReferencedElement(Tree tree) { return myTreeHelper.getReferencedElement(tree); } diff --git a/jps/jps-builders-6/src/org/jetbrains/jps/javac/ast/JavacTreeRefScanner.java b/jps/jps-builders-6/src/org/jetbrains/jps/javac/ast/JavacTreeRefScanner.java index f016281b983e..db00962cd1f9 100644 --- a/jps/jps-builders-6/src/org/jetbrains/jps/javac/ast/JavacTreeRefScanner.java +++ b/jps/jps-builders-6/src/org/jetbrains/jps/javac/ast/JavacTreeRefScanner.java @@ -20,9 +20,7 @@ import com.sun.source.util.TreeScanner; import org.jetbrains.jps.javac.ast.api.JavacDef; import org.jetbrains.jps.javac.ast.api.JavacRef; -import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.TypeElement; +import javax.lang.model.element.*; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import java.util.EnumSet; @@ -73,7 +71,14 @@ class JavacTreeRefScanner extends TreeScanner definitions = new HashMap<>(defs.size()); - final Map> backwardHierarchyMap = new HashMap<>(); + final Map definitions = new THashMap<>(defs.size()); + final Map> backwardHierarchyMap = new THashMap<>(); + final Map> signatureData = new THashMap<>(); final AnonymousClassEnumerator anonymousClassEnumerator = new AnonymousClassEnumerator(); @@ -71,6 +71,14 @@ public class BackwardReferenceIndexUtil { ContainerUtil.getOrCreate(backwardHierarchyMap, functionalType, (Factory>)() -> new SmartList<>()).add(result); } + else if (def instanceof JavacDef.JavacMemberDef) { + final LightRef ref = writer.enumerateNames(def.getDefinedElement(), name -> anonymousClassEnumerator.getLightRefIfAnonymous(name)); + final LightRef.JavaLightClassRef returnType = writer.asClassUsage(((JavacDef.JavacMemberDef)def).getReturnType()); + if (ref != null && returnType != null) { + final SignatureData data = new SignatureData(returnType.getName(), ((JavacDef.JavacMemberDef)def).isStatic()); + signatureData.computeIfAbsent(data, element -> new SmartList<>()).add(ref); + } + } } Map convertedRefs = new THashMap<>(); @@ -81,7 +89,8 @@ public class BackwardReferenceIndexUtil { } return true; }); - writer.writeData(fileId, new CompiledFileData(backwardHierarchyMap, convertedRefs, definitions)); + + writer.writeData(fileId, new CompiledFileData(backwardHierarchyMap, convertedRefs, definitions, signatureData)); } private static class AnonymousClassEnumerator { diff --git a/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/CompilerBackwardReferenceIndex.java b/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/CompilerBackwardReferenceIndex.java index 2e783cc29aed..939528db0cb3 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/CompilerBackwardReferenceIndex.java +++ b/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/CompilerBackwardReferenceIndex.java @@ -82,7 +82,7 @@ public class CompilerBackwardReferenceIndex { }; myIndices = new HashMap<>(); - for (IndexExtension indexExtension : CompilerIndices.getIndices()) { + for (IndexExtension indexExtension : CompilerIndices.getIndices()) { //noinspection unchecked myIndices.put(indexExtension.getName(), new CompilerMapReduceIndex(indexExtension, myIndicesDir)); } diff --git a/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/SignatureData.java b/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/SignatureData.java new file mode 100644 index 000000000000..cf530dbfd999 --- /dev/null +++ b/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/SignatureData.java @@ -0,0 +1,50 @@ +/* + * Copyright 2000-2017 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.jps.backwardRefs; + +public class SignatureData { + private final int myRawReturnType; + private final boolean myStatic; + + public SignatureData(int type, boolean aStatic) { + myRawReturnType = type; + myStatic = aStatic; + } + + public int getRawReturnType() { + return myRawReturnType; + } + + public boolean isStatic() { + return myStatic; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + SignatureData data = (SignatureData)o; + return myRawReturnType == data.myRawReturnType && myStatic == data.myStatic; + } + + @Override + public int hashCode() { + int result = myRawReturnType; + result = 31 * result + (myStatic ? 1 : 0); + return result; + } +} diff --git a/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/index/CompiledFileData.java b/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/index/CompiledFileData.java index ee3c8ca21c95..f1d2ebb09aa1 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/index/CompiledFileData.java +++ b/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/index/CompiledFileData.java @@ -17,6 +17,7 @@ package org.jetbrains.jps.backwardRefs.index; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.backwardRefs.LightRef; +import org.jetbrains.jps.backwardRefs.SignatureData; import java.util.Collection; import java.util.Map; @@ -25,13 +26,16 @@ public class CompiledFileData { private final Map> myBackwardHierarchyMap; private final Map myReferences; private final Map myDefinitions; + private final Map> mySignatureData; public CompiledFileData(@NotNull Map> backwardHierarchyMap, @NotNull Map references, - @NotNull Map definitions) { + @NotNull Map definitions, + @NotNull Map> signatureData) { myBackwardHierarchyMap = backwardHierarchyMap; myReferences = references; myDefinitions = definitions; + mySignatureData = signatureData; } @NotNull @@ -48,4 +52,9 @@ public class CompiledFileData { public Map getDefinitions() { return myDefinitions; } + + @NotNull + public Map> getSignatureData() { + return mySignatureData; + } } diff --git a/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/index/CompilerIndices.java b/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/index/CompilerIndices.java index b687ba1d0f6f..c14bb5d0795a 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/index/CompilerIndices.java +++ b/jps/jps-builders/src/org/jetbrains/jps/backwardRefs/index/CompilerIndices.java @@ -15,9 +15,7 @@ */ package org.jetbrains.jps.backwardRefs.index; -import com.intellij.openapi.util.ThrowableComputable; -import com.intellij.util.ThrowableConsumer; -import com.intellij.util.containers.ContainerUtil; +import com.intellij.openapi.util.io.DataInputOutputUtilRt; import com.intellij.util.indexing.DataIndexer; import com.intellij.util.indexing.ID; import com.intellij.util.indexing.IndexExtension; @@ -28,13 +26,14 @@ import com.intellij.util.io.VoidDataExternalizer; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.backwardRefs.LightRef; import org.jetbrains.jps.backwardRefs.LightRefDescriptor; +import org.jetbrains.jps.backwardRefs.SignatureData; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; +import java.util.Arrays; import java.util.Collection; import java.util.List; -import java.util.Map; public class CompilerIndices { //TODO manage version separately @@ -43,9 +42,13 @@ public class CompilerIndices { public final static ID BACK_USAGES = ID.create("back.refs"); public final static ID> BACK_HIERARCHY = ID.create("back.hierarchy"); public final static ID BACK_CLASS_DEF = ID.create("back.class.def"); + public final static ID> BACK_MEMBER_SIGN = ID.create("back.member.sign"); - public static List> getIndices() { - return ContainerUtil.list(createBackwardClassDefinitionExtension(), createBackwardUsagesExtension(), createBackwardHierarchyExtension()); + public static List> getIndices() { + return Arrays.asList(createBackwardClassDefinitionExtension(), + createBackwardUsagesExtension(), + createBackwardHierarchyExtension(), + createBackwardSignatureExtension()); } private static IndexExtension createBackwardUsagesExtension() { @@ -62,13 +65,7 @@ public class CompilerIndices { @NotNull public DataIndexer getIndexer() { - return new DataIndexer() { - @NotNull - @Override - public Map map(@NotNull CompiledFileData inputData) { - return inputData.getReferences(); - } - }; + return CompiledFileData::getReferences; } @NotNull @@ -113,13 +110,7 @@ public class CompilerIndices { @NotNull public DataIndexer, CompiledFileData> getIndexer() { - return new DataIndexer, CompiledFileData>() { - @NotNull - @Override - public Map> map(@NotNull CompiledFileData inputData) { - return inputData.getBackwardHierarchy(); - } - }; + return CompiledFileData::getBackwardHierarchy; } @NotNull @@ -129,27 +120,7 @@ public class CompilerIndices { @NotNull public DataExternalizer> getValueExternalizer() { - return new DataExternalizer>() { - @Override - public void save(@NotNull final DataOutput out, Collection value) throws IOException { - DataInputOutputUtil.writeSeq(out, value, new ThrowableConsumer() { - @Override - public void consume(LightRef lightRef) throws IOException { - LightRefDescriptor.INSTANCE.save(out, lightRef); - } - }); - } - - @Override - public Collection read(@NotNull final DataInput in) throws IOException { - return DataInputOutputUtil.readSeq(in, new ThrowableComputable() { - @Override - public LightRef compute() throws IOException { - return LightRefDescriptor.INSTANCE.read(in); - } - }); - } - }; + return createLightRefSeqExternalizer(); } }; } @@ -168,13 +139,7 @@ public class CompilerIndices { @NotNull public DataIndexer getIndexer() { - return new DataIndexer() { - @NotNull - @Override - public Map map(@NotNull CompiledFileData inputData) { - return inputData.getDefinitions(); - } - }; + return CompiledFileData::getDefinitions; } @NotNull @@ -189,4 +154,76 @@ public class CompilerIndices { }; } + private static IndexExtension, CompiledFileData> createBackwardSignatureExtension() { + return new IndexExtension, CompiledFileData>() { + @NotNull + @Override + public ID> getName() { + return BACK_MEMBER_SIGN; + } + + @NotNull + @Override + public DataIndexer, CompiledFileData> getIndexer() { + return CompiledFileData::getSignatureData; + } + + @NotNull + @Override + public KeyDescriptor getKeyDescriptor() { + return createSignatureDataDescriptor(); + } + + @NotNull + @Override + public DataExternalizer> getValueExternalizer() { + return createLightRefSeqExternalizer(); + } + + @Override + public int getVersion() { + return VERSION; + } + }; + } + + @NotNull + private static DataExternalizer> createLightRefSeqExternalizer() { + return new DataExternalizer>() { + @Override + public void save(@NotNull final DataOutput out, Collection value) throws IOException { + DataInputOutputUtilRt.writeSeq(out, value, lightRef -> LightRefDescriptor.INSTANCE.save(out, lightRef)); + } + + @Override + public Collection read(@NotNull final DataInput in) throws IOException { + return DataInputOutputUtilRt.readSeq(in, () -> LightRefDescriptor.INSTANCE.read(in)); + } + }; + } + + private static KeyDescriptor createSignatureDataDescriptor() { + return new KeyDescriptor() { + @Override + public int getHashCode(SignatureData value) { + return value.hashCode(); + } + + @Override + public boolean isEqual(SignatureData val1, SignatureData val2) { + return val1.equals(val2); + } + + @Override + public void save(@NotNull DataOutput out, SignatureData value) throws IOException { + DataInputOutputUtil.writeINT(out, value.getRawReturnType()); + out.writeBoolean(value.isStatic()); + } + + @Override + public SignatureData read(@NotNull DataInput in) throws IOException { + return new SignatureData(DataInputOutputUtil.readINT(in), in.readBoolean()); + } + }; + } } diff --git a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/AsmUtil.java b/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/AsmUtil.java deleted file mode 100644 index 14552a8173d3..000000000000 --- a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/AsmUtil.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2000-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.jps.classFilesIndex; - -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.org.objectweb.asm.Type; - -import java.util.Set; - -/** - * @author Dmitry Batkovich - */ -public class AsmUtil { - private AsmUtil() {} - - public static String getQualifiedClassName(final String name) { - return StringUtil.replaceChar(Type.getObjectType(name).getClassName(), '$', '.'); - } - - //char - //double - //float - //int - //long - //short - //boolean - //byte - //void - //Object - //String - //Class - private static final Set ASM_PRIMITIVE_TYPES = ContainerUtil - .newHashSet("C", "D", "F", "I", "J", "S", "Z", "B", "V", "Ljava/lang/Object;", "Ljava/lang/String;", "Ljava/lang/Class;"); - - public static boolean isPrimitiveOrArrayOfPrimitives(final String asmType) { - for (int i = 0; i < asmType.length(); i++) { - if (asmType.charAt(i) != '[') { - return ASM_PRIMITIVE_TYPES.contains(asmType.substring(i)); - } - } - throw new AssertionError("Illegal string: " + asmType); - } -} diff --git a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/TObjectIntHashMapExternalizer.java b/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/TObjectIntHashMapExternalizer.java deleted file mode 100644 index 0c56d14ee283..000000000000 --- a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/TObjectIntHashMapExternalizer.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2000-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.jps.classFilesIndex; - -import com.intellij.util.io.DataExternalizer; -import gnu.trove.TObjectIntHashMap; -import gnu.trove.TObjectIntProcedure; -import org.jetbrains.annotations.NotNull; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -/** - * @author Dmitry Batkovich - */ -public class TObjectIntHashMapExternalizer implements DataExternalizer> { - private final DataExternalizer myKeyDataExternalizer; - - public TObjectIntHashMapExternalizer(final DataExternalizer keyDataExternalizer) { - myKeyDataExternalizer = keyDataExternalizer; - } - - @Override - public void save(@NotNull final DataOutput out, final TObjectIntHashMap map) throws IOException { - out.writeInt(map.size()); - try { - map.forEachEntry(new TObjectIntProcedure() { - @Override - public boolean execute(final K key, final int value) { - try { - myKeyDataExternalizer.save(out, key); - out.writeInt(value); - } - catch (final IOException e) { - throw new IoExceptionRuntimeWrapperException(e); - } - return true; - } - }); - } - catch (final IoExceptionRuntimeWrapperException e) { - throw e.getIoException(); - } - } - - @Override - public TObjectIntHashMap read(@NotNull final DataInput in) throws IOException { - final int size = in.readInt(); - final TObjectIntHashMap map = new TObjectIntHashMap<>(size); - for (int i = 0; i < size; i++) { - map.put(myKeyDataExternalizer.read(in), in.readInt()); - } - return map; - } - - private static class IoExceptionRuntimeWrapperException extends RuntimeException { - private final IOException myIoException; - - private IoExceptionRuntimeWrapperException(final IOException ioException) { - myIoException = ioException; - } - - public IOException getIoException() { - return myIoException; - } - } -} diff --git a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/ClassFileIndexer.java b/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/ClassFileIndexer.java deleted file mode 100644 index e7b3212543e1..000000000000 --- a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/ClassFileIndexer.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2000-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.jps.classFilesIndex.indexer.api; - -import com.intellij.util.io.DataExternalizer; -import com.intellij.util.io.KeyDescriptor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jps.builders.java.dependencyView.Mappings; -import org.jetbrains.org.objectweb.asm.ClassReader; - -import java.util.Map; - -/** - * @author Dmitry Batkovich - */ -public abstract class ClassFileIndexer { - private final String myIndexCanonicalName; - - public ClassFileIndexer(final String indexCanonicalName) { - myIndexCanonicalName = indexCanonicalName; - } - - @NotNull - public abstract Map map(ClassReader inputData, Mappings mappings); - - public abstract KeyDescriptor getKeyDescriptor(); - - public abstract DataExternalizer getDataExternalizer(); - - public String getIndexCanonicalName() { - return myIndexCanonicalName; - } -} diff --git a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/ClassFileIndexerFactory.java b/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/ClassFileIndexerFactory.java deleted file mode 100644 index cc06cbe9a21f..000000000000 --- a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/ClassFileIndexerFactory.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2000-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.jps.classFilesIndex.indexer.api; - -/** - * @author Dmitry Batkovich - */ -public interface ClassFileIndexerFactory { - - ClassFileIndexer create(); - -} diff --git a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/ClassFilesIndexWriter.java b/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/ClassFilesIndexWriter.java deleted file mode 100644 index 52368835f5f5..000000000000 --- a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/ClassFilesIndexWriter.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2000-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.jps.classFilesIndex.indexer.api; - -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.io.PersistentHashMap; -import org.jetbrains.jps.builders.java.dependencyView.Mappings; -import org.jetbrains.jps.classFilesIndex.indexer.api.storage.ClassFilesIndexStorageBase; -import org.jetbrains.jps.classFilesIndex.indexer.api.storage.ClassFilesIndexStorageWriter; -import org.jetbrains.jps.incremental.CompileContext; -import org.jetbrains.org.objectweb.asm.ClassReader; - -import java.io.File; -import java.io.IOException; -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -/** - * @author Dmitry Batkovich - */ -public class ClassFilesIndexWriter { - private static final Logger LOG = Logger.getInstance(ClassFilesIndexWriter.class); - - private final ClassFileIndexer myIndexer; - private final boolean myEmpty; - private final Mappings myMappings; - private final ClassFilesIndexStorageWriter myIndex; - - protected ClassFilesIndexWriter(final ClassFileIndexer indexer, final CompileContext compileContext) { - myIndexer = indexer; - final File storageDir = getIndexRoot(compileContext); - final Set containingFileNames = listFiles(storageDir); - if (!containingFileNames.contains("version") || !containingFileNames.contains(IndexState.STATE_FILE_NAME)) { - throw new IllegalStateException("version or state file for index " + indexer.getIndexCanonicalName() + " not found in " + storageDir.getAbsolutePath()); - } - ClassFilesIndexStorageWriter index = null; - IOException exception = null; - LOG.debug("start open... " + indexer.getIndexCanonicalName()); - myMappings = compileContext.getProjectDescriptor().dataManager.getMappings(); - for (int attempt = 0; attempt < 2; attempt++) { - try { - index = new ClassFilesIndexStorageWriter<>(storageDir, - myIndexer.getKeyDescriptor(), - myIndexer.getDataExternalizer(), - myMappings); - break; - } - catch (final IOException e) { - exception = e; - PersistentHashMap.deleteFilesStartingWith(ClassFilesIndexStorageBase.getIndexFile(storageDir)); - } - } - LOG.debug("opened " + indexer.getIndexCanonicalName()); - if (index == null) { - throw new RuntimeException(exception); - } - myIndex = index; - myEmpty = IndexState.EXIST != IndexState.load(storageDir) || exception != null; - IndexState.CORRUPTED.save(storageDir); - } - - private static Set listFiles(final File dir) { - final String[] containingFileNames = dir.list(); - return containingFileNames == null ? Collections.emptySet() : ContainerUtil.newHashSet(containingFileNames); - } - - private File getIndexRoot(final CompileContext compileContext) { - final File rootFile = compileContext.getProjectDescriptor().dataManager.getDataPaths().getDataStorageRoot(); - return ClassFilesIndexStorageBase.getIndexDir(myIndexer.getIndexCanonicalName(), rootFile); - } - - public final boolean isEmpty() { - return myEmpty; - } - - public final void close(final CompileContext compileContext) { - try { - myIndex.close(); - IndexState.EXIST.save(getIndexRoot(compileContext)); - } - catch (final IOException e) { - throw new RuntimeException(e); - } - } - - public final void update(final String id, final ClassReader inputData) { - for (final Map.Entry e : myIndexer.map(inputData, myMappings).entrySet()) { - myIndex.putData(e.getKey(), e.getValue(), id); - } - } -} diff --git a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/ClassFilesIndicesBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/ClassFilesIndicesBuilder.java deleted file mode 100644 index 0bdc7bd9e2c5..000000000000 --- a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/ClassFilesIndicesBuilder.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2000-2016 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.jps.classFilesIndex.indexer.api; - -import com.intellij.compiler.instrumentation.InstrumentationClassFinder; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jps.ModuleChunk; -import org.jetbrains.jps.builders.java.JavaBuilderUtil; -import org.jetbrains.jps.incremental.BinaryContent; -import org.jetbrains.jps.incremental.CompileContext; -import org.jetbrains.jps.incremental.CompiledClass; -import org.jetbrains.jps.incremental.instrumentation.BaseInstrumentingBuilder; -import org.jetbrains.jps.service.JpsServiceManager; -import org.jetbrains.org.objectweb.asm.ClassReader; -import org.jetbrains.org.objectweb.asm.ClassWriter; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Set; - -/** - * @author Dmitry Batkovich - */ -public class ClassFilesIndicesBuilder extends BaseInstrumentingBuilder { - public static final Logger LOG = Logger.getInstance(ClassFilesIndicesBuilder.class); - private static final String PRESENTABLE_NAME = "Class-files indexer"; - private static final String PROGRESS_MESSAGE = "Indexing class-files..."; - public static final String PROPERTY_NAME = "intellij.compiler.output.index"; - - private final Collection myIndexWriters = new ArrayList<>(); - - @Override - @SuppressWarnings("unchecked") - public void buildStarted(final CompileContext context) { - super.buildStarted(context); - final boolean isEnabled = isEnabled(); - LOG.info("class files data index " + (isEnabled ? "enabled" : "disabled")); - if (!isEnabled) { - return; - } - final Set enabledIndicesBuilders = ContainerUtil.newHashSet(System.getProperty(PROPERTY_NAME).split(";")); - final boolean forcedRecompilation = JavaBuilderUtil.isForcedRecompilationAllJavaModules(context); - final Iterable extensions = JpsServiceManager.getInstance().getExtensions(ClassFileIndexerFactory.class); - int newIndicesCount = 0; - for (final ClassFileIndexerFactory builder : extensions) { - if (enabledIndicesBuilders.contains(builder.getClass().getName())) { - final ClassFilesIndexWriter indexWriter = new ClassFilesIndexWriter(builder.create(), context); - if (!indexWriter.isEmpty()) { - myIndexWriters.add(indexWriter); - } - else if (forcedRecompilation) { - newIndicesCount++; - myIndexWriters.add(indexWriter); - } - else { - indexWriter.close(context); - } - } - } - if (forcedRecompilation) { - LOG.info(String.format("class files indexing: %d indices, %d new", myIndexWriters.size(), newIndicesCount)); - } - else { - LOG.info(String.format("class files indexing: %d indices", myIndexWriters.size())); - } - } - - @Override - public void buildFinished(final CompileContext context) { - super.buildFinished(context); - if (!isEnabled()) { - return; - } - for (final ClassFilesIndexWriter index : myIndexWriters) { - index.close(context); - } - myIndexWriters.clear(); - } - - @Nullable - @Override - protected BinaryContent instrument(final CompileContext context, - final CompiledClass compiled, - final ClassReader reader, - final ClassWriter writer, - final InstrumentationClassFinder finder) { - String className = compiled.getClassName(); - if (className == null) { - LOG.debug("class name is empty for " + compiled.getOutputFile().getAbsolutePath()); - } - else { - className = className.replace('.', '/'); - for (final ClassFilesIndexWriter index : myIndexWriters) { - index.update(className, reader); - } - } - return null; - } - - @Override - protected boolean canInstrument(final CompiledClass compiledClass, final int classFileVersion) { - return !"module-info".equals(compiledClass.getClassName()); - } - - @Override - protected boolean isEnabled(final CompileContext context, final ModuleChunk chunk) { - return isEnabled(); - } - - private static boolean isEnabled() { - return System.getProperty(PROPERTY_NAME) != null; - } - - @Override - protected String getProgressMessage() { - return PROGRESS_MESSAGE; - } - - @NotNull - @Override - public String getPresentableName() { - return PRESENTABLE_NAME; - } - -} \ No newline at end of file diff --git a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/IndexState.java b/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/IndexState.java deleted file mode 100644 index 7b34401984cd..000000000000 --- a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/IndexState.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2000-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.jps.classFilesIndex.indexer.api; - -import com.intellij.openapi.util.io.FileUtil; - -import java.io.File; -import java.io.IOException; - -/** - * @author Dmitry Batkovich - */ -public enum IndexState { - CORRUPTED, - NOT_EXIST, - EXIST; - - public static final String STATE_FILE_NAME = "state"; - - public void save(final File indexDir) { - try { - FileUtil.writeToFile(new File(indexDir, STATE_FILE_NAME), name()); - } - catch (final IOException e) { - throw new RuntimeException(e); - } - } - - public static IndexState load(final File indexDir) { - try { - final File indexStateFile = new File(indexDir, STATE_FILE_NAME); - if (!indexStateFile.exists()) { - NOT_EXIST.save(indexDir); - return NOT_EXIST; - } - return Enum.valueOf(IndexState.class, FileUtil.loadFile(indexStateFile)); - } - catch (final IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/storage/ClassFilesIndexStorageBase.java b/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/storage/ClassFilesIndexStorageBase.java deleted file mode 100644 index 8017168bdd6a..000000000000 --- a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/storage/ClassFilesIndexStorageBase.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright 2000-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.jps.classFilesIndex.indexer.api.storage; - -import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.SLRUCache; -import com.intellij.util.io.DataExternalizer; -import com.intellij.util.io.EnumeratorIntegerDescriptor; -import com.intellij.util.io.KeyDescriptor; -import com.intellij.util.io.PersistentHashMap; -import gnu.trove.TIntObjectHashMap; -import gnu.trove.TIntObjectProcedure; -import org.jetbrains.annotations.NotNull; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -/** - * @author Dmitry Batkovich - */ -public class ClassFilesIndexStorageBase { - private static final String INDEX_FILE_NAME = "index"; - private static final int INITIAL_INDEX_SIZE = 16 * 1024; - private static final int CACHE_QUEUES_SIZE = 16 * 1024; - - private final File myIndexFile; - private final KeyDescriptor myKeyDescriptor; - private final DataExternalizer myValueExternalizer; - private PersistentHashMap> myMap; - - protected final Lock myWriteLock = new ReentrantLock(); - protected SLRUCache> myCache; - - public ClassFilesIndexStorageBase(final File indexDir, final KeyDescriptor keyDescriptor, final DataExternalizer valueExternalizer) - throws IOException { - myIndexFile = getIndexFile(indexDir); - myKeyDescriptor = keyDescriptor; - myValueExternalizer = valueExternalizer; - initialize(); - } - - private void initialize() throws IOException { - myMap = new PersistentHashMap<>(myIndexFile, myKeyDescriptor, - createValueContainerExternalizer(myValueExternalizer), - INITIAL_INDEX_SIZE); - myCache = new SLRUCache>(CACHE_QUEUES_SIZE, CACHE_QUEUES_SIZE) { - @NotNull - @Override - public CompiledDataValueContainer createValue(final K key) { - try { - final CompiledDataValueContainer valueContainer = myMap.get(key); - if (valueContainer != null) { - return valueContainer; - } - } - catch (final IOException e) { - throw new RuntimeException(e); - } - return new CompiledDataValueContainer<>(); - } - - @Override - protected void onDropFromCache(final K key, final CompiledDataValueContainer value) { - try { - myMap.put(key, value); - } - catch (final IOException e) { - throw new RuntimeException(e); - } - } - }; - } - - public void delete() throws IOException { - try { - myWriteLock.lock(); - doDelete(); - } - finally { - myWriteLock.unlock(); - } - } - - private void doDelete() throws IOException { - close(); - PersistentHashMap.deleteFilesStartingWith(myIndexFile); - } - - public void clear() throws IOException { - try { - myWriteLock.lock(); - doDelete(); - initialize(); - } - finally { - myWriteLock.unlock(); - } - } - - public void flush() { - try { - myWriteLock.lock(); - myCache.clear(); - } - finally { - myWriteLock.unlock(); - } - myMap.force(); - } - - public void close() throws IOException { - flush(); - myMap.close(); - } - - public static class CompiledDataValueContainer { - private final TIntObjectHashMap myUnderlying; - - private CompiledDataValueContainer(final TIntObjectHashMap map) { - myUnderlying = map; - } - - private CompiledDataValueContainer() { - this(new TIntObjectHashMap<>()); - } - - public void putValue(final Integer inputId, final V value) { - myUnderlying.put(inputId, value); - } - - public Collection getValues() { - return ContainerUtil.list((V[])myUnderlying.getValues()); - } - - } - - public static File getIndexFile(final File indexDir) { - return new File(indexDir, INDEX_FILE_NAME); - } - - public static File getIndexDir(final String indexName, final File projectSystemBuildDirectory) { - return new File(projectSystemBuildDirectory, "compiler.output.data.indices/" + indexName); - } - - private static DataExternalizer> createValueContainerExternalizer(final DataExternalizer valueExternalizer) { - return new DataExternalizer>() { - @Override - public void save(@NotNull final DataOutput out, final CompiledDataValueContainer value) throws IOException { - final TIntObjectHashMap underlying = value.myUnderlying; - out.writeInt(underlying.size()); - final IOException[] ioException = {null}; - underlying.forEachEntry(new TIntObjectProcedure() { - @Override - public boolean execute(final int k, final V v) { - try { - EnumeratorIntegerDescriptor.INSTANCE.save(out, k); - valueExternalizer.save(out, v); - return true; - } - catch (final IOException e) { - ioException[0] = e; - return false; - } - } - }); - if (ioException[0] != null) { - throw ioException[0]; - } - } - - @Override - public CompiledDataValueContainer read(@NotNull final DataInput in) throws IOException { - final TIntObjectHashMap map = new TIntObjectHashMap<>(); - final int size = in.readInt(); - for (int i = 0; i < size; i++) { - map.put(EnumeratorIntegerDescriptor.INSTANCE.read(in), valueExternalizer.read(in)); - } - return new CompiledDataValueContainer<>(map); - } - }; - } -} diff --git a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/storage/ClassFilesIndexStorageWriter.java b/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/storage/ClassFilesIndexStorageWriter.java deleted file mode 100644 index 0002c5e565aa..000000000000 --- a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/api/storage/ClassFilesIndexStorageWriter.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2000-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.jps.classFilesIndex.indexer.api.storage; - -import com.intellij.util.io.DataExternalizer; -import com.intellij.util.io.KeyDescriptor; -import org.jetbrains.jps.builders.java.dependencyView.Mappings; - -import java.io.File; -import java.io.IOException; - -/** - * @author Dmitry Batkovich - */ -public class ClassFilesIndexStorageWriter extends ClassFilesIndexStorageBase { - private final Mappings myMappings; - - public ClassFilesIndexStorageWriter(final File indexDir, - final KeyDescriptor keyDescriptor, - final DataExternalizer valueExternalizer, - final Mappings mappings) throws IOException { - super(indexDir, keyDescriptor, valueExternalizer); - myMappings = mappings; - } - - public void putData(final K key, final V value, final String containingClass) { - final int id = myMappings.getName(containingClass); - try { - myWriteLock.lock(); - final CompiledDataValueContainer container = myCache.get(key); - container.putValue(id, value); - } - finally { - myWriteLock.unlock(); - } - } -} diff --git a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/impl/EnumeratedMethodIncompleteSignature.java b/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/impl/EnumeratedMethodIncompleteSignature.java deleted file mode 100644 index b93a7da728f5..000000000000 --- a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/impl/EnumeratedMethodIncompleteSignature.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2000-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.jps.classFilesIndex.indexer.impl; - -import com.intellij.util.io.DataExternalizer; -import com.intellij.util.io.EnumeratorStringDescriptor; -import org.jetbrains.annotations.NotNull; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -/** - * @author Dmitry Batkovich - */ -public class EnumeratedMethodIncompleteSignature { - - private final int myOwner; - private final int myName; - private final boolean myStatic; - - public EnumeratedMethodIncompleteSignature(final int owner, final int name, final boolean aStatic) { - myOwner = owner; - myName = name; - myStatic = aStatic; - } - - public int getOwner() { - return myOwner; - } - - public int getName() { - return myName; - } - - public boolean isStatic() { - return myStatic; - } - - public static DataExternalizer createDataExternalizer() { - return new DataExternalizer() { - @Override - public void save(@NotNull final DataOutput out, final EnumeratedMethodIncompleteSignature value) throws IOException { - out.writeInt(value.getOwner()); - out.writeInt(value.getName()); - out.writeBoolean(value.isStatic()); - } - - @Override - public EnumeratedMethodIncompleteSignature read(@NotNull final DataInput in) throws IOException { - return new EnumeratedMethodIncompleteSignature(in.readInt(), - in.readInt(), - in.readBoolean()); - } - }; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - final EnumeratedMethodIncompleteSignature that = (EnumeratedMethodIncompleteSignature)o; - - if (myName != that.myName) return false; - if (myOwner != that.myOwner) return false; - if (myStatic != that.myStatic) return false; - - return true; - } - - @Override - public int hashCode() { - int result = myOwner; - result = 31 * result + myName; - result = 31 * result + (myStatic ? 1 : 0); - return result; - } -} diff --git a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/impl/MethodsUsageIndexer.java b/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/impl/MethodsUsageIndexer.java deleted file mode 100644 index 7dc56c33b7e0..000000000000 --- a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/impl/MethodsUsageIndexer.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2000-2016 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.jps.classFilesIndex.indexer.impl; - -import com.intellij.util.io.DataExternalizer; -import com.intellij.util.io.EnumeratorIntegerDescriptor; -import com.intellij.util.io.KeyDescriptor; -import gnu.trove.TObjectIntHashMap; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jps.builders.java.dependencyView.Mappings; -import org.jetbrains.jps.classFilesIndex.AsmUtil; -import org.jetbrains.jps.classFilesIndex.TObjectIntHashMapExternalizer; -import org.jetbrains.jps.classFilesIndex.indexer.api.ClassFileIndexer; -import org.jetbrains.org.objectweb.asm.*; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Dmitry Batkovich - */ -public class MethodsUsageIndexer extends ClassFileIndexer> { - public static final String METHODS_USAGE_INDEX_CANONICAL_NAME = "MethodsUsageIndex"; - - public MethodsUsageIndexer() { - super(METHODS_USAGE_INDEX_CANONICAL_NAME); - } - - @NotNull - @Override - public Map> map(final ClassReader inputData, final Mappings mappings) { - final Map> map = - new HashMap<>(); - final MethodVisitor methodVisitor = new MethodVisitor(Opcodes.API_VERSION) { - @Override - public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { - final Type returnType = Type.getReturnType(desc); - if (AsmUtil.isPrimitiveOrArrayOfPrimitives(returnType.getDescriptor()) || "".equals(name)) { - return; - } - final boolean isStatic = opcode == Opcodes.INVOKESTATIC; - final String returnClassName = returnType.getInternalName(); - if (!owner.equals(returnClassName) || isStatic) { - final EnumeratedMethodIncompleteSignature mi = - new EnumeratedMethodIncompleteSignature(mappings.getName(owner), mappings.getName(name), isStatic); - final int enumeratedClassName = mappings.getName(returnClassName); - TObjectIntHashMap occurrences = map.get(enumeratedClassName); - if (occurrences == null) { - occurrences = new TObjectIntHashMap<>(); - map.put(enumeratedClassName, occurrences); - } - if (!occurrences.increment(mi)) { - occurrences.put(mi, 1); - } - } - } - }; - inputData.accept(new ClassVisitor(Opcodes.API_VERSION) { - @Override - public MethodVisitor visitMethod(final int access, - final String name, - final String desc, - final String signature, - final String[] exceptions) { - return methodVisitor; - } - }, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES); - return map; - } - - @Override - public KeyDescriptor getKeyDescriptor() { - return EnumeratorIntegerDescriptor.INSTANCE; - } - - @Override - public DataExternalizer> getDataExternalizer() { - return new TObjectIntHashMapExternalizer<>(EnumeratedMethodIncompleteSignature.createDataExternalizer()); - } -} \ No newline at end of file diff --git a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/impl/MethodsUsageIndexerFactory.java b/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/impl/MethodsUsageIndexerFactory.java deleted file mode 100644 index 5b4526a9ba62..000000000000 --- a/jps/jps-builders/src/org/jetbrains/jps/classFilesIndex/indexer/impl/MethodsUsageIndexerFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2000-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.jps.classFilesIndex.indexer.impl; - -import gnu.trove.TObjectIntHashMap; -import org.jetbrains.jps.classFilesIndex.indexer.api.ClassFileIndexer; -import org.jetbrains.jps.classFilesIndex.indexer.api.ClassFileIndexerFactory; - -/** -* @author Dmitry Batkovich -*/ -public class MethodsUsageIndexerFactory implements ClassFileIndexerFactory> { - @Override - public ClassFileIndexer> create() { - return new MethodsUsageIndexer(); - } -} diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/JavaBuilderService.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/JavaBuilderService.java index 503bb8d584f7..528cbfdac169 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/JavaBuilderService.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/JavaBuilderService.java @@ -19,7 +19,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.builders.BuildTargetType; import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType; import org.jetbrains.jps.builders.java.ResourcesTargetType; -import org.jetbrains.jps.classFilesIndex.indexer.api.ClassFilesIndicesBuilder; import org.jetbrains.jps.backwardRefs.BackwardReferenceIndexBuilder; import org.jetbrains.jps.incremental.instrumentation.NotNullInstrumentingBuilder; import org.jetbrains.jps.incremental.instrumentation.RmiStubsGenerator; @@ -50,7 +49,6 @@ public class JavaBuilderService extends BuilderService { return Arrays.asList(new JavaBuilder(SharedThreadPool.getInstance()), new NotNullInstrumentingBuilder(), new RmiStubsGenerator(), - new ClassFilesIndicesBuilder(), new BackwardReferenceIndexBuilder()); } diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index affe6be791c9..142eee5b0dfc 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -556,7 +556,6 @@ svn.use.svnkit.for.https.server.certificate.check.description=Use SVNKit to perf svn.use.sqlite.jdbc=true svn.use.sqlite.jdbc.description=Use SQLite JDBC driver (instead of SQLJet) to access svn working copy database -completion.enable.relevant.method.chain.suggestions=false ide.mac.message.sheets.java.emulation=false ide.mac.message.sheets.java.emulation.description=Use Java message sheets instead of native ones ide.mac.message.sheets.java.emulation.dialogs=true diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 9721fe30e6c8..6d3b137e9b4e 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -55,10 +55,6 @@ - - com.intellij.compiler.classFilesIndex.api.index.ClassFilesIndexFeaturesHolder - - com.intellij.psi.RefResolveService com.intellij.psi.refResolve.RefResolveServiceImpl diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml index 6dbb8498fa2c..d809f45a4bc8 100644 --- a/resources/src/idea/RichPlatformPlugin.xml +++ b/resources/src/idea/RichPlatformPlugin.xml @@ -370,7 +370,6 @@ -