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


Java ArrayUtil.getFirstElement方法代码示例

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


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

示例1: getVariants

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@NotNull
public Object[] getVariants() {
  final ASTNode categoryNode = getCategoryNode();
  if (categoryNode != null && categoryNode.getText().startsWith("In") && !categoryNode.getText().startsWith("Intelli")) {
    return UNICODE_BLOCKS;
  }
  else {
    boolean startsWithIs = categoryNode != null && categoryNode.getText().startsWith("Is");
    Collection<LookupElement> result = ContainerUtil.newArrayList();
    for (String[] properties : RegExpLanguageHosts.getInstance().getAllKnownProperties(getElement())) {
      String name = ArrayUtil.getFirstElement(properties);
      if (name != null) {
        String typeText = properties.length > 1 ? properties[1] : ("Character.is" + name.substring("java".length()) + "()");
        result.add(PrioritizedLookupElement.withPriority(LookupElementBuilder.create(name)
                                                           .withPresentableText(startsWithIs ? "Is" + name : name)
                                                           .withIcon(PlatformIcons.PROPERTY_ICON)
                                                           .withTypeText(typeText), getPriority(name)));
      }
    }
    return ArrayUtil.toObjectArray(result);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:RegExpPropertyImpl.java

示例2: getFirstStatement

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Nullable
private static PsiStatement getFirstStatement(@NotNull PsiStatement body) {
  if (body instanceof PsiBlockStatement) {
    final PsiBlockStatement block = (PsiBlockStatement)body;
    final PsiCodeBlock codeBlock = block.getCodeBlock();
    return ArrayUtil.getFirstElement(codeBlock.getStatements());
  }
  else {
    return body;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:WhileCanBeForeachInspection.java

示例3: chooseFile

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Nullable
public static VirtualFile chooseFile(@NotNull final FileChooserDescriptor descriptor,
                                     @Nullable final Component parent,
                                     @Nullable final Project project,
                                     @Nullable final VirtualFile toSelect) {
  LOG.assertTrue(!descriptor.isChooseMultiple());
  return ArrayUtil.getFirstElement(chooseFiles(descriptor, parent, project, toSelect));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:FileChooser.java

示例4: update

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Override
public void update(@NotNull AnActionEvent e) {
  FindUsagesInFileAction.updateFindUsagesAction(e);

  if (e.getPresentation().isEnabled()) {
    UsageTarget[] usageTargets = e.getData(UsageView.USAGE_TARGETS_KEY);
    if (usageTargets != null && !(ArrayUtil.getFirstElement(usageTargets) instanceof PsiElementUsageTarget)) {
      e.getPresentation().setEnabled(false);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ShowUsagesAction.java

示例5: getFileEditorProvider

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Override
public FileEditorProvider getFileEditorProvider() {
  return new FileEditorProvider() {
    @Override
    public FileEditor openFileEditor() {
      final VirtualFile file = myPsiFile.getVirtualFile();
      if (file == null) {
        return null;
      }
      return ArrayUtil.getFirstElement(FileEditorManager.getInstance(getProject()).openFile(file, false));
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:SelectInContextImpl.java

示例6: tryNotNullizeDirectory

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Nullable
private static PsiDirectory tryNotNullizeDirectory(@NotNull Project project, @Nullable PsiDirectory defaultTargetDirectory) {
  if (defaultTargetDirectory == null) {
    VirtualFile root = ArrayUtil.getFirstElement(ProjectRootManager.getInstance(project).getContentRoots());
    if (root == null) root = project.getBaseDir();
    if (root == null) root = VfsUtil.getUserHomeDir();
    defaultTargetDirectory = root != null ? PsiManager.getInstance(project).findDirectory(root) : null;

    if (defaultTargetDirectory == null) {
      LOG.warn("No directory found for project: " + project.getName() +", root: " + root);
    }
  }
  return defaultTargetDirectory;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:CopyFilesOrDirectoriesHandler.java

示例7: getImportPriority

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@NotNull
public static ImportPriority getImportPriority(@NotNull PyImportStatementBase importStatement) {
  final PsiElement resolved;
  if (importStatement instanceof PyFromImportStatement) {
    final PyFromImportStatement fromImportStatement = (PyFromImportStatement)importStatement;
    if (fromImportStatement.isFromFuture()) {
      return ImportPriority.FUTURE;
    }
    resolved = fromImportStatement.resolveImportSource();
  }
  else {
    final PyImportElement firstImportElement = ArrayUtil.getFirstElement(importStatement.getImportElements());
    if (firstImportElement == null) {
      return ImportPriority.THIRD_PARTY;
    }
    resolved = firstImportElement.resolve();
  }
  if (resolved == null) {
    return ImportPriority.THIRD_PARTY;
  }

  final PsiFileSystemItem resolvedFileOrDir;
  if (resolved instanceof PsiDirectory) {
    resolvedFileOrDir = (PsiFileSystemItem)resolved;
  }
  else {
    resolvedFileOrDir = resolved.getContainingFile();
  }
  return getImportPriority(importStatement, resolvedFileOrDir);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:AddImportHelper.java

示例8: addMissingAttributes

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
private static void addMissingAttributes(@NotNull XmlTag tag, @NotNull Map<String, String> attributes) {
  for (Map.Entry<String, String> attribute : attributes.entrySet()) {
    if (!XmlEmmetParser.DEFAULT_ATTRIBUTE_NAME.equals(attribute.getKey()) && tag.getAttribute(attribute.getKey()) == null) {
      XmlTag htmlTag = XmlElementFactory.getInstance(tag.getProject()).createHTMLTagFromText("<dummy " + attribute.getKey() + "=\"\"/>");
      final XmlAttribute newAttribute = ArrayUtil.getFirstElement(htmlTag.getAttributes());
      if (newAttribute != null) {
        tag.add(newAttribute);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:TemplateToken.java

示例9: getAnchor

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Nullable
private static GrStatement getAnchor(GrOpenBlock block) {
  GrStatement[] statements = block.getStatements();
  GrStatement fist = ArrayUtil.getFirstElement(statements);
  if (fist instanceof GrConstructorInvocation) {
    return statements.length > 1 ? statements[1] : null;
  }
  else {
    return fist;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:GrCreateFieldForParameterIntention.java

示例10: getModuleDefinitions

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@NotNull
    private List<MuleModuleDefinition> getModuleDefinitions(Project project, GlobalSearchScope searchScope) {
        final List<MuleModuleDefinition> result = new ArrayList<>();
        final Collection<VirtualFile> files = FileTypeIndex.getFiles(XmlFileType.INSTANCE, searchScope);
        for (VirtualFile file : files) {
            final PsiFile xmlFile = PsiManager.getInstance(project).findFile(file);
            if (xmlFile != null && isMuleSchema(xmlFile)) {
//                System.out.println("xmlFile = " + xmlFile.getName());
                final PsiElement[] children = xmlFile.getChildren();
                final XmlTag rootTag = ((XmlDocument) children[0]).getRootTag();
                if (rootTag != null) {
                    final String namespace = getNamespace(rootTag);
                    final String name = ArrayUtil.getLastElement(namespace.split("/"));
//                    System.out.println("namespace = " + namespace);
//                    System.out.println("name = " + name);
                    final XmlTag[] elements = rootTag.findSubTags("element", MuleSchemaUtils.HTTP_WWW_W3_ORG_2001_XMLSCHEMA);
                    final List<MuleElementDefinition> definitions = new ArrayList<>();
                    for (XmlTag element : elements) {
                        final String elementName = element.getAttributeValue("name");
//                        System.out.println("name = " + elementName);
                        final MuleElementType muleElementType = MuleSchemaUtils.getMuleElementTypeFromElement(element);
                        if (muleElementType != null) {
                            String description = "";
                            final XmlTag annotation = ArrayUtil.getFirstElement(element.findSubTags("annotation", MuleSchemaUtils.HTTP_WWW_W3_ORG_2001_XMLSCHEMA));
                            if (annotation != null) {
                                final XmlTag documentation = ArrayUtil.getFirstElement(annotation.findSubTags("documentation", MuleSchemaUtils.HTTP_WWW_W3_ORG_2001_XMLSCHEMA));
                                if (documentation != null) {
                                    description = documentation.getValue().getText();
                                }
                            }
                            definitions.add(new MuleElementDefinition(element, elementName, description, muleElementType));
//                            System.out.println("muleElementType = " + muleElementType);
//                            System.out.println("description = " + description);
                        }
                    }
                    result.add(new MuleModuleDefinition(name, StringUtil.capitalize(name), namespace, xmlFile, definitions));
                }
            }
        }
        return result;
    }
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:42,代码来源:MuleElementDefinitionService.java

示例11: getPsiClass

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
public PsiClass getPsiClass() {
  return ArrayUtil.getFirstElement(myClasses);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:ExceptionWorker.java

示例12: getFile

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
public PsiFile getFile() {
  return ArrayUtil.getFirstElement(myFiles);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:ExceptionWorker.java

示例13: getContentRoot

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
public static VirtualFile getContentRoot(Module module) {
  return ArrayUtil.getFirstElement(ModuleRootManager.getInstance(module).getContentRoots());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:ModuleDeploymentSourceImpl.java

示例14: customizeComponent

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Override
protected void customizeComponent(JList list, Object value, boolean isSelected) {
  ListPopupStep<Object> step = myPopup.getListStep();
  boolean isSelectable = step.isSelectable(value);
  myTextLabel.setEnabled(isSelectable);
  if (!isSelected && step instanceof BaseListPopupStep) {
    Color bg = ((BaseListPopupStep)step).getBackgroundFor(value);
    Color fg = ((BaseListPopupStep)step).getForegroundFor(value);
    if (fg != null) myTextLabel.setForeground(fg);
    if (bg != null) UIUtil.setBackgroundRecursively(myComponent, bg);
  }

  if (step.isMnemonicsNavigationEnabled()) {
    final int pos = step.getMnemonicNavigationFilter().getMnemonicPos(value);
    if (pos != -1) {
      String text = myTextLabel.getText();
      text = text.substring(0, pos) + text.substring(pos + 1);
      myTextLabel.setText(text);
      myTextLabel.setDisplayedMnemonicIndex(pos);
    }
  }
  else {
    myTextLabel.setDisplayedMnemonicIndex(-1);
  }

  if (step.hasSubstep(value) && isSelectable) {
    myNextStepLabel.setVisible(true);
    final boolean isDark = ColorUtil.isDark(UIUtil.getListSelectionBackground());
    myNextStepLabel.setIcon(isSelected ? isDark ? AllIcons.Icons.Ide.NextStepInverted
                                                : AllIcons.Icons.Ide.NextStep
                                       : AllIcons.Icons.Ide.NextStepGrayed);
  }
  else {
    myNextStepLabel.setVisible(false);
    //myNextStepLabel.setIcon(PopupIcons.EMPTY_ICON);
  }

  setSelected(myNextStepLabel, isSelected);


  if (myShortcutLabel != null) {
    myShortcutLabel.setText("");
    if (value instanceof ShortcutProvider) {
      ShortcutSet set = ((ShortcutProvider)value).getShortcut();
      if (set != null) {
        Shortcut shortcut = ArrayUtil.getFirstElement(set.getShortcuts());
        if (shortcut != null) {
          myShortcutLabel.setText("     " + KeymapUtil.getShortcutText(shortcut));
        }
      }
    }
    setSelected(myShortcutLabel, isSelected);
    myShortcutLabel.setForeground(isSelected ? UIManager.getColor("MenuItem.acceleratorSelectionForeground") : UIManager.getColor("MenuItem.acceleratorForeground"));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:PopupListElementRenderer.java

示例15: invoke

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) throws IncorrectOperationException {
  final PyStringLiteralExpression pyString = PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()),
                                                                         PyStringLiteralExpression.class);
  final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project);
  if (pyString != null) {
    final StringBuilder result = new StringBuilder();
    final List<StringNodeInfo> nodeInfos = extractStringNodesInfo(pyString);
    for (int i = 0; i < nodeInfos.size(); i++) {
      final StringNodeInfo info = nodeInfos.get(i);
      List<String> lines = StringUtil.split(info.getContent(), "\n", true, false);
      boolean lastLineExcluded = false;
      if (lines.size() > 1 && lines.get(lines.size() - 1).isEmpty()) {
        lastLineExcluded = true;
        lines = lines.subList(0, lines.size() - 1);
      }

      final boolean inLastNode = i == nodeInfos.size() - 1;
      for (int j = 0; j < lines.size(); j++) {
        final String line = lines.get(j);
        final boolean inLastLine = j == lines.size() - 1;

        if (info.isRaw()) {
          appendSplittedRawStringLine(result, info, line);
          if (!inLastLine || lastLineExcluded) {
            result.append(" ").append(info.getSingleQuote()).append("\\n").append(info.getSingleQuote());
          }
        }
        else {
          result.append(info.getPrefix());
          result.append(info.getSingleQuote());
          result.append(convertToValidSubString(line, info.getSingleQuote(), info.isTripleQuoted()));
          if (!inLastLine || lastLineExcluded) {
            result.append("\\n");
          }
          result.append(info.getSingleQuote());
        }
        if (!(inLastNode && inLastLine)) {
          result.append("\n");
        }
      }
    }
    if (result.indexOf("\n") >= 0) {
      result.insert(0, "(");
      result.append(")");
    }
    PyExpression expression = elementGenerator.createExpressionFromText(LanguageLevel.forElement(pyString), result.toString());

    final PsiElement parent = pyString.getParent();
    if (expression instanceof PyParenthesizedExpression &&
        (parent instanceof PyParenthesizedExpression ||
         parent instanceof PyTupleExpression ||
         parent instanceof PyArgumentList && ArrayUtil.getFirstElement(((PyArgumentList)parent).getArguments()) == pyString)) {
      expression = ((PyParenthesizedExpression)expression).getContainedExpression();
    }
    if (expression != null) {
      pyString.replace(expression);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:60,代码来源:PyConvertTripleQuotedStringIntention.java


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