Java Code Examples for com.intellij.util.containers.ContainerUtil#notNullize()

The following examples show how to use com.intellij.util.containers.ContainerUtil#notNullize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExternalExec.java    From idea-gitignore with MIT License 6 votes vote down vote up
/**
 * Returns list of unignored files for the given directory.
 *
 * @param language to check
 * @param project  current project
 * @param file     current file
 * @return unignored files list
 */
@NotNull
public static List<String> getUnignoredFiles(@NotNull IgnoreLanguage language, @NotNull Project project,
                                             @NotNull VirtualFile file) {
    if (!Utils.isInProject(file, project)) {
        return new ArrayList<>();
    }

    ArrayList<String> result = run(
            language,
            GIT_UNIGNORED_FILES,
            file.getParent(),
            new GitUnignoredFilesOutputParser()
    );
    return ContainerUtil.notNullize(result);
}
 
Example 2
Source File: AbstractAutoTestManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static List<RunConfiguration> loadConfigurations(State state, Project project) {
  List<RunConfiguration> configurations = ContainerUtil.newArrayList();
  RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
  List<RunConfigurationDescriptor> descriptors = ContainerUtil.notNullize(state.myEnabledRunConfigurations);
  for (RunConfigurationDescriptor descriptor : descriptors) {
    if (descriptor.myType != null && descriptor.myName != null) {
      RunnerAndConfigurationSettings settings = runManager.findConfigurationByTypeAndName(descriptor.myType,
                                                                                          descriptor.myName);
      RunConfiguration configuration = settings != null ? settings.getConfiguration() : null;
      if (configuration != null) {
        configurations.add(configuration);
      }
    }
  }
  return configurations;
}
 
Example 3
Source File: LibraryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<String> getInvalidRootUrls(@Nonnull OrderRootType type) {
  if (myDisposed) return Collections.emptyList();

  VirtualFilePointerContainer container = myRoots.get(type);
  final List<VirtualFilePointer> pointers = container == null ? Collections.emptyList() : container.getList();
  List<String> invalidPaths = null;
  for (VirtualFilePointer pointer : pointers) {
    if (!pointer.isValid()) {
      if (invalidPaths == null) {
        invalidPaths = new SmartList<>();
      }
      invalidPaths.add(pointer.getUrl());
    }
  }
  return ContainerUtil.notNullize(invalidPaths);
}
 
Example 4
Source File: StateStorageManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<SaveSession> createSaveSessions() {
  if (mySessions.isEmpty()) {
    return Collections.emptyList();
  }

  List<SaveSession> saveSessions = null;
  Collection<StateStorage.ExternalizationSession> externalizationSessions = mySessions.values();
  for (StateStorage.ExternalizationSession session : externalizationSessions) {
    SaveSession saveSession = session.createSaveSession();
    if (saveSession != null) {
      if (saveSessions == null) {
        if (externalizationSessions.size() == 1) {
          return Collections.singletonList(saveSession);
        }
        saveSessions = new SmartList<>();
      }
      saveSessions.add(saveSession);
    }
  }
  return ContainerUtil.notNullize(saveSessions);
}
 
Example 5
Source File: XDebuggerConfigurableProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Collection<Configurable> getConfigurables(@Nonnull DebuggerSettingsCategory category) {
  List<Configurable> list;
  if (category == DebuggerSettingsCategory.GENERAL) {
    list = new SmartList<>(new XDebuggerGeneralConfigurable());
  }
  else {
    list = null;
  }

  for (XDebuggerSettings<?> settings : XDebuggerSettingManagerImpl.getInstanceImpl().getSettingsList()) {
    Collection<? extends Configurable> configurables = settings.createConfigurables(category);
    if (!configurables.isEmpty()) {
      if (list == null) {
        list = new SmartList<>();
      }
      list.addAll(configurables);
    }
  }
  return ContainerUtil.notNullize(list);
}
 
Example 6
Source File: RunManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * Template configuration is not included
 */
@Override
@Nonnull
public List<RunConfiguration> getConfigurationsList(@Nonnull ConfigurationType type) {
  List<RunConfiguration> result = null;
  for (RunnerAndConfigurationSettings settings : getSortedConfigurations()) {
    RunConfiguration configuration = settings.getConfiguration();
    if (type.getId().equals(configuration.getType().getId())) {
      if (result == null) {
        result = new SmartList<>();
      }
      result.add(configuration);
    }
  }
  return ContainerUtil.notNullize(result);
}
 
Example 7
Source File: RunManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private List<BeforeRunTask> readStepsBeforeRun(@Nullable Element child, @Nonnull RunnerAndConfigurationSettings settings) {
  List<BeforeRunTask> result = null;
  if (child != null) {
    for (Element methodElement : child.getChildren(OPTION)) {
      Key<? extends BeforeRunTask> id = getProviderKey(methodElement.getAttributeValue(NAME_ATTR));
      BeforeRunTask beforeRunTask = getProvider(id).createTask(settings.getConfiguration());
      if (beforeRunTask != null) {
        beforeRunTask.readExternal(methodElement);
        if (result == null) {
          result = new SmartList<>();
        }
        result.add(beforeRunTask);
      }
    }
  }
  return ContainerUtil.notNullize(result);
}
 
Example 8
Source File: ExternalExec.java    From idea-gitignore with MIT License 5 votes vote down vote up
/**
 * Returns list of ignored files for the given repository.
 *
 * @param vcsRoot repository to check
 * @return unignored files list
 */
@NotNull
public static List<String> getIgnoredFiles(@NotNull VcsRoot vcsRoot) {
    ArrayList<String> result = run(
            GitLanguage.INSTANCE,
            GIT_IGNORED_FILES,
            vcsRoot.getPath(),
            new SimpleOutputParser()
    );
    return ContainerUtil.notNullize(result);
}
 
Example 9
Source File: XDebuggerManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public <T extends XDebugProcess> List<? extends T> getDebugProcesses(Class<T> processClass) {
  List<T> list = null;
  for (XDebugSessionImpl session : mySessions.values()) {
    final XDebugProcess process = session.getDebugProcess();
    if (processClass.isInstance(process)) {
      if (list == null) {
        list = new SmartList<>();
      }
      list.add(processClass.cast(process));
    }
  }
  return ContainerUtil.notNullize(list);
}
 
Example 10
Source File: RunManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
Collection<RunnerAndConfigurationSettings> getStableConfigurations(boolean shared) {
  List<RunnerAndConfigurationSettings> result = null;
  for (RunnerAndConfigurationSettings configuration : myConfigurations.values()) {
    if (!configuration.isTemporary() && isConfigurationShared(configuration) == shared) {
      if (result == null) {
        result = new SmartList<>();
      }
      result.add(configuration);
    }
  }
  return ContainerUtil.notNullize(result);
}
 
Example 11
Source File: FileBasedIndexImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public <K, V> Map<K, V> getFileData(@Nonnull ID<K, V> id, @Nonnull VirtualFile virtualFile, @Nonnull Project project) {
  int fileId = getFileId(virtualFile);
  Map<K, V> map = processExceptions(id, virtualFile, GlobalSearchScope.fileScope(project, virtualFile), index -> index.getIndexedFileData(fileId));
  return ContainerUtil.notNullize(map);
}
 
Example 12
Source File: UnifiedDiffViewer.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
protected List<UnifiedDiffChange> getChanges() {
  return ContainerUtil.notNullize(getDiffChanges());
}
 
Example 13
Source File: DiffUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static void addNotification(@Nullable JComponent component, @Nonnull UserDataHolder holder) {
  if (component == null) return;
  List<JComponent> oldComponents = ContainerUtil.notNullize(holder.getUserData(DiffUserDataKeys.NOTIFICATIONS));
  holder.putUserData(DiffUserDataKeys.NOTIFICATIONS, ContainerUtil.append(oldComponents, component));
}
 
Example 14
Source File: DiffUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static List<JComponent> getCustomNotifications(@Nonnull DiffContent content) {
  return ContainerUtil.notNullize(content.getUserData(DiffUserDataKeys.NOTIFICATIONS));
}
 
Example 15
Source File: Notification.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public List<AnAction> getActions() {
  return ContainerUtil.notNullize(myActions);
}