mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 05:21:29 +07:00
notnull
This commit is contained in:
@@ -22,6 +22,7 @@ import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class CompilerMessageImpl implements CompilerMessage {
|
||||
@@ -30,7 +31,7 @@ public final class CompilerMessageImpl implements CompilerMessage {
|
||||
private final CompilerMessageCategory myCategory;
|
||||
@Nullable private Navigatable myNavigatable;
|
||||
private final String myMessage;
|
||||
private VirtualFile myFile;
|
||||
private final VirtualFile myFile;
|
||||
private final int myRow;
|
||||
private final int myColumn;
|
||||
|
||||
@@ -39,7 +40,7 @@ public final class CompilerMessageImpl implements CompilerMessage {
|
||||
}
|
||||
|
||||
public CompilerMessageImpl(Project project,
|
||||
CompilerMessageCategory category,
|
||||
@NotNull CompilerMessageCategory category,
|
||||
String message,
|
||||
@Nullable final VirtualFile file,
|
||||
int row,
|
||||
@@ -54,14 +55,18 @@ public final class CompilerMessageImpl implements CompilerMessage {
|
||||
myFile = file;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CompilerMessageCategory getCategory() {
|
||||
return myCategory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return myMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Navigatable getNavigatable() {
|
||||
if (myNavigatable != null) {
|
||||
return myNavigatable;
|
||||
@@ -76,10 +81,12 @@ public final class CompilerMessageImpl implements CompilerMessage {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile getVirtualFile() {
|
||||
return myFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExportTextPrefix() {
|
||||
if (getLine() >= 0) {
|
||||
return CompilerBundle.message("compiler.results.export.text.prefix", getLine());
|
||||
@@ -87,6 +94,7 @@ public final class CompilerMessageImpl implements CompilerMessage {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRenderTextPrefix() {
|
||||
if (getLine() >= 0) {
|
||||
return "(" + getLine() + ", " + getColumn() + ")";
|
||||
|
||||
@@ -108,18 +108,19 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
|
||||
return myProject;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CompilerMessage[] getMessages(CompilerMessageCategory category) {
|
||||
public CompilerMessage[] getMessages(@NotNull CompilerMessageCategory category) {
|
||||
return myMessages.getMessages(category).toArray(CompilerMessage.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessage(CompilerMessageCategory category, String message, String url, int lineNum, int columnNum) {
|
||||
public void addMessage(@NotNull CompilerMessageCategory category, String message, String url, int lineNum, int columnNum) {
|
||||
addMessage(category, message, url, lineNum, columnNum, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessage(CompilerMessageCategory category, String message, String url, int lineNum, int columnNum, Navigatable navigatable) {
|
||||
public void addMessage(@NotNull CompilerMessageCategory category, String message, String url, int lineNum, int columnNum, Navigatable navigatable) {
|
||||
final CompilerMessage msg = myMessages.addMessage(category, message, url, lineNum, columnNum, navigatable);
|
||||
if (msg != null) {
|
||||
addToProblemsView(msg);
|
||||
@@ -184,7 +185,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
|
||||
}
|
||||
|
||||
@Override
|
||||
public Module getModuleByFile(VirtualFile file) {
|
||||
public Module getModuleByFile(@NotNull VirtualFile file) {
|
||||
final Module module = myProjectFileIndex.getModuleForFile(file);
|
||||
if (module != null) {
|
||||
LOG.assertTrue(!module.isDisposed());
|
||||
@@ -194,7 +195,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile getModuleOutputDirectory(Module module) {
|
||||
public VirtualFile getModuleOutputDirectory(@NotNull Module module) {
|
||||
return CompilerPaths.getModuleOutputDirectory(module, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class MessagesContainer {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<CompilerMessage> getMessages(CompilerMessageCategory category) {
|
||||
public Collection<CompilerMessage> getMessages(@NotNull CompilerMessageCategory category) {
|
||||
final Collection<CompilerMessage> collection = myMessages.get(category);
|
||||
if (collection == null) {
|
||||
return Collections.emptyList();
|
||||
@@ -58,11 +58,7 @@ public class MessagesContainer {
|
||||
}
|
||||
|
||||
public boolean addMessage(CompilerMessage msg) {
|
||||
Collection<CompilerMessage> messages = myMessages.get(msg.getCategory());
|
||||
if (messages == null) {
|
||||
messages = new LinkedHashSet<>();
|
||||
myMessages.put(msg.getCategory(), messages);
|
||||
}
|
||||
Collection<CompilerMessage> messages = myMessages.computeIfAbsent(msg.getCategory(), k -> new LinkedHashSet<>());
|
||||
return messages.add(msg);
|
||||
}
|
||||
|
||||
@@ -79,7 +75,7 @@ public class MessagesContainer {
|
||||
return file;
|
||||
}
|
||||
|
||||
public int getMessageCount(CompilerMessageCategory category) {
|
||||
public int getMessageCount(@Nullable CompilerMessageCategory category) {
|
||||
if (category != null) {
|
||||
Collection<CompilerMessage> collection = myMessages.get(category);
|
||||
return collection != null ? collection.size() : 0;
|
||||
|
||||
@@ -41,7 +41,7 @@ final class AutomakeCompileContext extends UserDataHolderBase implements Compile
|
||||
private final EmptyProgressIndicator myIndicator;
|
||||
private final boolean myAnnotationProcessingEnabled;
|
||||
|
||||
public AutomakeCompileContext(Project project) {
|
||||
AutomakeCompileContext(Project project) {
|
||||
myProject = project;
|
||||
myScope = new ProjectCompileScope(project);
|
||||
myMessages = new MessagesContainer(project);
|
||||
@@ -74,22 +74,29 @@ final class AutomakeCompileContext extends UserDataHolderBase implements Compile
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addMessage(CompilerMessageCategory category, String message, @Nullable String url, int lineNum, int columnNum) {
|
||||
@Override
|
||||
public void addMessage(@NotNull CompilerMessageCategory category, String message, @Nullable String url, int lineNum, int columnNum) {
|
||||
addMessage(category, message, url, lineNum, columnNum, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessage(CompilerMessageCategory category, String message, @Nullable String url, int lineNum, int columnNum, Navigatable navigatable) {
|
||||
public void addMessage(@NotNull CompilerMessageCategory category, String message, @Nullable String url, int lineNum, int columnNum, Navigatable navigatable) {
|
||||
createAndAddMessage(category, message, url, lineNum, columnNum, navigatable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompilerMessage[] getMessages(CompilerMessageCategory category) {
|
||||
@NotNull
|
||||
public CompilerMessage[] getMessages(@NotNull CompilerMessageCategory category) {
|
||||
return myMessages.getMessages(category).toArray(CompilerMessage.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CompilerMessage createAndAddMessage(CompilerMessageCategory category, String message, @Nullable String url, int lineNum, int columnNum, Navigatable navigatable) {
|
||||
CompilerMessage createAndAddMessage(CompilerMessageCategory category,
|
||||
String message,
|
||||
@Nullable String url,
|
||||
int lineNum,
|
||||
int columnNum,
|
||||
Navigatable navigatable) {
|
||||
return myMessages.addMessage(category, message, url, lineNum, columnNum, navigatable);
|
||||
}
|
||||
|
||||
@@ -120,14 +127,16 @@ final class AutomakeCompileContext extends UserDataHolderBase implements Compile
|
||||
}
|
||||
|
||||
@Override
|
||||
public Module getModuleByFile(VirtualFile file) {
|
||||
public Module getModuleByFile(@NotNull VirtualFile file) {
|
||||
return ProjectRootManager.getInstance(myProject).getFileIndex().getModuleForFile(file);
|
||||
}
|
||||
|
||||
public VirtualFile getModuleOutputDirectory(final Module module) {
|
||||
@Override
|
||||
public VirtualFile getModuleOutputDirectory(@NotNull final Module module) {
|
||||
return CompilerPaths.getModuleOutputDirectory(module, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile getModuleOutputDirectoryForTests(final Module module) {
|
||||
return CompilerPaths.getModuleOutputDirectory(module, true);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,8 @@ public abstract class BuildProcessParametersProvider {
|
||||
* Override this method to include additional jars to the build process classpath
|
||||
* @return list of paths to additional jars to be included to the build process classpath
|
||||
*/
|
||||
public @NotNull List<String> getClassPath() {
|
||||
@NotNull
|
||||
public List<String> getClassPath() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -40,11 +41,13 @@ public abstract class BuildProcessParametersProvider {
|
||||
* custom implementation of Java compiler which must be loaded by the same classloader as tools.jar
|
||||
* @return list of paths to additional jars to be included to the build process launcher classpath
|
||||
*/
|
||||
public @NotNull List<String> getLauncherClassPath() {
|
||||
@NotNull
|
||||
public List<String> getLauncherClassPath() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public @NotNull List<String> getVMArguments() {
|
||||
@NotNull
|
||||
public List<String> getVMArguments() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public interface CompileContext extends UserDataHolder {
|
||||
* @param lineNum a line number, -1 if not available.
|
||||
* @param columnNum a column number, -1 if not available.
|
||||
*/
|
||||
void addMessage(CompilerMessageCategory category, String message, @Nullable String url, int lineNum, int columnNum);
|
||||
void addMessage(@NotNull CompilerMessageCategory category, String message, @Nullable String url, int lineNum, int columnNum);
|
||||
|
||||
/**
|
||||
* Allows to add a message to be shown in Compiler message view, with a specified Navigatable
|
||||
@@ -52,7 +52,7 @@ public interface CompileContext extends UserDataHolder {
|
||||
* @param navigatable the navigatable pointing to the error location.
|
||||
* @since 6.0
|
||||
*/
|
||||
void addMessage(CompilerMessageCategory category, String message, @Nullable String url, int lineNum, int columnNum,
|
||||
void addMessage(@NotNull CompilerMessageCategory category, String message, @Nullable String url, int lineNum, int columnNum,
|
||||
Navigatable navigatable);
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,8 @@ public interface CompileContext extends UserDataHolder {
|
||||
* @param category the category for which messages are requested.
|
||||
* @return all compiler messages of the specified category
|
||||
*/
|
||||
CompilerMessage[] getMessages(CompilerMessageCategory category);
|
||||
@NotNull
|
||||
CompilerMessage[] getMessages(@NotNull CompilerMessageCategory category);
|
||||
|
||||
/**
|
||||
* Returns the count of messages of the specified category added during the current compile session.
|
||||
@@ -69,7 +70,7 @@ public interface CompileContext extends UserDataHolder {
|
||||
* @param category the category for which messages are requested.
|
||||
* @return the number of messages of the specified category
|
||||
*/
|
||||
int getMessageCount(CompilerMessageCategory category);
|
||||
int getMessageCount(@Nullable CompilerMessageCategory category);
|
||||
|
||||
/**
|
||||
* Returns the progress indicator of the compilation process.
|
||||
@@ -112,7 +113,7 @@ public interface CompileContext extends UserDataHolder {
|
||||
* @param file the file to check.
|
||||
* @return the module to which the file belongs
|
||||
*/
|
||||
Module getModuleByFile(VirtualFile file);
|
||||
Module getModuleByFile(@NotNull VirtualFile file);
|
||||
|
||||
/**
|
||||
* Returns the output directory for the specified module.
|
||||
@@ -121,7 +122,7 @@ public interface CompileContext extends UserDataHolder {
|
||||
* @return the output directory for the module specified, null if corresponding VirtualFile is not valid or directory not specified
|
||||
*/
|
||||
@Nullable
|
||||
VirtualFile getModuleOutputDirectory(Module module);
|
||||
VirtualFile getModuleOutputDirectory(@NotNull Module module);
|
||||
|
||||
/**
|
||||
* Returns the test output directory for the specified module.
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.openapi.compiler;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -35,6 +36,7 @@ public interface CompilerMessage {
|
||||
*
|
||||
* @return a category this message belongs to (error, warning, information).
|
||||
*/
|
||||
@NotNull
|
||||
CompilerMessageCategory getCategory();
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.util.PathUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.java.compiler.AnnotationProcessingConfiguration;
|
||||
|
||||
@@ -105,7 +106,7 @@ public class CompilerPaths {
|
||||
* Null is returned if output directory is not specified or is not valid
|
||||
*/
|
||||
@Nullable
|
||||
public static VirtualFile getModuleOutputDirectory(final Module module, boolean forTestClasses) {
|
||||
public static VirtualFile getModuleOutputDirectory(@NotNull Module module, boolean forTestClasses) {
|
||||
final CompilerModuleExtension compilerModuleExtension = CompilerModuleExtension.getInstance(module);
|
||||
if (compilerModuleExtension == null) {
|
||||
return null;
|
||||
|
||||
@@ -41,11 +41,11 @@ public class DummyCompileContext implements CompileContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addMessage(CompilerMessageCategory category, String message, String url, int lineNum, int columnNum) {
|
||||
public void addMessage(@NotNull CompilerMessageCategory category, String message, String url, int lineNum, int columnNum) {
|
||||
}
|
||||
|
||||
|
||||
public void addMessage(CompilerMessageCategory category,
|
||||
public void addMessage(@NotNull CompilerMessageCategory category,
|
||||
String message,
|
||||
@Nullable String url,
|
||||
int lineNum,
|
||||
@@ -53,7 +53,8 @@ public class DummyCompileContext implements CompileContext {
|
||||
Navigatable navigatable) {
|
||||
}
|
||||
|
||||
public CompilerMessage[] getMessages(CompilerMessageCategory category) {
|
||||
@NotNull
|
||||
public CompilerMessage[] getMessages(@NotNull CompilerMessageCategory category) {
|
||||
return CompilerMessage.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@@ -86,7 +87,7 @@ public class DummyCompileContext implements CompileContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Module getModuleByFile(VirtualFile file) {
|
||||
public Module getModuleByFile(@NotNull VirtualFile file) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -94,7 +95,7 @@ public class DummyCompileContext implements CompileContext {
|
||||
return false;
|
||||
}
|
||||
|
||||
public VirtualFile getModuleOutputDirectory(final Module module) {
|
||||
public VirtualFile getModuleOutputDirectory(@NotNull final Module module) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<VirtualFile>() {
|
||||
public VirtualFile compute() {
|
||||
return CompilerModuleExtension.getInstance(module).getCompilerOutputPath();
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkTypeId;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JavaAwareProjectJdkTableImpl extends ProjectJdkTableImpl {
|
||||
public static JavaAwareProjectJdkTableImpl getInstanceEx() {
|
||||
@@ -32,10 +33,11 @@ public class JavaAwareProjectJdkTableImpl extends ProjectJdkTableImpl {
|
||||
private final JavaSdk myJavaSdk;
|
||||
private Sdk myInternalJdk;
|
||||
|
||||
public JavaAwareProjectJdkTableImpl(final JavaSdk javaSdk) {
|
||||
public JavaAwareProjectJdkTableImpl(@NotNull JavaSdk javaSdk) {
|
||||
myJavaSdk = javaSdk;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Sdk getInternalJdk() {
|
||||
if (myInternalJdk == null) {
|
||||
final String jdkHome = SystemProperties.getJavaHome();
|
||||
@@ -46,7 +48,7 @@ public class JavaAwareProjectJdkTableImpl extends ProjectJdkTableImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeJdk(final Sdk jdk) {
|
||||
public void removeJdk(@NotNull final Sdk jdk) {
|
||||
super.removeJdk(jdk);
|
||||
if (jdk.equals(myInternalJdk)) {
|
||||
myInternalJdk = null;
|
||||
@@ -54,6 +56,7 @@ public class JavaAwareProjectJdkTableImpl extends ProjectJdkTableImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public SdkTypeId getDefaultSdkType() {
|
||||
return myJavaSdk;
|
||||
}
|
||||
|
||||
@@ -56,17 +56,13 @@ public class ProjectJdkTableImpl extends ProjectJdkTable implements ExportableCo
|
||||
private final Map<String, ProjectJdkImpl> myCachedProjectJdks = new HashMap<>();
|
||||
private final MessageBus myMessageBus;
|
||||
|
||||
public ProjectJdkTableImpl() {
|
||||
ProjectJdkTableImpl() {
|
||||
myMessageBus = ApplicationManager.getApplication().getMessageBus();
|
||||
myListenerList = new MessageListenerList<>(myMessageBus, JDK_TABLE_TOPIC);
|
||||
// support external changes to jdk libraries (Endorsed Standards Override)
|
||||
final MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect();
|
||||
connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
|
||||
private FileTypeManager myFileTypeManager = FileTypeManager.getInstance();
|
||||
|
||||
@Override
|
||||
public void before(@NotNull List<? extends VFileEvent> events) {
|
||||
}
|
||||
private final FileTypeManager myFileTypeManager = FileTypeManager.getInstance();
|
||||
|
||||
@Override
|
||||
public void after(@NotNull List<? extends VFileEvent> events) {
|
||||
@@ -177,13 +173,15 @@ public class ProjectJdkTableImpl extends ProjectJdkTable implements ExportableCo
|
||||
return type;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Sdk[] getAllJdks() {
|
||||
return mySdks.toArray(new Sdk[mySdks.size()]);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Sdk> getSdksOfType(final SdkTypeId type) {
|
||||
public List<Sdk> getSdksOfType(@NotNull final SdkTypeId type) {
|
||||
List<Sdk> result = new ArrayList<>();
|
||||
final Sdk[] sdks = getAllJdks();
|
||||
for (Sdk sdk : sdks) {
|
||||
@@ -195,21 +193,21 @@ public class ProjectJdkTableImpl extends ProjectJdkTable implements ExportableCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addJdk(Sdk jdk) {
|
||||
public void addJdk(@NotNull Sdk jdk) {
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
mySdks.add(jdk);
|
||||
myMessageBus.syncPublisher(JDK_TABLE_TOPIC).jdkAdded(jdk);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeJdk(Sdk jdk) {
|
||||
public void removeJdk(@NotNull Sdk jdk) {
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
myMessageBus.syncPublisher(JDK_TABLE_TOPIC).jdkRemoved(jdk);
|
||||
mySdks.remove(jdk);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateJdk(Sdk originalJdk, Sdk modifiedJdk) {
|
||||
public void updateJdk(@NotNull Sdk originalJdk, @NotNull Sdk modifiedJdk) {
|
||||
final String previousName = originalJdk.getName();
|
||||
final String newName = modifiedJdk.getName();
|
||||
|
||||
@@ -222,26 +220,29 @@ public class ProjectJdkTableImpl extends ProjectJdkTable implements ExportableCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(Listener listener) {
|
||||
public void addListener(@NotNull Listener listener) {
|
||||
myListenerList.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(Listener listener) {
|
||||
public void removeListener(@NotNull Listener listener) {
|
||||
myListenerList.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public SdkTypeId getDefaultSdkType() {
|
||||
return UnknownSdkType.getInstance("");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public SdkTypeId getSdkTypeByName(@NotNull String sdkTypeName) {
|
||||
return findSdkTypeByName(sdkTypeName);
|
||||
}
|
||||
|
||||
public static SdkTypeId findSdkTypeByName(@NotNull String sdkTypeName) {
|
||||
@NotNull
|
||||
private static SdkTypeId findSdkTypeByName(@NotNull String sdkTypeName) {
|
||||
final SdkType[] allSdkTypes = SdkType.getAllTypes();
|
||||
for (final SdkType type : allSdkTypes) {
|
||||
if (type.getName().equals(sdkTypeName)) {
|
||||
@@ -251,8 +252,9 @@ public class ProjectJdkTableImpl extends ProjectJdkTable implements ExportableCo
|
||||
return UnknownSdkType.getInstance(sdkTypeName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Sdk createSdk(final String name, final SdkTypeId sdkType) {
|
||||
public Sdk createSdk(@NotNull final String name, @NotNull final SdkTypeId sdkType) {
|
||||
return new ProjectJdkImpl(name, sdkType);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,17 +40,19 @@ public abstract class ProjectJdkTable {
|
||||
@Nullable
|
||||
public abstract Sdk findJdk(String name, String type);
|
||||
|
||||
@NotNull
|
||||
public abstract Sdk[] getAllJdks();
|
||||
|
||||
public abstract List<Sdk> getSdksOfType(SdkTypeId type);
|
||||
@NotNull
|
||||
public abstract List<Sdk> getSdksOfType(@NotNull SdkTypeId type);
|
||||
|
||||
@Nullable
|
||||
public Sdk findMostRecentSdkOfType(final SdkTypeId type) {
|
||||
public Sdk findMostRecentSdkOfType(@NotNull SdkTypeId type) {
|
||||
return findMostRecentSdk(sdk -> sdk.getSdkType() == type);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Sdk findMostRecentSdk(Condition<Sdk> condition) {
|
||||
public Sdk findMostRecentSdk(@NotNull Condition<Sdk> condition) {
|
||||
Sdk found = null;
|
||||
for (Sdk each : getAllJdks()) {
|
||||
if (!condition.value(each)) continue;
|
||||
@@ -63,7 +65,7 @@ public abstract class ProjectJdkTable {
|
||||
return found;
|
||||
}
|
||||
|
||||
public abstract void addJdk(Sdk jdk);
|
||||
public abstract void addJdk(@NotNull Sdk jdk);
|
||||
|
||||
@TestOnly
|
||||
public void addJdk(@NotNull Sdk jdk, @NotNull Disposable parentDisposable) {
|
||||
@@ -71,37 +73,40 @@ public abstract class ProjectJdkTable {
|
||||
Disposer.register(parentDisposable, () -> WriteAction.run(() -> removeJdk(jdk)));
|
||||
}
|
||||
|
||||
public abstract void removeJdk(Sdk jdk);
|
||||
public abstract void removeJdk(@NotNull Sdk jdk);
|
||||
|
||||
public abstract void updateJdk(Sdk originalJdk, Sdk modifiedJdk);
|
||||
public abstract void updateJdk(@NotNull Sdk originalJdk, @NotNull Sdk modifiedJdk);
|
||||
|
||||
public interface Listener extends EventListener {
|
||||
void jdkAdded(Sdk jdk);
|
||||
void jdkRemoved(Sdk jdk);
|
||||
void jdkNameChanged(Sdk jdk, String previousName);
|
||||
void jdkAdded(@NotNull Sdk jdk);
|
||||
void jdkRemoved(@NotNull Sdk jdk);
|
||||
void jdkNameChanged(@NotNull Sdk jdk, @NotNull String previousName);
|
||||
}
|
||||
|
||||
public static class Adapter implements Listener {
|
||||
@Override public void jdkAdded(Sdk jdk) { }
|
||||
@Override public void jdkRemoved(Sdk jdk) { }
|
||||
@Override public void jdkNameChanged(Sdk jdk, String previousName) { }
|
||||
@Override public void jdkAdded(@NotNull Sdk jdk) { }
|
||||
@Override public void jdkRemoved(@NotNull Sdk jdk) { }
|
||||
@Override public void jdkNameChanged(@NotNull Sdk jdk, @NotNull String previousName) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link ProjectJdkTable#JDK_TABLE_TOPIC} instead
|
||||
*/
|
||||
public abstract void addListener(Listener listener);
|
||||
public abstract void addListener(@NotNull Listener listener);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link ProjectJdkTable#JDK_TABLE_TOPIC} instead
|
||||
*/
|
||||
public abstract void removeListener(Listener listener);
|
||||
public abstract void removeListener(@NotNull Listener listener);
|
||||
|
||||
@NotNull
|
||||
public abstract SdkTypeId getDefaultSdkType();
|
||||
|
||||
@NotNull
|
||||
public abstract SdkTypeId getSdkTypeByName(@NotNull String name);
|
||||
|
||||
public abstract Sdk createSdk(final String name, final SdkTypeId sdkType);
|
||||
@NotNull
|
||||
public abstract Sdk createSdk(@NotNull String name, @NotNull SdkTypeId sdkType);
|
||||
|
||||
public static final Topic<Listener> JDK_TABLE_TOPIC = Topic.create("Project JDK table", Listener.class);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public class CoreProjectJdkTable extends ProjectJdkTable {
|
||||
return findJdk(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Sdk[] getAllJdks() {
|
||||
synchronized (mySdks) {
|
||||
@@ -54,8 +55,9 @@ public class CoreProjectJdkTable extends ProjectJdkTable {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Sdk> getSdksOfType(SdkTypeId type) {
|
||||
public List<Sdk> getSdksOfType(@NotNull SdkTypeId type) {
|
||||
List<Sdk> result = new ArrayList<>();
|
||||
synchronized (mySdks) {
|
||||
for (Sdk sdk : mySdks) {
|
||||
@@ -68,44 +70,47 @@ public class CoreProjectJdkTable extends ProjectJdkTable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addJdk(Sdk jdk) {
|
||||
public void addJdk(@NotNull Sdk jdk) {
|
||||
synchronized (mySdks) {
|
||||
mySdks.add(jdk);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeJdk(Sdk jdk) {
|
||||
public void removeJdk(@NotNull Sdk jdk) {
|
||||
synchronized (mySdks) {
|
||||
mySdks.remove(jdk);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateJdk(Sdk originalJdk, Sdk modifiedJdk) {
|
||||
public void updateJdk(@NotNull Sdk originalJdk, @NotNull Sdk modifiedJdk) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(Listener listener) {
|
||||
public void addListener(@NotNull Listener listener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(Listener listener) {
|
||||
public void removeListener(@NotNull Listener listener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public SdkTypeId getDefaultSdkType() {
|
||||
return CoreSdkType.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public SdkTypeId getSdkTypeByName(@NotNull String name) {
|
||||
return CoreSdkType.INSTANCE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Sdk createSdk(String name, SdkTypeId sdkType) {
|
||||
public Sdk createSdk(@NotNull String name, @NotNull SdkTypeId sdkType) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,21 +119,21 @@ public class InheritedJdkOrderEntryImpl extends LibraryOrderEntryBaseImpl implem
|
||||
|
||||
private class MyJdkTableListener implements ProjectJdkTable.Listener {
|
||||
@Override
|
||||
public void jdkRemoved(Sdk jdk) {
|
||||
public void jdkRemoved(@NotNull Sdk jdk) {
|
||||
if (jdk.equals(getJdk())) {
|
||||
updateFromRootProviderAndSubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdkAdded(Sdk jdk) {
|
||||
public void jdkAdded(@NotNull Sdk jdk) {
|
||||
if (isAffectedByJdk(jdk)) {
|
||||
updateFromRootProviderAndSubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdkNameChanged(Sdk jdk, String previousName) {
|
||||
public void jdkNameChanged(@NotNull Sdk jdk, @NotNull String previousName) {
|
||||
if (isAffectedByJdk(jdk)) {
|
||||
// if current name matches my name
|
||||
updateFromRootProviderAndSubscribe();
|
||||
|
||||
@@ -91,10 +91,10 @@ public class ModuleJdkOrderEntryImpl extends LibraryOrderEntryBaseImpl implement
|
||||
init(that.myJdk, that.getJdkName(), that.getJdkType());
|
||||
}
|
||||
|
||||
public ModuleJdkOrderEntryImpl(final String jdkName,
|
||||
final String jdkType,
|
||||
@NotNull final RootModelImpl rootModel,
|
||||
@NotNull final ProjectRootManagerImpl projectRootManager) {
|
||||
ModuleJdkOrderEntryImpl(final String jdkName,
|
||||
final String jdkType,
|
||||
@NotNull final RootModelImpl rootModel,
|
||||
@NotNull final ProjectRootManagerImpl projectRootManager) {
|
||||
super(rootModel, projectRootManager);
|
||||
init(null, jdkName, jdkType);
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public class ModuleJdkOrderEntryImpl extends LibraryOrderEntryBaseImpl implement
|
||||
|
||||
@Override
|
||||
public void jdkAdded(@NotNull Sdk jdk) {
|
||||
if (myJdk == null && getJdkName().equals(jdk.getName())) {
|
||||
if (myJdk == null && jdk.getName().equals(getJdkName())) {
|
||||
myJdk = jdk;
|
||||
setJdkName(null);
|
||||
setJdkType(null);
|
||||
@@ -173,8 +173,8 @@ public class ModuleJdkOrderEntryImpl extends LibraryOrderEntryBaseImpl implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdkNameChanged(@NotNull Sdk jdk, String previousName) {
|
||||
if (myJdk == null && getJdkName().equals(jdk.getName())) {
|
||||
public void jdkNameChanged(@NotNull Sdk jdk, @NotNull String previousName) {
|
||||
if (myJdk == null && jdk.getName().equals(getJdkName())) {
|
||||
myJdk = jdk;
|
||||
setJdkName(null);
|
||||
setJdkType(null);
|
||||
@@ -183,7 +183,7 @@ public class ModuleJdkOrderEntryImpl extends LibraryOrderEntryBaseImpl implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdkRemoved(Sdk jdk) {
|
||||
public void jdkRemoved(@NotNull Sdk jdk) {
|
||||
if (jdk == myJdk) {
|
||||
setJdkName(myJdk.getName());
|
||||
setJdkType(myJdk.getSdkType().getName());
|
||||
|
||||
@@ -588,7 +588,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Pers
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdkAdded(final Sdk jdk) {
|
||||
public void jdkAdded(@NotNull final Sdk jdk) {
|
||||
mergeRootsChangesDuring(() -> {
|
||||
for (ProjectJdkTable.Listener listener : getListeners()) {
|
||||
listener.jdkAdded(jdk);
|
||||
@@ -597,7 +597,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Pers
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdkRemoved(final Sdk jdk) {
|
||||
public void jdkRemoved(@NotNull final Sdk jdk) {
|
||||
mergeRootsChangesDuring(() -> {
|
||||
for (ProjectJdkTable.Listener listener : getListeners()) {
|
||||
listener.jdkRemoved(jdk);
|
||||
@@ -606,7 +606,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Pers
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdkNameChanged(final Sdk jdk, final String previousName) {
|
||||
public void jdkNameChanged(@NotNull final Sdk jdk, @NotNull final String previousName) {
|
||||
mergeRootsChangesDuring(() -> {
|
||||
for (ProjectJdkTable.Listener listener : getListeners()) {
|
||||
listener.jdkNameChanged(jdk, previousName);
|
||||
|
||||
@@ -53,7 +53,7 @@ class PluginModuleCompilationTest : BaseCompilerTestCase() {
|
||||
val rootPath = FileUtil.toSystemIndependentName(PathManager.getJarPathForClass(FileUtilRt::class.java)!!)
|
||||
modificator.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByPath(rootPath), OrderRootType.CLASSES)
|
||||
modificator.commitChanges()
|
||||
table.addJdk(pluginSdk)
|
||||
table.addJdk(pluginSdk!!)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class PluginModuleCompilationTest : BaseCompilerTestCase() {
|
||||
override fun tearDown() {
|
||||
try {
|
||||
if (pluginSdk != null) {
|
||||
runWriteAction { ProjectJdkTable.getInstance().removeJdk(pluginSdk) }
|
||||
runWriteAction { ProjectJdkTable.getInstance().removeJdk(pluginSdk!!) }
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.jetbrains.python.sdk.PythonSdkType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -34,7 +35,7 @@ public class PythonSdkTableListener implements Disposable {
|
||||
public PythonSdkTableListener(MessageBus messageBus) {
|
||||
ProjectJdkTable.Listener jdkTableListener = new ProjectJdkTable.Listener() {
|
||||
@Override
|
||||
public void jdkAdded(final Sdk sdk) {
|
||||
public void jdkAdded(@NotNull final Sdk sdk) {
|
||||
if (sdk.getSdkType() instanceof PythonSdkType) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
addLibrary(sdk);
|
||||
@@ -43,14 +44,14 @@ public class PythonSdkTableListener implements Disposable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdkRemoved(final Sdk sdk) {
|
||||
public void jdkRemoved(@NotNull final Sdk sdk) {
|
||||
if (sdk.getSdkType() instanceof PythonSdkType) {
|
||||
removeLibrary(sdk);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdkNameChanged(final Sdk sdk, final String previousName) {
|
||||
public void jdkNameChanged(@NotNull final Sdk sdk, @NotNull final String previousName) {
|
||||
if (sdk.getSdkType() instanceof PythonSdkType) {
|
||||
renameLibrary(sdk, previousName);
|
||||
}
|
||||
|
||||
@@ -43,17 +43,17 @@ public class PythonSdkEditorTab extends FacetEditorTab {
|
||||
myConnection = project.getMessageBus().connect();
|
||||
myConnection.subscribe(ProjectJdkTable.JDK_TABLE_TOPIC, new ProjectJdkTable.Listener() {
|
||||
@Override
|
||||
public void jdkAdded(Sdk jdk) {
|
||||
public void jdkAdded(@NotNull Sdk jdk) {
|
||||
mySdkComboBox.updateSdkList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdkRemoved(Sdk jdk) {
|
||||
public void jdkRemoved(@NotNull Sdk jdk) {
|
||||
mySdkComboBox.updateSdkList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdkNameChanged(Sdk jdk, String previousName) {
|
||||
public void jdkNameChanged(@NotNull Sdk jdk, @NotNull String previousName) {
|
||||
mySdkComboBox.updateSdkList();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.jetbrains.python.sdk.PythonSdkType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -34,7 +35,7 @@ public class PythonSdkTableListener implements Disposable {
|
||||
public PythonSdkTableListener(MessageBus messageBus) {
|
||||
ProjectJdkTable.Listener jdkTableListener = new ProjectJdkTable.Listener() {
|
||||
@Override
|
||||
public void jdkAdded(final Sdk sdk) {
|
||||
public void jdkAdded(@NotNull final Sdk sdk) {
|
||||
if (sdk.getSdkType() instanceof PythonSdkType) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
addLibrary(sdk);
|
||||
@@ -43,14 +44,14 @@ public class PythonSdkTableListener implements Disposable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdkRemoved(final Sdk sdk) {
|
||||
public void jdkRemoved(@NotNull final Sdk sdk) {
|
||||
if (sdk.getSdkType() instanceof PythonSdkType) {
|
||||
removeLibrary(sdk);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jdkNameChanged(final Sdk sdk, final String previousName) {
|
||||
public void jdkNameChanged(@NotNull final Sdk sdk, @NotNull final String previousName) {
|
||||
if (sdk.getSdkType() instanceof PythonSdkType) {
|
||||
renameLibrary(sdk, previousName);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class PythonSdkPathCache extends PythonPathCache implements Disposable {
|
||||
final MessageBusConnection connection = project.getMessageBus().connect(this);
|
||||
connection.subscribe(ProjectJdkTable.JDK_TABLE_TOPIC, new ProjectJdkTable.Adapter() {
|
||||
@Override
|
||||
public void jdkRemoved(Sdk jdk) {
|
||||
public void jdkRemoved(@NotNull Sdk jdk) {
|
||||
if (jdk == sdk) {
|
||||
Disposer.dispose(PythonSdkPathCache.this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user