diff --git a/jps/model-serialization/src/com/intellij/openapi/components/ExpandMacroToPathMap.java b/jps/model-serialization/src/com/intellij/openapi/components/ExpandMacroToPathMap.java index e9b322e3327f..b4bcef65e591 100644 --- a/jps/model-serialization/src/com/intellij/openapi/components/ExpandMacroToPathMap.java +++ b/jps/model-serialization/src/com/intellij/openapi/components/ExpandMacroToPathMap.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. @@ -19,6 +19,7 @@ import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.ContainerUtilRt; +import org.jetbrains.annotations.NotNull; import java.util.Map; @@ -30,19 +31,20 @@ public class ExpandMacroToPathMap extends PathMacroMap { private final Map myPlainMap = ContainerUtilRt.newLinkedHashMap(); private final Map myMacroExpands = ContainerUtil.newHashMap(); - public void addMacroExpand(String macroName, String path) { + public void addMacroExpand(@NotNull String macroName, @NotNull String path) { myMacroExpands.put(macroName, PathMacroMap.quotePath(path)); } - public void put(String fromText, String toText) { + public void put(@NotNull String fromText, @NotNull String toText) { myPlainMap.put(fromText, toText); } - public void putAll(ExpandMacroToPathMap another) { + public void putAll(@NotNull ExpandMacroToPathMap another) { myPlainMap.putAll(another.myPlainMap); myMacroExpands.putAll(another.myMacroExpands); } + @Override public String substitute(String text, boolean caseSensitive) { if (text == null) { //noinspection ConstantConditions @@ -66,7 +68,8 @@ public class ExpandMacroToPathMap extends PathMacroMap { return text; } - private static String replaceMacro(String text, String macroName, String replacement) { + @NotNull + private static String replaceMacro(@NotNull String text, @NotNull String macroName, @NotNull String replacement) { while (true) { int start = findMacroIndex(text, macroName); if (start < 0) { @@ -81,11 +84,11 @@ public class ExpandMacroToPathMap extends PathMacroMap { return text; } - private static int getSlashCount(String text, int pos) { + private static int getSlashCount(@NotNull String text, int pos) { return StringUtil.isChar(text, pos, '/') ? StringUtil.isChar(text, pos + 1, '/') ? 2 : 1 : 0; } - private static int findMacroIndex(String text, String macroName) { + private static int findMacroIndex(@NotNull String text, @NotNull String macroName) { int i = -1; while (true) { i = text.indexOf('$', i + 1); diff --git a/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java b/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java index e68c9b1e36ef..fc3404e9c598 100644 --- a/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java +++ b/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.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. @@ -80,7 +80,7 @@ public class LightVirtualFile extends LightVirtualFileBase { return myLanguage; } - public void setLanguage(final Language language) { + public void setLanguage(@NotNull Language language) { myLanguage = language; FileType type = language.getAssociatedFileType(); if (type == null) { diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/storage/ClasspathStorage.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/storage/ClasspathStorage.java index df75b15ae75c..7c16888afe73 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/storage/ClasspathStorage.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/storage/ClasspathStorage.java @@ -228,10 +228,10 @@ public class ClasspathStorage extends StateStorageBase entry : PathMacroUtil.getGlobalSystemMacros().entrySet()) { @@ -106,6 +108,7 @@ public class BasePathMacroManager extends PathMacroManager { return result; } + @NotNull protected ReplacePathToMacroMap getReplacePathMap() { ReplacePathToMacroMap result = new ReplacePathToMacroMap(); for (Map.Entry entry : PathMacroUtil.getGlobalSystemMacros().entrySet()) { @@ -151,7 +154,8 @@ public class BasePathMacroManager extends PathMacroManager { getReplacePathMap().substitute(element, SystemInfo.isFileSystemCaseSensitive); } - public PathMacrosImpl getPathMacros() { + @NotNull + private PathMacrosImpl getPathMacros() { if (myPathMacros == null) { myPathMacros = PathMacrosImpl.getInstanceEx(); } @@ -164,9 +168,6 @@ public class BasePathMacroManager extends PathMacroManager { private final MultiMap myMacroToComponentNames = MultiMap.createSet(); private final MultiMap myComponentNameToMacros = MultiMap.createSet(); - public MyTrackingPathMacroSubstitutor() { - } - @Override public void reset() { synchronized (myLock) { diff --git a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java index e8cc7bcd040a..bdae8e936c5c 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.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. @@ -20,6 +20,7 @@ import com.intellij.application.options.ReplacePathToMacroMap; import com.intellij.openapi.application.PathMacros; import com.intellij.openapi.components.ExpandMacroToPathMap; import com.intellij.openapi.module.Module; +import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.model.serialization.PathMacroUtil; public class ModulePathMacroManager extends BasePathMacroManager { @@ -30,6 +31,7 @@ public class ModulePathMacroManager extends BasePathMacroManager { myModule = module; } + @NotNull @Override public ExpandMacroToPathMap getExpandMacroMap() { final ExpandMacroToPathMap result = new ExpandMacroToPathMap(); @@ -41,6 +43,7 @@ public class ModulePathMacroManager extends BasePathMacroManager { return result; } + @NotNull @Override public ReplacePathToMacroMap getReplacePathMap() { final ReplacePathToMacroMap result = super.getReplacePathMap(); diff --git a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/ProjectPathMacroManager.java b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/ProjectPathMacroManager.java index 55c445bffc99..4e36ca52a933 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/ProjectPathMacroManager.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/ProjectPathMacroManager.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. @@ -21,6 +21,7 @@ import com.intellij.openapi.application.PathMacros; import com.intellij.openapi.components.ExpandMacroToPathMap; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class ProjectPathMacroManager extends BasePathMacroManager { @@ -31,6 +32,7 @@ public class ProjectPathMacroManager extends BasePathMacroManager { myProject = project; } + @NotNull @Override public ExpandMacroToPathMap getExpandMacroMap() { final ExpandMacroToPathMap result = super.getExpandMacroMap(); @@ -38,6 +40,7 @@ public class ProjectPathMacroManager extends BasePathMacroManager { return result; } + @NotNull @Override public ReplacePathToMacroMap getReplacePathMap() { final ReplacePathToMacroMap result = super.getReplacePathMap(); diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryBaseImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryBaseImpl.java index c2f12985dfb9..11d9fc3be301 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryBaseImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryBaseImpl.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. @@ -36,9 +36,9 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl implements L @NotNull protected DependencyScope myScope = DependencyScope.COMPILE; @Nullable private RootProvider myCurrentlySubscribedRootProvider = null; - LibraryOrderEntryBaseImpl(@NotNull RootModelImpl rootModel, @NotNull ProjectRootManagerImpl instanceImpl) { + LibraryOrderEntryBaseImpl(@NotNull RootModelImpl rootModel, @NotNull ProjectRootManagerImpl projectRootManager) { super(rootModel); - myProjectRootManagerImpl = instanceImpl; + myProjectRootManagerImpl = projectRootManager; } protected final void init() { diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryOrderEntryImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryOrderEntryImpl.java index d73c47e52814..94304fa8941d 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryOrderEntryImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryOrderEntryImpl.java @@ -47,7 +47,7 @@ public class ModuleLibraryOrderEntryImpl extends LibraryOrderEntryBaseImpl imple @NonNls public static final String EXPORTED_ATTR = JpsJavaModelSerializerExtension.EXPORTED_ATTRIBUTE; //cloning - private ModuleLibraryOrderEntryImpl(Library library, RootModelImpl rootModel, boolean isExported, DependencyScope scope) { + private ModuleLibraryOrderEntryImpl(@NotNull Library library, @NotNull RootModelImpl rootModel, boolean isExported, @NotNull DependencyScope scope) { super(rootModel, ProjectRootManagerImpl.getInstanceImpl(rootModel.getProject())); myLibrary = ((LibraryImpl)library).cloneLibrary(getRootModel()); doinit(); @@ -55,13 +55,13 @@ public class ModuleLibraryOrderEntryImpl extends LibraryOrderEntryBaseImpl imple myScope = scope; } - ModuleLibraryOrderEntryImpl(String name, final PersistentLibraryKind kind, RootModelImpl rootModel, ProjectRootManagerImpl projectRootManager) { + ModuleLibraryOrderEntryImpl(String name, final PersistentLibraryKind kind, @NotNull RootModelImpl rootModel, @NotNull ProjectRootManagerImpl projectRootManager) { super(rootModel, projectRootManager); myLibrary = LibraryTableImplUtil.createModuleLevelLibrary(name, kind, getRootModel()); doinit(); } - ModuleLibraryOrderEntryImpl(Element element, RootModelImpl rootModel, ProjectRootManagerImpl projectRootManager) throws InvalidDataException { + ModuleLibraryOrderEntryImpl(@NotNull Element element, @NotNull RootModelImpl rootModel, @NotNull ProjectRootManagerImpl projectRootManager) throws InvalidDataException { super(rootModel, projectRootManager); LOG.assertTrue(ENTRY_TYPE.equals(element.getAttributeValue(OrderEntryFactory.ORDER_ENTRY_TYPE_ATTR))); myExported = element.getAttributeValue(EXPORTED_ATTR) != null; diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryTable.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryTable.java index 4dbeeb3d5199..6cc3b11daa88 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryTable.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleLibraryTable.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. @@ -23,7 +23,10 @@ import com.intellij.openapi.roots.LibraryOrderEntry; import com.intellij.openapi.roots.OrderEntry; import com.intellij.openapi.roots.impl.libraries.LibraryTableBase; import com.intellij.openapi.roots.impl.libraries.LibraryTableImplUtil; -import com.intellij.openapi.roots.libraries.*; +import com.intellij.openapi.roots.libraries.Library; +import com.intellij.openapi.roots.libraries.LibraryTable; +import com.intellij.openapi.roots.libraries.LibraryTablePresentation; +import com.intellij.openapi.roots.libraries.PersistentLibraryKind; import com.intellij.openapi.util.Condition; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.ConvertingIterator; @@ -41,7 +44,9 @@ import java.util.Iterator; public class ModuleLibraryTable implements LibraryTable, LibraryTableBase.ModifiableModelEx { private static final ModuleLibraryOrderEntryCondition MODULE_LIBRARY_ORDER_ENTRY_FILTER = new ModuleLibraryOrderEntryCondition(); private static final OrderEntryToLibraryConvertor ORDER_ENTRY_TO_LIBRARY_CONVERTOR = new OrderEntryToLibraryConvertor(); + @NotNull private final RootModelImpl myRootModel; + @NotNull private final ProjectRootManagerImpl myProjectRootManager; public static final LibraryTablePresentation MODULE_LIBRARY_TABLE_PRESENTATION = new LibraryTablePresentation() { @Override @@ -60,7 +65,7 @@ public class ModuleLibraryTable implements LibraryTable, LibraryTableBase.Modifi } }; - ModuleLibraryTable(RootModelImpl rootModel, ProjectRootManagerImpl projectRootManager) { + ModuleLibraryTable(@NotNull RootModelImpl rootModel, @NotNull ProjectRootManagerImpl projectRootManager) { myRootModel = rootModel; myProjectRootManager = projectRootManager; } @@ -86,7 +91,7 @@ public class ModuleLibraryTable implements LibraryTable, LibraryTableBase.Modifi @Override public Library createLibrary(String name, @Nullable PersistentLibraryKind kind) { - final ModuleLibraryOrderEntryImpl orderEntry = new ModuleLibraryOrderEntryImpl(name, kind, myRootModel, myProjectRootManager); + LibraryOrderEntry orderEntry = new ModuleLibraryOrderEntryImpl(name, kind, myRootModel, myProjectRootManager); myRootModel.addOrderEntry(orderEntry); return orderEntry.getLibrary(); } @@ -144,25 +149,25 @@ public class ModuleLibraryTable implements LibraryTable, LibraryTableBase.Modifi } @Override - public void addListener(Listener listener) { + public void addListener(@NotNull Listener listener) { throw new UnsupportedOperationException(); } @Override - public void addListener(Listener listener, Disposable parentDisposable) { + public void addListener(@NotNull Listener listener, @NotNull Disposable parentDisposable) { throw new UnsupportedOperationException("Method addListener is not yet implemented in " + getClass().getName()); } @Override - public void removeListener(Listener listener) { + public void removeListener(@NotNull Listener listener) { throw new UnsupportedOperationException(); } + @NotNull public Module getModule() { return myRootModel.getModule(); } - private static class ModuleLibraryOrderEntryCondition implements Condition { @Override public boolean value(OrderEntry entry) { @@ -186,6 +191,7 @@ public class ModuleLibraryTable implements LibraryTable, LibraryTableBase.Modifi return myRootModel.isChanged(); } + @NotNull @Override public ModifiableModel getModifiableModel() { return this; diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/OrderEntryFactory.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/OrderEntryFactory.java index 1e71cf158c11..f2f679dc0945 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/OrderEntryFactory.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/OrderEntryFactory.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. @@ -21,6 +21,7 @@ import com.intellij.openapi.roots.OrderEntry; import com.intellij.openapi.util.InvalidDataException; import org.jdom.Element; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.model.serialization.module.JpsModuleRootModelSerializer; /** @@ -31,7 +32,10 @@ public class OrderEntryFactory { @NonNls public static final String ORDER_ENTRY_ELEMENT_NAME = JpsModuleRootModelSerializer.ORDER_ENTRY_TAG; @NonNls public static final String ORDER_ENTRY_TYPE_ATTR = JpsModuleRootModelSerializer.TYPE_ATTRIBUTE; - static OrderEntry createOrderEntryByElement(Element element, RootModelImpl rootModel, ProjectRootManagerImpl projectRootManager) throws InvalidDataException { + @NotNull + static OrderEntry createOrderEntryByElement(@NotNull Element element, + @NotNull RootModelImpl rootModel, + @NotNull ProjectRootManagerImpl projectRootManager) throws InvalidDataException { LOG.assertTrue(ORDER_ENTRY_ELEMENT_NAME.equals(element.getName())); final String type = element.getAttributeValue(ORDER_ENTRY_TYPE_ATTR); if (type == null) { @@ -40,25 +44,26 @@ public class OrderEntryFactory { if (ModuleSourceOrderEntryImpl.ENTRY_TYPE.equals(type)) { return new ModuleSourceOrderEntryImpl(element, rootModel); } - else if (ModuleJdkOrderEntryImpl.ENTRY_TYPE.equals(type)) { + if (ModuleJdkOrderEntryImpl.ENTRY_TYPE.equals(type)) { return new ModuleJdkOrderEntryImpl(element, rootModel, projectRootManager); } - else if (InheritedJdkOrderEntryImpl.ENTRY_TYPE.equals(type)) { + if (InheritedJdkOrderEntryImpl.ENTRY_TYPE.equals(type)) { return new InheritedJdkOrderEntryImpl(element, rootModel, projectRootManager); } - else if (LibraryOrderEntryImpl.ENTRY_TYPE.equals(type)) { + if (LibraryOrderEntryImpl.ENTRY_TYPE.equals(type)) { return new LibraryOrderEntryImpl(element, rootModel, projectRootManager); } - else if (ModuleLibraryOrderEntryImpl.ENTRY_TYPE.equals(type)) { + if (ModuleLibraryOrderEntryImpl.ENTRY_TYPE.equals(type)) { return new ModuleLibraryOrderEntryImpl(element, rootModel, projectRootManager); } - else if (ModuleOrderEntryImpl.ENTRY_TYPE.equals(type)) { + if (ModuleOrderEntryImpl.ENTRY_TYPE.equals(type)) { return new ModuleOrderEntryImpl(element, rootModel); } - else throw new InvalidDataException("Unknown order entry type:" + type); + throw new InvalidDataException("Unknown order entry type:" + type); } - static Element createOrderEntryElement(String type) { + @NotNull + static Element createOrderEntryElement(@NotNull String type) { final Element element = new Element(ORDER_ENTRY_ELEMENT_NAME); element.setAttribute(ORDER_ENTRY_TYPE_ATTR, type); return element; diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootModelComponentBase.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootModelComponentBase.java index 5dc97011e512..603e71f04d9d 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootModelComponentBase.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootModelComponentBase.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. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull; * @author dsl */ public abstract class RootModelComponentBase implements Disposable { + @NotNull private final RootModelImpl myRootModel; private boolean myDisposed; @@ -33,6 +34,7 @@ public abstract class RootModelComponentBase implements Disposable { } + @NotNull public RootModelImpl getRootModel() { return myRootModel; } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java index 48f2bf068443..e1862603a622 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java @@ -79,7 +79,7 @@ public class LibraryImpl extends TraceableDisposable implements LibraryEx.Modifi private final Disposable myPointersDisposable = Disposer.newDisposable(); private final JarDirectoryWatcher myRootsWatcher = JarDirectoryWatcherFactory.getInstance().createWatcher(myJarDirectories, myRootProvider); - LibraryImpl(LibraryTable table, Element element, ModifiableRootModel rootModel) throws InvalidDataException { + LibraryImpl(LibraryTable table, @NotNull Element element, ModifiableRootModel rootModel) throws InvalidDataException { this(table, rootModel, null, element.getAttributeValue(LIBRARY_NAME_ATTR), (PersistentLibraryKind)LibraryKind.findById(element.getAttributeValue(LIBRARY_TYPE_ATTR))); readProperties(element); diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableBase.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableBase.java index e7f00dacd907..406376a98202 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableBase.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableBase.java @@ -41,6 +41,7 @@ public abstract class LibraryTableBase implements PersistentStateComponent