Java 类com.intellij.openapi.project.ProjectCoreUtil 实例源码

项目:intellij-ce-playground    文件:AnalysisScope.java   
private void accept(@NotNull final PsiElementVisitor visitor, final boolean clearResolveCache) {
  final boolean needReadAction = !ApplicationManager.getApplication().isReadAccessAllowed();
  final PsiManager psiManager = PsiManager.getInstance(myProject);
  final FileIndex fileIndex = getFileIndex();
  accept(new Processor<VirtualFile>() {
    @Override
    public boolean process(VirtualFile file) {
      if (file.isDirectory()) return true;
      if (ProjectCoreUtil.isProjectOrWorkspaceFile(file)) return true;
      if (fileIndex.isInContent(file) && (myIncludeTestSource || !fileIndex.isInTestSourceContent(file))
          && !isInGeneratedSources(file, myProject)) {
        return processFile(file, visitor, psiManager, needReadAction, clearResolveCache);
      }
      return true;
    }
  });
}
项目:intellij-ce-playground    文件:MergeVersion.java   
@Nullable
public static Runnable prepareToReportChangedProjectFiles(@NotNull final Project project, @NotNull Collection<VirtualFile> files) {
  final Set<VirtualFile> vfs = new THashSet<VirtualFile>();
  for (VirtualFile file : files) {
    if (file != null && !file.isDirectory()) {
      if (ProjectCoreUtil.isProjectOrWorkspaceFile(file) || isProjectFile(file)) {
        vfs.add(file);
      }
    }
  }
  return vfs.isEmpty() ? null : new Runnable() {
    @Override
    public void run() {
      ProjectManagerEx ex = ProjectManagerEx.getInstanceEx();
      for (VirtualFile vf : vfs) {
        ex.saveChangedProjectFile(vf, project);
      }
    }
  };
}
项目:intellij-ce-playground    文件:TreeElement.java   
public PsiManagerEx getManager() {
  Project project = ProjectCoreUtil.theOnlyOpenProject();
  if (project != null) {
    return (PsiManagerEx)PsiManager.getInstance(project);
  }
  TreeElement element;
  for (element = this; element.getTreeParent() != null; element = element.getTreeParent()) {
  }

  if (element instanceof FileElement) { //TODO!!
    return element.getManager();
  }
  else {
    if (getTreeParent() != null) {
      return getTreeParent().getManager();
    }
    return null;
  }
}
项目:intellij-ce-playground    文件:HighlightingSettingsPerFile.java   
@Override
public boolean shouldInspect(@NotNull PsiElement psiRoot) {
  if (ApplicationManager.getApplication().isUnitTestMode()) return true;

  final FileHighlightingSetting settingForRoot = getHighlightingSettingForRoot(psiRoot);
  if (settingForRoot == FileHighlightingSetting.SKIP_HIGHLIGHTING ||
      settingForRoot == FileHighlightingSetting.SKIP_INSPECTION) {
    return false;
  }
  final Project project = psiRoot.getProject();
  final VirtualFile virtualFile = psiRoot.getContainingFile().getVirtualFile();
  if (virtualFile == null || !virtualFile.isValid()) return false;

  if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false;

  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  if (ProjectScope.getLibrariesScope(project).contains(virtualFile) && !fileIndex.isInContent(virtualFile)) return false;

  return !SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile);
}
项目:tools-idea    文件:HighlightLevelUtil.java   
public static boolean shouldInspect(@NotNull PsiElement psiRoot) {
  if (ApplicationManager.getApplication().isUnitTestMode()) return true;

  if (!shouldHighlight(psiRoot)) return false;
  final Project project = psiRoot.getProject();
  final VirtualFile virtualFile = psiRoot.getContainingFile().getVirtualFile();
  if (virtualFile == null || !virtualFile.isValid()) return false;

  if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false;

  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  if (ProjectScope.getLibrariesScope(project).contains(virtualFile) && !fileIndex.isInContent(virtualFile)) return false;

  if (SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile)) return false;

  final HighlightingSettingsPerFile component = HighlightingSettingsPerFile.getInstance(project);
  if (component == null) return true;

  final FileHighlightingSetting settingForRoot = component.getHighlightingSettingForRoot(psiRoot);
  return settingForRoot != FileHighlightingSetting.SKIP_INSPECTION;
}
项目:consulo    文件:AnalysisScope.java   
private void accept(@Nonnull final PsiElementVisitor visitor, final boolean clearResolveCache) {
  final boolean needReadAction = !ApplicationManager.getApplication().isReadAccessAllowed();
  final PsiManager psiManager = PsiManager.getInstance(myProject);
  final FileIndex fileIndex = getFileIndex();
  accept(new Processor<VirtualFile>() {
    @Override
    public boolean process(VirtualFile file) {
      if (file.isDirectory()) return true;
      if (ProjectCoreUtil.isProjectOrWorkspaceFile(file)) return true;
      if (fileIndex.isInContent(file) && (myIncludeTestSource || !fileIndex.isInTestSourceContent(file))
          && !isInGeneratedSources(file, myProject)) {
        return processFile(file, visitor, psiManager, needReadAction, clearResolveCache);
      }
      return true;
    }
  });
}
项目:consulo    文件:ASTDelegatePsiElement.java   
@Override
public PsiManagerEx getManager() {
  Project project = ProjectCoreUtil.theOnlyOpenProject();
  if (project != null) {
    return PsiManagerEx.getInstanceEx(project);
  }
  PsiElement parent = this;

  while (parent instanceof ASTDelegatePsiElement) {
    parent = parent.getParent();
  }

  if (parent == null) {
    throw new PsiInvalidElementAccessException(this);
  }

  return (PsiManagerEx)parent.getManager();
}
项目:consulo    文件:TreeElement.java   
public PsiManagerEx getManager() {
  Project project = ProjectCoreUtil.theOnlyOpenProject();
  if (project != null) {
    return PsiManagerEx.getInstanceEx(project);
  }
  TreeElement element;
  for (element = this; element.getTreeParent() != null; element = element.getTreeParent()) {
  }

  if (element instanceof FileElement) { //TODO!!
    return element.getManager();
  }
  else {
    if (getTreeParent() != null) {
      return getTreeParent().getManager();
    }
    return null;
  }
}
项目:consulo    文件:HighlightingSettingsPerFile.java   
@Override
public boolean shouldInspect(@Nonnull PsiElement psiRoot) {
  if (ApplicationManager.getApplication().isUnitTestMode()) return true;

  if (!shouldHighlight(psiRoot)) return false;
  final Project project = psiRoot.getProject();
  final VirtualFile virtualFile = psiRoot.getContainingFile().getVirtualFile();
  if (virtualFile == null || !virtualFile.isValid()) return false;

  if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false;

  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  if (ProjectScope.getLibrariesScope(project).contains(virtualFile) && !fileIndex.isInContent(virtualFile)) return false;

  if (SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile)) return false;

  final FileHighlightingSetting settingForRoot = getHighlightingSettingForRoot(psiRoot);
  return settingForRoot != FileHighlightingSetting.SKIP_INSPECTION;
}
项目:consulo    文件:HighlightLevelUtil.java   
public static boolean shouldInspect(@Nonnull PsiElement psiRoot) {
  if (ApplicationManager.getApplication().isUnitTestMode()) return true;

  if (!shouldHighlight(psiRoot)) return false;
  final Project project = psiRoot.getProject();
  final VirtualFile virtualFile = psiRoot.getContainingFile().getVirtualFile();
  if (virtualFile == null || !virtualFile.isValid()) return false;

  if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false;

  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  if (ProjectScope.getLibrariesScope(project).contains(virtualFile) && !fileIndex.isInContent(virtualFile)) return false;

  if (SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile)) return false;

  final HighlightingSettingsPerFile component = HighlightingSettingsPerFile.getInstance(project);
  if (component == null) return true;

  final FileHighlightingSetting settingForRoot = component.getHighlightingSettingForRoot(psiRoot);
  return settingForRoot != FileHighlightingSetting.SKIP_INSPECTION;
}
项目:intellij-ce-playground    文件:DelayedDocumentWatcher.java   
@Override
public void documentChanged(DocumentEvent event) {
  if (myDocumentSavingInProgress) {
    /** When {@link FileDocumentManager#saveAllDocuments} is called,
     *  {@link com.intellij.openapi.editor.impl.TrailingSpacesStripper} can change a document.
     *  These needless 'documentChanged' events should be filtered out.
     */
    return;
  }
  final Document document = event.getDocument();
  final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
  if (file == null) {
    return;
  }
  if (!myChangedFiles.contains(file)) {
    if (ProjectCoreUtil.isProjectOrWorkspaceFile(file)) {
      return;
    }
    if (myChangedFileFilter != null && !myChangedFileFilter.value(file)) {
      return;
    }

    myChangedFiles.add(file);
  }

  myAlarm.cancelRequest(myAlarmRunnable);
  myAlarm.addRequest(myAlarmRunnable, myDelayMillis);
  myModificationStamp++;
}
项目:intellij-ce-playground    文件:LazyParseablePsiElement.java   
@Override
@NotNull
public Project getProject() {
  Project project = ProjectCoreUtil.theOnlyOpenProject();
  if (project != null) {
    return project;
  }
  final PsiManager manager = getManager();
  if (manager == null) throw new PsiInvalidElementAccessException(this);

  return manager.getProject();
}
项目:intellij-ce-playground    文件:CompositePsiElement.java   
@Override
@NotNull
public Project getProject() {
  Project project = ProjectCoreUtil.theOnlyOpenProject();
  if (project != null) {
    return project;
  }
  final PsiManager manager = getManager();
  if (manager == null) throw new PsiInvalidElementAccessException(this);

  return manager.getProject();
}
项目:intellij-ce-playground    文件:LeafPsiElement.java   
@Override
@NotNull
public Project getProject() {
  Project project = ProjectCoreUtil.theOnlyOpenProject();
  if (project != null) {
    return project;
  }
  final PsiManager manager = getManager();
  if (manager == null) invalid();
  return manager.getProject();
}
项目:intellij-ce-playground    文件:FileTypeUtil.java   
public boolean isSupportedFile(VirtualFile file) {
  if (file == null || file.isDirectory()) {
    return false;
  }

  if (ProjectCoreUtil.isProjectOrWorkspaceFile(file)) return false;
  FileType type = file.getFileType();

  return getMap().get(type.getName()) != null;
}
项目:intellij-ce-playground    文件:FileTypeUtil.java   
public static boolean isSupportedFile(PsiFile file) {
  if (file == null || file instanceof PsiDirectory || file instanceof PsiCodeFragment) {
    return false;
  }
  final VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null) return false;
  if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false;
  return isSupportedType(virtualFile.getFileType());
}
项目:tools-idea    文件:AnalysisScope.java   
@SuppressWarnings({"SimplifiableIfStatement"})
private boolean processFile(@NotNull final VirtualFile fileOrDir,
                            @NotNull final PsiElementVisitor visitor,
                            @NotNull final FileIndex projectFileIndex,
                            @NotNull final PsiManager psiManager,
                            final boolean needReadAction) {
  if (fileOrDir.isDirectory()) return true;
  if (ProjectCoreUtil.isProjectOrWorkspaceFile(fileOrDir)) return true;
  if (projectFileIndex.isInContent(fileOrDir) && (myIncludeTestSource || !projectFileIndex.isInTestSourceContent(fileOrDir))) {
    return processFile(fileOrDir, visitor, psiManager, needReadAction);
  }
  return true;
}
项目:tools-idea    文件:MergeVersion.java   
public static void reportProjectFileChangeIfNeeded(Project project, VirtualFile file) {
  if (file != null && ! file.isDirectory()) {
    if (ProjectCoreUtil.isProjectOrWorkspaceFile(file) || isProjectFile(file)) {
      ProjectManagerEx.getInstanceEx().saveChangedProjectFile(file, project);
    }
  }
}
项目:tools-idea    文件:FileTypeUtil.java   
public boolean isSupportedFile(VirtualFile file) {
  if (file == null || file.isDirectory()) {
    return false;
  }

  if (ProjectCoreUtil.isProjectOrWorkspaceFile(file)) return false;
  FileType type = file.getFileType();

  return getMap().get(type.getName()) != null;
}
项目:tools-idea    文件:FileTypeUtil.java   
public static boolean isSupportedFile(PsiFile file) {
  if (file == null || file instanceof PsiDirectory) {
    return false;
  }
  final VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null) return false;
  if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false;
  return isSupportedType(virtualFile.getFileType());
}
项目:consulo    文件:DelayedDocumentWatcher.java   
@Override
public void documentChanged(DocumentEvent event) {
  if (myDocumentSavingInProgress) {
    /* When {@link FileDocumentManager#saveAllDocuments} is called,
       {@link com.intellij.openapi.editor.impl.TrailingSpacesStripper} can change a document.
       These needless 'documentChanged' events should be filtered out.
     */
    return;
  }
  final Document document = event.getDocument();
  final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
  if (file == null) {
    return;
  }
  if (!myChangedFiles.contains(file)) {
    if (ProjectCoreUtil.isProjectOrWorkspaceFile(file)) {
      return;
    }
    if (myChangedFileFilter != null && !myChangedFileFilter.value(file)) {
      return;
    }

    myChangedFiles.add(file);
  }

  myAlarm.cancelRequest(myAlarmRunnable);
  myAlarm.addRequest(myAlarmRunnable, myDelayMillis);
  myModificationStamp++;
}
项目:consulo    文件:MergeVersion.java   
public static void reportProjectFileChangeIfNeeded(Project project, VirtualFile file) {
  if (file != null && ! file.isDirectory()) {
    if (ProjectCoreUtil.isProjectOrWorkspaceFile(file) || isProjectFile(file)) {
      ProjectManagerEx.getInstanceEx().saveChangedProjectFile(file, project);
    }
  }
}
项目:consulo    文件:StubBasedPsiElementBase.java   
@Override
public PsiManagerEx getManager() {
  Project project = ProjectCoreUtil.theOnlyOpenProject();
  if (project != null) {
    return PsiManagerEx.getInstanceEx(project);
  }
  return (PsiManagerEx)getContainingFile().getManager();
}
项目:consulo    文件:StubBasedPsiElementBase.java   
@Override
@Nonnull
public Project getProject() {
  Project project = ProjectCoreUtil.theOnlyOpenProject();
  if (project != null) {
    return project;
  }
  return getContainingFile().getProject();
}
项目:consulo    文件:LazyParseablePsiElement.java   
@Override
@Nonnull
public Project getProject() {
  Project project = ProjectCoreUtil.theOnlyOpenProject();
  if (project != null) {
    return project;
  }
  final PsiManager manager = getManager();
  if (manager == null) throw new PsiInvalidElementAccessException(this);

  return manager.getProject();
}
项目:consulo    文件:CompositePsiElement.java   
@Override
@Nonnull
public Project getProject() {
  Project project = ProjectCoreUtil.theOnlyOpenProject();
  if (project != null) {
    return project;
  }
  final PsiManager manager = getManager();
  if (manager == null) throw new PsiInvalidElementAccessException(this);

  return manager.getProject();
}
项目:consulo    文件:LeafPsiElement.java   
@Override
@Nonnull
public Project getProject() {
  Project project = ProjectCoreUtil.theOnlyOpenProject();
  if (project != null) {
    return project;
  }
  final PsiManager manager = getManager();
  if (manager == null) invalid();
  return manager.getProject();
}
项目:intellij-csv-validator    文件:CsvCodeStyleSettings.java   
public static String getCurrentSeparator() {
    return getCurrentSeparator(ProjectCoreUtil.theOnlyOpenProject());
}
项目:intellij-ce-playground    文件:MergeVersion.java   
public static void reportProjectFileChangeIfNeeded(@Nullable Project project, @Nullable VirtualFile file) {
  if (project != null && file != null && !file.isDirectory() && (ProjectCoreUtil.isProjectOrWorkspaceFile(file) || isProjectFile(file))) {
    ProjectManagerEx.getInstanceEx().saveChangedProjectFile(file, project);
  }
}
项目:intellij-ce-playground    文件:PsiChangeHandler.java   
private boolean shouldBeIgnored(@NotNull VirtualFile virtualFile) {
  return ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile) ||
         ProjectRootManager.getInstance(myProject).getFileIndex().isExcluded(virtualFile);
}
项目:consulo    文件:PsiChangeHandler.java   
private boolean shouldBeIgnored(@Nonnull VirtualFile virtualFile) {
  return ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile) ||
         ProjectRootManager.getInstance(myProject).getFileIndex().isExcluded(virtualFile);
}