本文整理汇总了Java中com.intellij.util.containers.ContainerUtilRt.newHashSet方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerUtilRt.newHashSet方法的具体用法?Java ContainerUtilRt.newHashSet怎么用?Java ContainerUtilRt.newHashSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.containers.ContainerUtilRt
的用法示例。
在下文中一共展示了ContainerUtilRt.newHashSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onProjectRename
import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
private static <V> void onProjectRename(@NotNull Map<IntegrationKey, V> data,
@NotNull String oldName,
@NotNull String newName)
{
Set<IntegrationKey> keys = ContainerUtilRt.newHashSet(data.keySet());
for (IntegrationKey key : keys) {
if (!key.getIdeProjectName().equals(oldName)) {
continue;
}
IntegrationKey newKey = new IntegrationKey(newName,
key.getIdeProjectLocationHash(),
key.getExternalSystemId(),
key.getExternalProjectConfigPath());
V value = data.get(key);
data.put(newKey, value);
data.remove(key);
if (value instanceof Consumer) {
//noinspection unchecked
((Consumer)value).consume(newKey);
}
}
}
示例2: enhanceRemoteProcessing
import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
@Override
public void enhanceRemoteProcessing(@NotNull SimpleJavaParameters parameters) throws ExecutionException {
final Set<String> additionalEntries = ContainerUtilRt.newHashSet();
for (GradleProjectResolverExtension extension : RESOLVER_EXTENSIONS.getValue()) {
ContainerUtilRt.addIfNotNull(additionalEntries, PathUtil.getJarPathForClass(extension.getClass()));
for (Class aClass : extension.getExtraProjectModelClasses()) {
ContainerUtilRt.addIfNotNull(additionalEntries, PathUtil.getJarPathForClass(aClass));
}
extension.enhanceRemoteProcessing(parameters);
}
final PathsList classPath = parameters.getClassPath();
for (String entry : additionalEntries) {
classPath.add(entry);
}
parameters.getVMParametersList().addProperty(
ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY, GradleConstants.SYSTEM_ID.getId());
}
示例3: onProjectRename
import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
private static <V> void onProjectRename(@Nonnull Map<IntegrationKey, V> data,
@Nonnull String oldName,
@Nonnull String newName)
{
Set<IntegrationKey> keys = ContainerUtilRt.newHashSet(data.keySet());
for (IntegrationKey key : keys) {
if (!key.getIdeProjectName().equals(oldName)) {
continue;
}
IntegrationKey newKey = new IntegrationKey(newName,
key.getIdeProjectLocationHash(),
key.getExternalSystemId(),
key.getExternalProjectConfigPath());
V value = data.get(key);
data.put(newKey, value);
data.remove(key);
if (value instanceof Consumer) {
//noinspection unchecked
((Consumer)value).consume(newKey);
}
}
}
示例4: loadClassFromParents
import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
@Nullable
private Class loadClassFromParents(final String name, Set<ClassLoader> visited) {
for (ClassLoader parent : myParents) {
if (visited == null) visited = ContainerUtilRt.newHashSet(this);
if (!visited.add(parent)) {
continue;
}
if (parent instanceof PluginClassLoader) {
Class c = ((PluginClassLoader)parent).tryLoadingClass(name, false, visited);
if (c != null) {
return c;
}
continue;
}
try {
return parent.loadClass(name);
}
catch (ClassNotFoundException ignoreAndContinue) {
// Ignore and continue
}
}
return null;
}
示例5: buildMethodDependencyInfo
import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
@Nullable
private ArrangementEntryDependencyInfo buildMethodDependencyInfo(@NotNull final PsiMethod method,
@NotNull Map<PsiMethod, ArrangementEntryDependencyInfo> cache) {
JavaElementArrangementEntry entry = myMethodEntriesMap.get(method);
if (entry == null) {
return null;
}
ArrangementEntryDependencyInfo result = new ArrangementEntryDependencyInfo(entry);
Stack<Pair<PsiMethod, ArrangementEntryDependencyInfo>> toProcess
= new Stack<Pair<PsiMethod, ArrangementEntryDependencyInfo>>();
toProcess.push(Pair.create(method, result));
Set<PsiMethod> usedMethods = ContainerUtilRt.newHashSet();
while (!toProcess.isEmpty()) {
Pair<PsiMethod, ArrangementEntryDependencyInfo> pair = toProcess.pop();
Set<PsiMethod> dependentMethods = myMethodDependencies.get(pair.first);
if (dependentMethods == null) {
continue;
}
usedMethods.add(pair.first);
for (PsiMethod dependentMethod : dependentMethods) {
if (usedMethods.contains(dependentMethod)) {
// Prevent cyclic dependencies.
return null;
}
JavaElementArrangementEntry dependentEntry = myMethodEntriesMap.get(dependentMethod);
if (dependentEntry == null) {
continue;
}
ArrangementEntryDependencyInfo dependentMethodInfo = cache.get(dependentMethod);
if (dependentMethodInfo == null) {
cache.put(dependentMethod, dependentMethodInfo = new ArrangementEntryDependencyInfo(dependentEntry));
}
Pair<PsiMethod, ArrangementEntryDependencyInfo> dependentPair = Pair.create(dependentMethod, dependentMethodInfo);
pair.second.addDependentEntryInfo(dependentPair.second);
toProcess.push(dependentPair);
}
}
return result;
}
示例6: getGroupingRules
import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
@NotNull
private static Set<ArrangementSettingsToken> getGroupingRules(@NotNull ArrangementSettings settings) {
Set<ArrangementSettingsToken> groupingRules = ContainerUtilRt.newHashSet();
for (ArrangementGroupingRule rule : settings.getGroupings()) {
groupingRules.add(rule.getGroupingType());
}
return groupingRules;
}
示例7: ensureTasks
import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
public void ensureTasks(@NotNull String externalProjectConfigPath, @NotNull Collection<ExternalTaskPojo> tasks) {
if (tasks.isEmpty()) {
return;
}
ExternalSystemNode<ExternalProjectPojo> moduleNode = findProjectNode(externalProjectConfigPath);
if (moduleNode == null) {
// LOG.warn(String.format(
// "Can't proceed tasks for module which external config path is '%s'. Reason: no such module node is found. Tasks: %s",
// externalProjectConfigPath, tasks
// ));
return;
}
Set<ExternalTaskExecutionInfo> toAdd = ContainerUtilRt.newHashSet();
for (ExternalTaskPojo task : tasks) {
toAdd.add(buildTaskInfo(task));
}
for (int i = 0; i < moduleNode.getChildCount(); i++) {
ExternalSystemNode<?> childNode = moduleNode.getChildAt(i);
Object element = childNode.getDescriptor().getElement();
if (element instanceof ExternalTaskExecutionInfo) {
if (!toAdd.remove(element)) {
removeNodeFromParent(childNode);
//noinspection AssignmentToForLoopParameter
i--;
}
}
}
if (!toAdd.isEmpty()) {
for (ExternalTaskExecutionInfo taskInfo : toAdd) {
insertNodeInto(
new ExternalSystemNode<ExternalTaskExecutionInfo>(descriptor(taskInfo, taskInfo.getDescription(), myUiAware.getTaskIcon())),
moduleNode);
}
}
}
示例8: linkExternalProject
import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
/**
* Tries to obtain external project info implied by the given settings and link that external project to the given ide project.
*
* @param externalSystemId target external system
* @param projectSettings settings of the external project to link
* @param project target ide project to link external project to
* @param executionResultCallback it might take a while to resolve external project info, that's why it's possible to provide
* a callback to be notified on processing result. It receives <code>true</code> if an external
* project has been successfully linked to the given ide project;
* <code>false</code> otherwise (note that corresponding notification with error details is expected
* to be shown to the end-user then)
* @param isPreviewMode flag which identifies if missing external project binaries should be downloaded
* @param progressExecutionMode identifies how progress bar will be represented for the current processing
*/
@SuppressWarnings("UnusedDeclaration")
public static void linkExternalProject(@NotNull final ProjectSystemId externalSystemId,
@NotNull final ExternalProjectSettings projectSettings,
@NotNull final Project project,
@Nullable final Consumer<Boolean> executionResultCallback,
boolean isPreviewMode,
@NotNull final ProgressExecutionMode progressExecutionMode)
{
ExternalProjectRefreshCallback callback = new ExternalProjectRefreshCallback() {
@SuppressWarnings("unchecked")
@Override
public void onSuccess(@Nullable final DataNode<ProjectData> externalProject) {
if (externalProject == null) {
if (executionResultCallback != null) {
executionResultCallback.consume(false);
}
return;
}
AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(project, externalSystemId);
Set<ExternalProjectSettings> projects = ContainerUtilRt.newHashSet(systemSettings.getLinkedProjectsSettings());
projects.add(projectSettings);
systemSettings.setLinkedProjectsSettings(projects);
ensureToolWindowInitialized(project, externalSystemId);
ServiceManager.getService(ProjectDataManager.class).importData(externalProject, project, true);
if (executionResultCallback != null) {
executionResultCallback.consume(true);
}
}
@Override
public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
if (executionResultCallback != null) {
executionResultCallback.consume(false);
}
}
};
refreshProject(project, externalSystemId, projectSettings.getExternalProjectPath(), callback, isPreviewMode, progressExecutionMode);
}
示例9: MyMultiExternalProjectRefreshCallback
import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
public MyMultiExternalProjectRefreshCallback(Project project,
ProjectDataManager projectDataManager,
ProjectSystemId externalSystemId) {
myProject = project;
myProjectDataManager = projectDataManager;
myExternalSystemId = externalSystemId;
myExternalModulePaths = ContainerUtilRt.newHashSet();
}
示例10: doImportProject
import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
private void doImportProject() {
AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(myProject, getExternalSystemId());
final ExternalProjectSettings projectSettings = getCurrentExternalProjectSettings();
projectSettings.setExternalProjectPath(getProjectPath());
Set<ExternalProjectSettings> projects = ContainerUtilRt.newHashSet(systemSettings.getLinkedProjectsSettings());
projects.remove(projectSettings);
projects.add(projectSettings);
systemSettings.setLinkedProjectsSettings(projects);
final Ref<Couple<String>> error = Ref.create();
ExternalSystemUtil.refreshProjects(
new ImportSpecBuilder(myProject, getExternalSystemId())
.use(ProgressExecutionMode.MODAL_SYNC)
.callback(new ExternalProjectRefreshCallback() {
@Override
public void onSuccess(@Nullable final DataNode<ProjectData> externalProject) {
if (externalProject == null) {
System.err.println("Got null External project after import");
return;
}
ServiceManager.getService(ProjectDataManager.class).importData(externalProject, myProject, true);
System.out.println("External project was successfully imported");
}
@Override
public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
error.set(Couple.of(errorMessage, errorDetails));
}
})
);
if (!error.isNull()) {
String failureMsg = "Import failed: " + error.get().first;
if (StringUtil.isNotEmpty(error.get().second)) {
failureMsg += "\nError details: \n" + error.get().second;
}
fail(failureMsg);
}
}
示例11: flatten
import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
public static <T> Set<T> flatten(@NotNull Iterable<? extends Iterable<T>> data) {
Set<T> result = ContainerUtilRt.newHashSet();
for (Iterable<T> i : data) {
for (T t : i) {
result.add(t);
}
}
return result;
}
示例12: buildDependency
import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
@NotNull
private static ModuleDependencyData buildDependency(@NotNull DataNode<ModuleData> ownerModule,
@NotNull IdeaModuleDependency dependency,
@NotNull DataNode<ProjectData> ideProject)
throws IllegalStateException {
IdeaModule module = dependency.getDependencyModule();
if (module == null) {
throw new IllegalStateException(
String.format("Can't parse gradle module dependency '%s'. Reason: referenced module is null", dependency)
);
}
String moduleName = module.getName();
if (moduleName == null) {
throw new IllegalStateException(String.format(
"Can't parse gradle module dependency '%s'. Reason: referenced module name is undefined (module: '%s') ", dependency, module
));
}
Set<String> registeredModuleNames = ContainerUtilRt.newHashSet();
Collection<DataNode<ModuleData>> modulesDataNode = ExternalSystemApiUtil.getChildren(ideProject, ProjectKeys.MODULE);
for (DataNode<ModuleData> moduleDataNode : modulesDataNode) {
String name = moduleDataNode.getData().getExternalName();
registeredModuleNames.add(name);
if (name.equals(moduleName)) {
return new ModuleDependencyData(ownerModule.getData(), moduleDataNode.getData());
}
}
throw new IllegalStateException(String.format(
"Can't parse gradle module dependency '%s'. Reason: no module with such name (%s) is found. Registered modules: %s",
dependency, moduleName, registeredModuleNames
));
}
示例13: getGroupingRules
import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
@NotNull
private static Set<ArrangementSettingsToken> getGroupingRules(@Nullable ArrangementSettings settings) {
Set<ArrangementSettingsToken> groupingRules = ContainerUtilRt.newHashSet();
if (settings != null) {
for (ArrangementGroupingRule rule : settings.getGroupings()) {
groupingRules.add(rule.getGroupingType());
}
}
return groupingRules;
}
示例14: buildMethodDependencyInfo
import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
@Nullable
private JavaArrangementMethodDependencyInfo buildMethodDependencyInfo(@NotNull final PsiMethod method,
@NotNull Map<PsiMethod, JavaArrangementMethodDependencyInfo> cache)
{
JavaElementArrangementEntry entry = myMethodEntriesMap.get(method);
if (entry == null) {
return null;
}
JavaArrangementMethodDependencyInfo result = new JavaArrangementMethodDependencyInfo(entry);
Stack<Pair<PsiMethod, JavaArrangementMethodDependencyInfo>> toProcess
= new Stack<Pair<PsiMethod, JavaArrangementMethodDependencyInfo>>();
toProcess.push(Pair.create(method, result));
Set<PsiMethod> usedMethods = ContainerUtilRt.newHashSet();
while (!toProcess.isEmpty()) {
Pair<PsiMethod, JavaArrangementMethodDependencyInfo> pair = toProcess.pop();
Set<PsiMethod> dependentMethods = myMethodDependencies.get(pair.first);
if (dependentMethods == null) {
continue;
}
usedMethods.add(pair.first);
for (PsiMethod dependentMethod : dependentMethods) {
if (usedMethods.contains(dependentMethod)) {
// Prevent cyclic dependencies.
return null;
}
JavaElementArrangementEntry dependentEntry = myMethodEntriesMap.get(dependentMethod);
if (dependentEntry == null) {
continue;
}
JavaArrangementMethodDependencyInfo dependentMethodInfo = cache.get(dependentMethod);
if (dependentMethodInfo == null) {
cache.put(dependentMethod, dependentMethodInfo = new JavaArrangementMethodDependencyInfo(dependentEntry));
}
Pair<PsiMethod, JavaArrangementMethodDependencyInfo> dependentPair = Pair.create(dependentMethod, dependentMethodInfo);
pair.second.addDependentMethodInfo(dependentPair.second);
toProcess.push(dependentPair);
}
}
return result;
}
示例15: ensureTasks
import com.intellij.util.containers.ContainerUtilRt; //导入方法依赖的package包/类
public void ensureTasks(@NotNull String externalProjectConfigPath, @NotNull Collection<ExternalTaskPojo> tasks) {
if (tasks.isEmpty()) {
return;
}
ExternalSystemNode<ExternalProjectPojo> moduleNode = findProjectNode(externalProjectConfigPath);
if (moduleNode == null) {
// LOG.warn(String.format(
// "Can't proceed tasks for module which external config path is '%s'. Reason: no such module node is found. Tasks: %s",
// externalProjectConfigPath, tasks
// ));
return;
}
Set<ExternalTaskExecutionInfo> toAdd = ContainerUtilRt.newHashSet();
for (ExternalTaskPojo task : tasks) {
toAdd.add(buildTaskInfo(task));
}
for (int i = 0; i < moduleNode.getChildCount(); i++) {
ExternalSystemNode<?> childNode = moduleNode.getChildAt(i);
Object element = childNode.getDescriptor().getElement();
if (element instanceof ExternalTaskExecutionInfo) {
if (!toAdd.remove(element)) {
moduleNode.remove(childNode);
myIndexHolder[0] = i;
myNodeHolder[0] = childNode;
nodesWereRemoved(moduleNode, myIndexHolder, myNodeHolder);
//noinspection AssignmentToForLoopParameter
i--;
}
}
}
if (!toAdd.isEmpty()) {
for (ExternalTaskExecutionInfo taskInfo : toAdd) {
moduleNode.add(new ExternalSystemNode<ExternalTaskExecutionInfo>(descriptor(taskInfo, myUiAware.getTaskIcon())));
myIndexHolder[0] = moduleNode.getChildCount() - 1;
nodesWereInserted(moduleNode, myIndexHolder);
}
}
ExternalSystemUiUtil.sort(moduleNode, this, NODE_COMPARATOR);
}