当前位置: 首页>>代码示例>>Java>>正文


Java ContainerUtil.getFirstItem方法代码示例

本文整理汇总了Java中com.intellij.util.containers.ContainerUtil.getFirstItem方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerUtil.getFirstItem方法的具体用法?Java ContainerUtil.getFirstItem怎么用?Java ContainerUtil.getFirstItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.containers.ContainerUtil的用法示例。


在下文中一共展示了ContainerUtil.getFirstItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onNewConfigurationCreated

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Override
public void onNewConfigurationCreated(@NotNull RunConfiguration configuration) {
  DeployToServerRunConfiguration<?,?> deployConfiguration = (DeployToServerRunConfiguration<?,?>)configuration;
  if (deployConfiguration.getServerName() == null) {
    RemoteServer<?> server = ContainerUtil.getFirstItem(RemoteServersManager.getInstance().getServers(myServerType));
    if (server != null) {
      deployConfiguration.setServerName(server.getName());
    }
  }

  if (deployConfiguration.getDeploymentSource() == null) {
    List<DeploymentSource> sources = deployConfiguration.getDeploymentConfigurator().getAvailableDeploymentSources();
    DeploymentSource source = ContainerUtil.getFirstItem(sources);
    if (source != null) {
      deployConfiguration.setDeploymentSource(source);
      DeploymentSourceType type = source.getType();
      type.setBuildBeforeRunTask(configuration, source);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:DeployToServerConfigurationType.java

示例2: getSingleResolveOutcome

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@NotNull
public static ResolveOutcome getSingleResolveOutcome(@NotNull final String path,
                                                     @NotNull final String fileContent,
                                                     final int line,
                                                     final int column) {
    Collection<ResolveOutcome> resolveOutcome = getResolveOutcomes(path, fileContent, line, column);
    return resolveOutcome.size() == 1
            ? ContainerUtil.getFirstItem(resolveOutcome, ResolveOutcome.NULL)
            : ResolveOutcome.NULL;
}
 
开发者ID:vhakulinen,项目名称:neovim-intellij-complete,代码行数:11,代码来源:EmbeditorUtil.java

示例3: findRootDescriptor

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Override
public R findRootDescriptor(String rootId, BuildRootIndex rootIndex) {
  final List<R> descriptors = rootIndex.getRootDescriptors(
    new File(rootId), Collections.singletonList((BuildTargetType<? extends JVMModuleBuildTarget<R>>)getTargetType()), null
  );
  return ContainerUtil.getFirstItem(descriptors);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:JVMModuleBuildTarget.java

示例4: isSuitableLambdaRole

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private boolean isSuitableLambdaRole(PsiType lambdaReturnType,
                                     PsiType baseMethodReturnType,
                                     PsiSubstitutor methodSubstitutor,
                                     PsiElement context) {
  if (lambdaReturnType == null) {
    return false;
  }
  if (myLambdaRole == LambdaRole.PREDICATE) {
    final PsiClassType boxedBoolean = PsiType.BOOLEAN.getBoxedType(context);
    if (!(PsiType.BOOLEAN.equals(lambdaReturnType) || (boxedBoolean != null && boxedBoolean.equals(lambdaReturnType)))) {
      return false;
    }
  }
  else {
    LOG.assertTrue(myLambdaRole == LambdaRole.FUNCTION);
    if (methodSubstitutor != null) {
      lambdaReturnType = methodSubstitutor.substitute(lambdaReturnType);
    }
    if (baseMethodReturnType instanceof PsiClassType) {
      final PsiClassType.ClassResolveResult resolveResult = ((PsiClassType)baseMethodReturnType).resolveGenerics();
      final Map<PsiTypeParameter, PsiType> substitutionMap = resolveResult.getSubstitutor().getSubstitutionMap();
      if (substitutionMap.size() != 1) {
        return false;
      }
      final PsiType iterableParametrizedType = ContainerUtil.getFirstItem(substitutionMap.values());
      if (!lambdaReturnType.equals(iterableParametrizedType)) {
        return false;
      }
    }
    else if (baseMethodReturnType instanceof PsiArrayType) {
      if (!lambdaReturnType.equals(((PsiArrayType)baseMethodReturnType).getComponentType())) {
        return false;
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:PseudoLambdaReplaceTemplate.java

示例5: addExternalLibraryDependency

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Override
public Promise<Void> addExternalLibraryDependency(@NotNull final Collection<Module> modules,
                                                  @NotNull final ExternalLibraryDescriptor descriptor,
                                                  @NotNull final DependencyScope scope) {
  List<String> defaultRoots = descriptor.getLibraryClassesRoots();
  Module firstModule = ContainerUtil.getFirstItem(modules);
  LOG.assertTrue(firstModule != null);
  LocateLibraryDialog dialog = new LocateLibraryDialog(firstModule, defaultRoots, descriptor.getPresentableName());
  List<String> classesRoots = dialog.showAndGetResult();
  if (!classesRoots.isEmpty()) {
    String libraryName = classesRoots.size() > 1 ? descriptor.getPresentableName() : null;
    final List<String> urls = OrderEntryFix.refreshAndConvertToUrls(classesRoots);
    if (modules.size() == 1) {
      ModuleRootModificationUtil.addModuleLibrary(firstModule, libraryName, urls, Collections.<String>emptyList(), scope);
    }
    else {
      new WriteAction() {
        protected void run(@NotNull Result result) {
          Library library =
            LibraryUtil.createLibrary(LibraryTablesRegistrar.getInstance().getLibraryTable(myProject), descriptor.getPresentableName());
          Library.ModifiableModel model = library.getModifiableModel();
          for (String url : urls) {
            model.addRoot(url, OrderRootType.CLASSES);
          }
          model.commit();
          for (Module module : modules) {
            ModuleRootModificationUtil.addDependency(module, library, scope, false);
          }
        }
      }.execute();
    }
  }
  return Promise.DONE;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:IdeaProjectModelModifier.java

示例6: createConfigurable

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Nullable
@Override
public Configurable createConfigurable() {
  final List<Configurable> availableConfigurables = getAvailableConfigurables();
  return availableConfigurables.size() == 1 
         ? new EmmetCompositeConfigurable(ContainerUtil.getFirstItem(availableConfigurables))
         : new EmmetCompositeConfigurable(availableConfigurables);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:EmmetConfigurableProvider.java

示例7: findBestHierarchyProvider

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Nullable
public static HierarchyProvider findBestHierarchyProvider(final LanguageExtension<HierarchyProvider> extension,
                                                          @Nullable PsiElement element,
                                                          DataContext dataContext) {
  if (element == null) return null;
  List<HierarchyProvider> providers = extension.allForLanguage(element.getLanguage());
  for (HierarchyProvider provider : providers) {
    PsiElement target = provider.getTarget(dataContext);
    if (target != null) {
      return provider;
    }
  }
  return ContainerUtil.getFirstItem(providers);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:BrowseHierarchyActionBase.java

示例8: actionPerformed

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Override
public void actionPerformed(@Nullable AnActionEvent e) {
  VirtualFile toSelect = getFileToSelect();
  List<OrderRoot> roots = selectRoots(toSelect);
  if (roots.isEmpty()) return;

  final List<OrderRoot> attachedRoots = attachFiles(roots);
  final OrderRoot first = ContainerUtil.getFirstItem(attachedRoots);
  if (first != null) {
    myLastChosen = first.getFile();
  }
  fireLibraryChanged();
  myTree.requestFocus();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:LibraryRootsComponent.java

示例9: testFooNoStubbedValueWhenNestedTags

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
public void testFooNoStubbedValueWhenNestedTags() {
  final ElementStub rootStub = getRootStub("foo.xml");
  assertEquals("", rootStub.getValue());

  final DomStub fooStub = assertOneElement(rootStub.getChildrenStubs());
  final ElementStub fooElementStub = assertInstanceOf(fooStub, ElementStub.class);
  assertEquals("", fooElementStub.getValue());

  final DomStub idStub = ContainerUtil.getFirstItem(fooStub.getChildrenStubs());
  final ElementStub idElementStub = assertInstanceOf(idStub, ElementStub.class);
  assertEquals("foo", idElementStub.getValue());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:DomStubBuilderTest.java

示例10: getInvalidElementsString

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private static String getInvalidElementsString(ConfigurationErrorType type, Collection<ConfigurationErrorDescription> descriptions) {
  if (descriptions.size() == 1) {
    final ConfigurationErrorDescription description = ContainerUtil.getFirstItem(descriptions);
    return type.getElementKind() + " " + description.getElementName();
  }

  return descriptions.size() + " " + StringUtil.pluralize(type.getElementKind());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ProjectLoadingErrorsNotifierImpl.java

示例11: showCyclicModulesHaveDifferentLanguageLevel

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private void showCyclicModulesHaveDifferentLanguageLevel(Set<Module> modulesInChunk) {
  Module firstModule = ContainerUtil.getFirstItem(modulesInChunk);
  LOG.assertTrue(firstModule != null);
  String moduleNameToSelect = firstModule.getName();
  final String moduleNames = getModulesString(modulesInChunk);
  Messages.showMessageDialog(myProject, CompilerBundle.message("error.chunk.modules.must.have.same.language.level", moduleNames),
                             CommonBundle.getErrorTitle(), Messages.getErrorIcon());
  showConfigurationDialog(moduleNameToSelect, null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:CompileDriver.java

示例12: createConfiguration

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Nullable
@Override
protected BuildoutFacetConfiguration createConfiguration(Collection<VirtualFile> files) {
  VirtualFile source = ContainerUtil.getFirstItem(files);
  LOG.info("Detecting Buildout facet for " + source.getPath());
  final VirtualFile baseDir = source.getParent();
  final VirtualFile runner = BuildoutFacet.getRunner(baseDir);
  if (runner != null) {
    final File script = BuildoutFacet.findScript(null, "buildout", baseDir);
    if (script != null) {
      BuildoutFacetConfiguration configuration = new BuildoutFacetConfiguration(script.getName());
      configuration.setScriptName(script.getPath());
      final VirtualFile scriptVFile = LocalFileSystem.getInstance().findFileByIoFile(script);
      if (scriptVFile != null) {
        configuration.setPaths(BuildoutFacet.extractBuildoutPaths(scriptVFile));
      }
      else {
        LOG.info("Could not find virtual file for buildout script " + script);
      }
      return configuration;
    }
    else {
      LOG.info("No buildout script found");
    }
  }
  else {
    LOG.info("No runner script found");
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:BuildoutFrameworkDetector.java

示例13: assertHasCorrectErrorMessage

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
private void assertHasCorrectErrorMessage(@NotNull Collection<Message> messages,
                                          @NotNull String expectedText,
                                          long expectedLine,
                                          long expectedColumn) {
  assertEquals("[message count]", 1, messages.size());
  Message message = ContainerUtil.getFirstItem(messages);
  assertNotNull(message);
  assertEquals("[file path]", sourceFilePath, message.getSourcePath());
  assertEquals("[message severity]", Message.Kind.ERROR, message.getKind());
  assertEquals("[message text]", expectedText, message.getText());
  assertEquals("[position line]", expectedLine, message.getLineNumber());
  assertEquals("[position column]", expectedColumn, message.getColumn());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:BuildOutputParserTest.java

示例14: getPreferredModuleEncoding

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
public String getPreferredModuleEncoding(JpsModule module) {
  final Set<String> encodings = getModuleCharsetMap().get(module);
  return ContainerUtil.getFirstItem(encodings, null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:CompilerEncodingConfiguration.java

示例15: getDebuggableUrl

import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Nullable
public static Url getDebuggableUrl(@Nullable PsiElement context) {
  return ContainerUtil.getFirstItem(getDebuggableUrls(context));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:WebBrowserServiceImpl.java


注:本文中的com.intellij.util.containers.ContainerUtil.getFirstItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。