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


Java PsiUtilCore.toPsiFileArray方法代码示例

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


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

示例1: getPsiFiles

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public static PsiFile[] getPsiFiles(final Project project, final Collection<VirtualFile> selectedFiles) {
  ArrayList<PsiFile> result = new ArrayList<PsiFile>();
  PsiManager psiManager = PsiManager.getInstance(project);

  VirtualFile projectFileDir = null;
  if (ProjectUtil.isDirectoryBased(project)) {
    VirtualFile baseDir = project.getBaseDir();
    if (baseDir != null) {
      projectFileDir = baseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
    }
  }

  for (VirtualFile file : selectedFiles) {
    if (file.isValid()) {
      if (isUnderProjectFileDir(projectFileDir, file) || !isFileUnderSourceRoot(project, file)
          || isOutOfSources(project, file)) {
        continue;
      }
      PsiFile psiFile = psiManager.findFile(file);
      if (psiFile != null) result.add(psiFile);
    }
  }
  return PsiUtilCore.toPsiFileArray(result);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:CheckinHandlerUtil.java

示例2: getItemsByName

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@Override
@NotNull
public NavigationItem[] getItemsByName(String name, final String pattern, Project project, boolean includeNonProjectItems) {
  final PsiManager psiManager = PsiManager.getInstance(project);
  final VirtualFile baseDir = project.getBaseDir();
  if (baseDir == null) return NavigationItem.EMPTY_NAVIGATION_ITEM_ARRAY;
  final VirtualFile[] files = baseDir.getChildren();
  final ArrayList<PsiFile> list = new ArrayList<PsiFile>();
  for (VirtualFile file : files) {
    if (isEditable(file, includeNonProjectItems) && Comparing.strEqual(name, file.getName())) {
      final PsiFile psiFile = psiManager.findFile(file);
      if (psiFile != null) {
        list.add(psiFile);
      }
    }
  }
  return PsiUtilCore.toPsiFileArray(list);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ProjectBaseDirNavigationContributor.java

示例3: getAssociationsFor

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public PsiFile[] getAssociationsFor(PsiFile file, FileType... fileTypes) {
  final VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null) return PsiFile.EMPTY_ARRAY;

  for (VirtualFilePointer pointer : myAssociations.keySet()) {
    if (pointer.isValid() && pointer.getUrl().equals(virtualFile.getUrl())) {
      final VirtualFilePointerContainer container = myAssociations.get(pointer);
      if (container != null) {
        final VirtualFile[] files = container.getFiles();
        final Set<PsiFile> list = new HashSet<PsiFile>();
        final PsiManager psiManager = PsiManager.getInstance(myProject);
        for (VirtualFile assoc : files) {
          final PsiFile psiFile = psiManager.findFile(assoc);
          if (psiFile != null && (fileTypes.length == 0 || matchesFileType(psiFile, fileTypes))) {
            list.add(psiFile);
          }
        }
        return PsiUtilCore.toPsiFileArray(list);
      }
      else {
        return PsiFile.EMPTY_ARRAY;
      }
    }
  }
  return PsiFile.EMPTY_ARRAY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:FileAssociationsManagerImpl.java

示例4: getTargetFiles

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
private PsiFile[] getTargetFiles() {
  Collection<PsiFile> fileList = new HashSet<PsiFile>();
  for(PsiClass psiClass: myTargetClasses) {
    fileList.add(psiClass.getContainingFile());
  }
  return PsiUtilCore.toPsiFileArray(fileList);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:CopyAbstractMethodImplementationHandler.java

示例5: getFilesWithTodoItems

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@Override
@NotNull
public PsiFile[] getFilesWithTodoItems() {
  if (myProject.isDefault()) {
    return PsiFile.EMPTY_ARRAY;
  }
  final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
  final Set<PsiFile> allFiles = new HashSet<PsiFile>();
  final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
  for (IndexPattern indexPattern : IndexPatternUtil.getIndexPatterns()) {
    final Collection<VirtualFile> files = fileBasedIndex.getContainingFiles(
      TodoIndex.NAME,
      new TodoIndexEntry(indexPattern.getPatternString(), indexPattern.isCaseSensitive()), GlobalSearchScope.allScope(myProject));
    ApplicationManager.getApplication().runReadAction(new Runnable() {
      @Override
      public void run() {
        for (VirtualFile file : files) {
          if (projectFileIndex.isInContent(file)) {
            final PsiFile psiFile = myPsiManager.findFile(file);
            if (psiFile != null) {
              allFiles.add(psiFile);
            }
          }
        }
      }
    });
  }
  return allFiles.isEmpty() ? PsiFile.EMPTY_ARRAY : PsiUtilCore.toPsiFileArray(allFiles);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:IndexTodoCacheManagerImpl.java

示例6: getFiles

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@Override
@NotNull
public PsiFile[] getFiles() {
  LOG.assertTrue(myFile.isValid());
  VirtualFile[] files = myFile.getChildren();
  ArrayList<PsiFile> psiFiles = new ArrayList<PsiFile>();
  for (VirtualFile file : files) {
    PsiFile psiFile = myManager.findFile(file);
    if (psiFile != null) {
      psiFiles.add(psiFile);
    }
  }
  return PsiUtilCore.toPsiFileArray(psiFiles);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:PsiDirectoryImpl.java

示例7: convertToPsiFiles

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public static PsiFile[] convertToPsiFiles(final VirtualFile[] files,Project project) {
  final PsiManager manager = PsiManager.getInstance(project);
  final ArrayList<PsiFile> result = new ArrayList<PsiFile>();
  for (VirtualFile virtualFile : files) {
    final PsiFile psiFile = manager.findFile(virtualFile);
    if (psiFile != null) result.add(psiFile);
  }
  return PsiUtilCore.toPsiFileArray(result);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ReformatCodeAction.java

示例8: createUsageViewDescriptor

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@NotNull
@Override
protected UsageViewDescriptor createUsageViewDescriptor(@NotNull UsageInfo[] usages) {
  PsiElement[] elements = new PsiElement[myFilesToMove.size()];
  final PsiFile[] classes = PsiUtilCore.toPsiFileArray(myFilesToMove.keySet());
  System.arraycopy(classes, 0, elements, 0, classes.length);
  return new MoveMultipleElementsViewDescriptor(elements, getTargetName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:MoveDirectoryWithClassesProcessor.java

示例9: getFiles

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
private static PsiFile[] getFiles(@NotNull PsiFile file, @NotNull MavenDomProjectModel model, @NotNull Set<MavenDomDependency> usages) {
  Set<PsiFile> files = new HashSet<PsiFile>();

  files.add(file);
  XmlElement xmlElement = model.getXmlElement();
  if (xmlElement != null) files.add(xmlElement.getContainingFile());
  for (MavenDomDependency usage : usages) {
    XmlElement element = usage.getXmlElement();
    if (element != null) {
      files.add(element.getContainingFile());
    }
  }

  return PsiUtilCore.toPsiFileArray(files);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ExtractManagedDependenciesAction.java

示例10: getChildElements

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@Override
public Object[] getChildElements(final Object element) {
  if (myRootElement == element) {
    if (myRootPsiElement == null) {
      return ArrayUtil.EMPTY_OBJECT_ARRAY;
    }
    if (!(myRootPsiElement instanceof PsiFile)) {
      return new Object[]{myRootPsiElement};
    }
    List<PsiFile> files = ((PsiFile)myRootPsiElement).getViewProvider().getAllFiles();
    return PsiUtilCore.toPsiFileArray(files);
  }
  final Object[][] children = new Object[1][];
  children[0] = ArrayUtil.EMPTY_OBJECT_ARRAY;
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    @Override
    public void run() {
      final Object[] result;
      if (myShowTreeNodes) {
        final ArrayList<Object> list = new ArrayList<Object>();
        ASTNode root = element instanceof PsiElement? SourceTreeToPsiMap.psiElementToTree((PsiElement)element) :
                             element instanceof ASTNode? (ASTNode)element : null;
        if (element instanceof Inject) {
          root = SourceTreeToPsiMap.psiElementToTree(((Inject)element).getPsi());
        }

        if (root != null) {
          ASTNode child = root.getFirstChildNode();
          while (child != null) {
            if (myShowWhiteSpaces || child.getElementType() != TokenType.WHITE_SPACE) {
              final PsiElement childElement = child.getPsi();
              list.add(childElement == null ? child : childElement);
            }
            child = child.getTreeNext();
          }
          final PsiElement psi = root.getPsi();
          if (psi instanceof PsiLanguageInjectionHost) {
            InjectedLanguageUtil.enumerate(psi, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
              @Override
              public void visit(@NotNull PsiFile injectedPsi, @NotNull List<PsiLanguageInjectionHost.Shred> places) {
                list.add(new Inject(psi, injectedPsi));
              }
            });
          }
        }
        result = ArrayUtil.toObjectArray(list);
      }
      else {
        final PsiElement[] elementChildren = ((PsiElement)element).getChildren();
        if (!myShowWhiteSpaces) {
          final List<PsiElement> childrenList = new ArrayList<PsiElement>(elementChildren.length);
          for (PsiElement psiElement : elementChildren) {
            if (!myShowWhiteSpaces && psiElement instanceof PsiWhiteSpace) {
              continue;
            }
            childrenList.add(psiElement);
          }
          result = PsiUtilCore.toPsiElementArray(childrenList);
        }
        else {
          result = elementChildren;
        }
      }
      children[0] = result;
    }
  });
  return children[0];
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:69,代码来源:ViewerTreeStructure.java

示例11: getFormFiles

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public PsiFile[] getFormFiles() {
  return PsiUtilCore.toPsiFileArray(myFormFiles);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:Form.java

示例12: createHandler

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@NotNull
public CheckinHandler createHandler(@NotNull final CheckinProjectPanel panel, @NotNull CommitContext commitContext) {
  return new CheckinHandler() {
    @Override
    public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
      final JCheckBox updateCopyrightCb = new JCheckBox("Update copyright");
      return new RefreshableOnComponent() {
        public JComponent getComponent() {
          return JBUI.Panels.simplePanel().addToLeft(updateCopyrightCb);
        }

        public void refresh() {
        }

        public void saveState() {
          UpdateCopyrightCheckinHandlerState.getInstance(panel.getProject()).UPDATE_COPYRIGHT = updateCopyrightCb.isSelected();
        }

        public void restoreState() {
          updateCopyrightCb.setSelected(UpdateCopyrightCheckinHandlerState.getInstance(panel.getProject()).UPDATE_COPYRIGHT);
        }
      };
    }

    @Override
    public ReturnResult beforeCheckin(@Nullable CommitExecutor executor, PairConsumer<Object, Object> additionalDataConsumer) {
      if (UpdateCopyrightCheckinHandlerState.getInstance(panel.getProject()).UPDATE_COPYRIGHT) {
        new UpdateCopyrightProcessor(panel.getProject(), null, getPsiFiles()).run();
        FileDocumentManager.getInstance().saveAllDocuments();
      }
      return super.beforeCheckin();
    }

    private PsiFile[] getPsiFiles() {
      final Collection<VirtualFile> files = panel.getVirtualFiles();
      final List<PsiFile> psiFiles = new ArrayList<PsiFile>();
      final PsiManager manager = PsiManager.getInstance(panel.getProject());
      for (final VirtualFile file : files) {
        final PsiFile psiFile = manager.findFile(file);
        if (psiFile != null) {
          psiFiles.add(psiFile);
        }
      }
      return PsiUtilCore.toPsiFileArray(psiFiles);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:48,代码来源:UpdateCopyrightCheckinHandlerFactory.java


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