This commit is contained in:
Alexey Kudravtsev
2015-03-30 15:34:24 +03:00
parent 6203206d82
commit 7be1a3db54
17 changed files with 101 additions and 81 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -76,11 +76,13 @@ public abstract class PathMacroMap {
substitute(e, caseSensitive, recursively, null);
}
public String substituteRecursively(String text, boolean caseSensitive) {
@NotNull
public String substituteRecursively(@NotNull String text, boolean caseSensitive) {
return substitute(text, caseSensitive);
}
protected static String quotePath(String path) {
@NotNull
protected static String quotePath(@NotNull String path) {
return FileUtil.toSystemIndependentName(path);
}
@@ -101,4 +101,16 @@ public class ComponentConfig {
public void setLoadForDefaultProject(boolean loadForDefaultProject) {
this.loadForDefaultProject = loadForDefaultProject;
}
@Override
public String toString() {
return "ComponentConfig{" +
"implementationClass='" + implementationClass + '\'' +
", interfaceClass='" + interfaceClass + '\'' +
", headlessImplementationClass='" + headlessImplementationClass + '\'' +
", loadForDefaultProject=" + loadForDefaultProject +
", options=" + options +
", pluginDescriptor=" + pluginDescriptor +
'}';
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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,32 +18,29 @@ package com.intellij.openapi.components.impl;
import com.intellij.openapi.components.ComponentConfig;
import com.intellij.openapi.extensions.PluginDescriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class ComponentManagerConfigurator {
private final ComponentManagerImpl myComponentManager;
public ComponentManagerConfigurator(final ComponentManagerImpl componentManager) {
public ComponentManagerConfigurator(@NotNull ComponentManagerImpl componentManager) {
myComponentManager = componentManager;
}
private void loadConfiguration(@NotNull ComponentConfig[] configs, final boolean defaultProject, final PluginDescriptor descriptor) {
for (ComponentConfig config : configs) {
loadSingleConfig(defaultProject, config, descriptor);
}
}
private void loadSingleConfig(final boolean defaultProject, @NotNull ComponentConfig config, final PluginDescriptor descriptor) {
private void loadSingleConfig(@NotNull ComponentConfig config,
@Nullable PluginDescriptor descriptor,
boolean defaultProject) {
if (defaultProject && !config.isLoadForDefaultProject()) return;
if (!myComponentManager.isComponentSuitable(config.options)) return;
myComponentManager.registerComponent(config, descriptor);
}
public void loadComponentsConfiguration(final ComponentConfig[] components,
final PluginDescriptor descriptor,
final boolean defaultProject) {
if (components == null) return;
loadConfiguration(components, defaultProject, descriptor);
void loadComponentsConfiguration(@NotNull ComponentConfig[] components,
@Nullable PluginDescriptor descriptor,
final boolean defaultProject) {
for (ComponentConfig config : components) {
loadSingleConfig(config, descriptor, defaultProject);
}
}
}
@@ -62,8 +62,8 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileAdapter;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.VirtualFilePropertyEvent;
import com.intellij.openapi.wm.StatusBar;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.openapi.wm.ex.StatusBarEx;
import com.intellij.openapi.wm.impl.status.TogglePopupHintsPanel;
import com.intellij.packageDependencies.DependencyValidationManager;
import com.intellij.profile.Profile;
@@ -140,8 +140,7 @@ public class DaemonListeners implements Disposable {
@NotNull UndoManager undoManager,
@NotNull ProjectLevelVcsManager projectLevelVcsManager,
@NotNull VcsDirtyScopeManager vcsDirtyScopeManager,
@NotNull FileStatusManager fileStatusManager,
@NotNull EditorColorsManager colorsManager) {
@NotNull FileStatusManager fileStatusManager) {
Disposer.register(project, this);
myProject = project;
myDaemonCodeAnalyzer = daemonCodeAnalyzer;
@@ -285,7 +284,7 @@ public class DaemonListeners implements Disposable {
}
});
colorsManager.addEditorColorsListener(new EditorColorsListener() {
editorColorsManager.addEditorColorsListener(new EditorColorsListener() {
@Override
public void globalSchemeChange(EditorColorsScheme scheme) {
stopDaemonAndRestartAllFiles("Global color scheme changed");
@@ -534,7 +533,7 @@ public class DaemonListeners implements Disposable {
@Override
public void run() {
if (myProject.isDisposed()) return;
StatusBarEx statusBar = (StatusBarEx)WindowManager.getInstance().getStatusBar(myProject);
StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
myTogglePopupHintsPanel = new TogglePopupHintsPanel(myProject);
statusBar.addWidget(myTogglePopupHintsPanel, myProject);
updateStatusBar();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -59,7 +59,7 @@ public class EditorTracker extends AbstractProjectComponent {
private final EventDispatcher<EditorTrackerListener> myDispatcher = EventDispatcher.create(EditorTrackerListener.class);
private IdeFrameImpl myIdeFrame;
private Window myActiveWindow = null;
private Window myActiveWindow;
public EditorTracker(Project project,
final WindowManager windowManager,
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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,9 +112,9 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
};
private static class Context {
final SmartPsiElementPointer element;
final String text;
final Rectangle viewRect;
private final SmartPsiElementPointer element;
private final String text;
private final Rectangle viewRect;
public Context(SmartPsiElementPointer element, String text, Rectangle viewRect) {
this.element = element;
@@ -253,7 +253,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
myScrollPane.setBorder(null);
myScrollPane.putClientProperty(DataManager.CLIENT_PROPERTY_DATA_PROVIDER, helpDataProvider);
final MouseAdapter mouseAdapter = new MouseAdapter() {
final MouseListener mouseAdapter = new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
myManager.requestFocus();
@@ -268,12 +268,12 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
}
});
final FocusAdapter focusAdapter = new FocusAdapter() {
final FocusListener focusAdapter = new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
Component previouslyFocused = WindowManagerEx.getInstanceEx().getFocusedComponent(manager.getProject(getElement()));
if (!(previouslyFocused == myEditorPane)) {
if (previouslyFocused != myEditorPane) {
if (myHint != null && !myHint.isDisposed()) myHint.cancel();
}
}
@@ -670,7 +670,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
private class EditDocumentationSourceAction extends BaseNavigateToSourceAction {
EditDocumentationSourceAction() {
private EditDocumentationSourceAction() {
super(true);
getTemplatePresentation().setIcon(AllIcons.Actions.EditSource);
getTemplatePresentation().setText("Edit Source");
@@ -698,7 +698,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
}
private class ExternalDocAction extends AnAction implements HintManagerImpl.ActionToIgnore {
public ExternalDocAction() {
private ExternalDocAction() {
super(CodeInsightBundle.message("javadoc.action.view.external"), null, AllIcons.Actions.Browser_externalJavaDoc);
registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_EXTERNAL_JAVADOC).getShortcutSet(), null);
}
@@ -867,16 +867,16 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
private class MyShowSettingsButton extends ActionButton {
MyShowSettingsButton() {
private MyShowSettingsButton() {
this(new MyShowSettingsAction(), new Presentation(), ActionPlaces.JAVADOC_INPLACE_SETTINGS, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE);
}
MyShowSettingsButton(AnAction action, Presentation presentation, String place, @NotNull Dimension minimumSize) {
private MyShowSettingsButton(AnAction action, Presentation presentation, String place, @NotNull Dimension minimumSize) {
super(action, presentation, place, minimumSize);
myPresentation.setIcon(AllIcons.General.SecondaryGroup);
}
public void hideSettings() {
private void hideSettings() {
if (!mySettingsPanel.isVisible()) {
return;
}
@@ -906,7 +906,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
}
}
private static abstract class MyDictionary<K, V> extends Dictionary<K, V> {
private abstract static class MyDictionary<K, V> extends Dictionary<K, V> {
@Override
public int size() {
throw new UnsupportedOperationException();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -50,6 +50,7 @@ public class ProjectWithModulesStoreImpl extends ProjectStoreImpl {
return true;
}
@NotNull
@Override
public TrackingPathMacroSubstitutor[] getSubstitutors() {
List<TrackingPathMacroSubstitutor> result = new SmartList<TrackingPathMacroSubstitutor>();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 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 @@ public interface IProjectStore extends IComponentStore.Reloadable {
@NotNull
String getProjectName();
@NotNull
TrackingPathMacroSubstitutor[] getSubstitutors();
@NotNull
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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,7 +28,7 @@ class ProjectStateStorageManager extends StateStorageManagerImpl {
protected final ProjectImpl myProject;
@NonNls protected static final String ROOT_TAG_NAME = "project";
public ProjectStateStorageManager(final TrackingPathMacroSubstitutor macroSubstitutor, ProjectImpl project) {
public ProjectStateStorageManager(@NotNull TrackingPathMacroSubstitutor macroSubstitutor, @NotNull ProjectImpl project) {
super(macroSubstitutor, ROOT_TAG_NAME, project, project.getPicoContainer());
myProject = project;
}
@@ -133,6 +133,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
.project(myProject).is();
}
@NotNull
@Override
public TrackingPathMacroSubstitutor[] getSubstitutors() {
return new TrackingPathMacroSubstitutor[] {getStateStorageManager().getMacroSubstitutor()};
@@ -154,7 +155,22 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
final LocalFileSystem fs = LocalFileSystem.getInstance();
final File file = new File(filePath);
if (!isIprPath(file)) {
if (isIprPath(file)) {
myScheme = StorageScheme.DEFAULT;
stateStorageManager.addMacro(StoragePathMacros.PROJECT_FILE, filePath);
final String workspacePath = composeWsPath(filePath);
stateStorageManager.addMacro(StoragePathMacros.WORKSPACE_FILE, workspacePath);
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
@Override
public void run() {
VfsUtil.markDirtyAndRefresh(false, true, false, fs.refreshAndFindFileByPath(filePath), fs.refreshAndFindFileByPath(workspacePath));
}
}, ModalityState.defaultModalityState());
}
else {
myScheme = StorageScheme.DIRECTORY_BASED;
final File dirStore = file.isDirectory() ? new File(file, Project.DIRECTORY_STORE_FOLDER)
@@ -176,21 +192,6 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
}
}, ModalityState.defaultModalityState());
}
else {
myScheme = StorageScheme.DEFAULT;
stateStorageManager.addMacro(StoragePathMacros.PROJECT_FILE, filePath);
final String workspacePath = composeWsPath(filePath);
stateStorageManager.addMacro(StoragePathMacros.WORKSPACE_FILE, workspacePath);
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
@Override
public void run() {
VfsUtil.markDirtyAndRefresh(false, true, false, fs.refreshAndFindFileByPath(filePath), fs.refreshAndFindFileByPath(workspacePath));
}
}, ModalityState.defaultModalityState());
}
myPresentableUrl = null;
}
@@ -200,7 +201,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
}
private static String composeWsPath(String filePath) {
final int lastDot = filePath.lastIndexOf(".");
final int lastDot = filePath.lastIndexOf('.');
final String filePathWithoutExt = lastDot > 0 ? filePath.substring(0, lastDot) : filePath;
return filePathWithoutExt + WorkspaceFileType.DOT_DEFAULT_EXTENSION;
}
@@ -284,7 +285,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
BufferedReader in = new BufferedReader(new InputStreamReader(nameFile.getInputStream(), CharsetToolkit.UTF8_CHARSET));
try {
final String name = in.readLine();
if (name != null && name.length() > 0) {
if (name != null && !name.isEmpty()) {
return name.trim();
}
}
@@ -405,7 +406,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
super(rootElementName, project);
}
WsStorageData(final WsStorageData storageData) {
private WsStorageData(final WsStorageData storageData) {
super(storageData);
}
@@ -480,21 +481,19 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
dropUnableToSaveProjectNotification(myProject, status.getReadonlyFiles());
throw new SaveCancelledException();
}
else {
List<Pair<SaveSession, VirtualFile>> oldList = new ArrayList<Pair<SaveSession, VirtualFile>>(readonlyFiles);
readonlyFiles.clear();
for (Pair<SaveSession, VirtualFile> entry : oldList) {
errors = executeSave(entry.first, readonlyFiles, errors);
}
List<Pair<SaveSession, VirtualFile>> oldList = new ArrayList<Pair<SaveSession, VirtualFile>>(readonlyFiles);
readonlyFiles.clear();
for (Pair<SaveSession, VirtualFile> entry : oldList) {
errors = executeSave(entry.first, readonlyFiles, errors);
}
if (errors != null) {
CompoundRuntimeException.doThrow(errors);
}
if (errors != null) {
CompoundRuntimeException.doThrow(errors);
}
if (!readonlyFiles.isEmpty()) {
dropUnableToSaveProjectNotification(myProject, getFilesList(readonlyFiles));
throw new SaveCancelledException();
}
if (!readonlyFiles.isEmpty()) {
dropUnableToSaveProjectNotification(myProject, getFilesList(readonlyFiles));
throw new SaveCancelledException();
}
return errors;
@@ -115,7 +115,6 @@
<component>
<implementation-class>com.intellij.codeInsight.daemon.impl.DaemonListeners</implementation-class>
<option name="workspace" value="true"/>
<!--<loadForDefaultProject/>-->
</component>
<component>
<implementation-class>com.intellij.codeInsight.daemon.impl.EditorTracker</implementation-class>
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -72,8 +72,9 @@ public class PathMacrosCollector extends PathMacroMap {
return result;
}
@NotNull
@Override
public String substituteRecursively(String text, boolean caseSensitive) {
public String substituteRecursively(@NotNull String text, boolean caseSensitive) {
if (StringUtil.isEmpty(text)) {
return text;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2015 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,6 +112,7 @@ public class ReplacePathToMacroMap extends PathMacroMap {
return myMacroMap.get(path) + text.substring(endOfOccurrence);
}
@NotNull
@Override
public String substituteRecursively(@NotNull String text, final boolean caseSensitive) {
for (final String path : getPathIndex()) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -29,5 +29,6 @@ public abstract class PathMacroManager implements PathMacroSubstitutor {
public abstract String collapsePathsRecursively(@NotNull String text);
@NotNull
public abstract TrackingPathMacroSubstitutor createTrackingSubstitutor();
}
@@ -115,6 +115,7 @@ public class BasePathMacroManager extends PathMacroManager {
return result;
}
@NotNull
@Override
public TrackingPathMacroSubstitutor createTrackingSubstitutor() {
return new MyTrackingPathMacroSubstitutor();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 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,6 +63,7 @@ public class MockProjectStore implements IProjectStore {
throw new UnsupportedOperationException("Method isReloadPossible is not yet implemented in " + getClass().getName());
}
@NotNull
@Override
public TrackingPathMacroSubstitutor[] getSubstitutors() {
return new TrackingPathMacroSubstitutor[0];
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -408,4 +408,9 @@ public class DefaultPicoContainer implements AreaPicoContainer, Serializable {
return res;
}
}
@Override
public String toString() {
return "DefaultPicoContainer" + (getParent() == null ? " (root)" : " (parent="+getParent()+")");
}
}