Java Code Examples for com.intellij.util.indexing.FileBasedIndex#getFileId()

The following examples show how to use com.intellij.util.indexing.FileBasedIndex#getFileId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Unity3dMetaManager.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Nullable
@RequiredReadAction
public String getGUID(@Nonnull VirtualFile virtualFile)
{
	String name = virtualFile.getName();

	VirtualFile parent = virtualFile.getParent();
	if(parent == null)
	{
		return null;
	}

	int targetId = FileBasedIndex.getFileId(virtualFile);

	Object o = myGUIDs.computeIfAbsent(targetId, integer ->
	{
		VirtualFile child = parent.findChild(name + "." + Unity3dMetaFileType.INSTANCE.getDefaultExtension());
		if(child != null)
		{
			String guid = null;
			PsiFile file = PsiManager.getInstance(myProject).findFile(child);
			if(file instanceof YAMLFile)
			{
				guid = Unity3dMetaIndexExtension.findGUIDFromFile((YAMLFile) file);
			}
			return guid == null ? ObjectUtil.NULL : guid;
		}
		return ObjectUtil.NULL;
	});
	return o instanceof String ? (String) o : null;
}
 
Example 2
Source File: TranslatingCompilerFilesMonitorImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public int getProjectId(Project project) {
  VirtualFile baseDir = project.getBaseDir();
  if(baseDir == null) {
    throw new IllegalArgumentException("there no base directory: " + project.getBasePath());
  }

  return FileBasedIndex.getFileId(baseDir);
}
 
Example 3
Source File: TranslationSourceFileInfo.java    From consulo with Apache License 2.0 5 votes vote down vote up
public boolean isAssociated(int projectId, String outputPath) {
  if (myProjectToOutputPathMap != null) {
    final Object val = myProjectToOutputPathMap.get(projectId);
    if (val instanceof Integer) {
      VirtualFile fileById = VirtualFileManager.getInstance().findFileById((Integer)val);
      return FileUtil.pathsEqual(outputPath, fileById != null ? fileById.getPath() : "");
    }
    if (val instanceof TIntHashSet) {
      VirtualFile vf = LocalFileSystem.getInstance().findFileByPath(outputPath);
      int _outputPath = vf == null ? -1 : FileBasedIndex.getFileId(vf);
      return ((TIntHashSet)val).contains(_outputPath);
    }
  }
  return false;
}
 
Example 4
Source File: TranslatingCompilerFilesMonitorImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static int getFileId(final VirtualFile file) {
  return FileBasedIndex.getFileId(file);
}
 
Example 5
Source File: TranslationOutputFileInfo.java    From consulo with Apache License 2.0 4 votes vote down vote up
TranslationOutputFileInfo(final VirtualFile sourcePath, @Nullable String className) throws IOException {
  mySourcePath = FileBasedIndex.getFileId(sourcePath);
  myClassName = className;
}