cleanup, notnull

This commit is contained in:
Alexey Kudravtsev
2009-11-16 11:19:44 +03:00
parent ae70c82d4d
commit 540b0010a7
9 changed files with 31 additions and 35 deletions
@@ -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);
@@ -126,4 +126,9 @@ public class OrderRootType {
public final boolean equals(Object obj) {
return super.equals(obj);
}
@Override
public String toString() {
return "Root " + name();
}
}
@@ -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);
}
@@ -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);
@@ -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);
@@ -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<String> result = new ArrayList<String>();
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<RootSetChangedListener> myListeners = new HashSet<RootSetChangedListener>();
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();
@@ -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<RootSetChangedListener> 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);
}
@@ -151,21 +151,6 @@ public abstract class LibraryTableBase implements PersistentStateComponent<Eleme
fireBeforeLibraryRemoved(library);
}
// dispose newly created instances of same (equals()) libraries
//for (final Library library : model.myLibraries) {
// if (addedLibraries.contains(library)) continue;
// for (final Library oldLibrary : myModel.myLibraries) {
// if (library.equals(oldLibrary) && library != oldLibrary) {
// final int index = model.myLibraries.indexOf(library);
// Disposer.dispose(library);
//
// // keep old library if somebody cached old instance
// model.myLibraries.set(index, oldLibrary);
// break;
// }
// }
//}
myModel = model;
for (Library library : removedLibraries) {
Disposer.dispose(library);
@@ -244,7 +244,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
return createModule(myProject.getName());
}
protected Module createModule(final String moduleName) {
protected Module createModule(@NonNls final String moduleName) {
return doCreateRealModule(moduleName);
}