From 540b0010a7d24f2114176d72a8c49b7d2f1c1af5 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 16 Nov 2009 10:50:52 +0300 Subject: [PATCH] cleanup, notnull --- .../com/intellij/openapi/roots/ModifiableRootModel.java | 3 ++- .../src/com/intellij/openapi/roots/OrderRootType.java | 5 +++++ .../src/com/intellij/openapi/roots/RootProvider.java | 11 ++++++----- .../src/com/intellij/openapi/roots/libraries/Library.java | 3 ++- .../intellij/openapi/roots/libraries/LibraryTable.java | 3 ++- .../openapi/projectRoots/impl/ProjectJdkImpl.java | 15 ++++++++------- .../intellij/openapi/roots/impl/RootProviderBaseImpl.java | 9 +++++---- .../openapi/roots/impl/libraries/LibraryTableBase.java | 15 --------------- .../src/com/intellij/testFramework/PlatformTestCase.java | 2 +- 9 files changed, 31 insertions(+), 35 deletions(-) diff --git a/platform/lang-api/src/com/intellij/openapi/roots/ModifiableRootModel.java b/platform/lang-api/src/com/intellij/openapi/roots/ModifiableRootModel.java index 23177170a3..fb40a96dc3 100644 --- a/platform/lang-api/src/com/intellij/openapi/roots/ModifiableRootModel.java +++ b/platform/lang-api/src/com/intellij/openapi/roots/ModifiableRootModel.java @@ -21,6 +21,7 @@ import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -81,7 +82,7 @@ public interface ModifiableRootModel extends ModuleRootModel { * @param level * @return */ - LibraryOrderEntry addInvalidLibrary(String name, String level); + LibraryOrderEntry addInvalidLibrary(@NonNls String name, String level); ModuleOrderEntry addModuleOrderEntry(Module module); diff --git a/platform/lang-api/src/com/intellij/openapi/roots/OrderRootType.java b/platform/lang-api/src/com/intellij/openapi/roots/OrderRootType.java index 60cc400a87..150fbb8d2e 100644 --- a/platform/lang-api/src/com/intellij/openapi/roots/OrderRootType.java +++ b/platform/lang-api/src/com/intellij/openapi/roots/OrderRootType.java @@ -126,4 +126,9 @@ public class OrderRootType { public final boolean equals(Object obj) { return super.equals(obj); } + + @Override + public String toString() { + return "Root " + name(); + } } diff --git a/platform/lang-api/src/com/intellij/openapi/roots/RootProvider.java b/platform/lang-api/src/com/intellij/openapi/roots/RootProvider.java index ad968a57ac..50df120497 100644 --- a/platform/lang-api/src/com/intellij/openapi/roots/RootProvider.java +++ b/platform/lang-api/src/com/intellij/openapi/roots/RootProvider.java @@ -17,6 +17,7 @@ package com.intellij.openapi.roots; import com.intellij.openapi.Disposable; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; import java.util.EventListener; @@ -25,14 +26,14 @@ import java.util.EventListener; * @author dsl */ public interface RootProvider { - String[] getUrls(OrderRootType rootType); - VirtualFile[] getFiles(OrderRootType rootType); + @NotNull String[] getUrls(@NotNull OrderRootType rootType); + @NotNull VirtualFile[] getFiles(@NotNull OrderRootType rootType); interface RootSetChangedListener extends EventListener { void rootSetChanged(RootProvider wrapper); } - void addRootSetChangedListener(RootSetChangedListener listener); - void addRootSetChangedListener(RootSetChangedListener listener, Disposable parentDisposable); - void removeRootSetChangedListener(RootSetChangedListener listener); + void addRootSetChangedListener(@NotNull RootSetChangedListener listener); + void addRootSetChangedListener(@NotNull RootSetChangedListener listener, @NotNull Disposable parentDisposable); + void removeRootSetChangedListener(@NotNull RootSetChangedListener listener); } diff --git a/platform/lang-api/src/com/intellij/openapi/roots/libraries/Library.java b/platform/lang-api/src/com/intellij/openapi/roots/libraries/Library.java index 1b42fee3a3..ea6700bd23 100644 --- a/platform/lang-api/src/com/intellij/openapi/roots/libraries/Library.java +++ b/platform/lang-api/src/com/intellij/openapi/roots/libraries/Library.java @@ -20,6 +20,7 @@ import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.RootProvider; import com.intellij.openapi.util.JDOMExternalizable; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; /** @@ -52,7 +53,7 @@ public interface Library extends JDOMExternalizable, Disposable { String getName(); - void addRoot(@NotNull String url, @NotNull OrderRootType rootType); + void addRoot(@NonNls @NotNull String url, @NotNull OrderRootType rootType); void addJarDirectory(@NotNull String url, boolean recursive); diff --git a/platform/lang-api/src/com/intellij/openapi/roots/libraries/LibraryTable.java b/platform/lang-api/src/com/intellij/openapi/roots/libraries/LibraryTable.java index b7f3d8ac15..5ba863bf91 100644 --- a/platform/lang-api/src/com/intellij/openapi/roots/libraries/LibraryTable.java +++ b/platform/lang-api/src/com/intellij/openapi/roots/libraries/LibraryTable.java @@ -16,6 +16,7 @@ package com.intellij.openapi.roots.libraries; import com.intellij.openapi.Disposable; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -31,7 +32,7 @@ public interface LibraryTable { Library createLibrary(); - Library createLibrary(String name); + Library createLibrary(@NonNls String name); void removeLibrary(@NotNull Library library); diff --git a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectJdkImpl.java b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectJdkImpl.java index e8aedada4b..76bd57f475 100644 --- a/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectJdkImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/ProjectJdkImpl.java @@ -237,7 +237,8 @@ public class ProjectJdkImpl implements JDOMExternalizable, Sdk, SdkModificator { } private class MyRootProvider extends RootProviderBaseImpl implements ProjectRootListener { - public String[] getUrls(OrderRootType rootType) { + @NotNull + public String[] getUrls(@NotNull OrderRootType rootType) { final ProjectRoot[] rootFiles = myRootContainer.getRoots(rootType); final ArrayList result = new ArrayList(); for (ProjectRoot rootFile : rootFiles) { @@ -246,20 +247,21 @@ public class ProjectJdkImpl implements JDOMExternalizable, Sdk, SdkModificator { return ArrayUtil.toStringArray(result); } - public VirtualFile[] getFiles(final OrderRootType rootType) { + @NotNull + public VirtualFile[] getFiles(@NotNull final OrderRootType rootType) { return myRootContainer.getRootFiles(rootType); } private final Set myListeners = new HashSet(); - public void addRootSetChangedListener(RootSetChangedListener listener) { + public void addRootSetChangedListener(@NotNull RootSetChangedListener listener) { synchronized (this) { myListeners.add(listener); } super.addRootSetChangedListener(listener); } - public void addRootSetChangedListener(final RootSetChangedListener listener, Disposable parentDisposable) { + public void addRootSetChangedListener(@NotNull final RootSetChangedListener listener, @NotNull Disposable parentDisposable) { super.addRootSetChangedListener(listener, parentDisposable); Disposer.register(parentDisposable, new Disposable() { public void dispose() { @@ -268,7 +270,7 @@ public class ProjectJdkImpl implements JDOMExternalizable, Sdk, SdkModificator { }); } - public void removeRootSetChangedListener(RootSetChangedListener listener) { + public void removeRootSetChangedListener(@NotNull RootSetChangedListener listener) { super.removeRootSetChangedListener(listener); synchronized (this) { myListeners.remove(listener); @@ -277,7 +279,7 @@ public class ProjectJdkImpl implements JDOMExternalizable, Sdk, SdkModificator { public void rootsChanged() { synchronized (this) { - if (myListeners.size() == 0) { + if (myListeners.isEmpty()) { return; } } @@ -290,7 +292,6 @@ public class ProjectJdkImpl implements JDOMExternalizable, Sdk, SdkModificator { } // SdkModificator implementation - public SdkModificator getSdkModificator() { try { ProjectJdkImpl sdk = (ProjectJdkImpl)clone(); diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/RootProviderBaseImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/RootProviderBaseImpl.java index 9d51f49251..af1cf2ffb2 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/RootProviderBaseImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/RootProviderBaseImpl.java @@ -16,24 +16,25 @@ package com.intellij.openapi.roots.impl; -import com.intellij.openapi.roots.RootProvider; import com.intellij.openapi.Disposable; +import com.intellij.openapi.roots.RootProvider; import com.intellij.util.EventDispatcher; +import org.jetbrains.annotations.NotNull; /** * @author dsl */ public abstract class RootProviderBaseImpl implements RootProvider { private final EventDispatcher myDispatcher = EventDispatcher.create(RootSetChangedListener.class); - public void addRootSetChangedListener(RootSetChangedListener listener) { + public void addRootSetChangedListener(@NotNull RootSetChangedListener listener) { myDispatcher.addListener(listener); } - public void removeRootSetChangedListener(RootSetChangedListener listener) { + public void removeRootSetChangedListener(@NotNull RootSetChangedListener listener) { myDispatcher.removeListener(listener); } - public void addRootSetChangedListener(RootSetChangedListener listener, Disposable parentDisposable) { + public void addRootSetChangedListener(@NotNull RootSetChangedListener listener, @NotNull Disposable parentDisposable) { myDispatcher.addListener(listener, parentDisposable); } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableBase.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableBase.java index 87d0555bba..274bbbf4b1 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableBase.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTableBase.java @@ -151,21 +151,6 @@ public abstract class LibraryTableBase implements PersistentStateComponent