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


Java FileContent.getFile方法代码示例

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


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

示例1: map

import com.intellij.util.indexing.FileContent; //导入方法依赖的package包/类
@Override
@NotNull
public Map<String, Void> map(@NotNull final FileContent inputData) {
  if (!PantsUtil.isPantsProject(inputData.getProject())) {
    return Collections.emptyMap();
  }

  final VirtualFile file = inputData.getFile();
  Optional<VirtualFile> buildRoot = PantsUtil.findBuildRoot(file);
  if (!buildRoot.isPresent()) {
    return Collections.emptyMap();
  }

  String relative = FileUtil.getRelativePath(buildRoot.get().getPath(), file.getParent().getPath(), File.separatorChar);
  if (relative == null || relative.isEmpty()) {
    return Collections.emptyMap();
  }
  else {
    return Collections.singletonMap(relative, null);
  }
}
 
开发者ID:pantsbuild,项目名称:intellij-pants-plugin,代码行数:22,代码来源:PantsBuildFileIndex.java

示例2: buildStubTree

import com.intellij.util.indexing.FileContent; //导入方法依赖的package包/类
@Override
public StubElement buildStubTree(FileContent fileContent) {
  try {
    VirtualFile file = fileContent.getFile();
    Project project = fileContent.getProject();
    byte[] content = fileContent.getContent();
    final ClsStubBuilderFactory[] factories = Extensions.getExtensions(ClsStubBuilderFactory.EP_NAME);
    for (ClsStubBuilderFactory factory : factories) {
      if (!factory.isInnerClass(file) && factory.canBeProcessed(file, content)) {
        PsiFileStub stub = factory.buildFileStub(file, content, project);
        if (stub != null) return stub;
      }
    }
    if (!fileContent.getFileName().contains("$")) {
      LOG.info("No stub built for file " + fileContent);
    }
    return null;
  }
  catch (ClsFormatException e) {
    return null;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:ClassFileStubBuilder.java

示例3: map

import com.intellij.util.indexing.FileContent; //导入方法依赖的package包/类
/**
 * Maps indexed files content to the {@link IgnoreEntryOccurrence}.
 *
 * @param inputData indexed file data
 * @return {@link IgnoreEntryOccurrence} data mapped with {@link IgnoreFileTypeKey}
 */
@NotNull
@Override
public Map<IgnoreFileTypeKey, IgnoreEntryOccurrence> map(@NotNull final FileContent inputData) {
    if (!(inputData.getPsiFile() instanceof IgnoreFile)) {
        return Collections.emptyMap();
    }
    final IgnoreEntryOccurrence result = new IgnoreEntryOccurrence(inputData.getFile());
    final IgnoreFileType type = (IgnoreFileType) inputData.getFileType();

    IgnoreFile ignoreFile = (IgnoreFile) inputData.getPsiFile();
    ignoreFile.acceptChildren(new IgnoreVisitor() {
        @Override
        public void visitEntry(@NotNull IgnoreEntry entry) {
            final Pattern pattern = Glob.createPattern(entry);
            if (pattern != null) {
                result.add(pattern.matcher(""), entry.isNegated());
            }
        }
    });

    return Collections.singletonMap(new IgnoreFileTypeKey(type), result);
}
 
开发者ID:hsz,项目名称:idea-gitignore,代码行数:29,代码来源:IgnoreFilesIndex.java

示例4: buildStubTree

import com.intellij.util.indexing.FileContent; //导入方法依赖的package包/类
@Override
public Stub buildStubTree(FileContent fileContent) {
  VirtualFile file = fileContent.getFile();
  Project project = fileContent.getProject();
  PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
  if (!(psiFile instanceof XmlFile)) return null;

  XmlFile xmlFile = (XmlFile)psiFile;
  try {
    XmlUtil.BUILDING_DOM_STUBS.set(Boolean.TRUE);
    psiFile.putUserData(CONTENT_FOR_DOM_STUBS, fileContent);
    DomFileElement<? extends DomElement> fileElement = DomManager.getDomManager(project).getFileElement(xmlFile);
    if (fileElement == null || !fileElement.getFileDescription().hasStubs()) return null;

    XmlFileHeader header = DomService.getInstance().getXmlFileHeader(xmlFile);
    if (header.getRootTagLocalName() == null) {
      LOG.error("null root tag for " + fileElement + " for " + file);
    }
    FileStub fileStub = new FileStub(header);
    DomStubBuilderVisitor visitor = new DomStubBuilderVisitor(fileStub);
    visitor.visitDomElement(fileElement.getRootElement());
    return fileStub;
  }
  finally {
    XmlUtil.BUILDING_DOM_STUBS.set(Boolean.FALSE);
    psiFile.putUserData(CONTENT_FOR_DOM_STUBS, null);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:DomStubBuilder.java

示例5: buildStubTree

import com.intellij.util.indexing.FileContent; //导入方法依赖的package包/类
@Override
public Stub buildStubTree(FileContent fileContent)
{
	VirtualFile file = fileContent.getFile();
	Project project = fileContent.getProject();
	PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
	if(!(psiFile instanceof XmlFile))
	{
		return null;
	}

	XmlFile xmlFile = (XmlFile) psiFile;
	try
	{
		XmlUtil.BUILDING_DOM_STUBS.set(Boolean.TRUE);
		psiFile.putUserData(CONTENT_FOR_DOM_STUBS, fileContent);
		DomFileElement<? extends DomElement> fileElement = DomManager.getDomManager(project).getFileElement(xmlFile);
		if(fileElement == null || !fileElement.getFileDescription().hasStubs())
		{
			return null;
		}

		XmlFileHeader header = DomService.getInstance().getXmlFileHeader(xmlFile);
		if(header.getRootTagLocalName() == null)
		{
			LOG.error("null root tag for " + fileElement + " for " + file);
		}
		FileStub fileStub = new FileStub(header);
		XmlTag rootTag = xmlFile.getRootTag();
		if(rootTag != null)
		{
			new DomStubBuilderVisitor(DomManagerImpl.getDomManager(project)).visitXmlElement(rootTag, fileStub, 0);
		}
		return fileStub;
	}
	finally
	{
		XmlUtil.BUILDING_DOM_STUBS.set(Boolean.FALSE);
		psiFile.putUserData(CONTENT_FOR_DOM_STUBS, null);
	}
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:42,代码来源:DomStubBuilder.java


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