本文整理汇总了Java中com.intellij.util.indexing.FileContent.getPsiFile方法的典型用法代码示例。如果您正苦于以下问题:Java FileContent.getPsiFile方法的具体用法?Java FileContent.getPsiFile怎么用?Java FileContent.getPsiFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.indexing.FileContent
的用法示例。
在下文中一共展示了FileContent.getPsiFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: map
import com.intellij.util.indexing.FileContent; //导入方法依赖的package包/类
@NotNull
@Override
public Map<String, Set<String>> map(@NotNull FileContent inputData) {
final Map<String, Set<String>> indexMap = new HashMap<>();
if (inputData.getFileType().isBinary()) {
return indexMap;
}
final PsiFile file = inputData.getPsiFile();
if (fileDetector.isMainOpenApiFile(file)) {
Set<String> partialOpenApiFileNames = getPartialOpenApiFileNames(file);
indexMap.put(OpenApiFileIndex.PARTIAL_OPEN_API_FILES, partialOpenApiFileNames);
indexMap.put(OpenApiFileIndex.MAIN_OPEN_API_FILE, ImmutableSet.of(file.getName() + DELIMITER + OpenApiFileType.MAIN));
}
return indexMap;
}
示例2: map
import com.intellij.util.indexing.FileContent; //导入方法依赖的package包/类
@NotNull
@Override
public Map<String, Set<String>> map(@NotNull FileContent inputData) {
final Map<String, Set<String>> indexMap = new HashMap<>();
if (inputData.getFileType().isBinary()) {
return indexMap;
}
final PsiFile file = inputData.getPsiFile();
if (fileDetector.isMainSwaggerFile(file)) {
Set<String> partialSwaggerFileNames = getPartialSwaggerFileNames(file);
indexMap.put(SwaggerFileIndex.PARTIAL_SWAGGER_FILES, partialSwaggerFileNames);
indexMap.put(SwaggerFileIndex.MAIN_SWAGGER_FILE, ImmutableSet.of(file.getName() + DELIMITER + SwaggerFileType.MAIN));
}
return indexMap;
}
示例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: map
import com.intellij.util.indexing.FileContent; //导入方法依赖的package包/类
@NotNull
@Override
public Map<String, Void> map(@NotNull FileContent fileContent) {
PsiFile psiFile = fileContent.getPsiFile();
if (NeosProjectComponent.isEnabledForIndex(psiFile.getProject())
&& isValidForIndex(fileContent, psiFile)) {
return doIndex(fileContent);
}
return Collections.emptyMap();
}
示例5: buildStubTree
import com.intellij.util.indexing.FileContent; //导入方法依赖的package包/类
@Override
public Stub buildStubTree(FileContent fileContent) {
PsiFile psiFile = fileContent.getPsiFile();
if (!(psiFile instanceof XmlFile)) return null;
Document document = FileDocumentManager.getInstance().getCachedDocument(fileContent.getFile());
Project project = fileContent.getProject();
if (project == null) {
project = psiFile.getProject();
}
if (document != null) {
PsiFile existingPsi = PsiDocumentManager.getInstance(project).getPsiFile(document);
if (existingPsi instanceof XmlFile) {
psiFile = existingPsi;
}
}
XmlFile xmlFile = (XmlFile)psiFile;
try {
XmlUtil.BUILDING_DOM_STUBS.set(Boolean.TRUE);
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 " + fileContent.getFile());
}
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);
SemService.getSemService(project).clearCache();
}
}
示例6: buildStubTree
import com.intellij.util.indexing.FileContent; //导入方法依赖的package包/类
@Nullable
public static Stub buildStubTree(final FileContent inputData) {
Stub data = inputData.getUserData(stubElementKey);
if (data != null) return data;
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (inputData) {
data = inputData.getUserData(stubElementKey);
if (data != null) return data;
final FileType fileType = inputData.getFileType();
final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
if (builder != null) {
data = builder.buildStubTree(inputData);
}
if (data == null && !fileType.isBinary()) {
final LanguageFileType languageFileType = (LanguageFileType)fileType;
Language l = languageFileType.getLanguage();
final IFileElementType type = LanguageParserDefinitions.INSTANCE.forLanguage(l).getFileNodeType();
PsiFile psi = inputData.getPsiFile();
psi = psi.getViewProvider().getStubBindingRoot();
CharSequence contentAsText = inputData.getContentAsText();
psi.putUserData(IndexingDataKeys.FILE_TEXT_CONTENT_KEY, contentAsText);
try {
if (type instanceof IStubFileElementType) {
data = ((IStubFileElementType)type).getBuilder().buildStubTree(psi);
}
else if (languageFileType instanceof SubstitutedFileType) {
SubstitutedFileType substituted = (SubstitutedFileType) languageFileType;
LanguageFileType original = (LanguageFileType)substituted.getOriginalFileType();
final IFileElementType originalType = LanguageParserDefinitions.INSTANCE.forLanguage(original.getLanguage()).getFileNodeType();
if (originalType instanceof IStubFileElementType) {
data = ((IStubFileElementType)originalType).getBuilder().buildStubTree(psi);
}
}
}
finally {
psi.putUserData(IndexingDataKeys.FILE_TEXT_CONTENT_KEY, null);
}
}
inputData.putUserData(stubElementKey, data);
return data;
}
}