This commit is contained in:
Alexey Kudravtsev
2019-01-29 16:52:11 +03:00
parent 277d47ecfb
commit d47409c3d0
166 changed files with 541 additions and 410 deletions
@@ -56,7 +56,7 @@ public class RegExpBackrefImpl extends RegExpElementImpl implements RegExpBackre
int groupCount;
@Override
public boolean isAccepted(PsiElement element) {
public boolean isAccepted(@NotNull PsiElement element) {
if (element instanceof RegExpGroup) {
if (((RegExpGroup)element).isCapturing() && ++groupCount == index) {
return true;
@@ -27,6 +27,7 @@ import java.util.List;
* @author nik
*/
final class ArtifactManagerStateSplitter extends StateSplitterEx {
@NotNull
@Override
public List<Pair<Element, String>> splitState(@NotNull Element state) {
return splitState(state, ArtifactState.NAME_ATTRIBUTE);
@@ -75,7 +75,8 @@ public class AlternativeJreClassFinder extends NonClasspathClassFinder {
if (profile instanceof ConfigurationWithAlternativeJre) {
ConfigurationWithAlternativeJre appConfig = (ConfigurationWithAlternativeJre)profile;
if (appConfig.isAlternativeJrePathEnabled()) {
return ProjectJdkTable.getInstance().findJdk(appConfig.getAlternativeJrePath());
String path = appConfig.getAlternativeJrePath();
return path == null ? null : ProjectJdkTable.getInstance().findJdk(path);
}
}
return null;
@@ -29,6 +29,7 @@ public class DefaultConsoleFiltersProvider implements ConsoleFilterProviderEx {
return getDefaultFilters(project, GlobalSearchScope.allScope(project));
}
@NotNull
@Override
public Filter[] getDefaultFilters(@NotNull Project project, @NotNull GlobalSearchScope scope) {
List<Filter> filters = ExceptionFilters.getFilters(scope);
@@ -47,7 +47,7 @@ public class YourkitFilter implements Filter{
}
@Override
public Result applyFilter(final String line, final int entireLength) {
public Result applyFilter(@NotNull final String line, final int entireLength) {
if (!line.endsWith(".java\n")) {
return null;
}
@@ -16,10 +16,12 @@
package com.intellij.execution.filters;
import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NotNull;
public class ExceptionBaseFilterFactory implements ExceptionFilterFactory {
@NotNull
@Override
public Filter create(GlobalSearchScope searchScope) {
public Filter create(@NotNull GlobalSearchScope searchScope) {
return new ExceptionFilter(searchScope);
}
}
@@ -51,7 +51,7 @@ public class ExceptionExFilterFactory implements ExceptionFilterFactory {
}
@Override
public Result applyFilter(final String line, final int textEndOffset) {
public Result applyFilter(@NotNull final String line, final int textEndOffset) {
return null;
}
@@ -97,7 +97,7 @@ public class ExceptionExFilterFactory implements ExceptionFilterFactory {
}
}
private static ExceptionWorker.ParsedLine doParse(ExceptionWorker worker, int lineEndOffset, String lineText) {
private static ExceptionWorker.ParsedLine doParse(@NotNull ExceptionWorker worker, int lineEndOffset, @NotNull String lineText) {
Result result = worker.execute(lineText, lineEndOffset);
if (result == null) return null;
HyperlinkInfo hyperlinkInfo = result.getHyperlinkInfo();
@@ -35,14 +35,14 @@ public class ExceptionFilter implements Filter, DumbAware {
}
@Override
public Result applyFilter(final String line, final int textEndOffset) {
public Result applyFilter(@NotNull final String line, final int textEndOffset) {
ExceptionWorker worker = new ExceptionWorker(myCache);
Result result = worker.execute(line, textEndOffset, myNextLineRefiner);
myNextLineRefiner = result == null ? getRefinerFromException(line) : worker.getLocationRefiner();
return result;
}
private static PsiElementFilter getRefinerFromException(String line) {
private static PsiElementFilter getRefinerFromException(@NotNull String line) {
String exceptionName = getExceptionFromMessage(line);
if (exceptionName == null) return null;
PsiElementFilter throwFilter = e -> {
@@ -128,6 +128,7 @@ public abstract class DownloadableLibraryType extends LibraryType<LibraryVersion
return getLibraryTypeIcon();
}
@NotNull
protected abstract String[] getDetectionClassNames();
@Override
@@ -380,13 +380,14 @@ public class SdkEditor implements Configurable, Place.Navigator {
}
private class EditedSdkModificator implements SdkModificator {
@NotNull
@Override
public String getName() {
return mySdk.getName();
}
@Override
public void setName(String name) {
public void setName(@NotNull String name) {
((ProjectJdkImpl)mySdk).setName(name);
}
@@ -15,6 +15,7 @@ import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesModifiableModel;
import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
import com.intellij.openapi.util.Disposer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Proxy;
@@ -25,7 +26,7 @@ import java.lang.reflect.Proxy;
public class IdeaModifiableModelsProvider implements ModifiableModelsProvider {
@Override
@Nullable
public ModifiableRootModel getModuleModifiableModel(final Module module) {
public ModifiableRootModel getModuleModifiableModel(@NotNull final Module module) {
final Project project = module.getProject();
final ModulesConfigurator configurator = getModulesConfigurator(project);
if (configurator != null) {
@@ -40,13 +41,13 @@ public class IdeaModifiableModelsProvider implements ModifiableModelsProvider {
}
@Nullable
private static ModulesConfigurator getModulesConfigurator(Project project) {
private static ModulesConfigurator getModulesConfigurator(@NotNull Project project) {
StructureConfigurableContext context = getProjectStructureContext(project);
return context != null ? context.getModulesConfigurator() : null;
}
@Override
public void commitModuleModifiableModel(final ModifiableRootModel model) {
public void commitModuleModifiableModel(@NotNull final ModifiableRootModel model) {
if (!(model instanceof Proxy)) {
model.commit();
}
@@ -54,15 +55,16 @@ public class IdeaModifiableModelsProvider implements ModifiableModelsProvider {
}
@Override
public void disposeModuleModifiableModel(final ModifiableRootModel model) {
public void disposeModuleModifiableModel(@NotNull final ModifiableRootModel model) {
if (!(model instanceof Proxy)) {
model.dispose();
}
//IDEA should dispose this model instead of us, because it is was given from StructureConfigurableContext
}
@NotNull
@Override
public ModifiableFacetModel getFacetModifiableModel(Module module) {
public ModifiableFacetModel getFacetModifiableModel(@NotNull Module module) {
final ModulesConfigurator configurator = getModulesConfigurator(module.getProject());
if (configurator != null) {
return configurator.getFacetsConfigurator().getOrCreateModifiableModel(module);
@@ -71,13 +73,14 @@ public class IdeaModifiableModelsProvider implements ModifiableModelsProvider {
}
@Override
public void commitFacetModifiableModel(Module module, ModifiableFacetModel model) {
public void commitFacetModifiableModel(@NotNull Module module, @NotNull ModifiableFacetModel model) {
final ModulesConfigurator configurator = getModulesConfigurator(module.getProject());
if (configurator == null || !(configurator.getFacetsConfigurator().getFacetModel(module) instanceof ModifiableFacetModel)) {
model.commit();
}
}
@NotNull
@Override
public LibraryTable.ModifiableModel getLibraryTableModifiableModel() {
final Project[] projects = ProjectManager.getInstance().getOpenProjects();
@@ -96,7 +99,7 @@ public class IdeaModifiableModelsProvider implements ModifiableModelsProvider {
}
@Override
public LibraryTable.ModifiableModel getLibraryTableModifiableModel(Project project) {
public LibraryTable.ModifiableModel getLibraryTableModifiableModel(@NotNull Project project) {
StructureConfigurableContext context = getProjectStructureContext(project);
if (context != null) {
LibraryTableModifiableModelProvider provider = context.createModifiableModelProvider(LibraryTablesRegistrar.PROJECT_LEVEL);
@@ -106,7 +109,7 @@ public class IdeaModifiableModelsProvider implements ModifiableModelsProvider {
}
@Override
public void disposeLibraryTableModifiableModel(LibraryTable.ModifiableModel model) {
public void disposeLibraryTableModifiableModel(@NotNull LibraryTable.ModifiableModel model) {
//IDEA should dispose this model instead of us, because it is was given from StructureConfigurableContext
if (!(model instanceof LibrariesModifiableModel)) {
Disposer.dispose(model);
@@ -114,7 +117,7 @@ public class IdeaModifiableModelsProvider implements ModifiableModelsProvider {
}
@Nullable
private static StructureConfigurableContext getProjectStructureContext(Project project) {
private static StructureConfigurableContext getProjectStructureContext(@NotNull Project project) {
if (ApplicationManager.getApplication().isHeadlessEnvironment()) return null;
final ProjectStructureConfigurable structureConfigurable = ProjectStructureConfigurable.getInstance(project);
@@ -17,7 +17,6 @@ import com.intellij.openapi.options.ModuleConfigurableEP;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.roots.impl.libraries.LibraryEx;
import com.intellij.openapi.roots.impl.libraries.LibraryTableBase;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.ui.navigation.History;
@@ -132,13 +131,12 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
return myModifiableRootModel;
}
@NotNull
public OrderEntry[] getOrderEntries() {
if (myModifiableRootModel == null) { // do not clone all model if not necessary
return ModuleRootManager.getInstance(getModule()).getOrderEntries();
}
else {
return myModifiableRootModel.getOrderEntries();
}
return myModifiableRootModel.getOrderEntries();
}
public ModifiableRootModel getModifiableRootModelProxy() {
@@ -207,12 +205,13 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
}
private static final Set<Class<?>> ourReportedDeprecatedClasses = new HashSet<>();
private static void reportDeprecatedModuleEditor(Class<?> aClass) {
private static void reportDeprecatedModuleEditor(@NotNull Class<?> aClass) {
if (ourReportedDeprecatedClasses.add(aClass)) {
LOG.warn(aClass.getName() + " uses deprecated way to register itself as a module editor. " + ModuleConfigurationEditorProvider.class.getName() + " extension point should be used instead");
}
}
@NotNull
private static ModuleConfigurationEditorProvider[] collectProviders(@NotNull Module module) {
List<ModuleConfigurationEditorProvider> result =
new ArrayList<>(ServiceKt.getComponents(module, ModuleConfigurationEditorProvider.class));
@@ -223,6 +222,7 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
return result.toArray(new ModuleConfigurationEditorProvider[0]);
}
@NotNull
public ModuleConfigurationState createModuleConfigurationState() {
return new ModuleConfigurationStateImpl(myProject, myModulesProvider) {
@Override
@@ -237,6 +237,7 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
};
}
@NotNull
private JPanel createPanel() {
getModifiableRootModel(); //initialize model if needed
getModifiableRootModelProxy();
@@ -254,6 +255,7 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
return myGenericSettingsPanel;
}
@NotNull
public JPanel getPanel() {
if (myGenericSettingsPanel == null) {
myGenericSettingsPanel = createPanel();
@@ -343,6 +345,7 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
}
}
@NotNull
public String getName() {
return myName;
}
@@ -354,7 +357,7 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
"removeOrderEntry", "setSdk", "inheritSdk", "inheritCompilerOutputPath", "setExcludeOutput", "replaceEntryOfType",
"rearrangeOrderEntries"));
ModifiableRootModelInvocationHandler(ModifiableRootModel model) {
ModifiableRootModelInvocationHandler(@NotNull ModifiableRootModel model) {
myDelegateModel = model;
}
@@ -389,7 +392,7 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
private final LibraryTable myDelegateTable;
@NonNls private final Set<String> myCheckedNames = new THashSet<>(Collections.singletonList("removeLibrary" /*,"createLibrary"*/));
LibraryTableInvocationHandler(LibraryTable table) {
LibraryTableInvocationHandler(@NotNull LibraryTable table) {
myDelegateTable = table;
}
@@ -402,8 +405,8 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{result instanceof LibraryEx ? LibraryEx.class : Library.class},
new LibraryInvocationHandler((Library)result));
}
else if (result instanceof LibraryTable.ModifiableModel) {
return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{LibraryTableBase.ModifiableModel.class},
if (result instanceof LibraryTable.ModifiableModel) {
return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{LibraryTable.ModifiableModel.class},
new LibraryTableModelInvocationHandler((LibraryTable.ModifiableModel)result));
}
if (result instanceof Library[]) {
@@ -436,7 +439,7 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
private class LibraryInvocationHandler implements InvocationHandler, ProxyDelegateAccessor {
private final Library myDelegateLibrary;
LibraryInvocationHandler(Library delegateLibrary) {
LibraryInvocationHandler(@NotNull Library delegateLibrary) {
myDelegateLibrary = delegateLibrary;
}
@@ -464,7 +467,7 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
private class LibraryModifiableModelInvocationHandler implements InvocationHandler, ProxyDelegateAccessor {
private final Library.ModifiableModel myDelegateModel;
LibraryModifiableModelInvocationHandler(Library.ModifiableModel delegateModel) {
LibraryModifiableModelInvocationHandler(@NotNull Library.ModifiableModel delegateModel) {
myDelegateModel = delegateModel;
}
@@ -493,7 +496,7 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
private class LibraryTableModelInvocationHandler implements InvocationHandler, ProxyDelegateAccessor {
private final LibraryTable.ModifiableModel myDelegateModel;
LibraryTableModelInvocationHandler(LibraryTable.ModifiableModel delegateModel) {
LibraryTableModelInvocationHandler(@NotNull LibraryTable.ModifiableModel delegateModel) {
myDelegateModel = delegateModel;
}
@@ -565,7 +568,7 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
return selectedEditor != null ? selectedEditor.getHelpTopic() : null;
}
public void setModuleName(final String name) {
public void setModuleName(@NotNull String name) {
myName = name;
}
@@ -126,7 +126,7 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change
@Override
@Nullable
public Module getModule(String name) {
public Module getModule(@NotNull String name) {
final Module moduleByName = myModuleModel.findModuleByName(name);
if (moduleByName != null) {
return moduleByName;
@@ -144,7 +144,8 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change
return getOrCreateModuleEditor(module).getRootModel();
}
public ModuleEditor getOrCreateModuleEditor(Module module) {
@NotNull
public ModuleEditor getOrCreateModuleEditor(@NotNull Module module) {
LOG.assertTrue(getModule(module.getName()) != null, "Module has been deleted");
ModuleEditor editor = getModuleEditor(module);
if (editor == null) {
@@ -153,7 +154,8 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change
return editor;
}
private ModuleEditor doCreateModuleEditor(final Module module) {
@NotNull
private ModuleEditor doCreateModuleEditor(@NotNull Module module) {
final ModuleEditor moduleEditor = new HeaderHidingTabbedModuleEditor(myProject, this, module) {
@Override
public ProjectFacetsConfigurator getFacetsConfigurator() {
@@ -173,6 +175,7 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change
return moduleEditor;
}
@NotNull
@Override
public FacetModel getFacetModel(@NotNull Module module) {
return myFacetsConfigurator.getOrCreateModifiableModel(module);
@@ -527,12 +530,12 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change
});
}
public static boolean showDialog(Project project, @Nullable final String moduleToSelect, @Nullable final String editorNameToSelect) {
public static boolean showDialog(@NotNull Project project, @Nullable final String moduleToSelect, @Nullable final String editorNameToSelect) {
final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(project);
return ShowSettingsUtil.getInstance().editConfigurable(project, config, () -> config.select(moduleToSelect, editorNameToSelect, true));
}
public void moduleRenamed(Module module, final String oldName, final String name) {
public void moduleRenamed(@NotNull Module module, final String oldName, @NotNull String name) {
ModuleEditor moduleEditor = myModuleEditors.get(module);
if (moduleEditor != null) {
moduleEditor.setModuleName(name);
@@ -107,7 +107,7 @@ public class LibraryEditingUtil {
PersistentLibraryKind<?> kind = ((LibraryEx)library).getKind();
if (kind != null) {
LibraryType type = LibraryType.findByKind(kind);
if (type != null && !type.isSuitableModule(rootModel.getModule(), facetsProvider)) {
if (!type.isSuitableModule(rootModel.getModule(), facetsProvider)) {
return false;
}
}
@@ -44,6 +44,7 @@ import java.util.Collections;
import java.util.List;
public abstract class BaseLibrariesConfigurable extends BaseStructureConfigurable {
@NotNull
protected final String myLevel;
protected BaseLibrariesConfigurable(final @NotNull Project project, @NotNull String libraryTableLevel) {
@@ -145,6 +146,7 @@ public abstract class BaseLibrariesConfigurable extends BaseStructureConfigurabl
});
}
@NotNull
public String getLevel() {
return myLevel;
}
@@ -30,7 +30,7 @@ public class ModuleConfigurable extends ProjectStructureElementConfigurable<Modu
private final ModuleProjectStructureElement myProjectStructureElement;
private final StructureConfigurableContext myContext;
public ModuleConfigurable(ModulesConfigurator modulesConfigurator, Module module, Runnable updateTree, ModuleGrouper moduleGrouper) {
public ModuleConfigurable(ModulesConfigurator modulesConfigurator, @NotNull Module module, Runnable updateTree, ModuleGrouper moduleGrouper) {
super(true, updateTree);
myModule = module;
myModuleGrouper = moduleGrouper;
@@ -79,6 +79,7 @@ public class ModuleConfigurable extends ProjectStructureElementConfigurable<Modu
}
@Override
@NotNull
public Module getEditableObject() {
return myModule;
}
@@ -98,6 +99,7 @@ public class ModuleConfigurable extends ProjectStructureElementConfigurable<Modu
return myModule.isDisposed() ? null : ModuleType.get(myModule).getIcon();
}
@NotNull
public Module getModule() {
return myModule;
}
@@ -112,14 +112,17 @@ public class StructureConfigurableContext implements Disposable, LibraryEditorLi
myLibraryEditorListeners.getMulticaster().libraryRenamed(library, oldName, newName);
}
@NotNull
public StructureLibraryTableModifiableModelProvider getGlobalLibrariesProvider() {
return createModifiableModelProvider(LibraryTablesRegistrar.APPLICATION_LEVEL);
}
public StructureLibraryTableModifiableModelProvider createModifiableModelProvider(final String level) {
@NotNull
public StructureLibraryTableModifiableModelProvider createModifiableModelProvider(@NotNull String level) {
return new StructureLibraryTableModifiableModelProvider(level, this);
}
@NotNull
public StructureLibraryTableModifiableModelProvider getProjectLibrariesProvider() {
return createModifiableModelProvider(LibraryTablesRegistrar.PROJECT_LEVEL);
}
@@ -134,14 +137,14 @@ public class StructureConfigurableContext implements Disposable, LibraryEditorLi
}
@Nullable
public Library getLibrary(final String libraryName, final String libraryLevel) {
public Library getLibrary(final String libraryName, @NotNull String libraryLevel) {
/* the null check is added only to prevent NPE when called from getLibrary */
final LibrariesModifiableModel model = myLevel2Providers.get(libraryLevel);
return model == null ? null : findLibraryModel(libraryName, model);
}
@Nullable
private static Library findLibraryModel(final @NotNull String libraryName, @NotNull LibrariesModifiableModel model) {
private static Library findLibraryModel(@NotNull final String libraryName, @NotNull LibrariesModifiableModel model) {
for (Library library : model.getLibraries()) {
final Library libraryModel = findLibraryModel(library, model);
if (libraryModel != null && libraryName.equals(libraryModel.getName())) {
@@ -16,6 +16,7 @@
package com.intellij.openapi.roots.ui.configuration.projectRoot;
import com.intellij.openapi.roots.ui.configuration.LibraryTableModifiableModelProvider;
import org.jetbrains.annotations.NotNull;
/**
* @author nik
@@ -24,8 +25,8 @@ public class StructureLibraryTableModifiableModelProvider implements LibraryTabl
private final String myLevel;
private final StructureConfigurableContext myContext;
public StructureLibraryTableModifiableModelProvider(String level,
final StructureConfigurableContext context) {
StructureLibraryTableModifiableModelProvider(@NotNull String level,
@NotNull StructureConfigurableContext context) {
myLevel = level;
myContext = context;
}
@@ -2,7 +2,6 @@
package com.intellij.openapi.roots;
import com.intellij.ide.projectView.impl.ProjectRootsUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
@@ -28,8 +27,6 @@ import java.util.*;
* @author nik
*/
public class JavaProjectRootsUtil {
private static final Logger LOG = Logger.getInstance(JavaProjectRootsUtil.class);
public static boolean isOutsideJavaSourceRoot(@Nullable PsiFile psiFile) {
if (psiFile == null) return false;
if (psiFile instanceof PsiCodeFragment) return false;
@@ -62,7 +59,7 @@ public class JavaProjectRootsUtil {
}
}
public static boolean isForGeneratedSources(SourceFolder sourceFolder) {
public static boolean isForGeneratedSources(@NotNull SourceFolder sourceFolder) {
JavaSourceRootProperties properties = sourceFolder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
JavaResourceRootProperties resourceProperties = sourceFolder.getJpsElement().getProperties(JavaModuleSourceRootTypes.RESOURCES);
return properties != null && properties.isForGeneratedSources() || resourceProperties != null && resourceProperties.isForGeneratedSources();
@@ -82,6 +79,7 @@ public class JavaProjectRootsUtil {
return folder != null && isForGeneratedSources(folder);
}
@NotNull
public static GlobalSearchScope getScopeWithoutGeneratedSources(@NotNull GlobalSearchScope baseScope, @NotNull Project project) {
return new NonGeneratedSourceScope(baseScope, project);
}
@@ -28,6 +28,7 @@ import org.jetbrains.annotations.Nullable;
public class JCiPExternalLibraryResolver extends ExternalLibraryResolver {
private static final ExternalLibraryDescriptor JDCIP_LIBRARY_DESCRIPTOR =
new ExternalLibraryDescriptor("net.jcip", "jcip-annotations", null, null, "1.0") {
@NotNull
@Override
public String getPresentableName() {
return "jcip-annotations.jar";
@@ -21,7 +21,7 @@ import java.util.List;
public class JavaSdkUtil {
private static final String IDEA_PREPEND_RT_JAR = "idea.prepend.rtjar";
public static void addRtJar(PathsList pathsList) {
public static void addRtJar(@NotNull PathsList pathsList) {
String ideaRtJarPath = getIdeaRtJarPath();
if (Boolean.getBoolean(IDEA_PREPEND_RT_JAR)) {
pathsList.addFirst(ideaRtJarPath);
@@ -31,14 +31,17 @@ public class JavaSdkUtil {
}
}
@NotNull
public static String getJunit4JarPath() {
return PathUtil.getJarPathForClass(ReflectionUtil.forName("org.junit.Test"));
}
@NotNull
public static String getJunit3JarPath() {
return PathUtil.getJarPathForClass(ReflectionUtil.forName("junit.runner.TestSuiteLoader")); //junit3 specific class
}
@NotNull
public static String getIdeaRtJarPath() {
return PathUtil.getJarPathForClass(JavacRunner.class);
}
@@ -61,11 +61,6 @@ public class JavaAwareProjectJdkTableImpl extends ProjectJdkTableImpl {
}
}
@Override
protected String getSdkTypeName(String type) {
return type != null ? type : JavaSdk.getInstance().getName();
}
@TestOnly
public static void removeInternalJdkInTests() {
WriteAction.run(()-> {
@@ -20,26 +20,29 @@ import com.intellij.openapi.projectRoots.JavaSdkType;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkType;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/**
* @author Dmitry Avdeev
*/
public abstract class JavaDependentSdkType extends DependentSdkType implements JavaSdkType {
public JavaDependentSdkType(@NonNls String name) {
public JavaDependentSdkType(@NonNls @NotNull String name) {
super(name);
}
@Override
protected boolean isValidDependency(Sdk sdk) {
protected boolean isValidDependency(@NotNull Sdk sdk) {
return sdk.getSdkType() instanceof JavaSdkType;
}
@NotNull
@Override
public String getUnsatisfiedDependencyMessage() {
return "You need to configure a Java SDK first";
}
@NotNull
@Override
public SdkType getDependencyType() {
return JavaSdk.getInstance();
@@ -142,6 +142,7 @@ public class JavaSdkImpl extends JavaSdk {
@Override
public void saveAdditionalData(@NotNull SdkAdditionalData additionalData, @NotNull Element additional) { }
@NotNull
@Override
public Comparator<Sdk> versionComparator() {
return (sdk1, sdk2) -> {
@@ -351,8 +352,9 @@ public class JavaSdkImpl extends JavaSdk {
MultiMap<OrderRootType, VirtualFile> roots = MultiMap.create();
SdkModificator sdkModificator = new SdkModificator() {
@NotNull
@Override public String getName() { throw new UnsupportedOperationException(); }
@Override public void setName(String name) { throw new UnsupportedOperationException(); }
@Override public void setName(@NotNull String name) { throw new UnsupportedOperationException(); }
@Override public String getHomePath() { throw new UnsupportedOperationException(); }
@Override public void setHomePath(String path) { throw new UnsupportedOperationException(); }
@Override public String getVersionString() { throw new UnsupportedOperationException(); }
@@ -29,6 +29,7 @@ import java.util.List;
public class ExternalLibraryDescriptor {
private static final Logger LOG = Logger.getInstance(ExternalLibraryDescriptor.class);
private final String myLibraryGroupId;
@NotNull
private final String myLibraryArtifactId;
private final String myMinVersion;
private final String myMaxVersion;
@@ -88,6 +89,7 @@ public class ExternalLibraryDescriptor {
return myPreferredVersion;
}
@NotNull
public String getPresentableName() {
return myLibraryArtifactId;
}
@@ -19,13 +19,14 @@ import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiUtilCore;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class JdkUtils {
@Nullable
public static Sdk getJdkForElement(PsiElement element) {
public static Sdk getJdkForElement(@NotNull PsiElement element) {
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);
if (virtualFile == null) return null;
final List<OrderEntry> entries = ProjectRootManager.getInstance(element.getProject()).getFileIndex().getOrderEntriesForFile(virtualFile);
@@ -36,7 +37,6 @@ public class JdkUtils {
if (jdk != null) break;
}
}
if (jdk == null) return null;
return jdk;
}
}
@@ -283,7 +283,7 @@ public class VcsContentAnnotationExceptionFilter implements Filter, FilterMixin
}
@Override
public Result applyFilter(String line, int entireLength) {
public Result applyFilter(@NotNull String line, int entireLength) {
return null;
}
}
@@ -18,10 +18,12 @@ package com.intellij.openapi.vcs.contentAnnotation;
import com.intellij.execution.filters.ExceptionFilterFactory;
import com.intellij.execution.filters.Filter;
import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NotNull;
public class VcsContentAnnotationExceptionFilterFactory implements ExceptionFilterFactory {
@NotNull
@Override
public Filter create(GlobalSearchScope searchScope) {
public Filter create(@NotNull GlobalSearchScope searchScope) {
return new VcsContentAnnotationExceptionFilter(searchScope);
}
}
@@ -570,7 +570,7 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager {
private static String findLiteralText(@NotNull PsiExpression expr) {
final PsiElement[] literals = PsiTreeUtil.collectElements(expr, new PsiElementFilter() {
@Override
public boolean isAccepted(PsiElement element) {
public boolean isAccepted(@NotNull PsiElement element) {
if (isStringPsiLiteral(element) && isNameSupplier(element)) {
final PsiElement exprList = element.getParent();
if (exprList instanceof PsiExpressionList) {
@@ -305,7 +305,7 @@ public class MoveClassToInnerProcessor extends BaseRefactoringProcessor {
private static PsiElement[] collectPackageLocalMembers(PsiElement classToMove) {
return PsiTreeUtil.collectElements(classToMove, new PsiElementFilter() {
@Override
public boolean isAccepted(final PsiElement element) {
public boolean isAccepted(@NotNull final PsiElement element) {
if (element instanceof PsiMember) {
PsiMember member = (PsiMember) element;
if (VisibilityUtil.getVisibilityModifier(member.getModifierList()) == PsiModifier.PACKAGE_LOCAL) {
@@ -47,8 +47,8 @@ public class InheritedJdkTest extends ModuleTestCase {
ModuleRootModificationUtil.setSdkInherited(myModule);
});
assertTrue("JDK is inherited after explicit inheritSdk()", rootManager.isSdkInherited());
assertEquals("Correct jdk inherited", jdk, rootManager.getSdk());
assertTrue("JDK isn't inherited after explicit inheritSdk()", rootManager.isSdkInherited());
assertEquals("Incorrect jdk inherited", jdk, rootManager.getSdk());
ModuleRootModificationUtil.setModuleSdk(myModule, null);
@@ -65,11 +65,11 @@ public class ExceptionWorker {
myCache = cache;
}
public Filter.Result execute(final String line, final int textEndOffset) {
public Filter.Result execute(@NotNull String line, final int textEndOffset) {
return execute(line, textEndOffset, null);
}
public Filter.Result execute(final String line, final int textEndOffset, PsiElementFilter elementMatcher) {
public Filter.Result execute(@NotNull String line, final int textEndOffset, @Nullable PsiElementFilter elementMatcher) {
myResult = null;
myInfo = parseExceptionLine(line);
if (myInfo == null) {
@@ -133,9 +133,11 @@ public class ExceptionWorker {
Filter.Result result = new Filter.Result(highlightStartOffset, highlightEndOffset, linkInfo, attributes);
if (myMethod.startsWith("access$")) {
myLocationRefiner = elementMatcher;
} else if (myMethod.startsWith("lambda$")) {
}
else if (myMethod.startsWith("lambda$")) {
myLocationRefiner = new FunctionCallMatcher();
} else {
}
else {
myLocationRefiner = new StackFrameMatcher(line, myInfo);
}
myResult = result;
@@ -146,7 +148,7 @@ public class ExceptionWorker {
return myLocationRefiner;
}
private static int getLineNumber(String lineString) {
private static int getLineNumber(@NotNull String lineString) {
// some quick checks to avoid costly exceptions
if (lineString.isEmpty() || lineString.length() > 9 || !Character.isDigit(lineString.charAt(0))) {
return -1;
@@ -180,14 +182,14 @@ public class ExceptionWorker {
return myInfo;
}
private static int findAtPrefix(String line) {
private static int findAtPrefix(@NotNull String line) {
if (line.startsWith(AT_PREFIX)) return 0;
int startIdx = line.indexOf(STANDALONE_AT);
return startIdx < 0 ? line.indexOf(AT_PREFIX) : startIdx;
}
private static int findFirstRParenAfterDigit(String line) {
private static int findFirstRParenAfterDigit(@NotNull String line) {
int rParenIdx = -1;
int rParenCandidate = line.lastIndexOf(')');
//Looking for minimal position for ')' after a digit
@@ -201,7 +203,7 @@ public class ExceptionWorker {
}
@Nullable
public static ParsedLine parseExceptionLine(final String line) {
public static ParsedLine parseExceptionLine(@NotNull String line) {
ParsedLine result = parseNormalStackTraceLine(line);
if (result == null) result = parseYourKitLine(line);
if (result == null) result = parseForcedLine(line);
@@ -209,7 +211,7 @@ public class ExceptionWorker {
}
@Nullable
private static ParsedLine parseNormalStackTraceLine(String line) {
private static ParsedLine parseNormalStackTraceLine(@NotNull String line) {
int startIdx = findAtPrefix(line);
int rParenIdx = findFirstRParenAfterDigit(line);
if (rParenIdx < 0) return null;
@@ -227,7 +229,8 @@ public class ExceptionWorker {
lParenIdx + 1, rParenIdx, line);
}
private static TextRange trimRange(String line, TextRange range) {
@NotNull
private static TextRange trimRange(@NotNull String line, @NotNull TextRange range) {
int start = handleSpaces(line, range.getStartOffset(), 1);
int end = handleSpaces(line, range.getEndOffset(), -1);
if (start != range.getStartOffset() || end != range.getEndOffset()) {
@@ -237,7 +240,7 @@ public class ExceptionWorker {
}
@Nullable
private static ParsedLine parseYourKitLine(String line) {
private static ParsedLine parseYourKitLine(@NotNull String line) {
int lineEnd = line.length() - 1;
if (lineEnd > 0 && line.charAt(lineEnd) == '\n') lineEnd--;
if (lineEnd > 0 && Character.isDigit(line.charAt(lineEnd))) {
@@ -257,7 +260,7 @@ public class ExceptionWorker {
}
@Nullable
private static ParsedLine parseForcedLine(String line) {
private static ParsedLine parseForcedLine(@NotNull String line) {
String dash = "- ";
if (!line.trim().startsWith(dash)) return null;
@@ -279,7 +282,7 @@ public class ExceptionWorker {
TextRange.create(lineNumberStart, lineNumberEnd), null, lineNumber);
}
private static TextRange findMethodNameCandidateBefore(String line, int start, int end) {
private static TextRange findMethodNameCandidateBefore(@NotNull String line, int start, int end) {
int lParenIdx = line.lastIndexOf('(', end);
if (lParenIdx < 0) return null;
@@ -289,7 +292,7 @@ public class ExceptionWorker {
return TextRange.create(dotIdx + 1, lParenIdx);
}
private static int handleSpaces(String line, int pos, int delta) {
private static int handleSpaces(@NotNull String line, int pos, int delta) {
int len = line.length();
while (pos >= 0 && pos < len) {
final char c = line.charAt(pos);
@@ -307,8 +310,8 @@ public class ExceptionWorker {
public final int lineNumber;
ParsedLine(@NotNull TextRange classFqnRange,
@NotNull TextRange methodNameRange,
@NotNull TextRange fileLineRange, @Nullable String fileName, int lineNumber) {
@NotNull TextRange methodNameRange,
@NotNull TextRange fileLineRange, @Nullable String fileName, int lineNumber) {
this.classFqnRange = classFqnRange;
this.methodNameRange = methodNameRange;
this.fileLineRange = fileLineRange;
@@ -318,8 +321,8 @@ public class ExceptionWorker {
@Nullable
private static ParsedLine createFromFileAndLine(@NotNull TextRange classFqnRange,
@NotNull TextRange methodNameRange,
int fileLineStart, int fileLineEnd, String line) {
@NotNull TextRange methodNameRange,
int fileLineStart, int fileLineEnd, @NotNull String line) {
TextRange fileLineRange = TextRange.create(fileLineStart, fileLineEnd);
String fileAndLine = fileLineRange.substring(line);
@@ -347,7 +350,7 @@ public class ExceptionWorker {
}
@Override
public boolean isAccepted(PsiElement element) {
public boolean isAccepted(@NotNull PsiElement element) {
if (!(element instanceof PsiIdentifier)) return false;
if (myMethodName.equals("<init>")) {
if (myHasDollarInName || element.textMatches(StringUtil.getShortName(myClassName))) {
@@ -422,7 +425,7 @@ public class ExceptionWorker {
private static class FunctionCallMatcher implements PsiElementFilter {
@Override
public boolean isAccepted(PsiElement element) {
public boolean isAccepted(@NotNull PsiElement element) {
if (!(element instanceof PsiIdentifier)) return false;
PsiElement parent = element.getParent();
if (!(parent instanceof PsiReferenceExpression)) return false;
@@ -17,11 +17,13 @@ public class StateAnnotation implements State {
storages = new Storage[]{storage};
}
@NotNull
@Override
public String name() {
return name;
}
@NotNull
@Override
public Storage[] storages() {
return storages;
@@ -21,12 +21,12 @@ import java.lang.reflect.Field;
* @author Konstantin Bulenkov
*/
public abstract class PropertiesComponent extends SimpleModificationTracker {
public abstract void unsetValue(String name);
public abstract void unsetValue(@NotNull String name);
public abstract boolean isValueSet(String name);
public abstract boolean isValueSet(@NotNull String name);
@Nullable
public abstract String getValue(@NonNls String name);
public abstract String getValue(@NonNls @NotNull String name);
/**
* Consider to use {@link #setValue(String, String, String)} to avoid write defaults.
@@ -61,9 +61,9 @@ public abstract class PropertiesComponent extends SimpleModificationTracker {
public abstract void setValue(@NotNull String name, boolean value, boolean defaultValue);
@Nullable
public abstract String[] getValues(@NonNls String name);
public abstract String[] getValues(@NonNls @NotNull String name);
public abstract void setValues(@NonNls String name, String[] values);
public abstract void setValues(@NonNls @NotNull String name, String[] values);
public static PropertiesComponent getInstance(Project project) {
return ServiceManager.getService(project, PropertiesComponent.class);
@@ -86,7 +86,7 @@ public abstract class PropertiesComponent extends SimpleModificationTracker {
}
@NotNull
public String getValue(@NonNls String name, @NotNull String defaultValue) {
public String getValue(@NonNls @NotNull String name, @NotNull String defaultValue) {
if (!isValueSet(name)) {
return defaultValue;
}
@@ -106,7 +106,7 @@ public abstract class PropertiesComponent extends SimpleModificationTracker {
return StringUtilRt.parseInt(getValue(name), defaultValue);
}
public final long getOrInitLong(@NonNls String name, long defaultValue) {
public final long getOrInitLong(@NonNls @NotNull String name, long defaultValue) {
try {
String value = getValue(name);
return value == null ? defaultValue : Long.parseLong(value);
@@ -120,7 +120,7 @@ public abstract class PropertiesComponent extends SimpleModificationTracker {
* @deprecated Use {@link #getValue(String, String)}
*/
@Deprecated
public String getOrInit(@NonNls String name, String defaultValue) {
public String getOrInit(@NonNls @NotNull String name, String defaultValue) {
if (!isValueSet(name)) {
setValue(name, defaultValue);
return defaultValue;
@@ -189,7 +189,7 @@ public abstract class PropertiesComponent extends SimpleModificationTracker {
}
}
public float getFloat(String name, float defaultValue) {
public float getFloat(@NotNull String name, float defaultValue) {
if (isValueSet(name)) {
try {
return Float.parseFloat(getValue(name));
@@ -31,6 +31,7 @@ public class FileTypeExtensionFactory<T> extends KeyedExtensionFactory<T, FileTy
super(interfaceClass, epName, ApplicationManager.getApplication().getPicoContainer());
}
@NotNull
@Override
public String getKey(@NotNull final FileType key) {
return key.getName();
@@ -64,7 +64,7 @@ public abstract class FileIndexFacade {
*/
public abstract boolean isValidAncestor(@NotNull VirtualFile baseDir, @NotNull VirtualFile child);
public boolean shouldBeFound(GlobalSearchScope scope, VirtualFile virtualFile) {
public boolean shouldBeFound(@NotNull GlobalSearchScope scope, @NotNull VirtualFile virtualFile) {
return scope.isSearchOutsideRootModel() || isInContent(virtualFile) || isInLibrarySource(virtualFile);
}
@@ -16,7 +16,9 @@
package com.intellij.psi.util;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
@FunctionalInterface
public interface PsiElementFilter {
boolean isAccepted(PsiElement element);
boolean isAccepted(@NotNull PsiElement element);
}
@@ -109,6 +109,7 @@ public abstract class KeyedExtensionFactory<T, KeyT> {
return (T)result;
}
@NotNull
public abstract String getKey(@NotNull KeyT key);
}
@@ -392,7 +392,7 @@ public abstract class AbstractIdeModifiableModelsProvider extends IdeModelsProvi
}
@Override
public Module getModule(String name) {
public Module getModule(@NotNull String name) {
return AbstractIdeModifiableModelsProvider.this.findIdeModule(name);
}
@@ -401,6 +401,7 @@ public abstract class AbstractIdeModifiableModelsProvider extends IdeModelsProvi
return AbstractIdeModifiableModelsProvider.this.getModifiableRootModel(module);
}
@NotNull
@Override
public FacetModel getFacetModel(@NotNull Module module) {
return AbstractIdeModifiableModelsProvider.this.getModifiableFacetModel(module);
@@ -46,19 +46,17 @@ public class CompositeFilter implements Filter, FilterMixin {
public CompositeFilter(@NotNull Project project, @NotNull List<Filter> filters) {
myDumbService = DumbService.getInstance(project);
myFilters = filters;
myFilters.forEach(filter -> {
myIsAnyHeavy |= filter instanceof FilterMixin;
});
myFilters.forEach(filter -> myIsAnyHeavy |= filter instanceof FilterMixin);
}
protected CompositeFilter(DumbService dumbService) {
protected CompositeFilter(@NotNull DumbService dumbService) {
myDumbService = dumbService;
myFilters = new ArrayList<>();
}
@Override
@Nullable
public Result applyFilter(final String line, final int entireLength) {
public Result applyFilter(@NotNull final String line, final int entireLength) {
final boolean dumb = myDumbService.isDumb();
List<Filter> filters = myFilters;
int count = filters.size();
@@ -80,25 +78,27 @@ public class CompositeFilter implements Filter, FilterMixin {
catch (Throwable t) {
throw new RuntimeException("Error while applying " + filter + " to '" + line + "'", t);
}
resultItems = merge(resultItems, result, entireLength, filter);
if (result != null) {
resultItems = merge(resultItems, result, entireLength, filter);
}
t0 = System.currentTimeMillis() - t0;
if (t0 > 1000) {
LOG.warn(filter.getClass().getSimpleName() + ".applyFilter() took " + t0 + " ms on '''" + line + "'''");
}
if (shouldStopFiltering(result)) {
if (result != null && shouldStopFiltering(result)) {
break;
}
}
}
return createFinalResult(resultItems);
}
@Nullable
private static Result createFinalResult(@Nullable List<ResultItem> resultItems) {
if (resultItems == null) {
return null;
}
return createFinalResult(resultItems);
}
@NotNull
private static Result createFinalResult(@NotNull List<ResultItem> resultItems) {
if (resultItems.size() == 1) {
ResultItem resultItem = resultItems.get(0);
return new Result(resultItem.getHighlightStartOffset(), resultItem.getHighlightEndOffset(), resultItem.getHyperlinkInfo(),
@@ -112,30 +112,27 @@ public class CompositeFilter implements Filter, FilterMixin {
return new Result(resultItems);
}
private boolean shouldStopFiltering(@Nullable Result result) {
return result != null && result.getNextAction() == NextAction.EXIT && !forceUseAllFilters;
private boolean shouldStopFiltering(@NotNull Result result) {
return result.getNextAction() == NextAction.EXIT && !forceUseAllFilters;
}
@Nullable
private List<ResultItem> merge(@Nullable List<ResultItem> resultItems, @Nullable Result newResult, int entireLength, Filter filter) {
if (newResult != null) {
if (resultItems == null) {
resultItems = new ArrayList<>();
}
List<ResultItem> newItems = newResult.getResultItems();
for (int i = 0; i < newItems.size(); i++) {
ResultItem item = newItems.get(i);
if ((item.getHyperlinkInfo() == null || !
intersects(resultItems, item)) &&
checkOffsetsCorrect(item, entireLength, filter)) {
resultItems.add(item);
}
@NotNull
private static List<ResultItem> merge(@Nullable List<ResultItem> resultItems, @NotNull Result newResult, int entireLength, @NotNull Filter filter) {
if (resultItems == null) {
resultItems = new ArrayList<>();
}
List<ResultItem> newItems = newResult.getResultItems();
for (int i = 0; i < newItems.size(); i++) {
ResultItem item = newItems.get(i);
if ((item.getHyperlinkInfo() == null || !
intersects(resultItems, item)) && checkOffsetsCorrect(item, entireLength, filter)) {
resultItems.add(item);
}
}
return resultItems;
}
private static boolean checkOffsetsCorrect(ResultItem item, int entireLength, Filter filter) {
private static boolean checkOffsetsCorrect(@NotNull ResultItem item, int entireLength, @NotNull Filter filter) {
int start = item.getHighlightStartOffset();
int end = item.getHighlightEndOffset();
if (end < start || end > entireLength) {
@@ -145,16 +142,16 @@ public class CompositeFilter implements Filter, FilterMixin {
return true;
}
protected boolean intersects(List<? extends ResultItem> items, ResultItem newItem) {
protected static boolean intersects(@NotNull List<? extends ResultItem> items, @NotNull ResultItem newItem) {
TextRange newItemTextRange = null;
for (int i = 0; i < items.size(); i++) {
ResultItem item = items.get(i);
if (item.getHyperlinkInfo() != null) {
if (newItemTextRange == null) {
newItemTextRange = new TextRange(newItem.highlightStartOffset, newItem.highlightEndOffset);
newItemTextRange = new TextRange(newItem.getHighlightStartOffset(), newItem.getHighlightEndOffset());
}
if (newItemTextRange.intersectsStrict(item.highlightStartOffset, item.highlightEndOffset)) {
if (newItemTextRange.intersectsStrict(item.getHighlightStartOffset(), item.getHighlightEndOffset())) {
return true;
}
}
@@ -21,5 +21,6 @@ import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NotNull;
public interface ConsoleFilterProviderEx extends ConsoleFilterProvider {
@NotNull
Filter[] getDefaultFilters(@NotNull Project project, @NotNull GlobalSearchScope scope);
}
@@ -155,12 +155,9 @@ public interface Filter {
static {
Application application = ApplicationManager.getApplication();
if (application != null) {
application.getMessageBus().connect().subscribe(EditorColorsManager.TOPIC, new EditorColorsListener() {
@Override
public void globalSchemeChange(EditorColorsScheme scheme) {
// invalidate cache on Appearance Theme/Editor Scheme change
GRAYED_BY_NORMAL_CACHE.clear();
}
application.getMessageBus().connect().subscribe(EditorColorsManager.TOPIC, __ -> {
// invalidate cache on Appearance Theme/Editor Scheme change
GRAYED_BY_NORMAL_CACHE.clear();
});
}
}
@@ -222,18 +219,15 @@ public interface Filter {
}
public int getHighlightStartOffset() {
//noinspection deprecation
return highlightStartOffset;
}
public int getHighlightEndOffset() {
//noinspection deprecation
return highlightEndOffset;
}
@Nullable
public TextAttributes getHighlightAttributes() {
//noinspection deprecation
return highlightAttributes;
}
@@ -244,7 +238,6 @@ public interface Filter {
@Nullable
public HyperlinkInfo getHyperlinkInfo() {
//noinspection deprecation
return hyperlinkInfo;
}
@@ -281,5 +274,5 @@ public interface Filter {
* @return <tt>null</tt>, if there was no match, otherwise, an instance of {@link Result}
*/
@Nullable
Result applyFilter(String line, int entireLength);
Result applyFilter(@NotNull String line, int entireLength);
}
@@ -21,6 +21,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
@@ -119,7 +120,7 @@ public class RegexpFilter implements Filter, DumbAware {
}
@Override
public Result applyFilter(String line, int entireLength) {
public Result applyFilter(@NotNull String line, int entireLength) {
Matcher matcher = myPattern.matcher(StringUtil.newBombedCharSequence(line, 100));
if (!matcher.find()) {
return null;
@@ -24,20 +24,23 @@ import java.util.List;
* @author dyoma
*/
public abstract class TextConsoleBuilder {
@NotNull
public abstract ConsoleView getConsole();
public abstract void addFilter(@NotNull Filter filter);
public abstract void setViewer(boolean isViewer);
public TextConsoleBuilder filters(Filter... filters) {
@NotNull
public TextConsoleBuilder filters(@NotNull Filter... filters) {
for (Filter filter : filters) {
addFilter(filter);
}
return this;
}
public TextConsoleBuilder filters(@NotNull List<Filter> filters) {
@NotNull
public TextConsoleBuilder filters(@NotNull List<? extends Filter> filters) {
for (Filter filter : filters) {
addFilter(filter);
}
@@ -25,8 +25,10 @@ import org.jetbrains.annotations.NotNull;
* @author dyoma
*/
public abstract class TextConsoleBuilderFactory {
@NotNull
public abstract TextConsoleBuilder createBuilder(@NotNull Project project);
@NotNull
public abstract TextConsoleBuilder createBuilder(@NotNull Project project, @NotNull GlobalSearchScope scope);
public static TextConsoleBuilderFactory getInstance() {
@@ -48,7 +48,7 @@ public class UrlFilter implements Filter, DumbAware {
@Nullable
@Override
public Result applyFilter(String line, int entireLength) {
public Result applyFilter(@NotNull String line, int entireLength) {
if (!URLUtil.canContainUrl(line)) return null;
int textStartOffset = entireLength - line.length();
@@ -98,6 +98,7 @@ public class UrlFilter implements Filter, DumbAware {
}
public static class UrlFilterProvider implements ConsoleFilterProviderEx {
@NotNull
@Override
public Filter[] getDefaultFilters(@NotNull Project project, @NotNull GlobalSearchScope scope) {
return new Filter[]{new UrlFilter(project)};
@@ -124,6 +124,7 @@ public class JdkUtil {
return new File(homePath, "modules/java.base").isDirectory();
}
@NotNull
public static GeneralCommandLine setupJVMCommandLine(@NotNull SimpleJavaParameters javaParameters) throws CantRunException {
Sdk jdk = javaParameters.getJdk();
if (jdk == null) throw new CantRunException(ExecutionBundle.message("run.configuration.error.no.jdk.specified"));
@@ -137,7 +138,7 @@ public class JdkUtil {
return commandLine;
}
private static void setupCommandLine(GeneralCommandLine commandLine, SimpleJavaParameters javaParameters) throws CantRunException {
private static void setupCommandLine(@NotNull GeneralCommandLine commandLine, @NotNull SimpleJavaParameters javaParameters) throws CantRunException {
commandLine.withWorkDirectory(javaParameters.getWorkingDirectory());
commandLine.withEnvironment(javaParameters.getEnv());
@@ -191,21 +192,21 @@ public class JdkUtil {
}
}
private static boolean isUrlClassloader(ParametersList vmParameters) {
private static boolean isUrlClassloader(@NotNull ParametersList vmParameters) {
return UrlClassLoader.class.getName().equals(vmParameters.getPropertyValue("java.system.class.loader"));
}
private static boolean explicitClassPath(ParametersList vmParameters) {
private static boolean explicitClassPath(@NotNull ParametersList vmParameters) {
return vmParameters.hasParameter("-cp") || vmParameters.hasParameter("-classpath") || vmParameters.hasParameter("--class-path");
}
private static boolean explicitModulePath(ParametersList vmParameters) {
private static boolean explicitModulePath(@NotNull ParametersList vmParameters) {
return vmParameters.hasParameter("-p") || vmParameters.hasParameter("--module-path");
}
private static void setArgFileParams(GeneralCommandLine commandLine,
SimpleJavaParameters javaParameters,
ParametersList vmParameters,
private static void setArgFileParams(@NotNull GeneralCommandLine commandLine,
@NotNull SimpleJavaParameters javaParameters,
@NotNull ParametersList vmParameters,
boolean dynamicVMOptions,
boolean dynamicParameters) throws CantRunException {
try {
@@ -262,7 +263,8 @@ public class JdkUtil {
}
/* https://docs.oracle.com/javase/9/tools/java.htm, "java Command-Line Argument Files" */
private static String quoteArg(String arg) {
@NotNull
private static String quoteArg(@NotNull String arg) {
String specials = " #'\"\n\r\t\f";
if (!StringUtil.containsAnyChar(arg, specials)) {
return arg;
@@ -282,10 +284,10 @@ public class JdkUtil {
return sb.toString();
}
private static void setCommandLineWrapperParams(GeneralCommandLine commandLine,
SimpleJavaParameters javaParameters,
ParametersList vmParameters,
Class commandLineWrapper,
private static void setCommandLineWrapperParams(@NotNull GeneralCommandLine commandLine,
@NotNull SimpleJavaParameters javaParameters,
@NotNull ParametersList vmParameters,
@NotNull Class commandLineWrapper,
boolean dynamicVMOptions,
boolean dynamicParameters) throws CantRunException {
try {
@@ -364,14 +366,15 @@ public class JdkUtil {
}
}
private static PrintWriter createOutputWriter(File vmParamsFile) throws FileNotFoundException {
@NotNull
private static PrintWriter createOutputWriter(@NotNull File vmParamsFile) throws FileNotFoundException {
return new PrintWriter(new OutputStreamWriter(new FileOutputStream(vmParamsFile), StandardCharsets.UTF_8));
}
private static void setClasspathJarParams(GeneralCommandLine commandLine,
SimpleJavaParameters javaParameters,
ParametersList vmParameters,
Class commandLineWrapper,
private static void setClasspathJarParams(@NotNull GeneralCommandLine commandLine,
@NotNull SimpleJavaParameters javaParameters,
@NotNull ParametersList vmParameters,
@NotNull Class commandLineWrapper,
boolean dynamicVMOptions,
boolean dynamicParameters) throws CantRunException {
try {
@@ -425,17 +428,17 @@ public class JdkUtil {
}
@SuppressWarnings("SpellCheckingInspection")
private static boolean isUserDefinedProperty(String param) {
private static boolean isUserDefinedProperty(@NotNull String param) {
return param.startsWith("-D") && !(param.startsWith("-Dsun.") || param.startsWith("-Djava."));
}
private static void throwUnableToCreateTempFile(IOException cause) throws CantRunException {
private static void throwUnableToCreateTempFile(@NotNull IOException cause) throws CantRunException {
throw new CantRunException("Failed to a create temporary file in " + FileUtilRt.getTempDirectory(), cause);
}
private static void appendParamsEncodingClasspath(SimpleJavaParameters javaParameters,
GeneralCommandLine commandLine,
ParametersList vmParameters) {
private static void appendParamsEncodingClasspath(@NotNull SimpleJavaParameters javaParameters,
@NotNull GeneralCommandLine commandLine,
@NotNull ParametersList vmParameters) {
commandLine.addParameters(vmParameters.getList());
appendEncoding(javaParameters, commandLine, vmParameters);
@@ -453,7 +456,9 @@ public class JdkUtil {
}
}
private static void appendEncoding(SimpleJavaParameters javaParameters, GeneralCommandLine commandLine, ParametersList parametersList) {
private static void appendEncoding(@NotNull SimpleJavaParameters javaParameters,
@NotNull GeneralCommandLine commandLine,
@NotNull ParametersList parametersList) {
// Value of file.encoding and charset of GeneralCommandLine should be in sync in order process's input and output be correctly handled.
String encoding = parametersList.getPropertyValue("file.encoding");
if (encoding == null) {
@@ -471,7 +476,8 @@ public class JdkUtil {
}
}
private static List<String> getMainClassParams(SimpleJavaParameters javaParameters) throws CantRunException {
@NotNull
private static List<String> getMainClassParams(@NotNull SimpleJavaParameters javaParameters) throws CantRunException {
String mainClass = javaParameters.getMainClass();
String moduleName = javaParameters.getModuleName();
String jarPath = javaParameters.getJarPath();
@@ -100,13 +100,13 @@ public abstract class SdkType implements SdkTypeId {
public abstract AdditionalDataConfigurable createAdditionalDataConfigurable(@NotNull SdkModel sdkModel, @NotNull SdkModificator sdkModificator);
@Nullable
public SdkAdditionalData loadAdditionalData(Element additional) {
public SdkAdditionalData loadAdditionalData(@NotNull Element additional) {
return null;
}
@Override
@Nullable
public SdkAdditionalData loadAdditionalData(@NotNull Sdk currentSdk, Element additional) {
public SdkAdditionalData loadAdditionalData(@NotNull Sdk currentSdk, @NotNull Element additional) {
return loadAdditionalData(additional);
}
@@ -159,7 +159,7 @@ public abstract class SdkType implements SdkTypeId {
public FileChooserDescriptor getHomeChooserDescriptor() {
FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false) {
@Override
public void validateSelectedFiles(VirtualFile[] files) throws Exception {
public void validateSelectedFiles(@NotNull VirtualFile[] files) throws Exception {
if (files.length != 0) {
String selectedPath = files[0].getPath();
boolean valid = isValidSdkHome(selectedPath);
@@ -272,6 +272,7 @@ public abstract class SdkType implements SdkTypeId {
return homeDir != null && homeDir.isValid();
}
@NotNull
public String sdkPath(@NotNull VirtualFile homePath) {
return homePath.getPath();
}
@@ -5,6 +5,7 @@ import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.libraries.LibraryTable;
import org.jetbrains.annotations.NotNull;
/**
* Returns the modifiable models from either the open Project Structure configurable (if any) or the standard module root manager.
@@ -21,14 +22,16 @@ public interface ModifiableModelsProvider {
}
}
ModifiableRootModel getModuleModifiableModel(final Module module);
void commitModuleModifiableModel(final ModifiableRootModel model);
void disposeModuleModifiableModel(final ModifiableRootModel model);
ModifiableRootModel getModuleModifiableModel(@NotNull Module module);
void commitModuleModifiableModel(@NotNull ModifiableRootModel model);
void disposeModuleModifiableModel(@NotNull ModifiableRootModel model);
ModifiableFacetModel getFacetModifiableModel(Module module);
void commitFacetModifiableModel(Module module, ModifiableFacetModel model);
@NotNull
ModifiableFacetModel getFacetModifiableModel(@NotNull Module module);
void commitFacetModifiableModel(@NotNull Module module, @NotNull ModifiableFacetModel model);
@NotNull
LibraryTable.ModifiableModel getLibraryTableModifiableModel();
LibraryTable.ModifiableModel getLibraryTableModifiableModel(Project project);
void disposeLibraryTableModifiableModel(LibraryTable.ModifiableModel model);
LibraryTable.ModifiableModel getLibraryTableModifiableModel(@NotNull Project project);
void disposeLibraryTableModifiableModel(@NotNull LibraryTable.ModifiableModel model);
}
@@ -35,6 +35,7 @@ public interface OrderRootTypeUIFactory {
KeyedExtensionFactory<OrderRootTypeUIFactory, OrderRootType> FACTORY =
new KeyedExtensionFactory<OrderRootTypeUIFactory, OrderRootType>(OrderRootTypeUIFactory.class, EP_NAME, ApplicationManager.getApplication().getPicoContainer()) {
@NotNull
@Override
public String getKey(@NotNull final OrderRootType key) {
return key.name();
@@ -49,7 +49,7 @@ public class DefaultModulesProvider implements ModulesProvider {
}
@Override
public Module getModule(String name) {
public Module getModule(@NotNull String name) {
return ModuleManager.getInstance(myProject).findModuleByName(name);
}
@@ -58,6 +58,7 @@ public class DefaultModulesProvider implements ModulesProvider {
return ModuleRootManager.getInstance(module);
}
@NotNull
@Override
public FacetModel getFacetModel(@NotNull Module module) {
return FacetManager.getInstance(module);
@@ -32,7 +32,7 @@ public interface ModulesProvider extends RootModelProvider {
return Module.EMPTY_ARRAY;
}
@Override
public Module getModule(String name) {
public Module getModule(@NotNull String name) {
return null;
}
@@ -41,6 +41,7 @@ public interface ModulesProvider extends RootModelProvider {
return ModuleRootManager.getInstance(module);
}
@NotNull
@Override
public FacetModel getFacetModel(@NotNull Module module) {
return FacetManager.getInstance(module);
@@ -48,7 +49,8 @@ public interface ModulesProvider extends RootModelProvider {
};
@Nullable
Module getModule(String name);
Module getModule(@NotNull String name);
@NotNull
FacetModel getFacetModel(@NotNull Module module);
}
@@ -107,7 +107,7 @@ public class OutputFileUtil {
private static class ShowOutputFileFilter implements Filter {
@Override
public Result applyFilter(String line, int entireLength) {
public Result applyFilter(@NotNull String line, int entireLength) {
if (line.startsWith(CONSOLE_OUTPUT_FILE_MESSAGE)) {
final String filePath = StringUtil.trimEnd(line.substring(CONSOLE_OUTPUT_FILE_MESSAGE.length()), "\n");
@@ -67,7 +67,7 @@ public abstract class AbstractFileHyperlinkFilter implements Filter {
@Nullable
@Override
public final Result applyFilter(String line, int entireLength) {
public final Result applyFilter(@NotNull String line, int entireLength) {
List<FileHyperlinkRawData> links;
try {
links = parse(line);
@@ -24,11 +24,13 @@ import org.jetbrains.annotations.NotNull;
* @author dyoma
*/
public class TextConsoleBuilderFactoryImpl extends TextConsoleBuilderFactory {
@NotNull
@Override
public TextConsoleBuilder createBuilder(@NotNull final Project project) {
return new TextConsoleBuilderImpl(project);
}
@NotNull
@Override
public TextConsoleBuilder createBuilder(@NotNull Project project, @NotNull GlobalSearchScope scope) {
return new TextConsoleBuilderImpl(project, scope);
@@ -43,6 +43,7 @@ public class TextConsoleBuilderImpl extends TextConsoleBuilder {
myScope = scope;
}
@NotNull
@Override
public ConsoleView getConsole() {
final ConsoleView consoleView = createConsole();
@@ -62,8 +63,9 @@ public class TextConsoleBuilderImpl extends TextConsoleBuilder {
myFilters.add(filter);
}
@NotNull
@Override
public TextConsoleBuilder filters(@NotNull List<Filter> filters) {
public TextConsoleBuilder filters(@NotNull List<? extends Filter> filters) {
myFilters.addAll(filters);
return this;
}
@@ -26,6 +26,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ComparatorUtil;
import com.intellij.util.containers.Convertor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
@@ -45,12 +46,12 @@ public class PathUtilEx {
private static final Convertor<Sdk, String> JDK_VERSION = jdk -> StringUtil.notNullize(jdk.getVersionString());
@Nullable
public static Sdk getAnyJdk(Project project) {
public static Sdk getAnyJdk(@NotNull Project project) {
return chooseJdk(project, Arrays.asList(ModuleManager.getInstance(project).getModules()));
}
@Nullable
public static Sdk chooseJdk(Project project, Collection<? extends Module> modules) {
public static Sdk chooseJdk(@NotNull Project project, @NotNull Collection<? extends Module> modules) {
Sdk projectJdk = ProjectRootManager.getInstance(project).getProjectSdk();
if (projectJdk != null) {
return projectJdk;
@@ -59,7 +60,7 @@ public class PathUtilEx {
}
@Nullable
public static Sdk chooseJdk(Collection<? extends Module> modules) {
public static Sdk chooseJdk(@NotNull Collection<? extends Module> modules) {
List<Sdk> jdks = skipNulls(map(skipNulls(modules), MODULE_JDK));
if (jdks.isEmpty()) {
return null;
@@ -19,19 +19,20 @@ import java.util.Arrays;
*/
public abstract class DependentSdkType extends SdkType {
public DependentSdkType(@NonNls String name) {
public DependentSdkType(@NonNls @NotNull String name) {
super(name);
}
/**
* Checks if dependencies satisfied.
*/
protected boolean checkDependency(SdkModel sdkModel) {
protected boolean checkDependency(@NotNull SdkModel sdkModel) {
return ContainerUtil.find(sdkModel.getSdks(), sdk -> isValidDependency(sdk)) != null;
}
protected abstract boolean isValidDependency(Sdk sdk);
protected abstract boolean isValidDependency(@NotNull Sdk sdk);
@NotNull
public abstract String getUnsatisfiedDependencyMessage();
@Override
@@ -54,15 +55,16 @@ public abstract class DependentSdkType extends SdkType {
}
@Override
@NotNull
public abstract SdkType getDependencyType();
protected Sdk fixDependency(SdkModel sdkModel, Consumer<Sdk> sdkCreatedCallback) {
protected Sdk fixDependency(@NotNull SdkModel sdkModel, @NotNull Consumer<? super Sdk> sdkCreatedCallback) {
return createSdkOfType(sdkModel, getDependencyType(), sdkCreatedCallback);
}
protected static Sdk createSdkOfType(final SdkModel sdkModel,
final SdkType sdkType,
final Consumer<? super Sdk> sdkCreatedCallback) {
protected static Sdk createSdkOfType(@NotNull SdkModel sdkModel,
@NotNull SdkType sdkType,
@NotNull Consumer<? super Sdk> sdkCreatedCallback) {
final Ref<Sdk> result = new Ref<>(null);
SdkConfigurationUtil.selectSdkHome(sdkType, home -> {
String newSdkName = SdkConfigurationUtil.createUniqueSdkName(sdkType, home, Arrays.asList(sdkModel.getSdks()));
@@ -117,7 +117,7 @@ public class ProjectJdkTableImpl extends ProjectJdkTable implements ExportableCo
@Override
@Nullable
public Sdk findJdk(String name) {
public Sdk findJdk(@NotNull String name) {
//noinspection ForLoopReplaceableByForEach
for (int i = 0, len = mySdks.size(); i < len; ++i) { // avoid foreach, it instantiates ArrayList$Itr, this traversal happens very often
final Sdk jdk = mySdks.get(i);
@@ -130,13 +130,12 @@ public class ProjectJdkTableImpl extends ProjectJdkTable implements ExportableCo
@Override
@Nullable
public Sdk findJdk(String name, String type) {
public Sdk findJdk(@NotNull String name, @NotNull String type) {
Sdk projectJdk = findJdk(name);
if (projectJdk != null) {
return projectJdk;
}
final String sdkTypeName = getSdkTypeName(type);
final String uniqueName = sdkTypeName + "." + name;
final String uniqueName = type + "." + name;
projectJdk = myCachedProjectJdks.get(uniqueName);
if (projectJdk != null) return projectJdk;
@@ -146,7 +145,7 @@ public class ProjectJdkTableImpl extends ProjectJdkTable implements ExportableCo
final SdkType[] sdkTypes = SdkType.getAllTypes();
for (SdkType sdkType : sdkTypes) {
if (Comparing.strEqual(sdkTypeName, sdkType.getName())) {
if (Comparing.strEqual(type, sdkType.getName())) {
if (sdkType.isValidSdkHome(jdkPath)) {
ProjectJdkImpl projectJdkImpl = new ProjectJdkImpl(name, sdkType);
projectJdkImpl.setHomePath(jdkPath);
@@ -160,10 +159,6 @@ public class ProjectJdkTableImpl extends ProjectJdkTable implements ExportableCo
return null;
}
protected String getSdkTypeName(final String type) {
return type;
}
@NotNull
@Override
public Sdk[] getAllJdks() {
@@ -53,19 +53,19 @@ public class SdkConfigurationUtil {
private SdkConfigurationUtil() { }
public static void createSdk(@Nullable final Project project,
final Sdk[] existingSdks,
final NullableConsumer<? super Sdk> onSdkCreatedCallBack,
@NotNull Sdk[] existingSdks,
@NotNull NullableConsumer<? super Sdk> onSdkCreatedCallBack,
final boolean createIfExists,
final SdkType... sdkTypes) {
@NotNull SdkType... sdkTypes) {
createSdk(project, existingSdks, onSdkCreatedCallBack, createIfExists, true, sdkTypes);
}
public static void createSdk(@Nullable final Project project,
final Sdk[] existingSdks,
final NullableConsumer<? super Sdk> onSdkCreatedCallBack,
@NotNull Sdk[] existingSdks,
@NotNull NullableConsumer<? super Sdk> onSdkCreatedCallBack,
final boolean createIfExists,
final boolean followSymLinks,
final SdkType... sdkTypes) {
@NotNull SdkType... sdkTypes) {
if (sdkTypes.length == 0) {
onSdkCreatedCallBack.consume(null);
return;
@@ -110,16 +110,17 @@ public class SdkConfigurationUtil {
}
public static void createSdk(@Nullable final Project project,
final Sdk[] existingSdks,
final NullableConsumer<? super Sdk> onSdkCreatedCallBack,
final SdkType... sdkTypes) {
@NotNull Sdk[] existingSdks,
@NotNull NullableConsumer<? super Sdk> onSdkCreatedCallBack,
@NotNull SdkType... sdkTypes) {
createSdk(project, existingSdks, onSdkCreatedCallBack, true, sdkTypes);
}
private static FileChooserDescriptor createCompositeDescriptor(final SdkType... sdkTypes) {
@NotNull
private static FileChooserDescriptor createCompositeDescriptor(@NotNull SdkType... sdkTypes) {
return new FileChooserDescriptor(sdkTypes[0].getHomeChooserDescriptor()) {
@Override
public void validateSelectedFiles(final VirtualFile[] files) throws Exception {
public void validateSelectedFiles(@NotNull final VirtualFile[] files) throws Exception {
if (files.length > 0) {
for (SdkType type : sdkTypes) {
if (type.isValidSdkHome(files[0].getPath())) {
@@ -137,14 +138,14 @@ public class SdkConfigurationUtil {
ApplicationManager.getApplication().runWriteAction(() -> ProjectJdkTable.getInstance().addJdk(sdk));
}
public static void removeSdk(final Sdk sdk) {
public static void removeSdk(@NotNull Sdk sdk) {
ApplicationManager.getApplication().runWriteAction(() -> ProjectJdkTable.getInstance().removeJdk(sdk));
}
@Nullable
public static Sdk setupSdk(@NotNull Sdk[] allSdks,
@NotNull VirtualFile homeDir,
final SdkType sdkType,
@NotNull SdkType sdkType,
final boolean silent,
@Nullable final SdkAdditionalData additionalData,
@Nullable final String customSdkSuggestedName) {
@@ -174,9 +175,9 @@ public class SdkConfigurationUtil {
@NotNull
public static ProjectJdkImpl createSdk(@NotNull Sdk[] allSdks,
@NotNull VirtualFile homeDir,
SdkType sdkType,
@Nullable SdkAdditionalData additionalData, @Nullable String customSdkSuggestedName) {
@NotNull VirtualFile homeDir,
@NotNull SdkType sdkType,
@Nullable SdkAdditionalData additionalData, @Nullable String customSdkSuggestedName) {
final List<Sdk> sdksList = Arrays.asList(allSdks);
String sdkPath = sdkType.sdkPath(homeDir);
@@ -208,9 +209,9 @@ public class SdkConfigurationUtil {
});
}
public static void configureDirectoryProjectSdk(final Project project,
public static void configureDirectoryProjectSdk(@NotNull Project project,
@Nullable Comparator<? super Sdk> preferredSdkComparator,
final SdkType... sdkTypes) {
@NotNull SdkType... sdkTypes) {
Sdk existingSdk = ProjectRootManager.getInstance(project).getProjectSdk();
if (existingSdk != null && ArrayUtil.contains(existingSdk.getSdkType(), sdkTypes)) {
return;
@@ -223,7 +224,7 @@ public class SdkConfigurationUtil {
}
@Nullable
public static Sdk findOrCreateSdk(@Nullable Comparator<? super Sdk> comparator, final SdkType... sdkTypes) {
public static Sdk findOrCreateSdk(@Nullable Comparator<? super Sdk> comparator, @NotNull SdkType... sdkTypes) {
final Project defaultProject = ProjectManager.getInstance().getDefaultProject();
final Sdk sdk = ProjectRootManager.getInstance(defaultProject).getProjectSdk();
if (sdk != null) {
@@ -256,11 +257,10 @@ public class SdkConfigurationUtil {
* Tries to create an SDK identified by path; if successful, add the SDK to the global SDK table.
*
* @param path identifies the SDK
* @param sdkType
* @return newly created SDK, or null.
*/
@Nullable
public static Sdk createAndAddSDK(final String path, SdkType sdkType) {
public static Sdk createAndAddSDK(@NotNull String path, @NotNull SdkType sdkType) {
VirtualFile sdkHome =
WriteAction.compute(() -> LocalFileSystem.getInstance().refreshAndFindFileByPath(path));
if (sdkHome != null) {
@@ -19,37 +19,39 @@ public class PlatformModifiableModelsProvider implements ModifiableModelsProvide
}
@Override
public void commitModuleModifiableModel(final ModifiableRootModel model) {
public void commitModuleModifiableModel(@NotNull final ModifiableRootModel model) {
model.commit();
}
@Override
public void disposeModuleModifiableModel(final ModifiableRootModel model) {
public void disposeModuleModifiableModel(@NotNull final ModifiableRootModel model) {
model.dispose();
}
@NotNull
@Override
public ModifiableFacetModel getFacetModifiableModel(Module module) {
public ModifiableFacetModel getFacetModifiableModel(@NotNull Module module) {
return FacetManager.getInstance(module).createModifiableModel();
}
@Override
public void commitFacetModifiableModel(Module module, ModifiableFacetModel model) {
public void commitFacetModifiableModel(@NotNull Module module, @NotNull ModifiableFacetModel model) {
model.commit();
}
@NotNull
@Override
public LibraryTable.ModifiableModel getLibraryTableModifiableModel() {
return LibraryTablesRegistrar.getInstance().getLibraryTable().getModifiableModel();
}
@Override
public LibraryTable.ModifiableModel getLibraryTableModifiableModel(Project project) {
public LibraryTable.ModifiableModel getLibraryTableModifiableModel(@NotNull Project project) {
return LibraryTablesRegistrar.getInstance().getLibraryTable(project).getModifiableModel();
}
@Override
public void disposeLibraryTableModifiableModel(LibraryTable.ModifiableModel model) {
public void disposeLibraryTableModifiableModel(@NotNull LibraryTable.ModifiableModel model) {
Disposer.dispose(model);
}
}
@@ -31,7 +31,7 @@ public class ExternalProjectSystemRegistryImpl implements ExternalProjectSystemR
@Override
@NotNull
public ProjectModelExternalSource getSourceById(String id) {
public ProjectModelExternalSource getSourceById(@NotNull String id) {
throw new IllegalStateException();
}
}
@@ -117,7 +117,7 @@ public class PushedFilePropertiesUpdaterImpl extends PushedFilePropertiesUpdater
}
@Override
public void pushRecursively(VirtualFile file, Project project) {
public void pushRecursively(@NotNull VirtualFile file, @NotNull Project project) {
queueTasks(ContainerUtil.createMaybeSingletonList(createRecursivePushTask(file, new FilePropertyPusher[]{pusher})));
}
});
@@ -57,6 +57,7 @@ public class LibraryTypeServiceImpl extends LibraryTypeService {
return doCreate(type, name, roots);
}
@NotNull
private static <P extends LibraryProperties<?>> NewLibraryConfiguration doCreate(final LibraryType<P> type, final String name, final List<? extends OrderRoot> roots) {
return new NewLibraryConfiguration(name, type, type != null ? type.getKind().createDefaultProperties() : null) {
@Override
@@ -66,6 +67,7 @@ public class LibraryTypeServiceImpl extends LibraryTypeService {
};
}
@NotNull
public static String suggestLibraryName(@NotNull VirtualFile[] classesRoots) {
if (classesRoots.length >= 1) {
return FileUtil.getNameWithoutExtension(PathUtil.getFileName(classesRoots[0].getPath()));
@@ -73,6 +75,7 @@ public class LibraryTypeServiceImpl extends LibraryTypeService {
return DEFAULT_LIBRARY_NAME;
}
@NotNull
public static String suggestLibraryName(@NotNull List<? extends OrderRoot> roots) {
if (roots.size() >= 1) {
return FileUtil.getNameWithoutExtension(PathUtil.getFileName(roots.get(0).getFile().getPath()));
@@ -24,7 +24,6 @@ import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.command.undo.BasicUndoableAction;
import com.intellij.openapi.command.undo.UndoManager;
import com.intellij.openapi.command.undo.UndoableAction;
import com.intellij.openapi.command.undo.UnexpectedUndoException;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
@@ -36,7 +35,6 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.refactoring.rename.RenameHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author Konstantin Bulenkov
@@ -78,9 +76,11 @@ public class RenameLibraryHandler implements RenameHandler, TitledHandler {
}
private static class MyInputValidator implements InputValidator {
@NotNull
private final Project myProject;
@NotNull
private final Library myLibrary;
MyInputValidator(Project project, Library library) {
MyInputValidator(@NotNull Project project, @NotNull Library library) {
myProject = project;
myLibrary = library;
}
@@ -94,24 +94,19 @@ public class RenameLibraryHandler implements RenameHandler, TitledHandler {
public boolean canClose(final String inputString) {
final String oldName = myLibrary.getName();
final Library.ModifiableModel modifiableModel = renameLibrary(inputString);
if (modifiableModel == null) return false;
final Ref<Boolean> success = Ref.create(Boolean.TRUE);
CommandProcessor.getInstance().executeCommand(myProject, () -> {
UndoableAction action = new BasicUndoableAction() {
@Override
public void undo() throws UnexpectedUndoException {
public void undo() {
final Library.ModifiableModel modifiableModel1 = renameLibrary(oldName);
if (modifiableModel1 != null) {
modifiableModel1.commit();
}
modifiableModel1.commit();
}
@Override
public void redo() throws UnexpectedUndoException {
public void redo() {
final Library.ModifiableModel modifiableModel1 = renameLibrary(inputString);
if (modifiableModel1 != null) {
modifiableModel1.commit();
}
modifiableModel1.commit();
}
};
UndoManager.getInstance(myProject).undoableActionPerformed(action);
@@ -120,7 +115,7 @@ public class RenameLibraryHandler implements RenameHandler, TitledHandler {
return success.get().booleanValue();
}
@Nullable
@NotNull
private Library.ModifiableModel renameLibrary(String inputString) {
final Library.ModifiableModel modifiableModel = myLibrary.getModifiableModel();
modifiableModel.setName(inputString);
@@ -23,12 +23,14 @@ public interface ClasspathStorageProvider {
new ExtensionPointName<>("com.intellij.classpathStorageProvider");
@NonNls
@NotNull
String getID();
@Nls
@NotNull
String getDescription();
void assertCompatible(final ModuleRootModel model) throws ConfigurationException;
void assertCompatible(@NotNull ModuleRootModel model) throws ConfigurationException;
void detach(@NotNull Module module);
@@ -98,11 +98,13 @@ public abstract class LibraryType<P extends LibraryProperties> extends LibraryPr
* @return Root types to collect library files which do not belong to the project and therefore
* indicate that the library is external.
*/
@NotNull
public OrderRootType[] getExternalRootTypes() {
return DEFAULT_EXTERNAL_ROOT_TYPES;
}
public static LibraryType findByKind(LibraryKind kind) {
@NotNull
public static LibraryType findByKind(@NotNull LibraryKind kind) {
for (LibraryType type : EP_NAME.getExtensions()) {
if (type.getKind() == kind) {
return type;
@@ -45,6 +45,7 @@ public abstract class NewLibraryConfiguration {
return myProperties;
}
@NotNull
public String getDefaultLibraryName() {
return myDefaultLibraryName;
}
@@ -420,7 +420,7 @@ public class CommonContentEntriesEditor extends ModuleElementsEditor {
ProjectBundle.message("module.paths.add.content.action.description"), AllIcons.General.Add);
myDescriptor = new FileChooserDescriptor(false, true, true, false, true, true) {
@Override
public void validateSelectedFiles(VirtualFile[] files) throws Exception {
public void validateSelectedFiles(@NotNull VirtualFile[] files) throws Exception {
validateContentEntriesCandidates(files);
}
};
@@ -281,7 +281,7 @@ public class FileChooserDescriptor implements Cloneable {
* @param files - selected files to be checked
* @throws Exception if the the files cannot be accepted
*/
public void validateSelectedFiles(VirtualFile[] files) throws Exception {
public void validateSelectedFiles(@NotNull VirtualFile[] files) throws Exception {
}
public boolean isForcedToUseIdeaFileChooser() {
@@ -220,7 +220,7 @@ public class SwitchBootJdkAction extends AnAction implements DumbAware {
}
@Override
public void validateSelectedFiles(VirtualFile[] files) throws Exception {
public void validateSelectedFiles(@NotNull VirtualFile[] files) throws Exception {
super.validateSelectedFiles(files);
assert files.length == 1 : Arrays.toString(files);
if (selectedBundle == null) {
@@ -16,6 +16,7 @@
package com.intellij.execution.filters;
import com.intellij.mock.MockDumbService;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.Assert;
import org.junit.Before;
@@ -92,7 +93,7 @@ public class CompositeFilterTest {
return new Filter() {
@Nullable
@Override
public Result applyFilter(String line, int entireLength) {
public Result applyFilter(@NotNull String line, int entireLength) {
return applyFilter(line, entireLength);
}
};
@@ -102,7 +103,7 @@ public class CompositeFilterTest {
return new Filter() {
@Nullable
@Override
public Result applyFilter(String line, int entireLength) {
public Result applyFilter(@NotNull String line, int entireLength) {
return null;
}
};
@@ -112,7 +113,7 @@ public class CompositeFilterTest {
return new Filter() {
@Nullable
@Override
public Result applyFilter(String line, int entireLength) {
public Result applyFilter(@NotNull String line, int entireLength) {
return createResult();
}
};
@@ -122,7 +123,7 @@ public class CompositeFilterTest {
return new Filter() {
@Nullable
@Override
public Result applyFilter(String line, int entireLength) {
public Result applyFilter(@NotNull String line, int entireLength) {
Result result = createResult();
result.setNextAction(NextAction.CONTINUE_FILTERING);
return result;
@@ -26,6 +26,7 @@ import java.util.Iterator;
import java.util.List;
public abstract class MainConfigurationStateSplitter extends StateSplitterEx {
@NotNull
@Override
public final List<Pair<Element, String>> splitState(@NotNull Element state) {
UniqueNameGenerator generator = new UniqueNameGenerator();
@@ -2,6 +2,7 @@
package com.intellij.openapi.components;
import com.intellij.openapi.util.Getter;
import org.jetbrains.annotations.NotNull;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -14,6 +15,7 @@ public @interface State {
/**
* Component name.
*/
@NotNull
String name();
/**
@@ -25,6 +27,7 @@ public @interface State {
*
* <p>Module-level: optional, corresponding module file will be used ({@code *.iml}).</p>
*/
@NotNull
Storage[] storages() default {};
/**
@@ -26,7 +26,8 @@ import java.util.List;
*/
@Deprecated
public interface StateSplitter {
List<Pair<Element, String>> splitState(@NotNull Element e);
@NotNull
List<Pair<Element, String>> splitState(@NotNull Element e);
void mergeStatesInto(Element target, Element[] elements);
void mergeStatesInto(@NotNull Element target, @NotNull Element[] elements);
}
@@ -14,6 +14,7 @@ import java.util.List;
@SuppressWarnings("deprecation")
public abstract class StateSplitterEx implements StateSplitter {
@NotNull
@Override
public abstract List<Pair<Element, String>> splitState(@NotNull Element state);
@@ -22,7 +23,7 @@ public abstract class StateSplitterEx implements StateSplitter {
}
@Override
public final void mergeStatesInto(Element target, Element[] elements) {
public final void mergeStatesInto(@NotNull Element target, @NotNull Element[] elements) {
throw new IllegalStateException();
}
@@ -15,14 +15,18 @@
*/
package com.intellij.openapi.module;
import org.jetbrains.annotations.NotNull;
public class ModuleWithNameAlreadyExists extends Exception {
@NotNull
private final String myModuleName;
public ModuleWithNameAlreadyExists(final String message, final String moduleName) {
public ModuleWithNameAlreadyExists(@NotNull String message, @NotNull String moduleName) {
super(message);
myModuleName = moduleName;
}
@NotNull
public String getModuleName() {
return myModuleName;
}
@@ -21,10 +21,10 @@ public abstract class ProjectJdkTable {
}
@Nullable
public abstract Sdk findJdk(String name);
public abstract Sdk findJdk(@NotNull String name);
@Nullable
public abstract Sdk findJdk(String name, String type);
public abstract Sdk findJdk(@NotNull String name, @NotNull String type);
@NotNull
public abstract Sdk[] getAllJdks();
@@ -39,7 +39,7 @@ public abstract class ProjectJdkTable {
/** @deprecated comparing version strings across SDK types makes no sense; use {@link #findMostRecentSdkOfType} (to be removed in IDEA 2019) */
@Deprecated
public Sdk findMostRecentSdk(@NotNull Condition<Sdk> condition) {
public Sdk findMostRecentSdk(@NotNull Condition<? super Sdk> condition) {
Sdk found = null;
for (Sdk each : getAllJdks()) {
if (condition.value(each) &&
@@ -16,9 +16,10 @@ import org.jetbrains.annotations.Nullable;
* Last, you must call {@link #commitChanges()}
*/
public interface SdkModificator {
@NotNull
String getName();
void setName(String name);
void setName(@NotNull String name);
String getHomePath();
@@ -21,7 +21,7 @@ public interface SdkTypeId {
void saveAdditionalData(@NotNull SdkAdditionalData additionalData, @NotNull Element additional);
@Nullable
SdkAdditionalData loadAdditionalData(@NotNull Sdk currentSdk, Element additional);
SdkAdditionalData loadAdditionalData(@NotNull Sdk currentSdk, @NotNull Element additional);
/**
* An SDK can be located on a local machine or on a remote or virtual machine. In the latter case this method returns false.
@@ -33,6 +33,7 @@ public interface SdkTypeId {
/**
* Note to implementors: you may need to override this method if SDKs of this type have non-trivial version strings.
*/
@NotNull
default Comparator<Sdk> versionComparator() {
return (sdk1, sdk2) -> {
assert sdk1.getSdkType() == this : sdk1;
@@ -31,7 +31,7 @@ public interface ExternalProjectSystemRegistry {
}
@NotNull
ProjectModelExternalSource getSourceById(String id);
ProjectModelExternalSource getSourceById(@NotNull String id);
@Nullable
ProjectModelExternalSource getExternalSource(@NotNull Module module);
@@ -152,7 +152,7 @@ public interface ModifiableRootModel extends ModuleRootModel {
boolean isWritable();
<T extends OrderEntry> void replaceEntryOfType(Class<T> entryClass, T entry);
<T extends OrderEntry> void replaceEntryOfType(@NotNull Class<T> entryClass, T entry);
@Nullable
String getSdkName();
@@ -16,13 +16,16 @@
package com.intellij.openapi.roots;
import com.intellij.openapi.module.Module;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author dsl
*/
public interface ModuleOrderEntry extends ExportableOrderEntry {
@Nullable Module getModule();
@Nullable
Module getModule();
@NotNull
String getModuleName();
}
@@ -16,6 +16,7 @@
package com.intellij.openapi.roots;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import java.util.EventObject;
@@ -24,7 +25,7 @@ import java.util.EventObject;
*/
public abstract class ModuleRootEvent extends EventObject{
protected ModuleRootEvent(final Project project) {
protected ModuleRootEvent(@NotNull Project project) {
super(project);
}
@@ -77,5 +77,5 @@ public abstract class ModuleRootManager implements ModuleRootModel, ProjectModel
* @param module the module to check.
* @return true if {@code module} is contained in the list of dependencies for the current module, false otherwise.
*/
public abstract boolean isDependsOn(Module module);
public abstract boolean isDependsOn(@NotNull Module module);
}
@@ -178,7 +178,7 @@ public interface ModuleRootModel {
* @return the value returned by the visitor.
* @see OrderEntry#accept(RootPolicy, Object)
*/
<R> R processOrder(RootPolicy<R> policy, R initialValue);
<R> R processOrder(@NotNull RootPolicy<R> policy, R initialValue);
/**
* Returns {@link OrderEnumerator} instance which can be used to process order entries of the module (with or without dependencies) and
@@ -15,10 +15,13 @@
*/
package com.intellij.openapi.roots;
import org.jetbrains.annotations.NotNull;
/**
* Order entry for content source folders
* @author dsl
*/
public interface ModuleSourceOrderEntry extends OrderEntry {
@NotNull
ModuleRootModel getRootModel();
}
@@ -40,6 +40,7 @@ public abstract class OrderEnumerationHandler {
public abstract boolean isApplicable(@NotNull Module module);
@NotNull
public abstract OrderEnumerationHandler createHandler(@NotNull Module module);
}
@@ -20,9 +20,10 @@ public class OrderRootType {
public static final ExtensionPointName<OrderRootType> EP_NAME = ExtensionPointName.create("com.intellij.orderRootType");
protected static PersistentOrderRootType[] ourPersistentOrderRootTypes = new PersistentOrderRootType[0];
@NotNull
static PersistentOrderRootType[] ourPersistentOrderRootTypes = new PersistentOrderRootType[0];
protected OrderRootType(String name) {
protected OrderRootType(@NotNull String name) {
myName = name;
}
@@ -65,6 +66,7 @@ public class OrderRootType {
}
}
@NotNull
public String name() {
return myName;
}
@@ -79,10 +81,12 @@ public class OrderRootType {
return false;
}
@NotNull
public static synchronized OrderRootType[] getAllTypes() {
return getAllPersistentTypes();
}
@NotNull
public static PersistentOrderRootType[] getAllPersistentTypes() {
if (!ourExtensionsLoaded) {
ourExtensionsLoaded = true;
@@ -91,6 +95,7 @@ public class OrderRootType {
return ourPersistentOrderRootTypes;
}
@NotNull
public static List<PersistentOrderRootType> getSortedRootTypes() {
List<PersistentOrderRootType> allTypes = new ArrayList<>();
Collections.addAll(allTypes, getAllPersistentTypes());
@@ -111,10 +116,12 @@ public class OrderRootType {
return null;
}
@Override
public final int hashCode() {
return super.hashCode();
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj);
}
@@ -16,8 +16,9 @@
package com.intellij.openapi.roots;
import org.jetbrains.annotations.NonNls;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -28,7 +29,7 @@ public class PersistentOrderRootType extends OrderRootType {
private final String myModulePathsName;
private final String myOldSdkRootName;
protected PersistentOrderRootType(@NonNls String name, @NonNls @Nullable String sdkRootName, @NonNls @Nullable String modulePathsName, @Nullable @NonNls final String oldSdkRootName) {
protected PersistentOrderRootType(@NonNls @NotNull String name, @NonNls @Nullable String sdkRootName, @NonNls @Nullable String modulePathsName, @Nullable @NonNls final String oldSdkRootName) {
super(name);
mySdkRootName = sdkRootName;
myModulePathsName = modulePathsName;
@@ -70,6 +70,7 @@ public abstract class ProjectRootManager extends SimpleModificationTracker {
* Unlike getContentRoots(), this includes the project base dir. Is this really necessary?
* TODO: remove this method?
*/
@NotNull
public abstract VirtualFile[] getContentRootsFromAllModules();
/**
@@ -58,7 +58,7 @@ public interface FilePropertyPusher<T> {
interface Engine {
void pushAll();
void pushRecursively(VirtualFile vile, Project project);
void pushRecursively(@NotNull VirtualFile vile, @NotNull Project project);
}
void afterRootsChanged(@NotNull Project project);
@@ -15,15 +15,20 @@
*/
package com.intellij.openapi.roots.libraries;
import org.jetbrains.annotations.NotNull;
/**
* @author peter
*/
public abstract class LibraryTablePresentation {
@NotNull
public abstract String getDisplayName(boolean plural);
@NotNull
public abstract String getDescription();
@NotNull
public abstract String getLibraryTableEditorTitle();
}
@@ -58,5 +58,6 @@ public abstract class LibraryTablesRegistrar {
*/
public abstract void registerLibraryTable(@NotNull LibraryTable libraryTable);
@NotNull
public abstract List<LibraryTable> getCustomLibraryTables();
}
@@ -26,13 +26,13 @@ import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.PathUtil;
import com.intellij.util.containers.ContainerUtil;
import java.util.HashSet;
import com.intellij.util.text.StringTokenizer;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -40,15 +40,15 @@ public class LibraryUtil {
private LibraryUtil() {
}
public static boolean isClassAvailableInLibrary(final Library library, final String fqn) {
public static boolean isClassAvailableInLibrary(@NotNull Library library, @NotNull String fqn) {
return isClassAvailableInLibrary(library.getFiles(OrderRootType.CLASSES), fqn);
}
public static boolean isClassAvailableInLibrary(VirtualFile[] files, final String fqn) {
public static boolean isClassAvailableInLibrary(@NotNull VirtualFile[] files, @NotNull String fqn) {
return isClassAvailableInLibrary(Arrays.asList(files), fqn);
}
public static boolean isClassAvailableInLibrary(List<? extends VirtualFile> files, final String fqn) {
public static boolean isClassAvailableInLibrary(@NotNull List<? extends VirtualFile> files, @NotNull String fqn) {
for (VirtualFile file : files) {
if (findInFile(file, new StringTokenizer(fqn, "."))) return true;
}
@@ -56,7 +56,7 @@ public class LibraryUtil {
}
@Nullable
public static Library findLibraryByClass(final String fqn, @Nullable Project project) {
public static Library findLibraryByClass(@NotNull String fqn, @Nullable Project project) {
if (project != null) {
final LibraryTable projectTable = LibraryTablesRegistrar.getInstance().getLibraryTable(project);
Library library = findInTable(projectTable, fqn);
@@ -69,7 +69,7 @@ public class LibraryUtil {
}
private static boolean findInFile(VirtualFile file, final StringTokenizer tokenizer) {
private static boolean findInFile(@NotNull VirtualFile file, @NotNull StringTokenizer tokenizer) {
if (!tokenizer.hasMoreTokens()) return true;
@NonNls StringBuilder name = new StringBuilder(tokenizer.nextToken());
if (!tokenizer.hasMoreTokens()) {
@@ -80,7 +80,7 @@ public class LibraryUtil {
}
@Nullable
private static Library findInTable(LibraryTable table, String fqn) {
private static Library findInTable(@NotNull LibraryTable table, @NotNull String fqn) {
for (Library library : table.getLibraries()) {
if (isClassAvailableInLibrary(library, fqn)) {
return library;
@@ -89,7 +89,8 @@ public class LibraryUtil {
return null;
}
public static Library createLibrary(final LibraryTable libraryTable, @NonNls final String baseName) {
@NotNull
public static Library createLibrary(@NotNull LibraryTable libraryTable, @NonNls @NotNull String baseName) {
String name = baseName;
int count = 2;
while (libraryTable.getLibraryByName(name) != null) {
@@ -98,15 +99,18 @@ public class LibraryUtil {
return libraryTable.createLibrary(name);
}
public static VirtualFile[] getLibraryRoots(final Project project) {
@NotNull
public static VirtualFile[] getLibraryRoots(@NotNull Project project) {
return getLibraryRoots(project, true, true);
}
public static VirtualFile[] getLibraryRoots(final Project project, final boolean includeSourceFiles, final boolean includeJdk) {
@NotNull
public static VirtualFile[] getLibraryRoots(@NotNull Project project, final boolean includeSourceFiles, final boolean includeJdk) {
return getLibraryRoots(ModuleManager.getInstance(project).getModules(), includeSourceFiles, includeJdk);
}
public static VirtualFile[] getLibraryRoots(final Module[] modules, final boolean includeSourceFiles, final boolean includeJdk) {
@NotNull
public static VirtualFile[] getLibraryRoots(@NotNull Module[] modules, final boolean includeSourceFiles, final boolean includeJdk) {
Set<VirtualFile> roots = new HashSet<>();
for (Module module : modules) {
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
@@ -147,8 +151,8 @@ public class LibraryUtil {
return result.get();
}
@Nullable
public static OrderEntry findLibraryEntry(VirtualFile file, final Project project) {
@Nullable
public static OrderEntry findLibraryEntry(@NotNull VirtualFile file, @NotNull Project project) {
List<OrderEntry> entries = ProjectRootManager.getInstance(project).getFileIndex().getOrderEntriesForFile(file);
for (OrderEntry entry : entries) {
if (entry instanceof LibraryOrderEntry || entry instanceof JdkOrderEntry) {
@@ -34,6 +34,7 @@ public abstract class PersistentLibraryKind<P extends LibraryProperties> extends
@NotNull
public abstract P createDefaultProperties();
@NotNull
public OrderRootType[] getAdditionalRootTypes() {
return new OrderRootType[0];
}
@@ -31,7 +31,7 @@ public class CoreProjectJdkTable extends ProjectJdkTable {
private final List<Sdk> mySdks = new ArrayList<>();
@Override
public Sdk findJdk(String name) {
public Sdk findJdk(@NotNull String name) {
synchronized (mySdks) {
for (Sdk jdk : mySdks) {
if (Comparing.strEqual(name, jdk.getName())) {
@@ -43,7 +43,7 @@ public class CoreProjectJdkTable extends ProjectJdkTable {
}
@Override
public Sdk findJdk(String name, String type) {
public Sdk findJdk(@NotNull String name, @NotNull String type) {
return findJdk(name);
}
@@ -46,7 +46,7 @@ public class CoreSdkType implements SdkTypeId {
}
@Override
public SdkAdditionalData loadAdditionalData(@NotNull Sdk currentSdk, Element additional) {
public SdkAdditionalData loadAdditionalData(@NotNull Sdk currentSdk, @NotNull Element additional) {
return null;
}
}
@@ -20,11 +20,11 @@ import org.jetbrains.annotations.Nullable;
public class ProjectRootsUtil {
private ProjectRootsUtil() { }
public static boolean isSourceRoot(final PsiDirectory psiDirectory) {
public static boolean isSourceRoot(@NotNull PsiDirectory psiDirectory) {
return isSourceRoot(psiDirectory.getVirtualFile(), psiDirectory.getProject());
}
public static boolean isSourceRoot(final VirtualFile directoryFile, final Project project) {
public static boolean isSourceRoot(@NotNull VirtualFile directoryFile, @NotNull Project project) {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
return directoryFile.equals(fileIndex.getSourceRootForFile(directoryFile));
}
@@ -100,8 +100,7 @@ public class ProjectRootsUtil {
return psiDirectory.getVirtualFile().equals(psiDirectory.getProject().getBaseDir());
}
public static boolean isOutsideSourceRoot(@Nullable PsiFile psiFile) {
if (psiFile == null) return false;
public static boolean isOutsideSourceRoot(@NotNull PsiFile psiFile) {
if (psiFile instanceof PsiCodeFragment) return false;
final VirtualFile file = psiFile.getVirtualFile();
if (file == null) return false;
@@ -111,7 +110,7 @@ public class ProjectRootsUtil {
@Nullable
public static SourceFolder findSourceFolder(@NotNull Module module, @NotNull VirtualFile root) {
final ProjectFileIndexImpl index = ((ProjectFileIndexImpl)ProjectRootManager.getInstance(module.getProject()).getFileIndex());
final ProjectFileIndexImpl index = (ProjectFileIndexImpl)ProjectRootManager.getInstance(module.getProject()).getFileIndex();
SourceFolder folder = index.getModuleForFile(root) == module ? index.getSourceFolder(root) : null;
return folder != null && root.equals(folder.getFile()) ? folder : null;
}
@@ -24,15 +24,10 @@ public class PropertiesComponentImpl extends PropertiesComponent implements Pers
@NonNls private static final String ATTRIBUTE_NAME = "name";
@NonNls private static final String ATTRIBUTE_VALUE = "value";
@NotNull
public String getComponentName() {
return "PropertiesComponent";
}
PropertiesComponentImpl() {
}
private void doPut(String key, String value) {
private void doPut(@NotNull String key, @NotNull String value) {
String reason = Verifier.checkCharacterData(key);
if (reason != null) {
LOG.error(reason);
@@ -70,7 +65,7 @@ public class PropertiesComponentImpl extends PropertiesComponent implements Pers
}
@Override
public String getValue(String name) {
public String getValue(@NotNull String name) {
return myMap.get(name);
}
@@ -125,25 +120,25 @@ public class PropertiesComponentImpl extends PropertiesComponent implements Pers
}
@Override
public void unsetValue(String name) {
public void unsetValue(@NotNull String name) {
myMap.remove(name);
incModificationCount();
}
@Override
public boolean isValueSet(String name) {
public boolean isValueSet(@NotNull String name) {
return myMap.containsKey(name);
}
@Nullable
@Override
public String[] getValues(@NonNls String name) {
public String[] getValues(@NotNull @NonNls String name) {
final String value = getValue(name);
return value != null ? value.split("\n") : null;
}
@Override
public void setValues(@NonNls String name, String[] values) {
public void setValues(@NotNull @NonNls String name, String[] values) {
if (values == null) {
setValue(name, null);
}

Some files were not shown because too many files have changed in this diff Show More