This commit is contained in:
Alexey Kudravtsev
2014-03-03 14:05:48 +04:00
parent 4c29f540eb
commit 90c2460fc1
92 changed files with 551 additions and 319 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -46,14 +46,14 @@ public class ImageInfoIndex extends SingleEntryFileBasedIndexExtension<ImageInfo
private final DataExternalizer<ImageInfo> myValueExternalizer = new DataExternalizer<ImageInfo>() {
@Override
public void save(final DataOutput out, final ImageInfo info) throws IOException {
public void save(@NotNull final DataOutput out, final ImageInfo info) throws IOException {
DataInputOutputUtil.writeINT(out, info.width);
DataInputOutputUtil.writeINT(out, info.height);
DataInputOutputUtil.writeINT(out, info.bpp);
}
@Override
public ImageInfo read(final DataInput in) throws IOException {
public ImageInfo read(@NotNull final DataInput in) throws IOException {
return new ImageInfo(DataInputOutputUtil.readINT(in), DataInputOutputUtil.readINT(in), DataInputOutputUtil.readINT(in));
}
};
@@ -83,16 +83,18 @@ public class ImageInfoIndex extends SingleEntryFileBasedIndexExtension<ImageInfo
.fileScope(project, virtualFile));
}
@NotNull
@Override
public DataExternalizer<ImageInfo> getValueExternalizer() {
return myValueExternalizer;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return new DefaultFileTypeSpecificInputFilter(ImageFileTypeManager.getInstance().getImageFileType()) {
@Override
public boolean acceptInput(final VirtualFile file) {
public boolean acceptInput(@NotNull final VirtualFile file) {
return file.isInLocalFileSystem() &&
file.getLength() / 1024 < ourMaxImageSize
;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -19,6 +19,7 @@ import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.EnumeratorStringDescriptor;
import com.intellij.util.io.PersistentHashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.io.DataInput;
import java.io.DataOutput;
@@ -92,11 +93,11 @@ public abstract class StateCache<T> {
private PersistentHashMap<String, T> createMap(final File file) throws IOException {
return new PersistentHashMap<String,T>(file, new EnumeratorStringDescriptor(), new DataExternalizer<T>() {
public void save(final DataOutput out, final T value) throws IOException {
public void save(@NotNull final DataOutput out, final T value) throws IOException {
StateCache.this.write(value, out);
}
public T read(final DataInput in) throws IOException {
public T read(@NotNull final DataInput in) throws IOException {
return StateCache.this.read(in);
}
});
@@ -607,7 +607,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
private void initOutputRootsFile(File rootsFile) throws IOException {
myOutputRootsStorage = new PersistentHashMap<Integer, TIntObjectHashMap<Pair<Integer, Integer>>>(rootsFile, EnumeratorIntegerDescriptor.INSTANCE, new DataExternalizer<TIntObjectHashMap<Pair<Integer, Integer>>>() {
public void save(DataOutput out, TIntObjectHashMap<Pair<Integer, Integer>> value) throws IOException {
public void save(@NotNull DataOutput out, TIntObjectHashMap<Pair<Integer, Integer>> value) throws IOException {
for (final TIntObjectIterator<Pair<Integer, Integer>> it = value.iterator(); it.hasNext();) {
it.advance();
DataInputOutputUtil.writeINT(out, it.key());
@@ -617,7 +617,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
}
}
public TIntObjectHashMap<Pair<Integer, Integer>> read(DataInput in) throws IOException {
public TIntObjectHashMap<Pair<Integer, Integer>> read(@NotNull DataInput in) throws IOException {
final DataInputStream _in = (DataInputStream)in;
final TIntObjectHashMap<Pair<Integer, Integer>> map = new TIntObjectHashMap<Pair<Integer, Integer>>();
while (_in.available() > 0) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* 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.
@@ -112,8 +112,8 @@ public class GenericCompilerCache<Key, SourceState, OutputState> {
}
public static class PersistentStateData<SourceState, OutputState> {
public final SourceState mySourceState;
public final OutputState myOutputState;
@NotNull public final SourceState mySourceState;
@NotNull public final OutputState myOutputState;
private PersistentStateData(@NotNull SourceState sourceState, @NotNull OutputState outputState) {
mySourceState = sourceState;
@@ -139,14 +139,14 @@ public class GenericCompilerCache<Key, SourceState, OutputState> {
}
@Override
public void save(DataOutput out, KeyAndTargetData<Key> value) throws IOException {
public void save(@NotNull DataOutput out, KeyAndTargetData<Key> value) throws IOException {
out.writeInt(value.myTarget);
myKeyDescriptor.save(out, value.myKey);
}
@Override
public KeyAndTargetData<Key> read(DataInput in) throws IOException {
public KeyAndTargetData<Key> read(@NotNull DataInput in) throws IOException {
int target = in.readInt();
final Key item = myKeyDescriptor.read(in);
return getKeyAndTargetData(item, target);
@@ -163,13 +163,13 @@ public class GenericCompilerCache<Key, SourceState, OutputState> {
}
@Override
public void save(DataOutput out, PersistentStateData<SourceState, OutputState> value) throws IOException {
public void save(@NotNull DataOutput out, PersistentStateData<SourceState, OutputState> value) throws IOException {
mySourceStateExternalizer.save(out, value.mySourceState);
myOutputStateExternalizer.save(out, value.myOutputState);
}
@Override
public PersistentStateData<SourceState, OutputState> read(DataInput in) throws IOException {
public PersistentStateData<SourceState, OutputState> read(@NotNull DataInput in) throws IOException {
SourceState sourceState = mySourceStateExternalizer.read(in);
OutputState outputState = myOutputStateExternalizer.read(in);
return new PersistentStateData<SourceState,OutputState>(sourceState, outputState);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -357,7 +357,7 @@ public class BackwardDependenciesStorage implements Flushable, Disposable {
}
private static class MyDataExternalizer implements DataExternalizer<DependenciesSet> {
public void save(DataOutput out, DependenciesSet ds) throws IOException {
public void save(@NotNull DataOutput out, DependenciesSet ds) throws IOException {
final TIntHashSet classes = new TIntHashSet();
final Map<Dependency.FieldRef, TIntHashSet> fieldsMap = new HashMap<Dependency.FieldRef, TIntHashSet>();
final Map<Dependency.MethodRef, TIntHashSet> methodsMap = new HashMap<Dependency.MethodRef, TIntHashSet>();
@@ -414,7 +414,7 @@ public class BackwardDependenciesStorage implements Flushable, Disposable {
}
}
public DependenciesSet read(DataInput in) throws IOException {
public DependenciesSet read(@NotNull DataInput in) throws IOException {
final Set<ReferencerItem> set = new THashSet<ReferencerItem>();
int classesCount = in.readInt();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -25,6 +25,7 @@ import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.EnumeratorIntegerDescriptor;
import com.intellij.util.io.PersistentHashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.DataInput;
@@ -54,10 +55,10 @@ public class Cache {
myStorePath = storePath;
new File(storePath).mkdirs();
myQNameToClassInfoMap = new CachedPersistentHashMap<Integer, ClassInfo>(getOrCreateFile("classes"), EnumeratorIntegerDescriptor.INSTANCE, new DataExternalizer<ClassInfo>() {
public void save(DataOutput out, ClassInfo value) throws IOException {
public void save(@NotNull DataOutput out, ClassInfo value) throws IOException {
value.save(out);
}
public ClassInfo read(DataInput in) throws IOException {
public ClassInfo read(@NotNull DataInput in) throws IOException {
return new ClassInfo(in);
}
}, cacheSize * 2) {
@@ -71,11 +72,11 @@ public class Cache {
myQNameToSubclassesMap = new CompilerDependencyStorage<Integer>(getOrCreateFile("subclasses"), EnumeratorIntegerDescriptor.INSTANCE, cacheSize);
myRemoteQNames = new PersistentHashMap<Integer, Boolean>(getOrCreateFile("remote"), EnumeratorIntegerDescriptor.INSTANCE, new DataExternalizer<Boolean>() {
public void save(DataOutput out, Boolean value) throws IOException {
public void save(@NotNull DataOutput out, Boolean value) throws IOException {
out.writeBoolean(value.booleanValue());
}
public Boolean read(DataInput in) throws IOException {
public Boolean read(@NotNull DataInput in) throws IOException {
return in.readBoolean();
}
}, cacheSize);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -40,14 +40,14 @@ public class CompilerDependencyStorage<Key> implements Flushable, Disposable {
public CompilerDependencyStorage(File file, KeyDescriptor<Key> keyDescriptor, final int cacheSize) throws IOException {
myMap = new PersistentHashMap<Key, int[]>(file, keyDescriptor, new DataExternalizer<int[]>() {
public void save(DataOutput out, int[] array) throws IOException {
public void save(@NotNull DataOutput out, int[] array) throws IOException {
out.writeInt(array.length);
for (int value : array) {
out.writeInt(value);
}
}
public int[] read(DataInput in) throws IOException {
public int[] read(@NotNull DataInput in) throws IOException {
final TIntHashSet set = new TIntHashSet();
DataInputStream stream = (DataInputStream)in;
while(stream.available() > 0) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* 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.
@@ -16,6 +16,7 @@
package com.intellij.openapi.compiler.generic;
import com.intellij.util.io.DataExternalizer;
import org.jetbrains.annotations.NotNull;
import java.io.DataInput;
import java.io.DataOutput;
@@ -33,11 +34,11 @@ public class DummyPersistentState {
private static class DummyPersistentStateExternalizer implements DataExternalizer<DummyPersistentState> {
@Override
public void save(DataOutput out, DummyPersistentState value) throws IOException {
public void save(@NotNull DataOutput out, DummyPersistentState value) throws IOException {
}
@Override
public DummyPersistentState read(DataInput in) throws IOException {
public DummyPersistentState read(@NotNull DataInput in) throws IOException {
return INSTANCE;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* 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.
@@ -16,6 +16,7 @@
package com.intellij.openapi.compiler.generic;
import com.intellij.util.io.DataExternalizer;
import org.jetbrains.annotations.NotNull;
import java.io.DataInput;
import java.io.DataOutput;
@@ -38,12 +39,12 @@ public class VirtualFilePersistentState {
private static class VirtualFileStateExternalizer implements DataExternalizer<VirtualFilePersistentState> {
@Override
public void save(DataOutput out, VirtualFilePersistentState value) throws IOException {
public void save(@NotNull DataOutput out, VirtualFilePersistentState value) throws IOException {
out.writeLong(value.getSourceTimestamp());
}
@Override
public VirtualFilePersistentState read(DataInput in) throws IOException {
public VirtualFilePersistentState read(@NotNull DataInput in) throws IOException {
return new VirtualFilePersistentState(in.readLong());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* 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.
@@ -67,7 +67,7 @@ public class VirtualFileSetState {
private byte[] myBuffer = IOUtil.allocReadWriteUTFBuffer();
@Override
public void save(DataOutput out, VirtualFileSetState value) throws IOException {
public void save(@NotNull DataOutput out, VirtualFileSetState value) throws IOException {
final Map<String, Long> dependencies = value.myTimestamps;
out.writeInt(dependencies.size());
for (Map.Entry<String, Long> entry : dependencies.entrySet()) {
@@ -77,7 +77,7 @@ public class VirtualFileSetState {
}
@Override
public VirtualFileSetState read(DataInput in) throws IOException {
public VirtualFileSetState read(@NotNull DataInput in) throws IOException {
final VirtualFileSetState state = new VirtualFileSetState();
int size = in.readInt();
while (size-- > 0) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* 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.
@@ -63,7 +63,7 @@ public class VirtualFileWithDependenciesState {
private byte[] myBuffer = IOUtil.allocReadWriteUTFBuffer();
@Override
public void save(DataOutput out, VirtualFileWithDependenciesState value) throws IOException {
public void save(@NotNull DataOutput out, VirtualFileWithDependenciesState value) throws IOException {
out.writeLong(value.mySourceTimestamp);
final Map<String, Long> dependencies = value.myDependencies;
out.writeInt(dependencies.size());
@@ -74,7 +74,7 @@ public class VirtualFileWithDependenciesState {
}
@Override
public VirtualFileWithDependenciesState read(DataInput in) throws IOException {
public VirtualFileWithDependenciesState read(@NotNull DataInput in) throws IOException {
final VirtualFileWithDependenciesState state = new VirtualFileWithDependenciesState(in.readLong());
int size = in.readInt();
while (size-- > 0) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* 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.
@@ -19,6 +19,7 @@ import com.intellij.openapi.util.Pair;
import com.intellij.util.SmartList;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.IOUtil;
import org.jetbrains.annotations.NotNull;
import java.io.DataInput;
import java.io.DataOutput;
@@ -31,7 +32,7 @@ public class ArtifactPackagingItemExternalizer implements DataExternalizer<Artif
private byte[] myBuffer = IOUtil.allocReadWriteUTFBuffer();
@Override
public void save(DataOutput out, ArtifactPackagingItemOutputState value) throws IOException {
public void save(@NotNull DataOutput out, ArtifactPackagingItemOutputState value) throws IOException {
out.writeInt(value.myDestinations.size());
for (Pair<String, Long> pair : value.myDestinations) {
IOUtil.writeUTFFast(myBuffer, out, pair.getFirst());
@@ -40,7 +41,7 @@ public class ArtifactPackagingItemExternalizer implements DataExternalizer<Artif
}
@Override
public ArtifactPackagingItemOutputState read(DataInput in) throws IOException {
public ArtifactPackagingItemOutputState read(@NotNull DataInput in) throws IOException {
int size = in.readInt();
SmartList<Pair<String, Long>> destinations = new SmartList<Pair<String, Long>>();
while (size-- > 0) {
@@ -34,6 +34,7 @@ import com.intellij.testFramework.SkipSlowTestLocally;
import com.intellij.util.indexing.MapIndexStorage;
import com.intellij.util.indexing.StorageException;
import com.intellij.util.io.*;
import org.jetbrains.annotations.NotNull;
import java.io.DataInput;
import java.io.DataOutput;
@@ -113,7 +114,7 @@ public class IndexTest extends IdeaTestCase {
private PersistentHashMap<Integer, Collection<String>> createMetaIndex(File metaIndexFile) throws IOException {
return new PersistentHashMap<Integer, Collection<String>>(metaIndexFile, new EnumeratorIntegerDescriptor(), new DataExternalizer<Collection<String>>() {
@Override
public void save(DataOutput out, Collection<String> value) throws IOException {
public void save(@NotNull DataOutput out, Collection<String> value) throws IOException {
DataInputOutputUtil.writeINT(out, value.size());
for (String key : value) {
out.writeUTF(key);
@@ -121,7 +122,7 @@ public class IndexTest extends IdeaTestCase {
}
@Override
public Collection<String> read(DataInput in) throws IOException {
public Collection<String> read(@NotNull DataInput in) throws IOException {
final int size = DataInputOutputUtil.readINT(in);
final List<String> list = new ArrayList<String>();
for (int idx = 0; idx < size; idx++) {
@@ -1,3 +1,18 @@
/*
* 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.index;
import com.intellij.openapi.util.Factory;
@@ -28,7 +43,7 @@ public class StringIndex {
myIndex.setInputIdToDataKeysIndex(factory);
}
public List<String> getFilesByWord(String word) throws StorageException {
public List<String> getFilesByWord(@NotNull String word) throws StorageException {
return myIndex.getData(word).toValueList();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -380,12 +380,12 @@ public class ClassRepr extends Proto {
public static DataExternalizer<ClassRepr> externalizer(final DependencyContext context) {
return new DataExternalizer<ClassRepr>() {
@Override
public void save(final DataOutput out, final ClassRepr value) throws IOException {
public void save(@NotNull final DataOutput out, final ClassRepr value) throws IOException {
value.save(out);
}
@Override
public ClassRepr read(final DataInput in) throws IOException {
public ClassRepr read(@NotNull final DataInput in) throws IOException {
return new ClassRepr(context, in);
}
};
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -16,6 +16,7 @@
package org.jetbrains.jps.builders.java.dependencyView;
import com.intellij.util.io.DataExternalizer;
import org.jetbrains.annotations.NotNull;
import java.io.DataInput;
import java.io.DataOutput;
@@ -57,12 +58,12 @@ class FieldRepr extends ProtoMember {
public static DataExternalizer<FieldRepr> externalizer(final DependencyContext context) {
return new DataExternalizer<FieldRepr>() {
@Override
public void save(final DataOutput out, final FieldRepr value) throws IOException {
public void save(@NotNull final DataOutput out, final FieldRepr value) throws IOException {
value.save(out);
}
@Override
public FieldRepr read(final DataInput in) throws IOException {
public FieldRepr read(@NotNull final DataInput in) throws IOException {
return new FieldRepr(context, in);
}
};
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -256,7 +256,7 @@ class IntIntPersistentMultiMaplet extends IntIntMultiMaplet {
private static class IntSetExternalizer implements DataExternalizer<TIntHashSet> {
@Override
public void save(final DataOutput out, final TIntHashSet value) throws IOException {
public void save(@NotNull final DataOutput out, final TIntHashSet value) throws IOException {
final Ref<IOException> exRef = new Ref<IOException>(null);
value.forEach(new TIntProcedure() {
@Override
@@ -278,7 +278,7 @@ class IntIntPersistentMultiMaplet extends IntIntMultiMaplet {
}
@Override
public TIntHashSet read(final DataInput in) throws IOException {
public TIntHashSet read(@NotNull final DataInput in) throws IOException {
final TIntHashSet result = new TIntHashSet();
final DataInputStream stream = (DataInputStream)in;
while (stream.available() > 0) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -245,14 +245,14 @@ class IntObjectPersistentMultiMaplet<V extends Streamable> extends IntObjectMult
}
@Override
public void save(final DataOutput out, final Collection<V> value) throws IOException {
public void save(@NotNull final DataOutput out, final Collection<V> value) throws IOException {
for (V x : value) {
myElementExternalizer.save(out, x);
}
}
@Override
public Collection<V> read(final DataInput in) throws IOException {
public Collection<V> read(@NotNull final DataInput in) throws IOException {
final Collection<V> result = myCollectionFactory.create();
final DataInputStream stream = (DataInputStream)in;
while (stream.available() > 0) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -18,6 +18,7 @@ package org.jetbrains.jps.builders.java.dependencyView;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.DataInputOutputUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.asm4.Type;
import org.jetbrains.jps.builders.storage.BuildDataCorruptedException;
@@ -159,12 +160,12 @@ class MethodRepr extends ProtoMember {
public static DataExternalizer<MethodRepr> externalizer(final DependencyContext context) {
return new DataExternalizer<MethodRepr>() {
@Override
public void save(final DataOutput out, final MethodRepr value) throws IOException {
public void save(@NotNull final DataOutput out, final MethodRepr value) throws IOException {
value.save(out);
}
@Override
public MethodRepr read(DataInput in) throws IOException {
public MethodRepr read(@NotNull DataInput in) throws IOException {
return new MethodRepr(context, in);
}
};
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -245,14 +245,14 @@ public class ObjectObjectPersistentMultiMaplet<K, V extends Streamable> extends
}
@Override
public void save(final DataOutput out, final Collection<V> value) throws IOException {
public void save(@NotNull final DataOutput out, final Collection<V> value) throws IOException {
for (V x : value) {
myElementExternalizer.save(out, x);
}
}
@Override
public Collection<V> read(final DataInput in) throws IOException {
public Collection<V> read(@NotNull final DataInput in) throws IOException {
final Collection<V> result = myCollectionFactory.create();
final DataInputStream stream = (DataInputStream)in;
while (stream.available() > 0) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -18,6 +18,7 @@ package org.jetbrains.jps.builders.java.dependencyView;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.DataInputOutputUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.asm4.Type;
import org.jetbrains.jps.builders.storage.BuildDataCorruptedException;
@@ -280,12 +281,12 @@ class TypeRepr {
public static DataExternalizer<AbstractType> externalizer(final DependencyContext context) {
return new DataExternalizer<AbstractType>() {
@Override
public void save(final DataOutput out, final AbstractType value) throws IOException {
public void save(@NotNull final DataOutput out, final AbstractType value) throws IOException {
value.save(out);
}
@Override
public AbstractType read(final DataInput in) throws IOException {
public AbstractType read(@NotNull final DataInput in) throws IOException {
AbstractType elementType;
int level = 0;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -19,6 +19,7 @@ import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.DataInputOutputUtil;
import gnu.trove.TIntHashSet;
import gnu.trove.TIntProcedure;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.asm4.Type;
import org.jetbrains.jps.builders.storage.BuildDataCorruptedException;
@@ -505,12 +506,12 @@ class UsageRepr {
public static class AnnotationUsage extends Usage {
public static final DataExternalizer<ElemType> elementTypeExternalizer = new DataExternalizer<ElemType>() {
@Override
public void save(final DataOutput out, final ElemType value) throws IOException {
public void save(@NotNull final DataOutput out, final ElemType value) throws IOException {
DataInputOutputUtil.writeINT(out, value.ordinal());
}
@Override
public ElemType read(final DataInput in) throws IOException {
public ElemType read(@NotNull final DataInput in) throws IOException {
final int ordinal = DataInputOutputUtil.readINT(in);
for (ElemType value : ElemType.values()) {
if (value.ordinal() == ordinal) {
@@ -699,12 +700,12 @@ class UsageRepr {
public static DataExternalizer<Usage> externalizer(final DependencyContext context) {
return new DataExternalizer<Usage>() {
@Override
public void save(final DataOutput out, final Usage value) throws IOException {
public void save(@NotNull final DataOutput out, final Usage value) throws IOException {
value.save(out);
}
@Override
public Usage read(DataInput in) throws IOException {
public Usage read(@NotNull DataInput in) throws IOException {
final byte tag = in.readByte();
switch (tag) {
case CLASS_USAGE:
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -18,6 +18,7 @@ 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;
@@ -34,7 +35,7 @@ public class TObjectIntHashMapExternalizer<K> implements DataExternalizer<TObjec
}
@Override
public void save(final DataOutput out, final TObjectIntHashMap<K> map) throws IOException {
public void save(@NotNull final DataOutput out, final TObjectIntHashMap<K> map) throws IOException {
out.writeInt(map.size());
try {
map.forEachEntry(new TObjectIntProcedure<K>() {
@@ -57,7 +58,7 @@ public class TObjectIntHashMapExternalizer<K> implements DataExternalizer<TObjec
}
@Override
public TObjectIntHashMap<K> read(final DataInput in) throws IOException {
public TObjectIntHashMap<K> read(@NotNull final DataInput in) throws IOException {
final int size = in.readInt();
final TObjectIntHashMap<K> map = new TObjectIntHashMap<K>(size);
for (int i = 0; i < size; i++) {
@@ -163,7 +163,7 @@ public class ClassFilesIndexStorageBase<K, V> {
private static <V> DataExternalizer<CompiledDataValueContainer<V>> createValueContainerExternalizer(final DataExternalizer<V> valueExternalizer) {
return new DataExternalizer<CompiledDataValueContainer<V>>() {
@Override
public void save(final DataOutput out, final CompiledDataValueContainer<V> value) throws IOException {
public void save(@NotNull final DataOutput out, final CompiledDataValueContainer<V> value) throws IOException {
final TIntObjectHashMap<V> underlying = value.myUnderlying;
out.writeInt(underlying.size());
final IOException[] ioException = {null};
@@ -187,7 +187,7 @@ public class ClassFilesIndexStorageBase<K, V> {
}
@Override
public CompiledDataValueContainer<V> read(final DataInput in) throws IOException {
public CompiledDataValueContainer<V> read(@NotNull final DataInput in) throws IOException {
final TIntObjectHashMap<V> map = new TIntObjectHashMap<V>();
final int size = in.readInt();
for (int i = 0; i < size; i++) {
@@ -53,14 +53,14 @@ public class EnumeratedMethodIncompleteSignature {
public static DataExternalizer<EnumeratedMethodIncompleteSignature> createDataExternalizer() {
return new DataExternalizer<EnumeratedMethodIncompleteSignature>() {
@Override
public void save(final DataOutput out, final EnumeratedMethodIncompleteSignature value) throws IOException {
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(final DataInput in) throws IOException {
public EnumeratedMethodIncompleteSignature read(@NotNull final DataInput in) throws IOException {
return new EnumeratedMethodIncompleteSignature(in.readInt(),
in.readInt(),
in.readBoolean());
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -20,6 +20,7 @@ import com.intellij.util.SmartList;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.IOUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.incremental.storage.AbstractStateStorage;
import org.jetbrains.jps.incremental.storage.PathStringDescriptor;
@@ -85,7 +86,7 @@ public class ArtifactOutputToSourceMapping extends AbstractStateStorage<String,
private final byte[] myBuffer = IOUtil.allocReadWriteUTFBuffer();
@Override
public void save(DataOutput out, List<SourcePathAndRootIndex> value) throws IOException {
public void save(@NotNull DataOutput out, List<SourcePathAndRootIndex> value) throws IOException {
for (SourcePathAndRootIndex pair : value) {
IOUtil.writeUTFFast(myBuffer, out, pair.myPath);
out.writeInt(pair.getRootIndex());
@@ -93,7 +94,7 @@ public class ArtifactOutputToSourceMapping extends AbstractStateStorage<String,
}
@Override
public List<SourcePathAndRootIndex> read(DataInput in) throws IOException {
public List<SourcePathAndRootIndex> read(@NotNull DataInput in) throws IOException {
List<SourcePathAndRootIndex> result = new SmartList<SourcePathAndRootIndex>();
final DataInputStream stream = (DataInputStream)in;
while (stream.available() > 0) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -18,6 +18,7 @@ package org.jetbrains.jps.incremental.storage;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.io.IOUtil;
import com.intellij.util.io.KeyDescriptor;
import org.jetbrains.annotations.NotNull;
import java.io.DataInput;
import java.io.DataOutput;
@@ -31,11 +32,11 @@ import java.io.IOException;
public final class FileKeyDescriptor implements KeyDescriptor<File> {
private final byte[] buffer = IOUtil.allocReadWriteUTFBuffer();
public void save(DataOutput out, File value) throws IOException {
public void save(@NotNull DataOutput out, File value) throws IOException {
IOUtil.writeUTFFast(buffer, out, value.getPath());
}
public File read(DataInput in) throws IOException {
public File read(@NotNull DataInput in) throws IOException {
return new File(IOUtil.readUTFFast(buffer, in));
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -83,13 +83,13 @@ public class OneToManyPathsMapping extends AbstractStateStorage<String, Collecti
private static class PathCollectionExternalizer implements DataExternalizer<Collection<String>> {
private final byte[] myBuffer = IOUtil.allocReadWriteUTFBuffer();
public void save(DataOutput out, Collection<String> value) throws IOException {
public void save(@NotNull DataOutput out, Collection<String> value) throws IOException {
for (String str : value) {
IOUtil.writeUTFFast(myBuffer, out, str);
}
}
public Collection<String> read(DataInput in) throws IOException {
public Collection<String> read(@NotNull DataInput in) throws IOException {
final Set<String> result = new THashSet<String>(FileUtil.PATH_HASHING_STRATEGY);
final DataInputStream stream = (DataInputStream)in;
while (stream.available() > 0) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -113,7 +113,7 @@ public class TimestampStorage extends AbstractStateStorage<File, TimestampStorag
}
private static class StateExternalizer implements DataExternalizer<TimestampPerTarget[]> {
public void save(DataOutput out, TimestampPerTarget[] value) throws IOException {
public void save(@NotNull DataOutput out, TimestampPerTarget[] value) throws IOException {
out.writeInt(value.length);
for (TimestampPerTarget target : value) {
out.writeInt(target.targetId);
@@ -121,7 +121,7 @@ public class TimestampStorage extends AbstractStateStorage<File, TimestampStorag
}
}
public TimestampPerTarget[] read(DataInput in) throws IOException {
public TimestampPerTarget[] read(@NotNull DataInput in) throws IOException {
int size = in.readInt();
TimestampPerTarget[] targets = new TimestampPerTarget[size];
for (int i = 0; i < size; i++) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -70,13 +70,13 @@ public class TodoIndex extends FileBasedIndexExtension<TodoIndexEntry, Integer>
}
@Override
public void save(final DataOutput out, final TodoIndexEntry value) throws IOException {
public void save(@NotNull final DataOutput out, final TodoIndexEntry value) throws IOException {
out.writeUTF(value.pattern);
out.writeBoolean(value.caseSensitive);
}
@Override
public TodoIndexEntry read(final DataInput in) throws IOException {
public TodoIndexEntry read(@NotNull final DataInput in) throws IOException {
final String pattern = in.readUTF();
final boolean caseSensitive = in.readBoolean();
return new TodoIndexEntry(pattern, caseSensitive);
@@ -106,7 +106,7 @@ public class TodoIndex extends FileBasedIndexExtension<TodoIndexEntry, Integer>
private final FileBasedIndex.InputFilter myInputFilter = new FileBasedIndex.InputFilter() {
@Override
public boolean acceptInput(final VirtualFile file) {
public boolean acceptInput(@NotNull final VirtualFile file) {
if (!file.isInLocalFileSystem()) {
return false; // do not index TODOs in library sources
}
@@ -147,16 +147,19 @@ public class TodoIndex extends FileBasedIndexExtension<TodoIndexEntry, Integer>
return myIndexer;
}
@NotNull
@Override
public KeyDescriptor<TodoIndexEntry> getKeyDescriptor() {
return myKeyDescriptor;
}
@NotNull
@Override
public DataExternalizer<Integer> getValueExternalizer() {
return myValueExternalizer;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return myInputFilter;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -32,7 +32,7 @@ public class DefaultFileTypeSpecificInputFilter implements FileBasedIndex.FileTy
}
@Override
public boolean acceptInput(VirtualFile file) {
public boolean acceptInput(@NotNull VirtualFile file) {
return true;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -137,7 +137,7 @@ public abstract class FileBasedIndex implements BaseComponent {
* @param project it is guaranteed to return data which is up-to-date withing the project
* Keys obtained from the files which do not belong to the project specified may not be up-to-date or even exist
*/
public abstract <K> boolean processAllKeys(@NotNull ID<K, ?> indexId, Processor<K> processor, @Nullable Project project);
public abstract <K> boolean processAllKeys(@NotNull ID<K, ?> indexId, @NotNull Processor<K> processor, @Nullable Project project);
public <K> boolean processAllKeys(@NotNull ID<K, ?> indexId, @NotNull Processor<K> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter idFilter) {
return processAllKeys(indexId, processor, scope.getProject());
@@ -156,7 +156,7 @@ public abstract class FileBasedIndex implements BaseComponent {
* Author: dmitrylomov
*/
public interface InputFilter {
boolean acceptInput(VirtualFile file);
boolean acceptInput(@NotNull VirtualFile file);
}
public interface FileTypeSpecificInputFilter extends InputFilter {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -39,11 +39,14 @@ public abstract class FileBasedIndexExtension<K, V> {
@NotNull
public abstract DataIndexer<K, V, FileContent> getIndexer();
@NotNull
public abstract KeyDescriptor<K> getKeyDescriptor();
@NotNull
public abstract DataExternalizer<V> getValueExternalizer();
@NotNull
public abstract FileBasedIndex.InputFilter getInputFilter();
public abstract boolean dependsOnFileContent();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -43,19 +43,19 @@ public class IdIndex extends FileBasedIndexExtension<IdIndexEntry, Integer> {
private final FileBasedIndex.InputFilter myInputFilter = new FileBasedIndex.InputFilter() {
@Override
public boolean acceptInput(final VirtualFile file) {
public boolean acceptInput(@NotNull final VirtualFile file) {
return isIndexable(file.getFileType());
}
};
private final DataExternalizer<Integer> myValueExternalizer = new DataExternalizer<Integer>() {
@Override
public void save(final DataOutput out, final Integer value) throws IOException {
public void save(@NotNull final DataOutput out, final Integer value) throws IOException {
out.writeByte(value.intValue());
}
@Override
public Integer read(final DataInput in) throws IOException {
public Integer read(@NotNull final DataInput in) throws IOException {
return Integer.valueOf(in.readByte());
}
};
@@ -107,16 +107,19 @@ public class IdIndex extends FileBasedIndexExtension<IdIndexEntry, Integer> {
return myIndexer;
}
@NotNull
@Override
public DataExternalizer<Integer> getValueExternalizer() {
return myValueExternalizer;
}
@NotNull
@Override
public KeyDescriptor<IdIndexEntry> getKeyDescriptor() {
return myKeyDescriptor;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return myInputFilter;
@@ -1,3 +1,18 @@
/*
* 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.psi.search;
import com.intellij.openapi.fileTypes.FileType;
@@ -47,11 +62,13 @@ public class FileTypeIndex extends ScalarIndexExtension<FileType>
return this;
}
@NotNull
@Override
public KeyDescriptor<FileType> getKeyDescriptor() {
return this;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return this;
@@ -73,17 +90,17 @@ public class FileTypeIndex extends ScalarIndexExtension<FileType>
}
@Override
public boolean acceptInput(VirtualFile file) {
public boolean acceptInput(@NotNull VirtualFile file) {
return !file.isDirectory();
}
@Override
public void save(DataOutput out, FileType value) throws IOException {
public void save(@NotNull DataOutput out, FileType value) throws IOException {
myEnumeratorStringDescriptor.save(out, value.getName());
}
@Override
public FileType read(DataInput in) throws IOException {
public FileType read(@NotNull DataInput in) throws IOException {
String read = myEnumeratorStringDescriptor.read(in);
return myFileTypeManager.findFileTypeByName(read);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -54,11 +54,13 @@ public class FilenameIndex extends ScalarIndexExtension<String> {
return myDataIndexer;
}
@NotNull
@Override
public KeyDescriptor<String> getKeyDescriptor() {
return myKeyDescriptor;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return myInputFilter;
@@ -156,7 +158,7 @@ public class FilenameIndex extends ScalarIndexExtension<String> {
private static class MyInputFilter implements FileBasedIndex.InputFilter {
@Override
public boolean acceptInput(final VirtualFile file) {
public boolean acceptInput(@NotNull final VirtualFile file) {
return true;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -17,6 +17,7 @@
package com.intellij.util.indexing;
import com.intellij.util.io.DataExternalizer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.DataInput;
@@ -31,6 +32,7 @@ public abstract class ScalarIndexExtension<K> extends FileBasedIndexExtension<K,
public static final DataExternalizer<Void> VOID_DATA_EXTERNALIZER = new VoidDataExternalizer();
@NotNull
@Override
public final DataExternalizer<Void> getValueExternalizer() {
return VOID_DATA_EXTERNALIZER;
@@ -39,12 +41,12 @@ public abstract class ScalarIndexExtension<K> extends FileBasedIndexExtension<K,
private static class VoidDataExternalizer implements DataExternalizer<Void> {
@Override
public void save(final DataOutput out, final Void value) throws IOException {
public void save(@NotNull final DataOutput out, final Void value) throws IOException {
}
@Override
@Nullable
public Void read(final DataInput in) throws IOException {
public Void read(@NotNull final DataInput in) throws IOException {
return null;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull;
* Date: Feb 18, 2009
*/
public abstract class SingleEntryFileBasedIndexExtension<V> extends FileBasedIndexExtension<Integer, V>{
@NotNull
@Override
public final KeyDescriptor<Integer> getKeyDescriptor() {
return EnumeratorIntegerDescriptor.INSTANCE;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -38,13 +38,13 @@ public class TrigramIndex extends ScalarIndexExtension<Integer> {
private static final FileBasedIndex.InputFilter INPUT_FILTER = new FileBasedIndex.InputFilter() {
@Override
public boolean acceptInput(VirtualFile file) {
public boolean acceptInput(@NotNull VirtualFile file) {
return !file.getFileType().isBinary();
}
};
private static final FileBasedIndex.InputFilter NO_FILES = new FileBasedIndex.InputFilter() {
@Override
public boolean acceptInput(VirtualFile file) {
public boolean acceptInput(@NotNull VirtualFile file) {
return false;
}
};
@@ -76,11 +76,13 @@ public class TrigramIndex extends ScalarIndexExtension<Integer> {
};
}
@NotNull
@Override
public KeyDescriptor<Integer> getKeyDescriptor() {
return EnumeratorIntegerDescriptor.INSTANCE;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
if (ENABLED) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* 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.
@@ -141,7 +141,7 @@ public class DetectedFrameworksData {
private static class TIntHashSetExternalizer implements DataExternalizer<TIntHashSet> {
@Override
public void save(DataOutput out, TIntHashSet value) throws IOException {
public void save(@NotNull DataOutput out, TIntHashSet value) throws IOException {
out.writeInt(value.size());
final TIntIterator iterator = value.iterator();
while (iterator.hasNext()) {
@@ -150,7 +150,7 @@ public class DetectedFrameworksData {
}
@Override
public TIntHashSet read(DataInput in) throws IOException {
public TIntHashSet read(@NotNull DataInput in) throws IOException {
int size = in.readInt();
final TIntHashSet set = new TIntHashSet(size);
while (size-- > 0) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* 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.
@@ -91,11 +91,13 @@ public class FrameworkDetectionIndex extends ScalarIndexExtension<Integer> {
};
}
@NotNull
@Override
public KeyDescriptor<Integer> getKeyDescriptor() {
return EnumeratorIntegerDescriptor.INSTANCE;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
final Set<FileType> acceptedTypes = new HashSet<FileType>();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -108,6 +108,7 @@ public class FileIncludeIndex extends FileBasedIndexExtension<FileIncludeIndex.K
};
}
@NotNull
@Override
public KeyDescriptor<Key> getKeyDescriptor() {
return new KeyDescriptor<Key>() {
@@ -122,24 +123,25 @@ public class FileIncludeIndex extends FileBasedIndexExtension<FileIncludeIndex.K
}
@Override
public void save(DataOutput out, Key value) throws IOException {
public void save(@NotNull DataOutput out, Key value) throws IOException {
out.writeBoolean(value.isInclude());
value.writeValue(out);
}
@Override
public Key read(DataInput in) throws IOException {
public Key read(@NotNull DataInput in) throws IOException {
boolean isInclude = in.readBoolean();
return isInclude ? IncludeKey.read(in) : new FileKey(in.readInt());
}
};
}
@NotNull
@Override
public DataExternalizer<List<FileIncludeInfoImpl>> getValueExternalizer() {
return new DataExternalizer<List<FileIncludeInfoImpl>>() {
@Override
public void save(DataOutput out, List<FileIncludeInfoImpl> value) throws IOException {
public void save(@NotNull DataOutput out, List<FileIncludeInfoImpl> value) throws IOException {
out.writeInt(value.size());
for (FileIncludeInfoImpl info : value) {
out.writeUTF(info.path);
@@ -150,7 +152,7 @@ public class FileIncludeIndex extends FileBasedIndexExtension<FileIncludeIndex.K
}
@Override
public List<FileIncludeInfoImpl> read(DataInput in) throws IOException {
public List<FileIncludeInfoImpl> read(@NotNull DataInput in) throws IOException {
int size = in.readInt();
ArrayList<FileIncludeInfoImpl> infos = new ArrayList<FileIncludeInfoImpl>(size);
for (int i = 0; i < size; i++) {
@@ -161,11 +163,12 @@ public class FileIncludeIndex extends FileBasedIndexExtension<FileIncludeIndex.K
};
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return new FileBasedIndex.FileTypeSpecificInputFilter() {
@Override
public boolean acceptInput(VirtualFile file) {
public boolean acceptInput(@NotNull VirtualFile file) {
if (file.getFileSystem() == JarFileSystem.getInstance()) {
return false;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -31,6 +31,7 @@ import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NotNullComputable;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.ManagingFS;
@@ -57,7 +58,6 @@ import org.jetbrains.annotations.Nullable;
import java.io.*;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
@@ -165,7 +165,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
private static class StubIdExternalizer implements DataExternalizer<StubIdList> {
@Override
public void save(final DataOutput out, @NotNull final StubIdList value) throws IOException {
public void save(@NotNull final DataOutput out, @NotNull final StubIdList value) throws IOException {
int size = value.size();
if (size == 0) {
DataInputOutputUtil.writeINT(out, Integer.MAX_VALUE);
@@ -183,7 +183,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
@NotNull
@Override
public StubIdList read(final DataInput in) throws IOException {
public StubIdList read(@NotNull final DataInput in) throws IOException {
int size = DataInputOutputUtil.readINT(in);
if (size == Integer.MAX_VALUE) {
return new StubIdList();
@@ -428,9 +428,10 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
public <K> void updateIndex(@NotNull StubIndexKey key, int fileId, @NotNull final Map<K, StubIdList> oldValues, @NotNull Map<K, StubIdList> newValues) {
try {
final MyIndex<K> index = (MyIndex<K>)myIndices.get(key);
index.updateWithMap(fileId, newValues, new Callable<Collection<K>>() {
index.updateWithMap(fileId, newValues, new NotNullComputable<Collection<K>>() {
@NotNull
@Override
public Collection<K> call() throws Exception {
public Collection<K> compute() {
return oldValues.keySet();
}
});
@@ -449,7 +450,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
@Override
public void updateWithMap(final int inputId,
@NotNull final Map<K, StubIdList> newData,
@NotNull Callable<Collection<K>> oldKeysGetter) throws StorageException {
@NotNull NotNullComputable<Collection<K>> oldKeysGetter) throws StorageException {
super.updateWithMap(inputId, newData, oldKeysGetter);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* 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.
@@ -23,6 +23,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.util.NotNullComputable;
import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.FileAttribute;
@@ -37,7 +38,6 @@ import org.jetbrains.annotations.NotNull;
import java.io.*;
import java.util.*;
import java.util.concurrent.Callable;
/*
* @author max
@@ -54,13 +54,13 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi
private static final DataExternalizer<SerializedStubTree> KEY_EXTERNALIZER = new DataExternalizer<SerializedStubTree>() {
@Override
public void save(final DataOutput out, @NotNull final SerializedStubTree v) throws IOException {
public void save(@NotNull final DataOutput out, @NotNull final SerializedStubTree v) throws IOException {
v.write(out);
}
@NotNull
@Override
public SerializedStubTree read(final DataInput in) throws IOException {
public SerializedStubTree read(@NotNull final DataInput in) throws IOException {
return new SerializedStubTree(in);
}
};
@@ -226,11 +226,11 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi
@NotNull
@Override
public UpdatableIndex<Integer, SerializedStubTree, FileContent> createIndexImplementation(final ID<Integer, SerializedStubTree> indexId, @NotNull final FileBasedIndex owner, @NotNull IndexStorage<Integer, SerializedStubTree> storage)
public UpdatableIndex<Integer, SerializedStubTree, FileContent> createIndexImplementation(@NotNull final ID<Integer, SerializedStubTree> indexId, @NotNull final FileBasedIndex owner, @NotNull IndexStorage<Integer, SerializedStubTree> storage)
throws StorageException {
if (storage instanceof MemoryIndexStorage) {
final MemoryIndexStorage<Integer, SerializedStubTree> memStorage = (MemoryIndexStorage<Integer, SerializedStubTree>)storage;
memStorage.addBufferingStateListsner(new MemoryIndexStorage.BufferingStateListener() {
memStorage.addBufferingStateListener(new MemoryIndexStorage.BufferingStateListener() {
@Override
public void bufferingStateChanged(final boolean newState) {
((StubIndexImpl)StubIndex.getInstance()).setDataBufferingEnabled(newState);
@@ -294,7 +294,7 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi
@Override
protected void updateWithMap(final int inputId,
@NotNull final Map<Integer, SerializedStubTree> newData,
@NotNull Callable<Collection<Integer>> oldKeysGetter)
@NotNull NotNullComputable<Collection<Integer>> oldKeysGetter)
throws StorageException {
checkNameStorage();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.Nullable;
*/
public interface AbstractIndex<Key, Value> {
@NotNull
ValueContainer<Value> getData(Key key) throws StorageException;
ValueContainer<Value> getData(@NotNull Key key) throws StorageException;
boolean processAllKeys(Processor<Key> processor, GlobalSearchScope scope, @Nullable IdFilter idFilter) throws StorageException;
boolean processAllKeys(@NotNull Processor<Key> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter idFilter) throws StorageException;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -19,6 +19,7 @@ package com.intellij.util.indexing;
import com.intellij.openapi.util.Computable;
import gnu.trove.TIntHashSet;
import gnu.trove.TIntProcedure;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Iterator;
@@ -72,11 +73,13 @@ class ChangeTrackingValueContainer<Value> extends UpdatableValueContainer<Value>
return getMergedData().size();
}
@NotNull
@Override
public Iterator<Value> getValueIterator() {
return getMergedData().getValueIterator();
}
@NotNull
@Override
public List<Value> toValueList() {
return getMergedData().toValueList();
@@ -87,11 +90,13 @@ class ChangeTrackingValueContainer<Value> extends UpdatableValueContainer<Value>
return getMergedData().isAssociated(value, inputId);
}
@NotNull
@Override
public IntPredicate getValueAssociationPredicate(Value value) {
return getMergedData().getValueAssociationPredicate(value);
}
@NotNull
@Override
public IntIterator getInputIdsIterator(final Value value) {
return getMergedData().getInputIdsIterator(value);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -23,6 +23,6 @@ import org.jetbrains.annotations.NotNull;
public abstract class CustomImplementationFileBasedIndexExtension<K, V, I> extends FileBasedIndexExtension<K, V> {
@NotNull
public abstract UpdatableIndex<K, V, I> createIndexImplementation(final ID<K, V> indexId, @NotNull FileBasedIndex owner, @NotNull IndexStorage<K, V> storage)
public abstract UpdatableIndex<K, V, I> createIndexImplementation(@NotNull ID<K, V> indexId, @NotNull FileBasedIndex owner, @NotNull IndexStorage<K, V> storage)
throws StorageException;
}
@@ -252,8 +252,8 @@ public class FileBasedIndexImpl extends FileBasedIndex {
myConnection = connection;
}
public static boolean isProjectOrWorkspaceFile(final VirtualFile file,
final @Nullable FileType fileType) {
public static boolean isProjectOrWorkspaceFile(@NotNull VirtualFile file,
@Nullable FileType fileType) {
if (fileType instanceof InternalFileType) return true;
VirtualFile parent = file.isDirectory() ? file: file.getParent();
while(parent instanceof VirtualFileSystemEntry) {
@@ -369,8 +369,6 @@ public class FileBasedIndexImpl extends FileBasedIndex {
}
/**
* @param extension
* @param isCurrentVersionCorrupted
* @return true if registered index requires full rebuild for some reason, e.g. is just created or corrupted
*/
private <K, V> boolean registerIndexer(@NotNull final FileBasedIndexExtension<K, V> extension, final boolean isCurrentVersionCorrupted)
@@ -394,7 +392,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
return versionChanged;
}
private <K, V> void initIndexStorage(final FileBasedIndexExtension<K, V> extension, int version, File versionFile)
private <K, V> void initIndexStorage(@NotNull FileBasedIndexExtension<K, V> extension, int version, @NotNull File versionFile)
throws IOException {
MapIndexStorage<K, V> storage = null;
final ID<K, V> name = extension.getName();
@@ -429,7 +427,8 @@ public class FileBasedIndexImpl extends FileBasedIndex {
ids.add(name);
}
});
} else {
}
else {
myIndicesWithoutFileTypeInfo.add(name);
}
@@ -545,12 +544,12 @@ public class FileBasedIndexImpl extends FileBasedIndex {
@NotNull MemoryIndexStorage<K, ?> storage)
throws IOException {
final File indexStorageFile = IndexInfrastructure.getInputIndexStorageFile(indexId);
final Ref<Boolean> isBufferingMode = new Ref<Boolean>(false);
final AtomicBoolean isBufferingMode = new AtomicBoolean();
final TIntObjectHashMap<Collection<K>> tempMap = new TIntObjectHashMap<Collection<K>>();
final DataExternalizer<Collection<K>> dataExternalizer = new DataExternalizer<Collection<K>>() {
@Override
public void save(DataOutput out, @NotNull Collection<K> value) throws IOException {
public void save(@NotNull DataOutput out, @NotNull Collection<K> value) throws IOException {
try {
DataInputOutputUtil.writeINT(out, value.size());
for (K key : value) {
@@ -564,7 +563,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
@NotNull
@Override
public Collection<K> read(DataInput in) throws IOException {
public Collection<K> read(@NotNull DataInput in) throws IOException {
try {
final int size = DataInputOutputUtil.readINT(in);
final List<K> list = new ArrayList<K>(size);
@@ -621,7 +620,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
}
};
storage.addBufferingStateListsner(new MemoryIndexStorage.BufferingStateListener() {
storage.addBufferingStateListener(new MemoryIndexStorage.BufferingStateListener() {
@Override
public void bufferingStateChanged(boolean newState) {
synchronized (map) {
@@ -715,10 +714,11 @@ public class FileBasedIndexImpl extends FileBasedIndex {
}
@Override
public <K> boolean processAllKeys(@NotNull final ID<K, ?> indexId, Processor<K> processor, @Nullable Project project) {
return processAllKeys(indexId, processor, project != null ? GlobalSearchScope.allScope(project) : new EverythingGlobalScope(), null);
public <K> boolean processAllKeys(@NotNull final ID<K, ?> indexId, @NotNull Processor<K> processor, @Nullable Project project) {
return processAllKeys(indexId, processor, project == null ? new EverythingGlobalScope() : GlobalSearchScope.allScope(project), null);
}
@Override
public <K> boolean processAllKeys(@NotNull ID<K, ?> indexId, @NotNull Processor<K> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter idFilter) {
try {
final UpdatableIndex<K, ?, FileContent> index = getIndex(indexId);
@@ -949,7 +949,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
return null;
}
private <K, V> boolean processValuesImpl(@NotNull final ID<K, V> indexId, final K dataKey, final boolean ensureValueProcessedOnce,
private <K, V> boolean processValuesImpl(@NotNull final ID<K, V> indexId, @NotNull final K dataKey, final boolean ensureValueProcessedOnce,
@Nullable final VirtualFile restrictToFile, @NotNull final ValueProcessor<V> processor,
@NotNull final GlobalSearchScope scope, @Nullable final IdFilter idFilter) {
ThrowableConvertor<UpdatableIndex<K, V, FileContent>, Boolean, StorageException> keyProcessor =
@@ -1058,6 +1058,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
});
}
@Override
public boolean containsFileId(int id) {
if (id < myMinId) return false;
if (id > myMaxId) return false;
@@ -1659,7 +1660,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
return (UpdatableIndex<K, V, FileContent>)pair.getFirst();
}
private InputFilter getInputFilter(ID<?, ?> indexId) {
private InputFilter getInputFilter(@NotNull ID<?, ?> indexId) {
final Pair<UpdatableIndex<?, ?, FileContent>, InputFilter> pair = myIndices.get(indexId);
assert pair != null : "Index data is absent for index " + indexId;
@@ -1766,7 +1767,8 @@ public class FileBasedIndexImpl extends FileBasedIndex {
}
}
public static FileType getFileType(VirtualFile file) {
@NotNull
public static FileType getFileType(@NotNull VirtualFile file) {
FileType fileType = file.getFileType();
if (fileType == FileTypes.PLAIN_TEXT && FileTypeManagerImpl.isFileTypeDetectedFromContent(file)) {
fileType = FileTypes.UNKNOWN;
@@ -1803,7 +1805,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
fc.putUserData(IndexingDataKeys.PROJECT, project);
}
private void updateSingleIndex(final ID<?, ?> indexId, @NotNull final VirtualFile file, @Nullable FileContent currentFC)
private void updateSingleIndex(@NotNull ID<?, ?> indexId, @NotNull final VirtualFile file, @Nullable FileContent currentFC)
throws StorageException {
if (ourRebuildStatus.get(indexId).get() == REQUIRES_REBUILD) {
return; // the index is scheduled for rebuild, no need to update
@@ -1823,8 +1825,9 @@ public class FileBasedIndexImpl extends FileBasedIndex {
);
}
private Runnable createIndexedStampUpdateRunnable(final ID<?, ?> indexId,
final VirtualFile file,
@NotNull
private Runnable createIndexedStampUpdateRunnable(@NotNull final ID<?, ?> indexId,
@NotNull final VirtualFile file,
final boolean hasContent) {
return new Runnable() {
@Override
@@ -1843,7 +1846,8 @@ public class FileBasedIndexImpl extends FileBasedIndex {
};
}
private Computable<Boolean> createUpdateComputableWithBufferingDisabled(final Computable<Boolean> update) {
@NotNull
private Computable<Boolean> createUpdateComputableWithBufferingDisabled(@NotNull final Computable<Boolean> update) {
return new Computable<Boolean>() {
@Override
public Boolean compute() {
@@ -2080,7 +2084,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
});
}
private void invalidateIndicesForFile(final VirtualFile file, boolean markForReindex) {
private void invalidateIndicesForFile(@NotNull final VirtualFile file, boolean markForReindex) {
cleanProcessedFlag(file);
IndexingStamp.flushCache(file);
@@ -2439,12 +2443,12 @@ public class FileBasedIndexImpl extends FileBasedIndex {
}
}
private boolean shouldIndexFile(final VirtualFile file, final ID<?, ?> indexId) {
private boolean shouldIndexFile(@NotNull VirtualFile file, @NotNull ID<?, ?> indexId) {
return getInputFilter(indexId).acceptInput(file) &&
(isMock(file) || !isFileIndexed(file, indexId));
}
private static boolean isFileIndexed(VirtualFile file, ID<?, ?> indexId) {
private static boolean isFileIndexed(VirtualFile file, @NotNull ID<?, ?> indexId) {
return IndexingStamp.isFileIndexed(file, indexId, IndexInfrastructure.getIndexCreationStamp(indexId));
}
@@ -2537,7 +2541,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
}
@Override
public boolean acceptInput(final VirtualFile file) {
public boolean acceptInput(@NotNull final VirtualFile file) {
return file instanceof VirtualFileWithId && myDelegate.acceptInput(file);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -119,14 +119,15 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple
return myIndex.getNumberOfPendingInvalidations();
}
@NotNull
@Override
public VirtualFile[] queryNeededFiles(ProgressIndicator indicator) {
public VirtualFile[] queryNeededFiles(@NotNull ProgressIndicator indicator) {
Collection<VirtualFile> files = myIndex.getFilesToUpdate(myProject);
return VfsUtilCore.toVirtualFileArray(files);
}
@Override
public void processFile(FileContent fileContent) {
public void processFile(@NotNull FileContent fileContent) {
myIndex.processRefreshedFile(myProject, fileContent);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -47,23 +47,28 @@ public class IndexInfrastructure {
private IndexInfrastructure() {
}
@NotNull
public static File getVersionFile(@NotNull ID<?, ?> indexName) {
return new File(getIndexDirectory(indexName, true), indexName + ".ver");
}
@NotNull
public static File getStorageFile(@NotNull ID<?, ?> indexName) {
return new File(getIndexRootDir(indexName), indexName.toString());
}
@NotNull
public static File getInputIndexStorageFile(@NotNull ID<?, ?> indexName) {
return new File(getIndexRootDir(indexName), indexName.toString()+"_inputs");
return new File(getIndexRootDir(indexName), indexName +"_inputs");
}
@NotNull
public static File getIndexRootDir(@NotNull ID<?, ?> indexName) {
return getIndexDirectory(indexName, false);
}
private static File getIndexDirectory(ID<?, ?> indexName, boolean forVersion) {
@NotNull
private static File getIndexDirectory(@NotNull ID<?, ?> indexName, boolean forVersion) {
final String dirName = indexName.toString().toLowerCase(Locale.US);
// store StubIndices under StubUpdating index' root to ensure they are deleted
// when StubUpdatingIndex version is changed
@@ -76,7 +81,7 @@ public class IndexInfrastructure {
private static volatile long ourLastStamp; // ensure any file index stamp increases
public static synchronized void rewriteVersion(final File file, final int version) throws IOException {
public static synchronized void rewriteVersion(@NotNull final File file, final int version) throws IOException {
final long prevLastModifiedValue = file.lastModified();
if (file.exists()) {
FileUtil.delete(file);
@@ -108,7 +113,7 @@ public class IndexInfrastructure {
}
}
public static long getIndexCreationStamp(ID<?, ?> indexName) {
public static long getIndexCreationStamp(@NotNull ID<?, ?> indexName) {
Long version = ourIndexIdToCreationStamp.get(indexName);
if (version != null) return version.longValue();
@@ -118,7 +123,7 @@ public class IndexInfrastructure {
return stamp;
}
public static boolean versionDiffers(final File versionFile, final int currentIndexVersion) {
public static boolean versionDiffers(@NotNull File versionFile, final int currentIndexVersion) {
try {
ourLastStamp = Math.max(ourLastStamp, versionFile.lastModified());
final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(versionFile)));
@@ -137,7 +142,7 @@ public class IndexInfrastructure {
}
@Nullable
public static VirtualFile findFileById(final PersistentFS fs, final int id) {
public static VirtualFile findFileById(@NotNull PersistentFS fs, final int id) {
if (ourUnitTestMode) {
final VirtualFile testFile = findTestFile(id);
if (testFile != null) {
@@ -159,7 +164,7 @@ public class IndexInfrastructure {
}
@Nullable
public static VirtualFile findFileByIdIfCached(final PersistentFS fs, final int id) {
public static VirtualFile findFileByIdIfCached(@NotNull PersistentFS fs, final int id) {
if (ourUnitTestMode) {
final VirtualFile testFile = findTestFile(id);
if (testFile != null) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -33,15 +33,16 @@ public interface IndexStorage<Key, Value> extends Flushable {
void addValue(Key key, int inputId, Value value) throws StorageException;
void removeAllValues(Key key, int inputId) throws StorageException;
void removeAllValues(@NotNull Key key, int inputId) throws StorageException;
void clear() throws StorageException;
@NotNull
ValueContainer<Value> read(Key key) throws StorageException;
boolean processKeys(Processor<Key> processor, GlobalSearchScope scope, @Nullable IdFilter idFilter) throws StorageException;
boolean processKeys(@NotNull Processor<Key> processor, GlobalSearchScope scope, @Nullable IdFilter idFilter) throws StorageException;
@NotNull
Collection<Key> getKeys() throws StorageException;
void close() throws StorageException;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -60,7 +60,7 @@ public final class MapIndexStorage<Key, Value> implements IndexStorage<Key, Valu
private final Lock l = new ReentrantLock();
private final DataExternalizer<Value> myDataExternalizer;
private boolean myHighKeySelectivity;
private final boolean myHighKeySelectivity;
private final LowMemoryWatcher myLowMemoryFlusher = LowMemoryWatcher.register(new Runnable() {
@Override
public void run() {
@@ -70,7 +70,8 @@ public final class MapIndexStorage<Key, Value> implements IndexStorage<Key, Valu
myCache.clear();
if (myMap.isDirty()) myMap.force();
}
} finally {
}
finally {
l.unlock();
}
}
@@ -89,9 +90,7 @@ public final class MapIndexStorage<Key, Value> implements IndexStorage<Key, Valu
@NotNull DataExternalizer<Value> valueExternalizer,
final int cacheSize,
boolean highKeySelectivity,
boolean buildKeyHashToVirtualFileMapping
) throws IOException {
boolean buildKeyHashToVirtualFileMapping) throws IOException {
myStorageFile = storageFile;
myKeyDescriptor = keyDescriptor;
myCacheSize = cacheSize;
@@ -150,6 +149,7 @@ public final class MapIndexStorage<Key, Value> implements IndexStorage<Key, Valu
myKeyHashToVirtualFileMapping = myBuildKeyHashToVirtualFileMapping ? new KeyHash2VirtualFileEnumerator(getProjectFile()) : null;
}
@NotNull
private File getProjectFile() {
return new File(myStorageFile.getPath() + ".project");
}
@@ -222,7 +222,7 @@ public final class MapIndexStorage<Key, Value> implements IndexStorage<Key, Valu
}
@Override
public boolean processKeys(final Processor<Key> processor, GlobalSearchScope scope, final IdFilter idFilter) throws StorageException {
public boolean processKeys(@NotNull final Processor<Key> processor, GlobalSearchScope scope, final IdFilter idFilter) throws StorageException {
l.lock();
try {
myCache.clear(); // this will ensure that all new keys are made into the map
@@ -298,7 +298,8 @@ public final class MapIndexStorage<Key, Value> implements IndexStorage<Key, Valu
}
}
private static TIntHashSet loadHashedIds(File fileWithCaches) throws IOException {
@NotNull
private static TIntHashSet loadHashedIds(@NotNull File fileWithCaches) throws IOException {
DataInputStream inputStream = null;
try {
inputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(fileWithCaches)));
@@ -315,12 +316,13 @@ public final class MapIndexStorage<Key, Value> implements IndexStorage<Key, Valu
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException ex) {}
}
catch (IOException ignored) {}
}
}
}
private void saveHashedIds(TIntHashSet hashMaskSet, int largestId, GlobalSearchScope scope) {
private void saveHashedIds(@NotNull TIntHashSet hashMaskSet, int largestId, @NotNull GlobalSearchScope scope) {
File newFileWithCaches = getSavedProjectFileValueIds(largestId, scope);
assert newFileWithCaches != null;
DataOutputStream stream = null;
@@ -341,17 +343,22 @@ public final class MapIndexStorage<Key, Value> implements IndexStorage<Key, Valu
}
});
if (result) myLastScannedId = largestId;
} catch (IOException ex) {}
}
catch (IOException ignored) {
}
finally {
if (stream != null) {
try {
stream.close();
} catch (IOException ex) {}
}
catch (IOException ignored) {}
}
}
}
private @Nullable File getSavedProjectFileValueIds(int id, GlobalSearchScope scope) {
@Nullable
private File getSavedProjectFileValueIds(int id, @NotNull GlobalSearchScope scope) {
Project project = scope.getProject();
if (project == null) return null;
return new File(myStorageFile.getPath() + ".project."+project.hashCode() + "."+id + "." + scope.isSearchInLibraries());
@@ -423,7 +430,7 @@ public final class MapIndexStorage<Key, Value> implements IndexStorage<Key, Valu
}
@Override
public void removeAllValues(Key key, int inputId) throws StorageException {
public void removeAllValues(@NotNull Key key, int inputId) throws StorageException {
try {
myMap.markDirty();
// important: assuming the key exists in the index
@@ -436,13 +443,13 @@ public final class MapIndexStorage<Key, Value> implements IndexStorage<Key, Valu
private static class IntPairInArrayKeyDescriptor implements KeyDescriptor<int[]>, DifferentSerializableBytesImplyNonEqualityPolicy {
@Override
public void save(DataOutput out, int[] value) throws IOException {
public void save(@NotNull DataOutput out, int[] value) throws IOException {
DataInputOutputUtil.writeINT(out, value[0]);
DataInputOutputUtil.writeINT(out, value[1]);
}
@Override
public int[] read(DataInput in) throws IOException {
public int[] read(@NotNull DataInput in) throws IOException {
return new int[] {DataInputOutputUtil.readINT(in), DataInputOutputUtil.readINT(in)};
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Factory;
import com.intellij.openapi.util.NotNullComputable;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.psi.search.GlobalSearchScope;
@@ -33,8 +34,10 @@ import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -146,18 +149,20 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
}
}
@NotNull
@Override
public final Lock getReadLock() {
return myLock.readLock();
}
@NotNull
@Override
public final Lock getWriteLock() {
return myLock.writeLock();
}
@Override
public boolean processAllKeys(Processor<Key> processor, GlobalSearchScope scope, IdFilter idFilter) throws StorageException {
public boolean processAllKeys(@NotNull Processor<Key> processor, @NotNull GlobalSearchScope scope, IdFilter idFilter) throws StorageException {
final Lock lock = getReadLock();
try {
lock.lock();
@@ -170,7 +175,7 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
@Override
@NotNull
public ValueContainer<Value> getData(final Key key) throws StorageException {
public ValueContainer<Value> getData(@NotNull final Key key) throws StorageException {
final Lock lock = getReadLock();
try {
lock.lock();
@@ -203,6 +208,7 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
return null;
}
@NotNull
@Override
public final Computable<Boolean> update(final int inputId, @Nullable final Input content) {
@@ -219,17 +225,24 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
@Override
public void run() {
try {
updateWithMap(inputId, data, new Callable<Collection<Key>>() {
updateWithMap(inputId, data, new NotNullComputable<Collection<Key>>() {
@NotNull
@Override
public Collection<Key> call() throws Exception {
public Collection<Key> compute() {
if (myInputsIndex == null) {
return new SmartList<Key>((Key)(Integer)inputId);
}
final Collection<Key> oldKeys = myInputsIndex.get(inputId);
return oldKeys == null? Collections.<Key>emptyList() : oldKeys;
try {
Collection<Key> oldKeys = myInputsIndex.get(inputId);
return oldKeys == null? Collections.<Key>emptyList() : oldKeys;
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
});
} catch (StorageException ex) {
}
catch (StorageException ex) {
exRef.set(ex);
}
}
@@ -239,20 +252,19 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
LOG.info(exRef.get());
FileBasedIndex.getInstance().requestRebuild(myIndexId);
return Boolean.FALSE;
} else {
return Boolean.TRUE;
}
return Boolean.TRUE;
}
};
}
protected void updateWithMap(final int inputId,
@NotNull Map<Key, Value> newData,
@NotNull Callable<Collection<Key>> oldKeysGetter) throws StorageException {
@NotNull NotNullComputable<Collection<Key>> oldKeysGetter) throws StorageException {
getWriteLock().lock();
try {
try {
for (Key key : oldKeysGetter.call()) {
for (Key key : oldKeysGetter.compute()) {
myStorage.removeAllValues(key, inputId);
}
}
@@ -277,7 +289,8 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
}
});
if (!b) throw exceptionRef.get();
} else {
}
else {
for (Map.Entry<Key, Value> entry : newData.entrySet()) {
myStorage.addValue(entry.getKey(), inputId, entry.getValue());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -34,6 +34,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
*/
public class MemoryIndexStorage<Key, Value> implements IndexStorage<Key, Value> {
private final Map<Key, ChangeTrackingValueContainer<Value>> myMap = new HashMap<Key, ChangeTrackingValueContainer<Value>>();
@NotNull
private final IndexStorage<Key, Value> myBackendStorage;
private final List<BufferingStateListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
private final AtomicBoolean myBufferingEnabled = new AtomicBoolean(false);
@@ -44,19 +45,20 @@ public class MemoryIndexStorage<Key, Value> implements IndexStorage<Key, Value>
void memoryStorageCleared();
}
public MemoryIndexStorage(IndexStorage<Key, Value> backend) {
public MemoryIndexStorage(@NotNull IndexStorage<Key, Value> backend) {
myBackendStorage = backend;
}
@NotNull
public IndexStorage<Key, Value> getBackendStorage() {
return myBackendStorage;
}
public void addBufferingStateListsner(BufferingStateListener listener) {
public void addBufferingStateListener(@NotNull BufferingStateListener listener) {
myListeners.add(listener);
}
public void removeBufferingStateListsner(BufferingStateListener listener) {
public void removeBufferingStateListener(@NotNull BufferingStateListener listener) {
myListeners.remove(listener);
}
@@ -99,6 +101,7 @@ public class MemoryIndexStorage<Key, Value> implements IndexStorage<Key, Value>
myBackendStorage.flush();
}
@NotNull
@Override
public Collection<Key> getKeys() throws StorageException {
final Set<Key> keys = new HashSet<Key>();
@@ -107,7 +110,7 @@ public class MemoryIndexStorage<Key, Value> implements IndexStorage<Key, Value>
}
@Override
public boolean processKeys(final Processor<Key> processor, GlobalSearchScope scope, IdFilter idFilter) throws StorageException {
public boolean processKeys(@NotNull final Processor<Key> processor, GlobalSearchScope scope, IdFilter idFilter) throws StorageException {
final Set<Key> stopList = new HashSet<Key>();
Processor<Key> decoratingProcessor = new Processor<Key>() {
@@ -129,7 +132,7 @@ public class MemoryIndexStorage<Key, Value> implements IndexStorage<Key, Value>
}
stopList.add(key);
}
return myBackendStorage.processKeys(stopList.size() == 0 && myMap.size() == 0 ? processor : decoratingProcessor, scope, idFilter);
return myBackendStorage.processKeys(stopList.isEmpty() && myMap.isEmpty() ? processor : decoratingProcessor, scope, idFilter);
}
@Override
@@ -147,7 +150,7 @@ public class MemoryIndexStorage<Key, Value> implements IndexStorage<Key, Value>
}
@Override
public void removeAllValues(Key key, int inputId) throws StorageException {
public void removeAllValues(@NotNull Key key, int inputId) throws StorageException {
if (myBufferingEnabled.get()) {
getMemValueContainer(key).removeAssociatedValue(inputId);
return;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.CollectingContentIterator;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -49,8 +50,9 @@ public class UnindexedFilesUpdater implements CacheUpdater {
return myIndex.getNumberOfPendingInvalidations();
}
@NotNull
@Override
public VirtualFile[] queryNeededFiles(ProgressIndicator indicator) {
public VirtualFile[] queryNeededFiles(@NotNull ProgressIndicator indicator) {
myIndex.filesUpdateStarted(myProject);
CollectingContentIterator finder = myIndex.createContentIterator(indicator);
long l = System.currentTimeMillis();
@@ -66,10 +68,11 @@ public class UnindexedFilesUpdater implements CacheUpdater {
}
@Override
public void processFile(final FileContent fileContent) {
public void processFile(@NotNull FileContent fileContent) {
try {
myIndex.indexFileContent(myProject, fileContent);
} finally {
}
finally {
IndexingStamp.flushCache(fileContent.getVirtualFile());
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -17,6 +17,7 @@
package com.intellij.util.indexing;
import com.intellij.openapi.util.Computable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.concurrent.locks.Lock;
@@ -31,12 +32,13 @@ public interface UpdatableIndex<Key, Value, Input> extends AbstractIndex<Key,Val
void flush() throws StorageException;
/**
*/
@NotNull
Computable<Boolean> update(int inputId, @Nullable Input content);
@NotNull
Lock getReadLock();
@NotNull
Lock getWriteLock();
void dispose();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -16,6 +16,8 @@
package com.intellij.util.indexing;
import org.jetbrains.annotations.NotNull;
import java.util.Iterator;
import java.util.List;
@@ -35,15 +37,19 @@ public abstract class ValueContainer<Value> {
abstract static class IntPredicate {
abstract boolean contains(int id);
}
@NotNull
public abstract IntIterator getInputIdsIterator(Value value);
public abstract boolean isAssociated(Value value, int inputId);
@NotNull
public abstract IntPredicate getValueAssociationPredicate(Value value);
@NotNull
public abstract Iterator<Value> getValueIterator();
@NotNull
public abstract List<Value> toValueList();
public abstract int size();
@@ -53,7 +59,7 @@ public abstract class ValueContainer<Value> {
boolean perform(int id, T value);
}
public final boolean forEach(final ContainerAction<Value> action) {
public final boolean forEach(@NotNull ContainerAction<Value> action) {
for (final Iterator<Value> valueIterator = getValueIterator(); valueIterator.hasNext();) {
final Value value = valueIterator.next();
for (final IntIterator intIterator = getInputIdsIterator(value); intIterator.hasNext();) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* 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.
@@ -21,6 +21,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.SmartList;
import com.intellij.util.containers.EmptyIterator;
import gnu.trove.*;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -139,6 +140,7 @@ class ValueContainerImpl<Value> extends UpdatableValueContainer<Value> implement
return true;
}
@NotNull
@Override
public Iterator<Value> getValueIterator() {
if (myInputIdMapping != null) {
@@ -190,6 +192,7 @@ class ValueContainerImpl<Value> extends UpdatableValueContainer<Value> implement
}
}
@NotNull
@Override
public List<Value> toValueList() {
if (myInputIdMapping == null) {
@@ -216,6 +219,7 @@ class ValueContainerImpl<Value> extends UpdatableValueContainer<Value> implement
return false;
}
@NotNull
@Override
public IntPredicate getValueAssociationPredicate(Value value) {
final Object input = getInput(value);
@@ -247,6 +251,7 @@ class ValueContainerImpl<Value> extends UpdatableValueContainer<Value> implement
};
}
@NotNull
@Override
public IntIterator getInputIdsIterator(Value value) {
final Object input = getInput(value);
@@ -335,6 +340,7 @@ class ValueContainerImpl<Value> extends UpdatableValueContainer<Value> implement
}
};
@NotNull
public ValueContainerImpl<Value> copy() {
ValueContainerImpl<Value> container = new ValueContainerImpl<Value>();
@@ -1,3 +1,18 @@
/*
* 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.util.indexing;
import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream;
@@ -71,7 +86,7 @@ class ValueContainerMap<Key, Value> extends PersistentHashMap<Key, ValueContaine
}
@Override
public void save(final DataOutput out, @NotNull final ValueContainer<T> container) throws IOException {
public void save(@NotNull final DataOutput out, @NotNull final ValueContainer<T> container) throws IOException {
saveImpl(out, container);
}
@@ -79,29 +94,24 @@ class ValueContainerMap<Key, Value> extends PersistentHashMap<Key, ValueContaine
DataInputOutputUtil.writeSINT(out, -inputId);
}
private void saveImpl(final DataOutput out, @NotNull final ValueContainer<T> container) throws IOException {
private void saveImpl(@NotNull DataOutput out, @NotNull final ValueContainer<T> container) throws IOException {
DataInputOutputUtil.writeSINT(out, container.size());
for (final Iterator<T> valueIterator = container.getValueIterator(); valueIterator.hasNext();) {
final T value = valueIterator.next();
myExternalizer.save(out, value);
final ValueContainer.IntIterator ids = container.getInputIdsIterator(value);
if (ids != null) {
DataInputOutputUtil.writeSINT(out, ids.size());
while (ids.hasNext()) {
final int id = ids.next();
DataInputOutputUtil.writeSINT(out, id);
}
}
else {
DataInputOutputUtil.writeSINT(out, 0);
DataInputOutputUtil.writeSINT(out, ids.size());
while (ids.hasNext()) {
final int id = ids.next();
DataInputOutputUtil.writeSINT(out, id);
}
}
}
@NotNull
@Override
public ValueContainerImpl<T> read(final DataInput in) throws IOException {
public ValueContainerImpl<T> read(@NotNull final DataInput in) throws IOException {
DataInputStream stream = (DataInputStream)in;
final ValueContainerImpl<T> valueContainer = new ValueContainerImpl<T>();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -18,13 +18,15 @@ package com.intellij.ide.caches;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
public interface CacheUpdater {
int getNumberOfPendingUpdateJobs();
VirtualFile[] queryNeededFiles(ProgressIndicator indicator);
@NotNull
VirtualFile[] queryNeededFiles(@NotNull ProgressIndicator indicator);
void processFile(FileContent fileContent);
void processFile(@NotNull FileContent fileContent);
void updatingDone();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -27,6 +27,7 @@ import com.intellij.openapi.project.DumbServiceImpl;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.TimeoutUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
@@ -50,14 +51,15 @@ public class ToggleDumbModeAction extends AnAction implements DumbAware {
return 0;
}
public VirtualFile[] queryNeededFiles(ProgressIndicator indicator) {
@NotNull
public VirtualFile[] queryNeededFiles(@NotNull ProgressIndicator indicator) {
while (myDumb) {
TimeoutUtil.sleep(100);
}
return VirtualFile.EMPTY_ARRAY;
}
public void processFile(FileContent fileContent) {
public void processFile(@NotNull FileContent fileContent) {
}
public void updatingDone() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -260,14 +260,14 @@ public class JarHandler extends JarHandlerBase {
private final byte[] myBuffer = IOUtil.allocReadWriteUTFBuffer();
@Override
public void save(DataOutput out, CacheLibraryInfo value) throws IOException {
public void save(@NotNull DataOutput out, CacheLibraryInfo value) throws IOException {
IOUtil.writeUTFFast(myBuffer, out, value.mySnapshotPath);
out.writeLong(value.myModificationTime);
out.writeLong(value.myFileLength);
}
@Override
public CacheLibraryInfo read(DataInput in) throws IOException {
public CacheLibraryInfo read(@NotNull DataInput in) throws IOException {
return new CacheLibraryInfo(IOUtil.readUTFFast(myBuffer, in), in.readLong(), in.readLong());
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -543,12 +543,12 @@ public class FSRecords implements Forceable {
private static class ContentHashesDescriptor implements KeyDescriptor<byte[]>, DifferentSerializableBytesImplyNonEqualityPolicy {
@Override
public void save(DataOutput out, byte[] value) throws IOException {
public void save(@NotNull DataOutput out, byte[] value) throws IOException {
out.write(value);
}
@Override
public byte[] read(DataInput in) throws IOException {
public byte[] read(@NotNull DataInput in) throws IOException {
byte[] b = new byte[SIGNATURE_LENGTH];
in.readFully(b);
return b;
@@ -1,3 +1,18 @@
/*
* 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.util.io;
import com.intellij.openapi.util.io.FileUtil;
@@ -8,6 +23,7 @@ import com.intellij.util.containers.IntObjectCache;
import com.intellij.util.io.storage.AbstractStorage;
import gnu.trove.THashSet;
import junit.framework.TestCase;
import org.jetbrains.annotations.NotNull;
import java.io.*;
import java.util.*;
@@ -424,13 +440,13 @@ public class PersistentMapTest extends TestCase {
FileUtil.createParentDirs(file);
EnumeratorStringDescriptor stringDescriptor = new EnumeratorStringDescriptor();
class PathCollectionExternalizer implements DataExternalizer<Collection<String>> {
public void save(DataOutput out, Collection<String> value) throws IOException {
public void save(@NotNull DataOutput out, Collection<String> value) throws IOException {
for (String str : value) {
IOUtil.writeString(str, out);
}
}
public Collection<String> read(DataInput in) throws IOException {
public Collection<String> read(@NotNull DataInput in) throws IOException {
final Set<String> result = new THashSet<String>(FileUtil.PATH_HASHING_STRATEGY);
final DataInputStream stream = (DataInputStream)in;
while (stream.available() > 0) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -15,12 +15,14 @@
*/
package com.intellij.util.io;
import org.jetbrains.annotations.NotNull;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public interface DataExternalizer<T> {
void save(DataOutput out, T value) throws IOException;
void save(@NotNull DataOutput out, T value) throws IOException;
T read(DataInput in) throws IOException;
T read(@NotNull DataInput in) throws IOException;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -37,13 +37,13 @@ public class EnumeratorStringDescriptor implements KeyDescriptor<String> {
}
@Override
public void save(final DataOutput storage, @NotNull final String value) throws IOException {
public void save(@NotNull final DataOutput storage, @NotNull final String value) throws IOException {
final byte[] buffer = IOUtil.allocReadWriteUTFBuffer();
IOUtil.writeUTFFast(buffer, storage, value);
}
@Override
public String read(final DataInput storage) throws IOException {
public String read(@NotNull final DataInput storage) throws IOException {
final byte[] buffer = IOUtil.allocReadWriteUTFBuffer();
return IOUtil.readUTFFast(buffer, storage);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -19,6 +19,8 @@
*/
package com.intellij.util.io;
import org.jetbrains.annotations.NotNull;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
@@ -35,12 +37,12 @@ public class ExternalIntegerKeyDescriptor implements KeyDescriptor<Integer> {
}
@Override
public void save(final DataOutput out, final Integer value) throws IOException {
public void save(@NotNull final DataOutput out, final Integer value) throws IOException {
DataInputOutputUtil.writeINT(out, value.intValue());
}
@Override
public Integer read(final DataInput in) throws IOException {
public Integer read(@NotNull final DataInput in) throws IOException {
return DataInputOutputUtil.readINT(in);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -19,6 +19,8 @@
*/
package com.intellij.util.io;
import org.jetbrains.annotations.NotNull;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
@@ -41,14 +43,14 @@ public abstract class InlineKeyDescriptor<T> implements KeyDescriptor<T> {
}
@Override
public final void save(DataOutput out, T value) throws IOException {
public final void save(@NotNull DataOutput out, T value) throws IOException {
int v = toInt(value);
if (myCompactFormat) DataInputOutputUtil.writeINT(out, v);
else out.writeInt(v);
}
@Override
public final T read(DataInput in) throws IOException {
public final T read(@NotNull DataInput in) throws IOException {
int n;
if (myCompactFormat) n = DataInputOutputUtil.readINT(in);
else n = in.readInt();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -15,6 +15,7 @@
*/
package com.intellij.util.io;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.DataOutput;
@@ -32,7 +33,7 @@ public class NullableDataExternalizer<T> implements DataExternalizer<T> {
}
@Override
public void save(DataOutput out, T value) throws IOException {
public void save(@NotNull DataOutput out, T value) throws IOException {
if (value == null) {
out.writeBoolean(false);
} else {
@@ -43,7 +44,7 @@ public class NullableDataExternalizer<T> implements DataExternalizer<T> {
@Override
@Nullable
public T read(DataInput in) throws IOException {
public T read(@NotNull DataInput in) throws IOException {
final boolean isDefined = in.readBoolean();
if (isDefined) {
return myNotNullExternalizer.read(in);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -79,12 +79,12 @@ class VcsLogHashMap implements Disposable {
private static class MyHashKeyDescriptor implements KeyDescriptor<Hash> {
@Override
public void save(DataOutput out, Hash value) throws IOException {
public void save(@NotNull DataOutput out, Hash value) throws IOException {
out.writeUTF(value.asString());
}
@Override
public Hash read(DataInput in) throws IOException {
public Hash read(@NotNull DataInput in) throws IOException {
return HashImpl.build(in.readUTF());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -98,11 +98,13 @@ public class AntImportsIndex extends ScalarIndexExtension<Integer>{
return DATA_INDEXER;
}
@NotNull
@Override
public KeyDescriptor<Integer> getKeyDescriptor() {
return EnumeratorIntegerDescriptor.INSTANCE;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return new DefaultFileTypeSpecificInputFilter(StdFileTypes.XML);
@@ -1,9 +1,12 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* 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.
@@ -88,7 +91,7 @@ public class NewGitUsersComponent {
private static class MyDataExternalizer implements DataExternalizer<List<String>> {
@Override
public List<String> read(DataInput in) throws IOException {
public List<String> read(@NotNull DataInput in) throws IOException {
final int size = in.readInt();
final ArrayList<String> result = new ArrayList<String>(size);
for (int i = 0; i < size; i++) {
@@ -98,7 +101,7 @@ public class NewGitUsersComponent {
}
@Override
public void save(DataOutput out, List<String> value) throws IOException {
public void save(@NotNull DataOutput out, List<String> value) throws IOException {
out.writeInt(value.size());
for (String s : value) {
out.writeUTF(s);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* 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.
@@ -39,6 +39,7 @@ import com.intellij.util.io.EnumeratorStringDescriptor;
import git4idea.GitRevisionNumber;
import git4idea.history.GitHistoryUtils;
import git4idea.history.browser.SHAHash;
import org.jetbrains.annotations.NotNull;
import java.io.*;
import java.util.*;
@@ -120,12 +121,12 @@ public class GitCommitsSequentialIndex implements GitCommitsSequentially {
private DataExternalizer<String> createExternalizer() {
return new DataExternalizer<String>() {
@Override
public void save(DataOutput out, String value) throws IOException {
public void save(@NotNull DataOutput out, String value) throws IOException {
out.writeUTF(value);
}
@Override
public String read(DataInput in) throws IOException {
public String read(@NotNull DataInput in) throws IOException {
return in.readUTF();
}
};
@@ -131,11 +131,13 @@ public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
return myDataIndexer;
}
@NotNull
@Override
public KeyDescriptor<String> getKeyDescriptor() {
return myKeyDescriptor;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return new MyInputFilter();
@@ -513,7 +515,7 @@ public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
}
@Override
public boolean acceptInput(final VirtualFile file) {
public boolean acceptInput(@NotNull final VirtualFile file) {
return "gdsl".equals(file.getExtension());
}
}
@@ -16,6 +16,7 @@
package org.jetbrains.plugins.javaFX;
import com.intellij.util.io.DataExternalizer;
import org.jetbrains.annotations.NotNull;
import java.io.DataInput;
import java.io.DataOutput;
@@ -29,7 +30,7 @@ import java.util.Set;
*/
public class FxmlDataExternalizer implements DataExternalizer<Set<String>> {
@Override
public void save(DataOutput out, Set<String> value) throws IOException {
public void save(@NotNull DataOutput out, Set<String> value) throws IOException {
out.writeInt(value.size());
for (String s : value) {
out.writeUTF(s);
@@ -37,7 +38,7 @@ public class FxmlDataExternalizer implements DataExternalizer<Set<String>> {
}
@Override
public Set<String> read(DataInput in) throws IOException {
public Set<String> read(@NotNull DataInput in) throws IOException {
final int size = in.readInt();
final Set<String> result = new HashSet<String>(size);
@@ -58,11 +58,13 @@ public class JavaFxControllerClassIndex extends ScalarIndexExtension<String> {
return myDataIndexer;
}
@NotNull
@Override
public KeyDescriptor<String> getKeyDescriptor() {
return myKeyDescriptor;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return myInputFilter;
@@ -133,7 +135,7 @@ public class JavaFxControllerClassIndex extends ScalarIndexExtension<String> {
super(StdFileTypes.XML);
}
@Override
public boolean acceptInput(final VirtualFile file) {
public boolean acceptInput(@NotNull final VirtualFile file) {
return JavaFxFileTypeFactory.isFxml(file);
}
}
@@ -81,11 +81,13 @@ public class JavaFxCustomComponentsIndex extends FileBasedIndexExtension<String,
return myDataIndexer;
}
@NotNull
@Override
public DataExternalizer<Set<String>> getValueExternalizer() {
return myDataExternalizer;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return myInputFilter;
@@ -97,6 +99,7 @@ public class JavaFxCustomComponentsIndex extends FileBasedIndexExtension<String,
return KEY;
}
@NotNull
@Override
public KeyDescriptor<String> getKeyDescriptor() {
return myKeyDescriptor;
@@ -42,11 +42,13 @@ public class JavaFxIdsIndex extends FileBasedIndexExtension<String, Set<String>>
return myDataIndexer;
}
@NotNull
@Override
public DataExternalizer<Set<String>> getValueExternalizer() {
return myDataExternalizer;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return myInputFilter;
@@ -58,6 +60,7 @@ public class JavaFxIdsIndex extends FileBasedIndexExtension<String, Set<String>>
return KEY;
}
@NotNull
@Override
public KeyDescriptor<String> getKeyDescriptor() {
return myKeyDescriptor;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -666,14 +666,14 @@ public class MavenIndex {
}
private static class SetDescriptor implements DataExternalizer<Set<String>> {
public void save(DataOutput s, Set<String> set) throws IOException {
public void save(@NotNull DataOutput s, Set<String> set) throws IOException {
s.writeInt(set.size());
for (String each : set) {
s.writeUTF(each);
}
}
public Set<String> read(DataInput s) throws IOException {
public Set<String> read(@NotNull DataInput s) throws IOException {
int count = s.readInt();
Set<String> result = new THashSet<String>(count);
while (count-- > 0) {
@@ -1,3 +1,18 @@
/*
* 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.lang.properties.xml;
import com.intellij.ide.highlighter.XmlFileType;
@@ -52,16 +67,19 @@ public class XmlPropertiesIndex extends FileBasedIndexExtension<XmlPropertiesInd
return this;
}
@NotNull
@Override
public KeyDescriptor<Key> getKeyDescriptor() {
return this;
}
@NotNull
@Override
public DataExternalizer<String> getValueExternalizer() {
return ENUMERATOR_STRING_DESCRIPTOR;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return this;
@@ -78,7 +96,7 @@ public class XmlPropertiesIndex extends FileBasedIndexExtension<XmlPropertiesInd
}
@Override
public boolean acceptInput(VirtualFile file) {
public boolean acceptInput(@NotNull VirtualFile file) {
return true;
}
@@ -139,7 +157,7 @@ public class XmlPropertiesIndex extends FileBasedIndexExtension<XmlPropertiesInd
private final byte[] buffer = IOUtil.allocReadWriteUTFBuffer();
@Override
public void save(DataOutput out, Key value) throws IOException {
public void save(@NotNull DataOutput out, Key value) throws IOException {
out.writeBoolean(value.isMarker);
if (value.key != null) {
IOUtil.writeUTFFast(buffer, out, value.key);
@@ -147,7 +165,7 @@ public class XmlPropertiesIndex extends FileBasedIndexExtension<XmlPropertiesInd
}
@Override
public Key read(DataInput in) throws IOException {
public Key read(@NotNull DataInput in) throws IOException {
boolean isMarker = in.readBoolean();
return isMarker ? MARKER_KEY : new Key(IOUtil.readUTFFast(buffer, in));
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* 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.
@@ -21,6 +21,7 @@ import com.intellij.openapi.vcs.persistent.SmallMapSerializer;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.EnumeratorStringDescriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.branchConfig.InfoStorage;
import org.jetbrains.idea.svn.branchConfig.SvnBranchConfigurationNew;
@@ -99,7 +100,7 @@ public class SvnLoadedBrachesStorage {
private DataExternalizer<Map<String, Collection<SvnBranchItem>>> createExternalizer() {
return new DataExternalizer<Map<String, Collection<SvnBranchItem>>>() {
@Override
public void save(DataOutput out, Map<String, Collection<SvnBranchItem>> value) throws IOException {
public void save(@NotNull DataOutput out, Map<String, Collection<SvnBranchItem>> value) throws IOException {
out.writeInt(value.size());
ArrayList<String> keys = new ArrayList<String>(value.keySet());
Collections.sort(keys);
@@ -117,7 +118,7 @@ public class SvnLoadedBrachesStorage {
}
@Override
public Map<String, Collection<SvnBranchItem>> read(DataInput in) throws IOException {
public Map<String, Collection<SvnBranchItem>> read(@NotNull DataInput in) throws IOException {
final HashMap<String, Collection<SvnBranchItem>> map = new HashMap<String, Collection<SvnBranchItem>>();
int mapSize = in.readInt();
for (int i = 0; i < mapSize; i++) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* 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.
@@ -28,6 +28,7 @@ import com.intellij.util.containers.MultiMap;
import com.intellij.util.continuation.TaskDescriptor;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.EnumeratorStringDescriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.SvnVcs;
import org.jetbrains.idea.svn.history.CopyData;
@@ -88,7 +89,7 @@ public class SvnBranchPointsCalculator {
}
private static class BranchDataExternalizer implements DataExternalizer<TreeMap<String,BranchCopyData>> {
public void save(DataOutput out, TreeMap<String,BranchCopyData> value) throws IOException {
public void save(@NotNull DataOutput out, TreeMap<String,BranchCopyData> value) throws IOException {
out.writeInt(value.size());
for (Map.Entry<String, BranchCopyData> entry : value.entrySet()) {
out.writeUTF(entry.getKey());
@@ -100,7 +101,7 @@ public class SvnBranchPointsCalculator {
}
}
public TreeMap<String,BranchCopyData> read(DataInput in) throws IOException {
public TreeMap<String,BranchCopyData> read(@NotNull DataInput in) throws IOException {
final TreeMap<String,BranchCopyData> result = new TreeMap<String, BranchCopyData>();
final int num = in.readInt();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -55,11 +55,13 @@ public class FormClassIndex extends ScalarIndexExtension<String> {
return myDataIndexer;
}
@NotNull
@Override
public KeyDescriptor<String> getKeyDescriptor() {
return myKeyDescriptor;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return new DefaultFileTypeSpecificInputFilter(StdFileTypes.GUI_DESIGNER_FORM);
@@ -132,21 +132,24 @@ public class XsltSymbolIndex extends FileBasedIndexExtension<String, XsltSymbolI
};
}
@NotNull
@Override
public DataExternalizer<Kind> getValueExternalizer() {
return new EnumDataDescriptor<Kind>(Kind.class);
}
@NotNull
@Override
public KeyDescriptor<String> getKeyDescriptor() {
return new EnumeratorStringDescriptor();
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return new DefaultFileTypeSpecificInputFilter(StdFileTypes.XML) {
@Override
public boolean acceptInput(VirtualFile file) {
public boolean acceptInput(@NotNull VirtualFile file) {
return !(file.getFileSystem() instanceof JarFileSystem);
}
};
@@ -70,11 +70,13 @@ public class PyModuleNameIndex extends ScalarIndexExtension<String> {
return myDataIndexer;
}
@NotNull
@Override
public KeyDescriptor<String> getKeyDescriptor() {
return myKeyDescriptor;
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return new DefaultFileTypeSpecificInputFilter(PythonFileType.INSTANCE);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -84,11 +84,13 @@ public class DomFileIndex extends ScalarIndexExtension<String>{
return myDataIndexer;
}
@NotNull
@Override
public KeyDescriptor<String> getKeyDescriptor() {
return new EnumeratorStringDescriptor();
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return new DefaultFileTypeSpecificInputFilter(StdFileTypes.XML);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -86,16 +86,18 @@ public class Html5CustomAttributesIndex extends ScalarIndexExtension<String> {
return myIndexer;
}
@NotNull
@Override
public KeyDescriptor<String> getKeyDescriptor() {
return new EnumeratorStringDescriptor();
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return new DefaultFileTypeSpecificInputFilter(StdFileTypes.HTML, StdFileTypes.XHTML) {
@Override
public boolean acceptInput(final VirtualFile file) {
public boolean acceptInput(@NotNull final VirtualFile file) {
return file.isInLocalFileSystem();
}
};
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -133,11 +133,12 @@ public class SchemaTypeInheritanceIndex extends XmlIndex<Set<SchemaTypeInfo>> {
};
}
@NotNull
@Override
public DataExternalizer<Set<SchemaTypeInfo>> getValueExternalizer() {
return new DataExternalizer<Set<SchemaTypeInfo>>() {
@Override
public void save(DataOutput out, Set<SchemaTypeInfo> value) throws IOException {
public void save(@NotNull DataOutput out, Set<SchemaTypeInfo> value) throws IOException {
out.writeInt(value.size());
for (SchemaTypeInfo key : value) {
out.writeUTF(key.getNamespaceUri());
@@ -147,7 +148,7 @@ public class SchemaTypeInheritanceIndex extends XmlIndex<Set<SchemaTypeInfo>> {
}
@Override
public Set<SchemaTypeInfo> read(DataInput in) throws IOException {
public Set<SchemaTypeInfo> read(@NotNull DataInput in) throws IOException {
final Set<SchemaTypeInfo> set = new HashSet<SchemaTypeInfo>();
final int size = in.readInt();
for (int i = 0; i < size; i++) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -70,6 +70,7 @@ public class XmlTagNamesIndex extends XmlIndex<Void> {
};
}
@NotNull
@Override
public DataExternalizer<Void> getValueExternalizer() {
return ScalarIndexExtension.VOID_DATA_EXTERNALIZER;
@@ -1,3 +1,18 @@
/*
* 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.intellij.plugins.relaxNG.model.resolve;
import com.intellij.ide.highlighter.XmlFileType;
@@ -129,16 +144,18 @@ public class RelaxSymbolIndex extends ScalarIndexExtension<String> {
};
}
@NotNull
@Override
public KeyDescriptor<String> getKeyDescriptor() {
return new EnumeratorStringDescriptor();
}
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return new DefaultFileTypeSpecificInputFilter(StdFileTypes.XML, RncFileType.getInstance()) {
@Override
public boolean acceptInput(VirtualFile file) {
public boolean acceptInput(@NotNull VirtualFile file) {
return !(file.getFileSystem() instanceof JarFileSystem);
}
};
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -95,13 +95,15 @@ public abstract class XmlIndex<V> extends FileBasedIndexExtension<String, V> {
};
}
@NotNull
public KeyDescriptor<String> getKeyDescriptor() {
return KEY_DESCRIPTOR;
}
@NotNull
public FileBasedIndex.InputFilter getInputFilter() {
return new DefaultFileTypeSpecificInputFilter(XmlFileType.INSTANCE, DTDFileType.INSTANCE) {
public boolean acceptInput(final VirtualFile file) {
public boolean acceptInput(@NotNull final VirtualFile file) {
FileType fileType = file.getFileType();
final String extension = file.getExtension();
return XmlFileType.INSTANCE.equals(fileType) && "xsd".equals(extension) ||
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -107,11 +107,12 @@ public class XmlNamespaceIndex extends XmlIndex<XsdNamespaceBuilder> {
};
}
@NotNull
@Override
public DataExternalizer<XsdNamespaceBuilder> getValueExternalizer() {
return new DataExternalizer<XsdNamespaceBuilder>() {
@Override
public void save(DataOutput out, XsdNamespaceBuilder value) throws IOException {
public void save(@NotNull DataOutput out, XsdNamespaceBuilder value) throws IOException {
out.writeUTF(value.getNamespace() == null ? "" : value.getNamespace());
out.writeUTF(value.getVersion() == null ? "" : value.getVersion());
out.writeInt(value.getTags().size());
@@ -121,7 +122,7 @@ public class XmlNamespaceIndex extends XmlIndex<XsdNamespaceBuilder> {
}
@Override
public XsdNamespaceBuilder read(DataInput in) throws IOException {
public XsdNamespaceBuilder read(@NotNull DataInput in) throws IOException {
int count;
XsdNamespaceBuilder builder = new XsdNamespaceBuilder(in.readUTF(), in.readUTF(), new ArrayList<String>(count = in.readInt()));