Cleanup (formatting; typos)

This commit is contained in:
Roman Shevchenko
2016-02-15 11:39:37 +01:00
parent f1fad08436
commit 3f9a3776ac
5 changed files with 36 additions and 48 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.ide.caches;
import com.intellij.openapi.util.UserDataHolderBase;
@@ -49,7 +48,6 @@ public class FileContent extends UserDataHolderBase {
if (myCachedBytes == null) {
myCachedBytes = myVirtualFile.isValid() ? myVirtualFile.contentsToByteArray(false) : ArrayUtil.EMPTY_BYTE_ARRAY;
}
return myCachedBytes;
}
@@ -83,4 +81,4 @@ public class FileContent extends UserDataHolderBase {
}
return myCachedWritable == Boolean.TRUE;
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,11 +46,16 @@ import java.util.Collection;
public class FileBasedIndexProjectHandler extends AbstractProjectComponent implements IndexableFileSet {
private static final Logger LOG = Logger.getInstance("#com.intellij.util.indexing.FileBasedIndexProjectHandler");
private final FileBasedIndex myIndex;
private final ProjectRootManagerEx myRootManager;
private final FileTypeManager myFileTypeManager;
public FileBasedIndexProjectHandler(final FileBasedIndex index, final Project project, final ProjectRootManagerComponent rootManager, FileTypeManager ftManager, final ProjectManager projectManager) {
public FileBasedIndexProjectHandler(FileBasedIndex index,
Project project,
ProjectRootManagerComponent rootManager,
FileTypeManager ftManager,
ProjectManager projectManager) {
super(project);
myIndex = index;
myRootManager = rootManager;
@@ -58,10 +63,8 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple
if (ApplicationManager.getApplication().isInternal()) {
project.getMessageBus().connect().subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
@Override
public void enteredDumbMode() {
}
public void enteredDumbMode() { }
@Override
public void exitDumbMode() {
@@ -130,7 +133,7 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple
@Override
public void disposeComponent() {
// done mostly for tests. In real life this is noop, because the set was removed on project closing
// done mostly for tests. In real life this is no-op, because the set was removed on project closing
myIndex.removeIndexableSet(this);
}
@@ -140,8 +143,8 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple
if (!(i instanceof FileBasedIndexImpl)) {
return null;
}
final FileBasedIndexImpl index = (FileBasedIndexImpl)i;
final FileBasedIndexImpl index = (FileBasedIndexImpl)i;
if (index.getChangedFileCount() < 20) {
return null;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -97,8 +97,8 @@ public class UnindexedFilesUpdater extends DumbModeTask {
indicator.setText(IdeBundle.message("progress.indexing.updating"));
indexFiles(indicator, files);
snapshot.logResponsivenessSinceCreation("Unindexed files update");
snapshot.logResponsivenessSinceCreation("Unindexed files update");
}
private void indexFiles(ProgressIndicator indicator, List<VirtualFile> files) {
@@ -119,8 +119,9 @@ public class UnindexedFilesUpdater extends DumbModeTask {
catch (ProcessCanceledException e) {
LOG.info("Unindexed files update canceled");
throw e;
} finally {
}
finally {
myIndex.filesUpdateFinished(myProject);
}
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,7 +56,7 @@ public class CacheUpdateRunner {
queue.queue(files, indicator);
Consumer<VirtualFile> progressUpdater = new Consumer<VirtualFile>() {
// need set here to handle queue.pushbacks after checkCancelled() in order
// need set here to handle queue push-backs after checkCancelled() in order
// not to count the same file several times
final Set<VirtualFile> processed = new THashSet<VirtualFile>();
private boolean fileNameWasShown;
@@ -256,7 +256,7 @@ public class CacheUpdateRunner {
);
}
catch (ProcessCanceledException e) {
myQueue.pushback(fileContent);
myQueue.pushBack(fileContent);
return;
}
finally {
@@ -269,4 +269,4 @@ public class CacheUpdateRunner {
}
}
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,22 +32,23 @@ import org.jetbrains.ide.PooledThreadExecutor;
import java.io.IOException;
import java.util.Collection;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author peter
*/
@SuppressWarnings({"SynchronizeOnThis"})
public class FileContentQueue {
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.startup.FileContentQueue");
private static final long MAX_SIZE_OF_BYTES_IN_QUEUE = 1024 * 1024;
private static final long PROCESSED_FILE_BYTES_THRESHOLD = 1024 * 1024 * 3;
private static final long LARGE_SIZE_REQUEST_THRESHOLD = PROCESSED_FILE_BYTES_THRESHOLD - 1024 * 300; // 300k for other threads
private static final int ourTasksNumber =
SystemProperties.getBooleanProperty("idea.allow.parallel.file.reading", true) ? CacheUpdateRunner.indexingThreadCount() : 1;
private static final ExecutorService ourExecutor = new BoundedTaskExecutor(PooledThreadExecutor.INSTANCE, ourTasksNumber);
// Unbounded (!)
private final LinkedBlockingDeque<FileContent> myLoadedContents = new LinkedBlockingDeque<FileContent>();
private final AtomicInteger myContentsToLoad = new AtomicInteger();
@@ -58,12 +59,6 @@ public class FileContentQueue {
private volatile long myBytesBeingProcessed;
private volatile boolean myLargeSizeRequested;
private final Object myProceedWithProcessingLock = new Object();
private static final boolean ourAllowParallelFileReading = SystemProperties.getBooleanProperty("idea.allow.parallel.file.reading", true);
private static final BoundedTaskExecutor ourLoadingContentsExecutor = new BoundedTaskExecutor(
PooledThreadExecutor.INSTANCE,
ourAllowParallelFileReading ? CacheUpdateRunner.indexingThreadCount() : 1
);
public void queue(@NotNull Collection<VirtualFile> files, @NotNull final ProgressIndicator indicator) {
int numberOfFiles = files.size();
@@ -72,9 +67,7 @@ public class FileContentQueue {
// ABQ is more memory efficient for significant number of files (e.g. 500K)
final BlockingQueue<VirtualFile> filesQueue = new ArrayBlockingQueue<VirtualFile>(numberOfFiles, false, files);
int maxFilesToBeLoadedInTheSameTime = ourAllowParallelFileReading ? CacheUpdateRunner.indexingThreadCount() : 1;
for(int i = 0 ; i < maxFilesToBeLoadedInTheSameTime; ++i) {
for (int i = 0; i < ourTasksNumber; ++i) {
Runnable task = new Runnable() {
@Override
public void run() {
@@ -85,7 +78,7 @@ public class FileContentQueue {
myLoadedContents.offer(loadContent(file, indicator));
// With loop contents of second / remaining projects will start loading only after finishing loading contents from first project.
// With resubmit loading of contents of second/remaining projects will also proceed
ourLoadingContentsExecutor.submit(this);
ourExecutor.submit(this);
}
catch (ProcessCanceledException e) {
// Do nothing, exit the thread.
@@ -98,22 +91,15 @@ public class FileContentQueue {
}
}
};
ourLoadingContentsExecutor.submit(task);
ourExecutor.submit(task);
}
}
private FileContent loadContent(@NotNull VirtualFile file, @NotNull final ProgressIndicator indicator) throws InterruptedException {
private FileContent loadContent(@NotNull VirtualFile file, @NotNull ProgressIndicator indicator) throws InterruptedException {
FileContent content = new FileContent(file);
if (isValidFile(file)) {
if (!doLoadContent(content, indicator)) {
content.setEmptyContent();
}
}
else {
if (!isValidFile(file) || !doLoadContent(content, indicator)) {
content.setEmptyContent();
}
return content;
}
@@ -180,7 +166,7 @@ public class FileContentQueue {
indicator.checkCanceled();
}
catch (ProcessCanceledException e) {
pushback(content);
pushBack(content);
throw e;
}
@@ -246,10 +232,10 @@ public class FileContentQueue {
}
}
public void pushback(@NotNull FileContent content) {
public void pushBack(@NotNull FileContent content) {
synchronized (myProceedWithLoadingLock) {
myLoadedBytesInQueue += content.getLength();
}
myLoadedContents.addFirst(content);
}
}
}