This commit is contained in:
Alexey Kudravtsev
2015-04-01 12:31:05 +03:00
parent e06fe4a200
commit b6847d3074
22 changed files with 153 additions and 126 deletions
@@ -120,12 +120,12 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
MessageBusConnection connection = project.getMessageBus().connect(project);
connection.subscribe(ProjectTopics.MODULES, new ModuleAdapter() {
@Override
public void beforeModuleRemoved(Project project, Module module) {
public void beforeModuleRemoved(@NotNull Project project, @NotNull Module module) {
getAnnotationProcessingConfiguration(module).removeModuleName(module.getName());
}
@Override
public void moduleAdded(Project project, Module module) {
public void moduleAdded(@NotNull Project project, @NotNull Module module) {
myProcessorsProfilesMap = null; // clear cache
}
});
@@ -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.
@@ -23,12 +23,12 @@ import com.intellij.openapi.module.ModifiableModuleModel;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.module.StdModuleTypes;
import com.intellij.openapi.roots.impl.ModifiableModelCommitter;
import com.intellij.openapi.project.ModuleAdapter;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.impl.ModifiableModelCommitter;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
@@ -36,6 +36,7 @@ import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.testFramework.ModuleTestCase;
import com.intellij.util.messages.MessageBusConnection;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.ArrayList;
@@ -209,12 +210,12 @@ public class MultiModuleEditingTest extends ModuleTestCase {
private final List<String> myLog = new ArrayList<String>();
@Override
public void moduleRemoved(Project project, Module module) {
public void moduleRemoved(@NotNull Project project, @NotNull Module module) {
myLog.add("-" + module.getName());
}
@Override
public void moduleAdded(Project project, Module module) {
public void moduleAdded(@NotNull Project project, @NotNull Module module) {
myLog.add("+" + module.getName());
}
@@ -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.
@@ -18,6 +18,7 @@ package com.intellij.openapi.project;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.util.Disposer;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.List;
@@ -40,14 +41,14 @@ public abstract class ModuleNameTracker extends ModuleAdapter {
}
@Override
public void moduleAdded(final Project project, final Module module) {
public void moduleAdded(@NotNull final Project project, @NotNull final Module module) {
if (myProject == project) {
myModulesNames.put(module, module.getName());
}
}
@Override
public void moduleRemoved(final Project project, final Module module) {
public void moduleRemoved(@NotNull final Project project, @NotNull final Module module) {
if (myProject == project) {
myModulesNames.remove(module);
}
@@ -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.
@@ -177,7 +177,7 @@ public final class ModuleRunConfigurationManager extends ModuleAdapter implement
}
@Override
public void beforeModuleRemoved(Project project, Module module) {
public void beforeModuleRemoved(@NotNull Project project, @NotNull Module module) {
if (myModule.equals(module)) {
LOG.debug("time to remove something from project (" + project + ")");
for (final RunnerAndConfigurationSettings settings : getModuleRunConfigurationSettings()) {
@@ -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.
@@ -46,12 +46,12 @@ public class ProjectWideFacetListenersRegistryImpl extends ProjectWideFacetListe
myFacetListener = new MyFacetManagerAdapter();
messageBus.connect().subscribe(ProjectTopics.MODULES, new ModuleAdapter() {
@Override
public void moduleAdded(Project project, Module module) {
public void moduleAdded(@NotNull Project project, @NotNull Module module) {
onModuleAdded(module);
}
@Override
public void beforeModuleRemoved(final Project project, final Module module) {
public void beforeModuleRemoved(@NotNull final Project project, @NotNull final Module module) {
Facet[] allFacets = FacetManager.getInstance(module).getAllFacets();
for (Facet facet : allFacets) {
onFacetRemoved(facet, true);
@@ -59,7 +59,7 @@ public class ProjectWideFacetListenersRegistryImpl extends ProjectWideFacetListe
}
@Override
public void moduleRemoved(Project project, Module module) {
public void moduleRemoved(@NotNull Project project, @NotNull Module module) {
onModuleRemoved(module);
}
});
@@ -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.
@@ -97,12 +97,12 @@ public class FacetPointersManagerImpl extends FacetPointersManager implements Pr
MessageBusConnection connection = myProject.getMessageBus().connect();
connection.subscribe(ProjectTopics.MODULES, new ModuleAdapter() {
@Override
public void moduleAdded(Project project, Module module) {
public void moduleAdded(@NotNull Project project, @NotNull Module module) {
refreshPointers(module);
}
@Override
public void modulesRenamed(Project project, List<Module> modules, Function<Module, String> oldNameProvider) {
public void modulesRenamed(@NotNull Project project, @NotNull List<Module> modules, @NotNull Function<Module, String> oldNameProvider) {
for (Module module : modules) {
refreshPointers(module);
}
@@ -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.
@@ -37,6 +37,7 @@ import com.intellij.openapi.project.impl.ProjectLifecycleListener;
import com.intellij.util.messages.MessageBus;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.messages.MessageHandler;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.lang.reflect.Method;
@@ -82,7 +83,7 @@ public class ModuleManagerComponent extends ModuleManagerImpl {
}
@Override
protected void showUnknownModuleTypeNotification(List<Module> modulesWithUnknownTypes) {
protected void showUnknownModuleTypeNotification(@NotNull List<Module> modulesWithUnknownTypes) {
if (!ApplicationManager.getApplication().isHeadlessEnvironment() && !modulesWithUnknownTypes.isEmpty()) {
String message;
if (modulesWithUnknownTypes.size() == 1) {
@@ -109,20 +110,22 @@ public class ModuleManagerComponent extends ModuleManagerImpl {
}
}
@NotNull
@Override
protected ModuleEx createModule(String filePath) {
protected ModuleEx createModule(@NotNull String filePath) {
return new ModuleImpl(filePath, myProject);
}
@NotNull
@Override
protected ModuleEx createAndLoadModule(String filePath) throws IOException {
protected ModuleEx createAndLoadModule(@NotNull String filePath) throws IOException {
ModuleImpl module = new ModuleImpl(filePath, myProject);
module.getStateStore().load();
return module;
}
@Override
protected boolean isUnknownModuleType(Module module) {
protected boolean isUnknownModuleType(@NotNull Module module) {
return ModuleType.get(module) instanceof UnknownModuleType;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 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.
@@ -51,12 +51,12 @@ public class ProjectLoadingErrorsNotifierImpl extends ProjectLoadingErrorsNotifi
}
@Override
public void registerError(ConfigurationErrorDescription errorDescription) {
public void registerError(@NotNull ConfigurationErrorDescription errorDescription) {
registerErrors(Collections.singletonList(errorDescription));
}
@Override
public void registerErrors(Collection<? extends ConfigurationErrorDescription> errorDescriptions) {
public void registerErrors(@NotNull Collection<? extends ConfigurationErrorDescription> errorDescriptions) {
if (myProject.isDisposed() || myProject.isDefault() || errorDescriptions.isEmpty()) return;
boolean first;
@@ -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.
@@ -46,23 +46,26 @@ public abstract class ModuleManager extends SimpleModificationTracker {
* Creates a module of the specified type at the specified path and adds it to the project
* to which the module manager is related.
*
* @param filePath the path at which the module is created.
* @param filePath the path at which the module is created.
* @param moduleTypeId the ID of the module type to create.
* @return the module instance.
*/
@NotNull public abstract Module newModule(@NotNull @NonNls String filePath, final String moduleTypeId);
@NotNull
public abstract Module newModule(@NotNull @NonNls String filePath, final String moduleTypeId);
/**
* Loads a module from an .iml file with the specified path and adds it to the project.
*
* @param filePath the path to load the module from.
* @return the module instance.
* @throws InvalidDataException if the data in the .iml file is semantically incorrect.
* @throws IOException if an I/O error occurred when loading the module file.
* @throws JDOMException if the file contains invalid XML data.
* @throws InvalidDataException if the data in the .iml file is semantically incorrect.
* @throws IOException if an I/O error occurred when loading the module file.
* @throws JDOMException if the file contains invalid XML data.
* @throws ModuleWithNameAlreadyExists if a module with such a name already exists in the project.
*/
@NotNull public abstract Module loadModule(@NotNull String filePath) throws InvalidDataException, IOException, JDOMException, ModuleWithNameAlreadyExists;
@NotNull
public abstract Module loadModule(@NotNull String filePath)
throws InvalidDataException, IOException, JDOMException, ModuleWithNameAlreadyExists;
/**
* Disposes of the specified module and removes it from the project.
@@ -76,7 +79,8 @@ public abstract class ModuleManager extends SimpleModificationTracker {
*
* @return the array of modules.
*/
@NotNull public abstract Module[] getModules();
@NotNull
public abstract Module[] getModules();
/**
* Returns the project module with the specified name.
@@ -84,7 +88,8 @@ public abstract class ModuleManager extends SimpleModificationTracker {
* @param name the name of the module to find.
* @return the module instance, or null if no module with such name exists.
*/
@Nullable public abstract Module findModuleByName(@NonNls @NotNull String name);
@Nullable
public abstract Module findModuleByName(@NonNls @NotNull String name);
/**
* Returns the list of modules sorted by dependency (the modules which do not depend
@@ -93,7 +98,8 @@ public abstract class ModuleManager extends SimpleModificationTracker {
*
* @return the sorted array of modules.
*/
@NotNull public abstract Module[] getSortedModules();
@NotNull
public abstract Module[] getSortedModules();
/**
* Returns the module comparator which can be used for sorting modules by dependency
@@ -102,17 +108,18 @@ public abstract class ModuleManager extends SimpleModificationTracker {
*
* @return the module comparator instance.
*/
@NotNull public abstract Comparator<Module> moduleDependencyComparator();
@NotNull
public abstract Comparator<Module> moduleDependencyComparator();
/**
* Returns the list of modules which directly depend on the specified module.
*
* @param module the module for which the list of dependent modules is requested.
* @return list of <i>modules that depend on</i> given module.
*
* @see ModuleUtilCore#getAllDependentModules(Module)
*/
@NotNull public abstract List<Module> getModuleDependentModules(@NotNull Module module);
@NotNull
public abstract List<Module> getModuleDependentModules(@NotNull Module module);
/**
* Checks if one of the specified modules directly depends on the other module.
@@ -128,7 +135,8 @@ public abstract class ModuleManager extends SimpleModificationTracker {
*
* @return the module dependency graph.
*/
@NotNull public abstract Graph<Module> moduleGraph();
@NotNull
public abstract Graph<Module> moduleGraph();
/**
* Returns the graph of dependencies between modules in the project.
@@ -137,7 +145,8 @@ public abstract class ModuleManager extends SimpleModificationTracker {
* @return the module dependency graph.
* @since 11.0
*/
@NotNull public abstract Graph<Module> moduleGraph(boolean includeTests);
@NotNull
public abstract Graph<Module> moduleGraph(boolean includeTests);
/**
* Returns the model for the list of modules in the project, which can be used to add,
@@ -145,7 +154,8 @@ public abstract class ModuleManager extends SimpleModificationTracker {
*
* @return the modifiable model instance.
*/
@NotNull public abstract ModifiableModuleModel getModifiableModel();
@NotNull
public abstract ModifiableModuleModel getModifiableModel();
/**
@@ -155,5 +165,6 @@ public abstract class ModuleManager extends SimpleModificationTracker {
* @param module the module for which the path is requested.
* @return the path to the group for the module, or null if the module does not belong to any group.
*/
@Nullable public abstract String[] getModuleGroupPath(@NotNull Module module);
@Nullable
public abstract String[] getModuleGroupPath(@NotNull Module module);
}
@@ -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.
@@ -17,6 +17,7 @@ package com.intellij.openapi.project;
import com.intellij.openapi.module.Module;
import com.intellij.util.Function;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -25,17 +26,17 @@ import java.util.List;
*/
public abstract class ModuleAdapter implements ModuleListener {
@Override
public void moduleAdded(Project project, Module module) { }
public void moduleAdded(@NotNull Project project, @NotNull Module module) { }
@Override
public void beforeModuleRemoved(Project project, Module module) { }
public void beforeModuleRemoved(@NotNull Project project, @NotNull Module module) { }
@Override
public void moduleRemoved(Project project, Module module) { }
public void moduleRemoved(@NotNull Project project, @NotNull Module module) { }
@SuppressWarnings("deprecation")
@Override
public void modulesRenamed(Project project, List<Module> modules, Function<Module, String> oldNameProvider) {
public void modulesRenamed(@NotNull Project project, @NotNull List<Module> modules, @NotNull Function<Module, String> oldNameProvider) {
modulesRenamed(project, modules);
}
@@ -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.
@@ -17,6 +17,7 @@ package com.intellij.openapi.project;
import com.intellij.openapi.module.Module;
import com.intellij.util.Function;
import org.jetbrains.annotations.NotNull;
import java.util.EventListener;
import java.util.List;
@@ -25,11 +26,11 @@ import java.util.List;
* @author max
*/
public interface ModuleListener extends EventListener {
void moduleAdded(Project project, Module module);
void moduleAdded(@NotNull Project project, @NotNull Module module);
void beforeModuleRemoved(Project project, Module module);
void beforeModuleRemoved(@NotNull Project project, @NotNull Module module);
void moduleRemoved(Project project, Module module);
void moduleRemoved(@NotNull Project project, @NotNull Module module);
void modulesRenamed(Project project, List<Module> modules, Function<Module, String> oldNameProvider);
void modulesRenamed(@NotNull Project project, @NotNull List<Module> modules, @NotNull Function<Module, String> oldNameProvider);
}
@@ -25,6 +25,7 @@ import com.intellij.openapi.roots.impl.ModuleRootManagerImpl;
import com.intellij.openapi.vfs.StandardFileSystems;
import com.intellij.openapi.vfs.VirtualFile;
import org.jdom.JDOMException;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
@@ -39,13 +40,15 @@ public class CoreModuleManager extends ModuleManagerImpl {
myParentDisposable = parentDisposable;
}
@NotNull
@Override
protected ModuleEx createModule(String filePath) {
protected ModuleEx createModule(@NotNull String filePath) {
return new CoreModule(myParentDisposable, myProject, filePath);
}
@NotNull
@Override
protected ModuleEx createAndLoadModule(String filePath) throws IOException {
protected ModuleEx createAndLoadModule(@NotNull String filePath) throws IOException {
final ModuleEx module = createModule(filePath);
VirtualFile vFile = StandardFileSystems.local().findFileByPath(filePath);
try {
@@ -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.
@@ -31,7 +31,7 @@ public abstract class ProjectLoadingErrorsNotifier {
return ServiceManager.getService(project, ProjectLoadingErrorsNotifier.class);
}
public abstract void registerError(ConfigurationErrorDescription errorDescription);
public abstract void registerError(@NotNull ConfigurationErrorDescription errorDescription);
public abstract void registerErrors(Collection<? extends ConfigurationErrorDescription> errorDescriptions);
public abstract void registerErrors(@NotNull Collection<? extends ConfigurationErrorDescription> errorDescriptions);
}
@@ -72,7 +72,7 @@ import java.util.*;
*/
public abstract class ModuleManagerImpl extends ModuleManager implements ProjectComponent, PersistentStateComponent<Element> {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.module.impl.ModuleManagerImpl");
public static final Key<String> DISPOSED_MODULE_NAME = Key.create("DisposedNeverAddedModuleName");
static final Key<String> DISPOSED_MODULE_NAME = Key.create("DisposedNeverAddedModuleName");
private static final String IML_EXTENSION = ".iml";
protected final Project myProject;
protected final MessageBus myMessageBus;
@@ -92,16 +92,16 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
return (ModuleManagerImpl)getInstance(project);
}
protected void cleanCachedStuff() {
myCachedModuleComparator = null;
myCachedSortedModules = null;
}
public ModuleManagerImpl(Project project, MessageBus messageBus) {
myProject = project;
myMessageBus = messageBus;
}
protected void cleanCachedStuff() {
myCachedModuleComparator = null;
myCachedSortedModules = null;
}
@Override
@NotNull
@@ -139,7 +139,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
}
});
private void setModuleGroupPath(@NotNull ModifiableModuleModel model, Module module, @Nullable String[] group) {
private void setModuleGroupPath(@NotNull ModifiableModuleModel model, @NotNull Module module, @Nullable String[] group) {
String[] cached = group == null ? null : paths.get(group);
if (cached == null && group != null) {
cached = new String[group.length];
@@ -185,7 +185,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
}
}
private ModulePath findCorrespondingPath(final Module existingModule) {
private ModulePath findCorrespondingPath(@NotNull Module existingModule) {
for (ModulePath modulePath : myModulePaths) {
if (modulePath.getPath().equals(existingModule.getModuleFilePath())) return modulePath;
}
@@ -212,7 +212,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
}
@NotNull
public static ModulePath[] getPathsToModuleFiles(Element element) {
public static ModulePath[] getPathsToModuleFiles(@NotNull Element element) {
final List<ModulePath> paths = new ArrayList<ModulePath>();
final Element modules = element.getChild(ELEMENT_MODULES);
if (modules != null) {
@@ -234,11 +234,11 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
return paths.toArray(new ModulePath[paths.size()]);
}
public void readExternal(final Element element) {
public void readExternal(@NotNull Element element) {
myModulePaths = new ArrayList<ModulePath>(Arrays.asList(getPathsToModuleFiles(element)));
}
protected void loadModules(final ModuleModelImpl moduleModel) {
protected void loadModules(@NotNull ModuleModelImpl moduleModel) {
if (myModulePaths == null || myModulePaths.isEmpty()) {
return;
}
@@ -294,26 +294,26 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
}
}
protected boolean isUnknownModuleType(Module module) {
protected boolean isUnknownModuleType(@NotNull Module module) {
return false;
}
protected void showUnknownModuleTypeNotification(List<Module> types) {
protected void showUnknownModuleTypeNotification(@NotNull List<Module> types) {
}
protected void fireModuleAdded(Module module) {
protected void fireModuleAdded(@NotNull Module module) {
myMessageBus.syncPublisher(ProjectTopics.MODULES).moduleAdded(myProject, module);
}
protected void fireModuleRemoved(Module module) {
protected void fireModuleRemoved(@NotNull Module module) {
myMessageBus.syncPublisher(ProjectTopics.MODULES).moduleRemoved(myProject, module);
}
protected void fireBeforeModuleRemoved(Module module) {
protected void fireBeforeModuleRemoved(@NotNull Module module) {
myMessageBus.syncPublisher(ProjectTopics.MODULES).beforeModuleRemoved(myProject, module);
}
protected void fireModulesRenamed(List<Module> modules, final Map<Module, String> oldNames) {
protected void fireModulesRenamed(@NotNull List<Module> modules, @NotNull final Map<Module, String> oldNames) {
if (!modules.isEmpty()) {
myMessageBus.syncPublisher(ProjectTopics.MODULES).modulesRenamed(myProject, modules, new Function<Module, String>() {
@Override
@@ -324,7 +324,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
}
}
protected void onModuleLoadErrors(final List<ModuleLoadingErrorDescription> errors) {
protected void onModuleLoadErrors(@NotNull List<ModuleLoadingErrorDescription> errors) {
if (errors.isEmpty()) return;
myModuleModel.myModulesCache = null;
@@ -343,7 +343,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
fireModuleLoadErrors(errors);
}
protected void fireModuleLoadErrors(List<ModuleLoadingErrorDescription> errors) {
protected void fireModuleLoadErrors(@NotNull List<ModuleLoadingErrorDescription> errors) {
if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
throw new RuntimeException(errors.get(0).getDescription());
}
@@ -364,12 +364,13 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
private abstract static class SaveItem {
@NotNull
protected abstract String getModuleName();
protected abstract String getGroupPathString();
@NotNull
protected abstract String getModuleFilePath();
public final void writeExternal(Element parentElement) {
public final void writeExternal(@NotNull Element parentElement) {
Element moduleElement = new Element(ELEMENT_MODULE);
final String moduleFilePath = getModuleFilePath();
final String url = VirtualFileManager.constructUrl(URLUtil.FILE_PROTOCOL, moduleFilePath);
@@ -388,11 +389,12 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
private class ModuleSaveItem extends SaveItem{
private final Module myModule;
public ModuleSaveItem(Module module) {
public ModuleSaveItem(@NotNull Module module) {
myModule = module;
}
@Override
@NotNull
protected String getModuleName() {
return myModule.getName();
}
@@ -404,6 +406,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
}
@Override
@NotNull
protected String getModuleFilePath() {
return myModule.getModuleFilePath().replace(File.separatorChar, '/');
}
@@ -414,7 +417,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
private final String myFilePath;
private final String myName;
public ModulePathSaveItem(ModulePath modulePath) {
private ModulePathSaveItem(@NotNull ModulePath modulePath) {
myModulePath = modulePath;
myFilePath = modulePath.getPath().replace(File.separatorChar, '/');
@@ -427,6 +430,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
}
@Override
@NotNull
protected String getModuleName() {
return myName;
}
@@ -437,16 +441,17 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
}
@Override
@NotNull
protected String getModuleFilePath() {
return myFilePath;
}
}
public void writeExternal(Element element) {
public void writeExternal(@NotNull Element element) {
final Element modules = new Element(ELEMENT_MODULES);
final Module[] collection = getModules();
ArrayList<SaveItem> sorted = new ArrayList<SaveItem>(collection.length + myFailedModulePaths.size());
List<SaveItem> sorted = new ArrayList<SaveItem>(collection.length + myFailedModulePaths.size());
for (Module module : collection) {
sorted.add(new ModuleSaveItem(module));
}
@@ -507,7 +512,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
return myModuleModel.getModules();
}
private volatile Module[] myCachedSortedModules = null;
private volatile Module[] myCachedSortedModules;
@Override
@NotNull
@@ -526,7 +531,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
return myModuleModel.findModuleByName(name);
}
private volatile Comparator<Module> myCachedModuleComparator = null;
private volatile Comparator<Module> myCachedModuleComparator;
@Override
@NotNull
@@ -556,7 +561,8 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
}
@Override
@NotNull public List<Module> getModuleDependentModules(@NotNull Module module) {
@NotNull
public List<Module> getModuleDependentModules(@NotNull Module module) {
ApplicationManager.getApplication().assertReadAccessAllowed();
return myModuleModel.getModuleDependentModules(module);
}
@@ -580,7 +586,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
}
}
protected void fireModuleAddedInWriteAction(final Module module) {
protected void fireModuleAddedInWriteAction(@NotNull final Module module) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
@@ -595,13 +601,15 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
myModuleModel.projectClosed();
}
public static void commitModelWithRunnable(ModifiableModuleModel model, Runnable runnable) {
public static void commitModelWithRunnable(@NotNull ModifiableModuleModel model, Runnable runnable) {
((ModuleModelImpl)model).commitWithRunnable(runnable);
}
protected abstract ModuleEx createModule(String filePath);
@NotNull
protected abstract ModuleEx createModule(@NotNull String filePath);
protected abstract ModuleEx createAndLoadModule(String filePath) throws IOException;
@NotNull
protected abstract ModuleEx createAndLoadModule(@NotNull String filePath) throws IOException;
class ModuleModelImpl implements ModifiableModuleModel {
final Map<String, Module> myPathToModule = new LinkedHashMap<String, Module>(new EqualityPolicy.ByHashingStrategy<String>(FilePathHashingStrategy.create()));
@@ -613,11 +621,11 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
private boolean myIsWritable;
private Map<Module, String[]> myModuleGroupPath;
ModuleModelImpl() {
private ModuleModelImpl() {
myIsWritable = false;
}
ModuleModelImpl(ModuleModelImpl that) {
private ModuleModelImpl(@NotNull ModuleModelImpl that) {
myPathToModule.putAll(that.myPathToModule);
final Map<Module, String[]> groupPath = that.myModuleGroupPath;
if (groupPath != null){
@@ -641,6 +649,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
return myModulesCache;
}
@NotNull
private Module[] getSortedModules() {
Module[] allModules = getModules().clone();
Arrays.sort(allModules, moduleDependencyComparator());
@@ -669,18 +678,13 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
return myNewNameToModule.get(newName);
}
public Module getModuleByNewName(String newName) {
private Module getModuleByNewName(@NotNull String newName) {
final Module moduleToBeRenamed = getModuleToBeRenamed(newName);
if (moduleToBeRenamed != null) {
return moduleToBeRenamed;
}
final Module moduleWithOldName = findModuleByName(newName);
if (myModuleToNewName.get(moduleWithOldName) == null) {
return moduleWithOldName;
}
else {
return null;
}
return myModuleToNewName.get(moduleWithOldName) == null ? moduleWithOldName : null;
}
@Override
@@ -711,13 +715,13 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
module.setOption(option.getKey(),option.getValue());
}
}
module.loadModuleComponents();
initModule(module);
}
return module;
}
private String resolveShortWindowsName(String filePath) {
@NotNull
private String resolveShortWindowsName(@NotNull String filePath) {
try {
return FileUtil.resolveShortWindowsName(filePath);
}
@@ -727,7 +731,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
}
@Nullable
private ModuleEx getModuleByFilePath(String filePath) {
private ModuleEx getModuleByFilePath(@NotNull String filePath) {
return (ModuleEx)myPathToModule.get(filePath);
}
@@ -743,7 +747,8 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
}
}
private Module loadModuleInternal(String filePath) throws ModuleWithNameAlreadyExists, IOException {
@NotNull
private Module loadModuleInternal(@NotNull String filePath) throws ModuleWithNameAlreadyExists, IOException {
filePath = resolveShortWindowsName(filePath);
final VirtualFile moduleFile = StandardFileSystems.local().findFileByPath(filePath);
if (moduleFile == null || !moduleFile.exists()) {
@@ -770,16 +775,16 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
}
}, ModalityState.any());
module = createAndLoadModule(moduleFile.getPath());
module.loadModuleComponents();
initModule(module);
}
return module;
}
private void initModule(ModuleEx module) {
private void initModule(@NotNull ModuleEx module) {
String path = module.getModuleFilePath();
myModulesCache = null;
myPathToModule.put(path, module);
module.loadModuleComponents();
module.init();
}
@@ -846,7 +851,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
ModifiableModelCommitter.multiCommit(rootModels, this);
}
public void commitWithRunnable(Runnable runnable) {
private void commitWithRunnable(Runnable runnable) {
commitModel(this, runnable);
clearRenamingStuff();
}
@@ -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.
@@ -43,17 +43,17 @@ public class ModulePointerManagerImpl extends ModulePointerManager {
myProject = project;
project.getMessageBus().connect().subscribe(ProjectTopics.MODULES, new ModuleAdapter() {
@Override
public void beforeModuleRemoved(Project project, Module module) {
public void beforeModuleRemoved(@NotNull Project project, @NotNull Module module) {
unregisterPointer(module);
}
@Override
public void moduleAdded(Project project, Module module) {
public void moduleAdded(@NotNull Project project, @NotNull Module module) {
moduleAppears(module);
}
@Override
public void modulesRenamed(Project project, List<Module> modules, Function<Module, String> oldNameProvider) {
public void modulesRenamed(@NotNull Project project, @NotNull List<Module> modules, @NotNull Function<Module, String> oldNameProvider) {
for (Module module : modules) {
moduleAppears(module);
}
@@ -320,7 +320,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
});
connection.subscribe(ProjectTopics.MODULES, new ModuleAdapter() {
@Override
public void moduleAdded(Project project, Module module) {
public void moduleAdded(@NotNull Project project, @NotNull Module module) {
fail("Adding modules is not permitted in LightIdeaTestCase.");
}
});
@@ -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.
@@ -106,13 +106,13 @@ public class ModuleVcsDetector implements ProjectComponent {
}
@Override
public void moduleAdded(final Project project, final Module module) {
public void moduleAdded(@NotNull final Project project, @NotNull final Module module) {
myMappingsForRemovedModules.removeAll(getMappings(module));
autoDetectModuleVcsMapping(module);
}
@Override
public void beforeModuleRemoved(final Project project, final Module module) {
public void beforeModuleRemoved(@NotNull final Project project, @NotNull final Module module) {
myMappingsForRemovedModules.addAll(getMappings(module));
}
}
@@ -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.
@@ -114,7 +114,7 @@ public class CloudGitChooseAccountStepImpl extends CloudGitChooseAccountStepBase
connection.subscribe(ProjectTopics.MODULES, new ModuleAdapter() {
@Override
public void moduleAdded(Project project, Module addedModule) {
public void moduleAdded(@NotNull Project project, @NotNull Module addedModule) {
if (addedModule == module) {
StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {
@@ -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.
@@ -83,12 +83,12 @@ public class GradleResourceCompilerConfigurationGenerator {
assert myExternalProjectDataService != null;
project.getMessageBus().connect(project).subscribe(ProjectTopics.MODULES, new ModuleAdapter() {
public void moduleRemoved(Project project, Module module) {
public void moduleRemoved(@NotNull Project project, @NotNull Module module) {
myModulesConfigurationHash.remove(module.getName());
}
@Override
public void modulesRenamed(Project project, List<Module> modules, Function<Module, String> oldNameProvider) {
public void modulesRenamed(@NotNull Project project, @NotNull List<Module> modules, @NotNull Function<Module, String> oldNameProvider) {
for (Module module : modules) {
moduleRemoved(project, module);
}
@@ -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.
@@ -101,7 +101,7 @@ public class MvcModuleStructureSynchronizer extends AbstractProjectComponent {
connection.subscribe(ProjectTopics.MODULES, new ModuleAdapter() {
@Override
public void moduleAdded(Project project, Module module) {
public void moduleAdded(@NotNull Project project, @NotNull Module module) {
queue(SyncAction.UpdateProjectStructure, module);
queue(SyncAction.CreateAppStructureIfNeeded, module);
}
@@ -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,7 +112,7 @@ public class MavenProjectsManagerWatcher {
myBusConnection.subscribe(ProjectTopics.MODULES, new ModuleAdapter() {
@Override
public void moduleRemoved(Project project, Module module) {
public void moduleRemoved(@NotNull Project project, @NotNull Module module) {
MavenProject mavenProject = myManager.findProject(module);
if (mavenProject != null && !myManager.isIgnored(mavenProject)) {
VirtualFile file = mavenProject.getFile();
@@ -127,7 +127,7 @@ public class MavenProjectsManagerWatcher {
}
@Override
public void moduleAdded(final Project project, final Module module) {
public void moduleAdded(@NotNull final Project project, @NotNull final Module module) {
// this method is needed to return non-ignored status for modules that were deleted (and thus ignored) and then created again with a different module type
if (myManager.isMavenizedModule(module)) {
MavenProject mavenProject = myManager.findProject(module);
@@ -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.
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.ModuleAdapter;
import com.intellij.openapi.project.Project;
import com.intellij.util.messages.MessageBus;
import com.jetbrains.python.run.AbstractPythonRunConfiguration;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
@@ -34,7 +35,7 @@ public class PyModuleListener {
public PyModuleListener(MessageBus messageBus) {
messageBus.connect().subscribe(ProjectTopics.MODULES, new ModuleAdapter() {
@Override
public void beforeModuleRemoved(Project project, Module module) {
public void beforeModuleRemoved(@NotNull Project project, @NotNull Module module) {
final RunManagerEx runManager = RunManagerEx.getInstanceEx(project);
final Collection<RunnerAndConfigurationSettings> configurations = new ArrayList<RunnerAndConfigurationSettings>(runManager.getSortedConfigurations());
for (RunnerAndConfigurationSettings configuration : configurations) {