本文整理汇总了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);
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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());
}
示例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());
}
示例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);
}
示例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;
}
示例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());
}
示例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);
}
示例15: getDebuggableUrl
import com.intellij.util.containers.ContainerUtil; //导入方法依赖的package包/类
@Nullable
public static Url getDebuggableUrl(@Nullable PsiElement context) {
return ContainerUtil.getFirstItem(getDebuggableUrls(context));
}