本文整理汇总了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);
}
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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);
}
}