use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class ExternalToolContentExternalizer method chooseExtension.
private String chooseExtension() {
DiffContent content = getContent();
VirtualFile contentFile = content.getFile();
String extension;
if (contentFile != null) {
extension = "." + contentFile.getExtension();
} else {
FileType contentType = content.getContentType();
if (contentType == null)
contentType = DiffUtil.chooseContentTypes(myRequest.getContents())[myIndex];
extension = contentType != null ? "." + contentType.getDefaultExtension() : null;
}
return extension;
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-plugins by JetBrains.
the class CfmlBraceMatcher method isLBraceToken.
public boolean isLBraceToken(HighlighterIterator iterator, CharSequence fileText, FileType fileType) {
final IElementType tokenType = iterator.getTokenType();
PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType.getLanguage());
if (matcher != null) {
BracePair[] pairs = matcher.getPairs();
for (BracePair pair : pairs) {
if (pair.getLeftBraceType() == tokenType)
return true;
}
}
if (!tokenType.getLanguage().equals(CfmlLanguage.INSTANCE)) {
FileType tokenFileType = iterator.getTokenType().getLanguage().getAssociatedFileType();
if (tokenFileType != null && tokenFileType != CfmlFileType.INSTANCE) {
for (FileTypeExtensionPoint<BraceMatcher> ext : Extensions.getExtensions(BraceMatcher.EP_NAME)) {
if (ext.filetype != null && ext.filetype.equals(tokenFileType.getName())) {
return ext.getInstance().isLBraceToken(iterator, fileText, tokenFileType instanceof XmlFileType ? StdFileTypes.HTML : tokenFileType);
}
}
}
}
for (BracePair pair : PAIRS) {
if (pair.getLeftBraceType() == tokenType) {
return true;
}
}
return tokenType.equals(CfmlTokenTypes.OPENER) && (!CfmlUtil.isEndTagRequired(getTagName(fileText, iterator), null) || findEndTag(fileText, iterator));
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-plugins by JetBrains.
the class CfmlStructureViewTest method createStructureViewModel.
private StructureView createStructureViewModel() {
VirtualFile virtualFile = myFixture.getFile().getVirtualFile();
final FileType fileType = virtualFile.getFileType();
final StructureViewBuilder structureViewBuilder;
if (fileType == CfmlFileType.INSTANCE) {
CfmlFileViewProvider viewProvider = (CfmlFileViewProvider) myFixture.getFile().getViewProvider();
structureViewBuilder = LanguageStructureViewBuilder.INSTANCE.forLanguage(viewProvider.getBaseLanguage()).getStructureViewBuilder(viewProvider.getPsi(viewProvider.getBaseLanguage()));
} else {
structureViewBuilder = StructureViewBuilder.PROVIDER.getStructureViewBuilder(fileType, virtualFile, getProject());
}
return structureViewBuilder.createStructureView(FileEditorManager.getInstance(getProject()).getSelectedEditor(virtualFile), getProject());
}
use of com.intellij.openapi.fileTypes.FileType in project android by JetBrains.
the class ResourceFolderRepository method scanValueFile.
private void scanValueFile(String qualifiers, VirtualFile virtualFile, FolderConfiguration folderConfiguration) {
FileType fileType = virtualFile.getFileType();
if (fileType == StdFileTypes.XML) {
if (myResourceFiles.containsKey(virtualFile)) {
myInitialScanState.countCacheHit();
return;
}
File file = VfsUtilCore.virtualToIoFile(virtualFile);
try {
ResourceFile resourceFile = myInitialScanState.loadFile(file);
if (resourceFile == null) {
// The file-based parser failed for some reason. Fall back to Psi in case it is more lax.
myInitialScanState.queuePsiValueResourceScan(new PsiValueResourceQueueEntry(virtualFile, qualifiers, folderConfiguration));
return;
}
for (ResourceItem item : resourceFile.getItems()) {
ListMultimap<String, ResourceItem> map = getMap(item.getType(), true);
map.put(item.getName(), item);
}
myInitialScanState.countCacheMiss();
myResourceFiles.put(virtualFile, resourceFile);
} catch (MergingException e) {
// The file-based parser failed for some reason. Fall back to Psi in case it is more lax.
myInitialScanState.queuePsiValueResourceScan(new PsiValueResourceQueueEntry(virtualFile, qualifiers, folderConfiguration));
}
}
}
use of com.intellij.openapi.fileTypes.FileType in project android by JetBrains.
the class ResourceFolderRepository method scanFileResourceFolder.
private void scanFileResourceFolder(@NotNull VirtualFile directory, ResourceFolderType folderType, String qualifiers, FolderConfiguration folderConfiguration) {
List<ResourceType> resourceTypes = FolderTypeRelationship.getRelatedResourceTypes(folderType);
assert resourceTypes.size() >= 1 : folderType;
ResourceType type = resourceTypes.get(0);
boolean idGeneratingFolder = FolderTypeRelationship.isIdGeneratingFolderType(folderType);
ListMultimap<String, ResourceItem> map = getMap(type, true);
for (VirtualFile file : directory.getChildren()) {
if (file.isValid() && !file.isDirectory()) {
FileType fileType = file.getFileType();
boolean idGeneratingFile = idGeneratingFolder && fileType == StdFileTypes.XML;
if (PsiProjectListener.isRelevantFileType(fileType) || folderType == ResourceFolderType.RAW) {
scanFileResourceFile(qualifiers, folderType, folderConfiguration, type, idGeneratingFile, map, file);
}
// TODO: Else warn about files that aren't expected to be found here?
}
}
}
Aggregations