diff --git a/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java b/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java index f8190dbbbb8e..35c02a43e760 100644 --- a/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java @@ -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 } }); diff --git a/java/java-tests/testSrc/com/intellij/roots/MultiModuleEditingTest.java b/java/java-tests/testSrc/com/intellij/roots/MultiModuleEditingTest.java index ef3800dfa489..37fdc6525948 100644 --- a/java/java-tests/testSrc/com/intellij/roots/MultiModuleEditingTest.java +++ b/java/java-tests/testSrc/com/intellij/roots/MultiModuleEditingTest.java @@ -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 myLog = new ArrayList(); @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()); } diff --git a/platform/lang-api/src/com/intellij/openapi/project/ModuleNameTracker.java b/platform/lang-api/src/com/intellij/openapi/project/ModuleNameTracker.java index b5331bfc6b49..66227ab4b8e2 100644 --- a/platform/lang-api/src/com/intellij/openapi/project/ModuleNameTracker.java +++ b/platform/lang-api/src/com/intellij/openapi/project/ModuleNameTracker.java @@ -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); } diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ModuleRunConfigurationManager.java b/platform/lang-impl/src/com/intellij/execution/impl/ModuleRunConfigurationManager.java index 169c68e17528..a8ec29cc85a8 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ModuleRunConfigurationManager.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ModuleRunConfigurationManager.java @@ -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()) { diff --git a/platform/lang-impl/src/com/intellij/facet/impl/ProjectWideFacetListenersRegistryImpl.java b/platform/lang-impl/src/com/intellij/facet/impl/ProjectWideFacetListenersRegistryImpl.java index 5f460d9ad56c..e628bbd8ddc8 100644 --- a/platform/lang-impl/src/com/intellij/facet/impl/ProjectWideFacetListenersRegistryImpl.java +++ b/platform/lang-impl/src/com/intellij/facet/impl/ProjectWideFacetListenersRegistryImpl.java @@ -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); } }); diff --git a/platform/lang-impl/src/com/intellij/facet/impl/pointers/FacetPointersManagerImpl.java b/platform/lang-impl/src/com/intellij/facet/impl/pointers/FacetPointersManagerImpl.java index 6f10de8b7608..de37780635ba 100644 --- a/platform/lang-impl/src/com/intellij/facet/impl/pointers/FacetPointersManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/facet/impl/pointers/FacetPointersManagerImpl.java @@ -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 modules, Function oldNameProvider) { + public void modulesRenamed(@NotNull Project project, @NotNull List modules, @NotNull Function oldNameProvider) { for (Module module : modules) { refreshPointers(module); } diff --git a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java index 828ee744b47e..eab9b48a10ec 100644 --- a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java +++ b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java @@ -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 modulesWithUnknownTypes) { + protected void showUnknownModuleTypeNotification(@NotNull List 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; } diff --git a/platform/lang-impl/src/com/intellij/openapi/module/impl/ProjectLoadingErrorsNotifierImpl.java b/platform/lang-impl/src/com/intellij/openapi/module/impl/ProjectLoadingErrorsNotifierImpl.java index 642512b004b9..fc30e878708b 100644 --- a/platform/lang-impl/src/com/intellij/openapi/module/impl/ProjectLoadingErrorsNotifierImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/module/impl/ProjectLoadingErrorsNotifierImpl.java @@ -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 errorDescriptions) { + public void registerErrors(@NotNull Collection errorDescriptions) { if (myProject.isDisposed() || myProject.isDefault() || errorDescriptions.isEmpty()) return; boolean first; diff --git a/platform/projectModel-api/src/com/intellij/openapi/module/ModuleManager.java b/platform/projectModel-api/src/com/intellij/openapi/module/ModuleManager.java index 59391a4f0065..96904b5bd4e9 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/module/ModuleManager.java +++ b/platform/projectModel-api/src/com/intellij/openapi/module/ModuleManager.java @@ -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 moduleDependencyComparator(); + @NotNull + public abstract Comparator 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 modules that depend on given module. - * * @see ModuleUtilCore#getAllDependentModules(Module) */ - @NotNull public abstract List getModuleDependentModules(@NotNull Module module); + @NotNull + public abstract List 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 moduleGraph(); + @NotNull + public abstract Graph 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 moduleGraph(boolean includeTests); + @NotNull + public abstract Graph 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); } diff --git a/platform/projectModel-api/src/com/intellij/openapi/project/ModuleAdapter.java b/platform/projectModel-api/src/com/intellij/openapi/project/ModuleAdapter.java index 5058eddfd912..357f9a96b871 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/project/ModuleAdapter.java +++ b/platform/projectModel-api/src/com/intellij/openapi/project/ModuleAdapter.java @@ -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 modules, Function oldNameProvider) { + public void modulesRenamed(@NotNull Project project, @NotNull List modules, @NotNull Function oldNameProvider) { modulesRenamed(project, modules); } diff --git a/platform/projectModel-api/src/com/intellij/openapi/project/ModuleListener.java b/platform/projectModel-api/src/com/intellij/openapi/project/ModuleListener.java index 79f978f0302c..78ebff886f42 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/project/ModuleListener.java +++ b/platform/projectModel-api/src/com/intellij/openapi/project/ModuleListener.java @@ -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 modules, Function oldNameProvider); + void modulesRenamed(@NotNull Project project, @NotNull List modules, @NotNull Function oldNameProvider); } diff --git a/platform/projectModel-impl/src/com/intellij/core/CoreModuleManager.java b/platform/projectModel-impl/src/com/intellij/core/CoreModuleManager.java index 5c1ff03857b5..e3b9a2380066 100644 --- a/platform/projectModel-impl/src/com/intellij/core/CoreModuleManager.java +++ b/platform/projectModel-impl/src/com/intellij/core/CoreModuleManager.java @@ -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 { diff --git a/platform/projectModel-impl/src/com/intellij/openapi/module/ProjectLoadingErrorsNotifier.java b/platform/projectModel-impl/src/com/intellij/openapi/module/ProjectLoadingErrorsNotifier.java index 3b66a002818b..9c57b472eb64 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/module/ProjectLoadingErrorsNotifier.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/module/ProjectLoadingErrorsNotifier.java @@ -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 errorDescriptions); + public abstract void registerErrors(@NotNull Collection errorDescriptions); } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java index fd3dd9d460e7..29782572b3f1 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java @@ -72,7 +72,7 @@ import java.util.*; */ public abstract class ModuleManagerImpl extends ModuleManager implements ProjectComponent, PersistentStateComponent { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.module.impl.ModuleManagerImpl"); - public static final Key DISPOSED_MODULE_NAME = Key.create("DisposedNeverAddedModuleName"); + static final Key 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 paths = new ArrayList(); 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(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 types) { + protected void showUnknownModuleTypeNotification(@NotNull List 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 modules, final Map oldNames) { + protected void fireModulesRenamed(@NotNull List modules, @NotNull final Map oldNames) { if (!modules.isEmpty()) { myMessageBus.syncPublisher(ProjectTopics.MODULES).modulesRenamed(myProject, modules, new Function() { @Override @@ -324,7 +324,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project } } - protected void onModuleLoadErrors(final List errors) { + protected void onModuleLoadErrors(@NotNull List 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 errors) { + protected void fireModuleLoadErrors(@NotNull List 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 sorted = new ArrayList(collection.length + myFailedModulePaths.size()); + List sorted = new ArrayList(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 myCachedModuleComparator = null; + private volatile Comparator myCachedModuleComparator; @Override @NotNull @@ -556,7 +561,8 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project } @Override - @NotNull public List getModuleDependentModules(@NotNull Module module) { + @NotNull + public List 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 myPathToModule = new LinkedHashMap(new EqualityPolicy.ByHashingStrategy(FilePathHashingStrategy.create())); @@ -613,11 +621,11 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project private boolean myIsWritable; private Map myModuleGroupPath; - ModuleModelImpl() { + private ModuleModelImpl() { myIsWritable = false; } - ModuleModelImpl(ModuleModelImpl that) { + private ModuleModelImpl(@NotNull ModuleModelImpl that) { myPathToModule.putAll(that.myPathToModule); final Map 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(); } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModulePointerManagerImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModulePointerManagerImpl.java index ad37bab51e7a..4f611f5edbf6 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModulePointerManagerImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModulePointerManagerImpl.java @@ -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 modules, Function oldNameProvider) { + public void modulesRenamed(@NotNull Project project, @NotNull List modules, @NotNull Function oldNameProvider) { for (Module module : modules) { moduleAppears(module); } diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java index 8c341c2bc92e..bc2edcb2e2f7 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java @@ -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."); } }); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleVcsDetector.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleVcsDetector.java index 5e797c532c84..9b40b32a197d 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleVcsDetector.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleVcsDetector.java @@ -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)); } } diff --git a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepImpl.java b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepImpl.java index 1de4eff05368..897e29967c33 100644 --- a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepImpl.java +++ b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepImpl.java @@ -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() { diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java index b2c904a255cb..4e8b6431eb9d 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java @@ -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 modules, Function oldNameProvider) { + public void modulesRenamed(@NotNull Project project, @NotNull List modules, @NotNull Function oldNameProvider) { for (Module module : modules) { moduleRemoved(project, module); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureSynchronizer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureSynchronizer.java index ff5770618030..27c826a5f77d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureSynchronizer.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureSynchronizer.java @@ -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); } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManagerWatcher.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManagerWatcher.java index af4eb57c44d5..443c499c1741 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManagerWatcher.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManagerWatcher.java @@ -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); diff --git a/python/ide/src/com/jetbrains/python/PyModuleListener.java b/python/ide/src/com/jetbrains/python/PyModuleListener.java index e538eb1dc35a..ce8866b1929d 100644 --- a/python/ide/src/com/jetbrains/python/PyModuleListener.java +++ b/python/ide/src/com/jetbrains/python/PyModuleListener.java @@ -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 configurations = new ArrayList(runManager.getSortedConfigurations()); for (RunnerAndConfigurationSettings configuration : configurations) {