use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class AboutHttpService method getAbout.
public static void getAbout(@NotNull OutputStream out, @Nullable QueryStringDecoder urlDecoder) throws IOException {
JsonWriter writer = createJsonWriter(out);
writer.beginObject();
IdeAboutInfoUtil.writeAboutJson(writer);
if (urlDecoder != null && getBooleanParameter("registeredFileTypes", urlDecoder)) {
writer.name("registeredFileTypes").beginArray();
for (FileType fileType : FileTypeRegistry.getInstance().getRegisteredFileTypes()) {
writer.beginObject();
writer.name("name").value(fileType.getName());
writer.name("description").value(fileType.getDescription());
writer.name("isBinary").value(fileType.isBinary());
writer.endObject();
}
writer.endArray();
}
if (urlDecoder != null && getBooleanParameter("more", urlDecoder)) {
ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
writer.name("vendor").value(appInfo.getCompanyName());
writer.name("isEAP").value(appInfo.isEAP());
writer.name("productCode").value(appInfo.getBuild().getProductCode());
writer.name("buildDate").value(appInfo.getBuildDate().getTime().getTime());
writer.name("isSnapshot").value(appInfo.getBuild().isSnapshot());
writer.name("configPath").value(PathManager.getConfigPath());
writer.name("systemPath").value(PathManager.getSystemPath());
writer.name("binPath").value(PathManager.getBinPath());
writer.name("logPath").value(PathManager.getLogPath());
writer.name("homePath").value(PathManager.getHomePath());
}
writer.endObject();
writer.close();
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class DiffHttpService method readContent.
@Nullable
private static String readContent(@NotNull JsonReader reader, @NotNull List<DiffContent> contents, @NotNull List<String> titles, @Nullable String defaultFileTypeName) throws IOException {
FileTypeRegistry fileTypeRegistry = FileTypeRegistry.getInstance();
FileType defaultFileType = defaultFileTypeName == null ? null : fileTypeRegistry.findFileTypeByName(defaultFileTypeName);
reader.beginArray();
while (reader.hasNext()) {
String title = null;
String fileType = null;
String content = null;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
if (name.equals("title")) {
title = reader.nextString();
} else if (name.equals("fileType")) {
fileType = reader.nextString();
} else if (name.equals("content")) {
content = reader.nextString();
} else {
reader.skipValue();
}
}
reader.endObject();
if (content == null) {
return "content is not specified";
}
FileType type = fileType == null ? defaultFileType : fileTypeRegistry.findFileTypeByName(fileType);
contents.add(DiffContentFactory.getInstance().create(content, type));
titles.add(StringUtil.isEmptyOrSpaces(title) ? "" : title);
}
reader.endArray();
return null;
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class DiffUtil method createEditorHighlighter.
@Nullable
private static EditorHighlighter createEditorHighlighter(@Nullable Project project, @NotNull DocumentContent content) {
FileType type = content.getContentType();
VirtualFile file = content.getHighlightFile();
Language language = content.getUserData(DiffUserDataKeys.LANGUAGE);
EditorHighlighterFactory highlighterFactory = EditorHighlighterFactory.getInstance();
if (language != null) {
SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, file);
return highlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme());
}
if (file != null && file.isValid()) {
if ((type == null || type == PlainTextFileType.INSTANCE) || file.getFileType() == type || file instanceof LightVirtualFile) {
return highlighterFactory.createEditorHighlighter(project, file);
}
}
if (type != null) {
return highlighterFactory.createEditorHighlighter(project, type);
}
return null;
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class DefaultCreateFromTemplateHandler method createFromTemplate.
@NotNull
@Override
public PsiElement createFromTemplate(final Project project, final PsiDirectory directory, String fileName, final FileTemplate template, final String templateText, @NotNull final Map<String, Object> props) throws IncorrectOperationException {
fileName = checkAppendExtension(fileName, template);
if (FileTypeManager.getInstance().isFileIgnored(fileName)) {
throw new IncorrectOperationException("This filename is ignored (Settings | Editor | File Types | Ignore files and folders)");
}
directory.checkCreateFile(fileName);
FileType type = FileTypeRegistry.getInstance().getFileTypeByFileName(fileName);
PsiFile file = PsiFileFactory.getInstance(project).createFileFromText(fileName, type, templateText);
if (template.isReformatCode()) {
CodeStyleManager.getInstance(project).reformat(file);
}
file = (PsiFile) directory.add(file);
return file;
}
use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.
the class FileTemplateUtil method canCreateFromTemplate.
public static boolean canCreateFromTemplate(PsiDirectory[] dirs, FileTemplate template) {
FileType fileType = FileTypeManagerEx.getInstanceEx().getFileTypeByExtension(template.getExtension());
if (fileType.equals(FileTypes.UNKNOWN))
return false;
CreateFromTemplateHandler handler = findHandler(template);
return handler.canCreate(dirs);
}
Aggregations