Java DirectoryIndex类代码示例(javadirectoryindex类代码示例汇总)

本文整理汇总了Java中com.intellij.openapi.roots.impl.DirectoryIndex的典型用法代码示例。如果您正苦于以下问题:Java DirectoryIndex类的具体用法?Java DirectoryIndex怎么用?Java DirectoryIndex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Java DirectoryIndex类代码示例(javadirectoryindex类代码示例汇总)

DirectoryIndex类属于com.intellij.openapi.roots.impl包,在下文中一共展示了DirectoryIndex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: findResourceFileInScope

import com.intellij.openapi.roots.impl.DirectoryIndex; //导入依赖的package包/类
@Nullable
public static VirtualFile findResourceFileInScope(final String resourceName,
                                                  final Project project,
                                                  final GlobalSearchScope scope) {
  int index = resourceName.lastIndexOf('/');
  String packageName = index >= 0 ? resourceName.substring(0, index).replace('/', '.') : "";
  final String fileName = index >= 0 ? resourceName.substring(index+1) : resourceName;

  final VirtualFile dir = new FilteredQuery<VirtualFile>(
    DirectoryIndex.getInstance(project).getDirectoriesByPackageName(packageName, false), new Condition<VirtualFile>() {
    @Override
    public boolean value(final VirtualFile file) {
      final VirtualFile child = file.findChild(fileName);
      return child != null && scope.contains(child);
    }
  }).findFirst();
  return dir != null ? dir.findChild(fileName) : null;
} 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ResourceFileUtil.java

示例2: getContextsForModule

import com.intellij.openapi.roots.impl.DirectoryIndex; //导入依赖的package包/类
static Collection<PsiFileSystemItem> getContextsForModule(@NotNull Module module, @NotNull String packageName, @Nullable GlobalSearchScope scope) {
  List<PsiFileSystemItem> result = null;
  Query<VirtualFile> query = DirectoryIndex.getInstance(module.getProject()).getDirectoriesByPackageName(packageName, false);
  PsiManager manager = null;

  for(VirtualFile file:query) {
    if (scope != null && !scope.contains(file)) continue;
    if (result == null) {
      result = new ArrayList<PsiFileSystemItem>();
      manager = PsiManager.getInstance(module.getProject());
    }
    PsiDirectory psiDirectory = manager.findDirectory(file);
    if (psiDirectory != null) result.add(psiDirectory);
  }

  return result != null ? result:Collections.<PsiFileSystemItem>emptyList();
} 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PsiFileReferenceHelper.java

示例3: findParentModule

import com.intellij.openapi.roots.impl.DirectoryIndex; //导入依赖的package包/类
@Nullable
private static Module findParentModule(@Nullable Project project, @NotNull VirtualFile[] files) {
  if (project == null) return null;
  Module result = null;
  DirectoryIndex index = DirectoryIndex.getInstance(project);
  for (VirtualFile file : files) {
    Module module = index.getInfoForFile(file).getModule();
    if (module == null) return null;
    if (result == null) {
      result = module;
    }
    else if (!result.equals(module)) {
      return null;
    }
  }
  return result;
} 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MarkRootActionBase.java

示例4: findLongestExistingPackage

import com.intellij.openapi.roots.impl.DirectoryIndex; //导入依赖的package包/类
@Nullable
private static String findLongestExistingPackage(Project project, String packageName, GlobalSearchScope scope) {
  final PsiManager manager = PsiManager.getInstance(project);
  DirectoryIndex index = DirectoryIndex.getInstance(project);

  String nameToMatch = packageName;
  while (true) {
    Query<VirtualFile> vFiles = index.getDirectoriesByPackageName(nameToMatch, false);
    PsiDirectory directory = getWritableModuleDirectory(vFiles, scope, manager);
    if (directory != null) return index.getPackageName(directory.getVirtualFile());

    int lastDotIndex = nameToMatch.lastIndexOf('.');
    if (lastDotIndex >= 0) {
      nameToMatch = nameToMatch.substring(0, lastDotIndex);
    }
    else {
      return null;
    }
  }
} 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PlatformPackageUtil.java

示例5: getPackageDirectories

import com.intellij.openapi.roots.impl.DirectoryIndex; //导入依赖的package包/类
private static PsiDirectory[] getPackageDirectories(Project project, String rootPackage, final GlobalSearchScope scope) {
  final PsiManager manager = PsiManager.getInstance(project);

  Query<VirtualFile> query = DirectoryIndex.getInstance(scope.getProject()).getDirectoriesByPackageName(rootPackage, true);
  query = new FilteredQuery<VirtualFile>(query, new Condition<VirtualFile>() {
    @Override
    public boolean value(VirtualFile virtualFile) {
      return scope.contains(virtualFile);
    }
  });

  List<PsiDirectory> directories = ContainerUtil.mapNotNull(query.findAll(), new Function<VirtualFile, PsiDirectory>() {
    @Override
    public PsiDirectory fun(VirtualFile virtualFile) {
      return manager.findDirectory(virtualFile);
    }
  });
  return directories.toArray(new PsiDirectory[directories.size()]);
} 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PlatformPackageUtil.java

示例6: projectOpened

import com.intellij.openapi.roots.impl.DirectoryIndex; //导入依赖的package包/类
@Override
public void projectOpened() {
  MessageBusConnection connection = myProject.getMessageBus().connect(myProject);
  connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          if (myProject.isDisposed() || !DirectoryIndex.getInstance(myProject).isInitialized()) return;
          VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
        }
      }, ModalityState.NON_MODAL);
    }
  });
  final WolfTheProblemSolver.ProblemListener myProblemListener = new MyProblemListener();
  WolfTheProblemSolver.getInstance(myProject).addProblemListener(myProblemListener,myProject);
} 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:VcsEventWatcher.java

示例7: findResourceFileInScope

import com.intellij.openapi.roots.impl.DirectoryIndex; //导入依赖的package包/类
@Nullable
public static VirtualFile findResourceFileInScope(final String resourceName,
                                                  final Project project,
                                                  final GlobalSearchScope scope) {
  int index = resourceName.lastIndexOf('/');
  String packageName = index >= 0 ? resourceName.substring(0, index).replace('/', '.') : "";
  final String fileName = index >= 0 ? resourceName.substring(index+1) : resourceName;
  Query<VirtualFile> directoriesByPackageName = DirectoryIndex.getInstance(project).getDirectoriesByPackageName(packageName, true);
  for (VirtualFile virtualFile : directoriesByPackageName) {
    final VirtualFile child = virtualFile.findChild(fileName);
    if(child != null && scope.contains(child)) {
      return child;
    }
  }
  return null;
} 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:ResourceFileUtil.java

示例8: getContextsForModule

import com.intellij.openapi.roots.impl.DirectoryIndex; //导入依赖的package包/类
static Collection<PsiFileSystemItem> getContextsForModule(@Nonnull Module module, @Nonnull String packageName, @Nullable GlobalSearchScope scope) {
  List<PsiFileSystemItem> result = null;
  Query<VirtualFile> query = DirectoryIndex.getInstance(module.getProject()).getDirectoriesByPackageName(packageName, false);
  PsiManager manager = null;

  for (VirtualFile file : query) {
    if (scope != null && !scope.contains(file)) continue;
    if (result == null) {
      result = new ArrayList<>();
      manager = PsiManager.getInstance(module.getProject());
    }
    PsiDirectory psiDirectory = manager.findDirectory(file);
    if (psiDirectory != null) result.add(psiDirectory);
  }

  return result != null ? result : Collections.emptyList();
} 
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:PsiFileReferenceHelper.java

示例9: processPackageDirectories

import com.intellij.openapi.roots.impl.DirectoryIndex; //导入依赖的package包/类
@Override
public boolean processPackageDirectories(@NotNull PsiJavaPackage psiPackage, @NotNull final GlobalSearchScope scope, @NotNull final Processor<PsiDirectory> consumer)
{
	final PsiManager psiManager = PsiManager.getInstance(getProject());
	return DirectoryIndex.getInstance(getProject()).getDirectoriesByPackageName(psiPackage.getQualifiedName(), false).forEach(new ReadActionProcessor<VirtualFile>()
	{
		@RequiredReadAction
		@Override
		public boolean processInReadAction(final VirtualFile dir)
		{
			if(!scope.contains(dir))
			{
				return true;
			}
			PsiDirectory psiDir = psiManager.findDirectory(dir);
			return psiDir == null || consumer.process(psiDir);
		}
	});
} 
开发者ID:consulo,项目名称:consulo-java,代码行数:20,代码来源:JavaPsiFacadeImpl.java

示例10: findLongestExistingPackage

import com.intellij.openapi.roots.impl.DirectoryIndex; //导入依赖的package包/类
private static PsiJavaPackage findLongestExistingPackage(Module module, String packageName)
{
	final PsiManager manager = PsiManager.getInstance(module.getProject());

	String nameToMatch = packageName;
	while(true)
	{
		Query<VirtualFile> vFiles = DirectoryIndex.getInstance(module.getProject()).getDirectoriesByPackageName(nameToMatch, false);
		PsiDirectory directory = getWritableModuleDirectory(vFiles, module, manager);
		if(directory != null)
		{
			return JavaDirectoryService.getInstance().getPackage(directory);
		}

		int lastDotIndex = nameToMatch.lastIndexOf('.');
		if(lastDotIndex >= 0)
		{
			nameToMatch = nameToMatch.substring(0, lastDotIndex);
		}
		else
		{
			return null;
		}
	}
} 
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:PackageUtil.java

示例11: JavaCoreProjectEnvironment

import com.intellij.openapi.roots.impl.DirectoryIndex; //导入依赖的package包/类
public JavaCoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
   super(parentDisposable, applicationEnvironment);

   myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myPsiManager));
   myProject.registerService(JavaPsiImplementationHelper.class, createJavaPsiImplementationHelper());
   myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager));
   myProject.registerService(JavaResolveCache.class, new JavaResolveCache(myMessageBus));
   myProject.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
   myProject.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());
   registerProjectExtensionPoint(PsiElementFinder.EP_NAME, PsiElementFinder.class);

/*   myPackageIndex = createCorePackageIndex();
   myProject.registerService(PackageIndex.class, myPackageIndex);     */

   myFileManager = createCoreFileManager();
   myProject.registerService(JavaFileManager.class, myFileManager);

   PsiPackageManager manager = new PsiPackageManagerImpl(getProject(), DirectoryIndex.getInstance(getProject()));

   myProject.registerService(PsiPackageManager.class, manager);

   JavaPsiFacadeImpl javaPsiFacade = new JavaPsiFacadeImpl(myProject, manager);
   registerProjectComponent(JavaPsiFacade.class, javaPsiFacade);
   myProject.registerService(JavaPsiFacade.class, javaPsiFacade);
 } 
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:JavaCoreProjectEnvironment.java

示例12: getClassesLanguageLevel

import com.intellij.openapi.roots.impl.DirectoryIndex; //导入依赖的package包/类
/**
 * For files under a library source root, returns the language level configured for the corresponding classes root.
 *
 * @param virtualFile virtual file for which language level is requested.
 * @return language level for classes root or null if file is not under a library source root or no matching classes root is found.
 */
@Nullable
private LanguageLevel getClassesLanguageLevel(VirtualFile virtualFile) {
  final ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();
  final VirtualFile sourceRoot = index.getSourceRootForFile(virtualFile);
  final VirtualFile folder = virtualFile.getParent();
  if (sourceRoot != null && folder != null) {
    String relativePath = VfsUtilCore.getRelativePath(folder, sourceRoot, '/');
    if (relativePath == null) {
      throw new AssertionError("Null relative path: folder=" + folder + "; root=" + sourceRoot);
    }
    List<OrderEntry> orderEntries = index.getOrderEntriesForFile(virtualFile);
    if (orderEntries.isEmpty()) {
      LOG.error("Inconsistent: " + DirectoryIndex.getInstance(myProject).getInfoForFile(folder).toString());
    }
    final String className = virtualFile.getNameWithoutExtension();
    final VirtualFile[] files = orderEntries.get(0).getFiles(OrderRootType.CLASSES);
    for (VirtualFile rootFile : files) {
      final VirtualFile classFile = rootFile.findFileByRelativePath(relativePath);
      if (classFile != null) {
        final PsiJavaFile javaFile = getPsiFileInRoot(classFile, className);
        if (javaFile != null) {
          return javaFile.getLanguageLevel();
        }
      }
    }
    return LanguageLevelProjectExtension.getInstance(myProject).getLanguageLevel();
  }
  return null;
} 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:JavaPsiImplementationHelperImpl.java

示例13: FileStatusManagerImpl

import com.intellij.openapi.roots.impl.DirectoryIndex; //导入依赖的package包/类
public FileStatusManagerImpl(Project project, StartupManager startupManager, EditorColorsManager colorsManager,
                             @SuppressWarnings("UnusedParameters") DirectoryIndex makeSureIndexIsInitializedFirst) {
  myProject = project;

  colorsManager.addEditorColorsListener(new EditorColorsListener() {
    @Override
    public void globalSchemeChange(EditorColorsScheme scheme) {
      fileStatusesChanged();
    }
  }, myProject);

  startupManager.registerPreStartupActivity(new Runnable() {
    @Override
    public void run() {
      DocumentAdapter documentListener = new DocumentAdapter() {
        @Override
        public void documentChanged(DocumentEvent event) {
          VirtualFile file = FileDocumentManager.getInstance().getFile(event.getDocument());
          if (file != null) {
            refreshFileStatusFromDocument(file, event.getDocument());
          }
        }
      };

      final EditorFactory factory = EditorFactory.getInstance();
      if (factory != null) {
        factory.getEventMulticaster().addDocumentListener(documentListener, myProject);
      }
    }
  });
  startupManager.registerPostStartupActivity(new DumbAwareRunnable() {
    @Override
    public void run() {
      fileStatusesChanged();
    }
  });
} 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:FileStatusManagerImpl.java

示例14: actionPerformed

import com.intellij.openapi.roots.impl.DirectoryIndex; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  final DirectoryIndex index = DirectoryIndex.getInstance(project);
  if (project != null) {
    final VirtualFile root = e.getData(CommonDataKeys.VIRTUAL_FILE);
    ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
      @Override
      public void run() {
        final ContentIterator contentIterator = new ContentIterator() {
          @Override
          public boolean processFile(VirtualFile fileOrDir) {
            LOG.info(fileOrDir.getPath());

            LOG.info(index.getInfoForFile(fileOrDir).toString());
            return true;
          }
        };
        if (root != null) {
          ProjectRootManager.getInstance(project).getFileIndex().iterateContentUnderDirectory(root, contentIterator);
        } else {
          ProjectRootManager.getInstance(project).getFileIndex().iterateContent(contentIterator);
        }
      }
    }, "Dumping directory index", true, project);
  }
} 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:DumpDirectoryInfoAction.java

示例15: getSourceRootDirectory

import com.intellij.openapi.roots.impl.DirectoryIndex; //导入依赖的package包/类
@Nullable
private static PsiDirectory getSourceRootDirectory(PsiDirectory directory) {
  PsiManager manager = directory.getManager();
  DirectoryIndex directoryIndex = DirectoryIndex.getInstance(manager.getProject());
  DirectoryInfo info = directoryIndex.getInfoForDirectory(directory.getVirtualFile());
  if (info == null || !info.hasSourceRoot()) return null;
  return manager.findDirectory(info.getSourceRoot());
} 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:9,代码来源:CreateClassUtil.java

本文标签属性:

示例:示例英文

代码:代码编程

java:java面试题

DirectoryIndex:DirectoryIndex

上一篇:C++ EnableWindow函数代码示例(c++enablewindow函数代码示例汇总)
下一篇:林志颖妈妈的老公是谁(婆婆妈妈林志颖妈妈是后妈吗?)

为您推荐