Cleanup (warnings; typos; formatting)

GitOrigin-RevId: bd80c70e4688e0d2c884931a265535135cde1d20
This commit is contained in:
Roman Shevchenko
2019-08-22 01:50:10 +03:00
committed by intellij-monorepo-bot
parent 3d44cb6513
commit 44e697f375
4 changed files with 41 additions and 52 deletions
@@ -50,6 +50,7 @@ public class UnindexedFilesUpdater extends DumbModeTask {
private void updateUnindexedFiles(ProgressIndicator indicator) {
if (!IndexInfrastructure.hasIndices()) return;
PerformanceWatcher.Snapshot snapshot = PerformanceWatcher.takeSnapshot();
myPusher.pushAllPropertiesNow();
boolean trackResponsiveness = !ApplicationManager.getApplication().isUnitTestMode();
@@ -152,10 +152,9 @@ public class StartupManagerImpl extends StartupManagerEx implements Disposable {
public void runPostStartupActivitiesFromExtensions() {
PerformanceWatcher.Snapshot snapshot = PerformanceWatcher.takeSnapshot();
// strictly speaking, it is not a sequential activity,
// because sub activities performed in a different threads (depends on dumb awareness),
// but because there is no any other concurrent phase and timeline end equals to last dumb-aware activity,
// we measure it as a sequential activity to put on a timeline and make clear what's going on the end (avoid last "unknown" phase).
// strictly speaking, the activity is not sequential, because sub-activities are performed in different threads
// (depending on dumb-awareness), but because there is no other concurrent phase and timeline end equals to last dumb-aware activity,
// we measure it as a sequential activity to put it on the timeline and make clear what's going on the end (avoid last "unknown" phase)
Activity dumbAwareActivity = StartUpMeasurer.start(Phases.RUN_PROJECT_POST_STARTUP_ACTIVITIES_DUMB_AWARE);
AtomicReference<Activity> edtActivity = new AtomicReference<>();
@@ -275,7 +274,7 @@ public class StartupManagerImpl extends StartupManagerEx implements Disposable {
break;
}
// queue each activity in smart mode separately so that if one of them starts dumb mode, the next ones just wait for it to finish
// queue each activity in smart mode separately so that if one of them starts the dumb mode, the next ones just wait for it to finish
for (Runnable activity : dumbUnaware) {
dumbService.runWhenSmart(() -> runActivity(activity));
}
@@ -386,8 +385,9 @@ public class StartupManagerImpl extends StartupManagerEx implements Disposable {
private void runActivities(@NotNull Deque<? extends Runnable> activities, @NotNull String phaseName) {
Activity activity = StartUpMeasurer.start(phaseName);
Runnable runnable;
while (true) {
Runnable runnable;
synchronized (myLock) {
runnable = activities.pollFirst();
}
@@ -405,6 +405,7 @@ public class StartupManagerImpl extends StartupManagerEx implements Disposable {
ParallelActivity.POST_STARTUP_ACTIVITY.record(startTime, runnable.getClass(), null, pluginId);
}
activity.end();
}
@@ -458,8 +459,8 @@ public class StartupManagerImpl extends StartupManagerEx implements Disposable {
//noinspection SynchronizeOnThis
synchronized (this) {
// in tests which simulate project opening, post-startup activities could have been run already.
// Then we should act as if the project was initialized
// in tests that simulate project opening, post-startup activities could have been run already
// then we should act as if the project was initialized
boolean initialized = myProject.isInitialized() || myProject.isDefault() || (myPostStartupActivitiesPassed && application.isUnitTestMode());
if (!initialized) {
registerPostStartupActivity(action);
@@ -35,10 +35,7 @@ import com.intellij.openapi.project.*;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.ShutDownTracker;
import com.intellij.openapi.util.UserDataHolderEx;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.vfs.VirtualFile;
@@ -74,8 +71,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
private static final Key<List<ProjectManagerListener>> LISTENERS_IN_PROJECT_KEY = Key.create("LISTENERS_IN_PROJECT_KEY");
@NotNull
private Project[] myOpenProjects = {}; // guarded by lock
private @NotNull Project[] myOpenProjects = {}; // guarded by lock
private final Map<String, Project> myOpenProjectByHash = ContainerUtil.newConcurrentMap();
private final Object lock = new Object();
@@ -156,7 +152,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
throw (ProcessCanceledException)e;
}
else {
LOG.error("From listener " + listener + " (" + listener.getClass() + ")", e);
LOG.error("From the listener " + listener + " (" + listener.getClass() + ")", e);
}
}
@@ -213,7 +209,8 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
ProjectImpl project = doCreateProject(projectName, projectFile);
try {
initProject(projectFile, project, isRefreshVfsNeeded, useDefaultProjectSettings ? getDefaultProject() : null, ProgressManager.getInstance().getProgressIndicator());
Project template = useDefaultProjectSettings ? getDefaultProject() : null;
initProject(projectFile, project, isRefreshVfsNeeded, template, ProgressManager.getInstance().getProgressIndicator());
if (LOG_PROJECT_LEAKAGE_IN_TESTS) {
myProjects.put(project, null);
}
@@ -281,7 +278,9 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
@TestOnly
private Collection<Project> getLeakedProjects() {
myProjects.remove(DummyProject.getInstance()); // process queue
return myProjects.keySet().stream().filter(project -> project.isDisposed() && !((ProjectImpl)project).isTemporarilyDisposed()).collect(Collectors.toCollection(UnsafeWeakList::new));
return myProjects.keySet().stream()
.filter(p -> p.isDisposed() && !((ProjectImpl)p).isTemporarilyDisposed())
.collect(Collectors.toCollection(UnsafeWeakList::new));
}
@TestOnly
@@ -290,7 +289,11 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
return (int)myProjects.keySet().stream().filter(project -> project.isDisposed() && !((ProjectImpl)project).isTemporarilyDisposed()).count();
}
private static void initProject(@NotNull Path file, @NotNull ProjectImpl project, boolean isRefreshVfsNeeded, @Nullable Project template, @Nullable ProgressIndicator indicator) {
private static void initProject(@NotNull Path file,
@NotNull ProjectImpl project,
boolean isRefreshVfsNeeded,
@Nullable Project template,
@Nullable ProgressIndicator indicator) {
LOG.assertTrue(!project.isDefault());
if (indicator != null) {
indicator.setIndeterminate(false);
@@ -345,12 +348,12 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
}
@NotNull
private static String toCanonicalName(@NotNull final String filePath) {
private static String toCanonicalName(@NotNull String filePath) {
try {
return FileUtil.resolveShortWindowsName(filePath);
}
catch (IOException e) {
// OK. File does not yet exist so it's canonical path will be equal to its original path.
// OK. File does not yet exist, so its canonical path will be equal to its original path.
}
return filePath;
@@ -704,12 +707,14 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
boolean checkCanClose) {
Application app = ApplicationManager.getApplication();
if (app.isWriteAccessAllowed()) {
throw new IllegalStateException("Must not call closeProject() from under write action because fireProjectClosing() listeners must have a chance to do something useful");
throw new IllegalStateException(
"Must not call closeProject() from under write action because fireProjectClosing() listeners must have a chance to do something useful");
}
app.assertIsDispatchThread();
if (isLight(project)) {
// if we close project at the end of the test, just mark it closed; if we are shutting down the entire test framework, proceed to full dispose
// if we close project at the end of the test, just mark it closed;
// if we are shutting down the entire test framework, proceed to full dispose
ProjectImpl projectImpl = (ProjectImpl)project;
if (!projectImpl.isTemporarilyDisposed()) {
projectImpl.setTemporarilyDisposed(true);
@@ -857,7 +862,6 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
}
activity.end();
//noinspection AssignmentToStaticFieldFromInstanceMethod
ProjectImpl.ourClassesAreLoaded = true;
}
@@ -892,8 +896,8 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
for (ProjectManagerListener listener : getAllListeners(project)) {
try {
//noinspection deprecation
boolean canClose = listener instanceof VetoableProjectManagerListener ? ((VetoableProjectManagerListener)listener).canClose(project) : listener.canCloseProject(project);
@SuppressWarnings("deprecation") boolean canClose =
listener instanceof VetoableProjectManagerListener ? ((VetoableProjectManagerListener)listener).canClose(project) : listener.canCloseProject(project);
if (!canClose) {
LOG.debug("close canceled by " + listener);
return false;
@@ -907,8 +911,6 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
return true;
}
// both lists are thread-safe (LockFreeCopyOnWriteArrayList), but ContainerUtil.concat cannot handle situation when list size is changed during iteration
// so, we have to create list.
@NotNull
private List<ProjectManagerListener> getAllListeners(@NotNull Project project) {
List<ProjectManagerListener> projectLevelListeners = getListeners(project);
@@ -965,14 +967,14 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
myFiles = files;
}
public UnableToSaveProjectNotification(@NotNull final Project project, @NotNull List<VirtualFile> readOnlyFiles) {
super("Project Settings", "Could not save project", "Unable to save project files. Please ensure project files are writable and you have permissions to modify them." +
" <a href=\"\">Try to save project again</a>.", NotificationType.ERROR,
public UnableToSaveProjectNotification(@NotNull Project project, @NotNull List<VirtualFile> readOnlyFiles) {
super("Project Settings", "Could not save project",
"Unable to save project files. Please ensure project files are writable and you have permissions to modify them." +
" <a href=\"\">Try to save project again</a>.", NotificationType.ERROR,
(notification, event) -> {
final UnableToSaveProjectNotification unableToSaveProjectNotification = (UnableToSaveProjectNotification)notification;
final Project _project = unableToSaveProjectNotification.myProject;
UnableToSaveProjectNotification unableToSaveProjectNotification = (UnableToSaveProjectNotification)notification;
Project _project = unableToSaveProjectNotification.myProject;
notification.expire();
if (_project != null && !_project.isDisposed()) {
_project.save();
}
@@ -994,4 +996,4 @@ public class ProjectManagerImpl extends ProjectManagerEx implements Disposable {
public String[] getAllExcludedUrls() {
return myExcludeRootsCache.getExcludedUrls();
}
}
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.util;
public class EmptyRunnable implements Runnable {
@@ -23,6 +9,5 @@ public class EmptyRunnable implements Runnable {
}
@Override
public void run() {
}
}
public void run() { }
}