use of com.intellij.openapi.fileTypes.LanguageFileType in project intellij-community by JetBrains.
the class PsiFileGistImpl method getPsiFile.
private static PsiFile getPsiFile(@NotNull Project project, @NotNull VirtualFile file) {
PsiFile psi = PsiManager.getInstance(project).findFile(file);
if (psi == null || !(psi instanceof PsiFileImpl) || ((PsiFileImpl) psi).isContentsLoaded()) {
return psi;
}
FileType fileType = file.getFileType();
if (!(fileType instanceof LanguageFileType))
return null;
return FileContentImpl.createFileFromText(project, psi.getViewProvider().getContents(), (LanguageFileType) fileType, file, file.getName());
}
use of com.intellij.openapi.fileTypes.LanguageFileType in project intellij-community by JetBrains.
the class StubUpdatingIndex method canHaveStub.
public static boolean canHaveStub(@NotNull VirtualFile file) {
final FileType fileType = file.getFileType();
if (fileType instanceof LanguageFileType) {
final Language l = ((LanguageFileType) fileType).getLanguage();
final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
if (parserDefinition == null) {
return false;
}
final IFileElementType elementType = parserDefinition.getFileNodeType();
if (elementType instanceof IStubFileElementType) {
if (((IStubFileElementType) elementType).shouldBuildStubFor(file)) {
return true;
}
FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
if (file instanceof NewVirtualFile && fileBasedIndex instanceof FileBasedIndexImpl && ((FileBasedIndexImpl) fileBasedIndex).getIndex(INDEX_ID).isIndexedStateForFile(((NewVirtualFile) file).getId(), file)) {
return true;
}
}
}
final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
return builder != null && builder.acceptsFile(file);
}
use of com.intellij.openapi.fileTypes.LanguageFileType in project intellij-community by JetBrains.
the class StubVersionMap method getVersionOwner.
private static Object getVersionOwner(FileType fileType) {
Object owner = null;
if (fileType instanceof LanguageFileType) {
Language l = ((LanguageFileType) fileType).getLanguage();
ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
if (parserDefinition != null) {
final IFileElementType type = parserDefinition.getFileNodeType();
if (type instanceof IStubFileElementType) {
owner = type;
}
}
}
BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
if (builder != null) {
owner = builder;
}
return owner;
}
use of com.intellij.openapi.fileTypes.LanguageFileType in project intellij-community by JetBrains.
the class SearchDialog method updateDialectsAndContexts.
private void updateDialectsAndContexts() {
final FileType fileType = (FileType) fileTypes.getSelectedItem();
if (fileType instanceof LanguageFileType) {
Language language = ((LanguageFileType) fileType).getLanguage();
Language[] languageDialects = LanguageUtil.getLanguageDialects(language);
Arrays.sort(languageDialects, Comparator.comparing(Language::getDisplayName));
Language[] variants = new Language[languageDialects.length + 1];
variants[0] = null;
System.arraycopy(languageDialects, 0, variants, 1, languageDialects.length);
dialects.setModel(new DefaultComboBoxModel<>(variants));
dialects.setEnabled(variants.length > 1);
}
final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByFileType(fileType);
if (profile instanceof StructuralSearchProfileBase) {
final String[] contextNames = ((StructuralSearchProfileBase) profile).getContextNames();
if (contextNames.length > 0) {
contexts.setModel(new DefaultComboBoxModel<>(contextNames));
contexts.setSelectedItem(contextNames[0]);
contexts.setEnabled(true);
return;
}
}
contexts.setSelectedItem(null);
contexts.setEnabled(false);
}
use of com.intellij.openapi.fileTypes.LanguageFileType in project intellij-community by JetBrains.
the class DuplicatesIndex method findDuplicatesProfile.
@Nullable
public static DuplicatesProfile findDuplicatesProfile(FileType fileType) {
if (!(fileType instanceof LanguageFileType))
return null;
Language language = ((LanguageFileType) fileType).getLanguage();
DuplicatesProfile profile = DuplicatesProfile.findProfileForLanguage(language);
return profile != null && (ourEnabledOldProfiles && profile.supportDuplicatesIndex() || profile instanceof LightDuplicateProfile) ? profile : null;
}
Aggregations