本文整理汇总了Java中com.intellij.openapi.fileTypes.FileTypes类的典型用法代码示例。如果您正苦于以下问题:Java FileTypes类的具体用法?Java FileTypes怎么用?Java FileTypes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileTypes类属于com.intellij.openapi.fileTypes包,在下文中一共展示了FileTypes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromTemplate
import com.intellij.openapi.fileTypes.FileTypes; //导入依赖的package包/类
/**
* @param templateFile Name of the generated file
* @param destinationPath Relative path to the target file system entry
* @param extensionDefinition Extension definition containing all relevant metadata
* @param context Template Context variables
* @param project Project in context
*/
public static PsiElement fromTemplate(@NotNull String templateFile, @NotNull String destinationPath, @NotNull String destinationFileName, @NotNull TYPO3ExtensionDefinition extensionDefinition, @NotNull Map<String, String> context, Project project) {
String template = readTemplateToString(templateFile, context);
VirtualFile targetDirectory = getOrCreateDestinationPath(extensionDefinition.getRootDirectory(), destinationPath);
LanguageFileType fileType = FileTypes.PLAIN_TEXT;
if (templateFile.endsWith(".php")) {
fileType = PhpFileType.INSTANCE;
}
PsiFile fileFromText = PsiFileFactory.getInstance(project).createFileFromText(destinationFileName, fileType, template);
CodeStyleManager.getInstance(project).reformat(fileFromText);
return PsiDirectoryFactory
.getInstance(project)
.createDirectory(targetDirectory)
.add(fileFromText);
}
示例2: createUIComponents
import com.intellij.openapi.fileTypes.FileTypes; //导入依赖的package包/类
private void createUIComponents() {
testTargetTextField = new EditorTextField("", getProject(), FileTypes.PLAIN_TEXT);
namespaceComboBox = new PhpNamespaceComboBox(getProject(), "", getDisposable());
directoryComboBox = new PhpPsrDirectoryComboBox(getProject()) {
@Override
public void init(@NotNull VirtualFile baseDir, @NotNull String namespace) {
super.init(baseDir, namespace);
ProjectFileIndex index = ProjectRootManager.getInstance(TesterNewTestCaseDialog.this.getProject()).getFileIndex();
this.setDirectoriesFilter(index::isInTestSourceContent);
this.updateDirectories(TesterNewTestCaseDialog.this.getNamespace());
}
};
classToTestLabel = new JBLabel(TesterBundle.message("dialog.newTestCase.label.classToTest"));
testClassLabel = new JBLabel(TesterBundle.message("dialog.newTestCase.label.testClass"));
namespaceLabel = new JBLabel(TesterBundle.message("dialog.newTestCase.label.namespace"));
fileNameLabel = new JBLabel(TesterBundle.message("dialog.newTestCase.label.fileName"));
directoryLabel = new JBLabel(TesterBundle.message("dialog.newTestCase.label.directory"));
testTargetCompletionHint = new JBLabel(UIUtil.ComponentStyle.MINI);
namespaceCompletionHint = new JBLabel(UIUtil.ComponentStyle.MINI);
directoryCompletionHint = new JBLabel(UIUtil.ComponentStyle.MINI);
}
示例3: testReplaceRegexp
import com.intellij.openapi.fileTypes.FileTypes; //导入依赖的package包/类
public void testReplaceRegexp() {
FindModel findModel = new FindModel();
findModel.setStringToFind("bug_(?=here)");
findModel.setStringToReplace("x_$0t");
findModel.setWholeWordsOnly(false);
findModel.setFromCursor(false);
findModel.setGlobal(true);
findModel.setMultipleFiles(false);
findModel.setProjectScope(true);
findModel.setRegularExpressions(true);
findModel.setPromptOnReplace(false);
myFindManager.setFindNextModel(null);
myFindManager.getFindInFileModel().copyFrom(findModel);
String text = "bug_here\nbug_here";
configureByText(FileTypes.PLAIN_TEXT, text);
assertTrue(FindUtil.replace(getProject(), getEditor(), 0, findModel));
assertEquals("x_bug_there\nx_bug_there", getEditor().getDocument().getText());
}
示例4: testReplaceRegexp1
import com.intellij.openapi.fileTypes.FileTypes; //导入依赖的package包/类
public void testReplaceRegexp1() {
FindModel findModel = new FindModel();
findModel.setStringToFind("bug_(?=here)");
findModel.setStringToReplace("$0");
findModel.setWholeWordsOnly(false);
findModel.setFromCursor(false);
findModel.setGlobal(true);
findModel.setMultipleFiles(false);
findModel.setProjectScope(true);
findModel.setRegularExpressions(true);
findModel.setPromptOnReplace(false);
myFindManager.setFindNextModel(null);
myFindManager.getFindInFileModel().copyFrom(findModel);
String text = "bug_here\nbug_here";
configureByText(FileTypes.PLAIN_TEXT, text);
assertTrue(FindUtil.replace(getProject(), getEditor(), 0, findModel));
assertEquals(text, getEditor().getDocument().getText());
}
示例5: testReplaceRegexpWithNewLine
import com.intellij.openapi.fileTypes.FileTypes; //导入依赖的package包/类
public void testReplaceRegexpWithNewLine() {
FindModel findModel = new FindModel();
findModel.setStringToFind("xxx");
findModel.setStringToReplace("xxx\\n");
findModel.setWholeWordsOnly(false);
findModel.setFromCursor(false);
findModel.setGlobal(true);
findModel.setMultipleFiles(false);
findModel.setProjectScope(true);
findModel.setRegularExpressions(true);
findModel.setPromptOnReplace(false);
myFindManager.setFindNextModel(null);
myFindManager.getFindInFileModel().copyFrom(findModel);
String text = "xxx";
configureByText(FileTypes.PLAIN_TEXT, text);
assertTrue(FindUtil.replace(getProject(), getEditor(), 0, findModel));
assertEquals(text+"\n", getEditor().getDocument().getText());
}
示例6: testReplacePreserveCase
import com.intellij.openapi.fileTypes.FileTypes; //导入依赖的package包/类
public void testReplacePreserveCase() {
configureByText(FileTypes.PLAIN_TEXT, "Bar bar BAR");
FindModel model = new FindModel();
model.setStringToFind("bar");
model.setStringToReplace("foo");
model.setPromptOnReplace(false);
model.setPreserveCase(true);
FindUtil.replace(myProject, myEditor, 0, model);
assertEquals("Foo foo FOO", myEditor.getDocument().getText());
configureByText(FileTypes.PLAIN_TEXT, "Bar bar");
model.setStringToFind("bar");
model.setStringToReplace("fooBar");
FindUtil.replace(myProject, myEditor, 0, model);
assertEquals("FooBar fooBar", myEditor.getDocument().getText());
}
示例7: testFindWholeWords
import com.intellij.openapi.fileTypes.FileTypes; //导入依赖的package包/类
public void testFindWholeWords() {
configureByText(FileTypes.PLAIN_TEXT, "-- -- ---");
FindModel model = new FindModel();
model.setStringToFind("--");
model.setWholeWordsOnly(true);
List<Usage> usages = FindUtil.findAll(myProject, myEditor, model);
assertNotNull(usages);
assertEquals(2, usages.size());
configureByText(FileTypes.PLAIN_TEXT, "[email protected]");
model = new FindModel();
model.setStringToFind("@AspectJ");
model.setWholeWordsOnly(true);
usages = FindUtil.findAll(myProject, myEditor, model);
assertNotNull(usages);
assertEquals(1, usages.size());
}
示例8: createComponent
import com.intellij.openapi.fileTypes.FileTypes; //导入依赖的package包/类
@NotNull
private JComponent createComponent(@NotNull DiffRequest request) {
if (request instanceof MessageDiffRequest) {
// TODO: explain some of ErrorDiffRequest exceptions ?
String message = ((MessageDiffRequest)request).getMessage();
return DiffUtil.createMessagePanel(message);
}
if (request instanceof ComponentDiffRequest) {
return ((ComponentDiffRequest)request).getComponent(myContext);
}
if (request instanceof ContentDiffRequest) {
List<DiffContent> contents = ((ContentDiffRequest)request).getContents();
for (final DiffContent content : contents) {
if (content instanceof FileContent && FileTypes.UNKNOWN.equals(content.getContentType())) {
final VirtualFile file = ((FileContent)content).getFile();
UnknownFileTypeDiffRequest unknownFileTypeRequest = new UnknownFileTypeDiffRequest(file, myRequest.getTitle());
return unknownFileTypeRequest.getComponent(myContext);
}
}
}
return DiffUtil.createMessagePanel("Can't show diff");
}
示例9: getFileToSelect
import com.intellij.openapi.fileTypes.FileTypes; //导入依赖的package包/类
@Nullable
public final VirtualFile getFileToSelect(VirtualFile file) {
if (file.isDirectory() && (myChooseFolders || isFileSelectable(file))) {
return file;
}
boolean isJar = file.getFileType() == FileTypes.ARCHIVE;
if (!isJar) {
return acceptAsGeneralFile(file) ? file : null;
}
if (myChooseJarsAsFiles) {
return file;
}
if (!acceptAsJarFile(file)) {
return null;
}
String path = file.getPath();
return JarFileSystem.getInstance().findFileByPath(path + JarFileSystem.JAR_SEPARATOR);
}
示例10: checkHardcodedCharsetFileType
import com.intellij.openapi.fileTypes.FileTypes; //导入依赖的package包/类
@NotNull
static Pair<Charset, String> checkHardcodedCharsetFileType(@NotNull VirtualFile virtualFile) {
FileType fileType = virtualFile.getFileType();
if (fileType.isBinary()) return Pair.create(null, "binary file");
// in lesser IDEs all special file types are plain text so check for that first
if (fileType == FileTypes.PLAIN_TEXT) return Pair.create(null, null);
if (fileType == StdFileTypes.GUI_DESIGNER_FORM) return Pair.create(CharsetToolkit.UTF8_CHARSET, "IDEA GUI Designer form");
if (fileType == StdFileTypes.IDEA_MODULE) return Pair.create(CharsetToolkit.UTF8_CHARSET, "IDEA module file");
if (fileType == StdFileTypes.IDEA_PROJECT) return Pair.create(CharsetToolkit.UTF8_CHARSET, "IDEA project file");
if (fileType == StdFileTypes.IDEA_WORKSPACE) return Pair.create(CharsetToolkit.UTF8_CHARSET, "IDEA workspace file");
if (fileType == StdFileTypes.PROPERTIES) return Pair.create(virtualFile.getCharset(), ".properties file");
if (fileType == StdFileTypes.XML || fileType == StdFileTypes.JSPX) {
return Pair.create(virtualFile.getCharset(), "XML file");
}
return Pair.create(null, null);
}
示例11: testRuby7852ErrantEditor
import com.intellij.openapi.fileTypes.FileTypes; //导入依赖的package包/类
public void testRuby7852ErrantEditor() {
myFixture.configureByText(FileTypes.PLAIN_TEXT, "\"aaa\"\nbbb\n\n");
myFixture.getEditor().getCaretModel().moveToOffset(0);
myFixture.getEditor().getSelectionModel().setSelection(0, 5);
final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction();
performAction(myFixture.getProject(), new Runnable() {
@Override
public void run() {
typedAction.actionPerformed(myFixture.getEditor(), '\'', ((EditorEx)myFixture.getEditor()).getDataContext());
}
});
myFixture.getEditor().getSelectionModel().removeSelection();
myFixture.checkResult("'aaa'\nbbb\n\n");
myFixture.getEditor().getCaretModel().moveToOffset(myFixture.getEditor().getDocument().getLineStartOffset(3));
performAction(myFixture.getProject(), new Runnable() {
@Override
public void run() {
typedAction.actionPerformed(myFixture.getEditor(), 'A', ((EditorEx)myFixture.getEditor()).getDataContext());
typedAction.actionPerformed(myFixture.getEditor(), 'B', ((EditorEx)myFixture.getEditor()).getDataContext());
}
});
myFixture.checkResult("'aaa'\nbbb\n\nAB");
}
示例12: isJarFile
import com.intellij.openapi.fileTypes.FileTypes; //导入依赖的package包/类
private static boolean isJarFile(final VirtualFile file) {
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
VirtualFile tempFile = file;
if ((file.getFileSystem() instanceof JarFileSystem) && file.getParent() == null) {
//[myakovlev] It was bug - directories with *.jar extensions was saved as files of JarFileSystem.
// so we can not just return true, we should filter such directories.
String path = file.getPath().substring(0, file.getPath().length() - JarFileSystem.JAR_SEPARATOR.length());
tempFile = LocalFileSystem.getInstance().findFileByPath(path);
}
if (tempFile != null && !tempFile.isDirectory()) {
return Boolean.valueOf(tempFile.getFileType().equals(FileTypes.ARCHIVE));
}
return Boolean.FALSE;
}
}).booleanValue();
}
示例13: ReplacementPreviewDialog
import com.intellij.openapi.fileTypes.FileTypes; //导入依赖的package包/类
public ReplacementPreviewDialog(final Project project, UsageInfo info, String replacementString) {
super(project,true);
setTitle(SSRBundle.message("structural.replace.preview.dialog.title"));
setOKButtonText(SSRBundle.message("replace.preview.oktext"));
this.project = project;
final PsiElement element = info.getElement();
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);
myFileType = virtualFile != null ? virtualFile.getFileType() : FileTypes.PLAIN_TEXT;
init();
Segment range = info.getSegment();
hilight(virtualFile, range.getStartOffset(), range.getEndOffset());
UIUtil.setContent(replacement, replacementString,0,-1,project);
final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByPsiElement(element);
if (profile != null) {
UIUtil.updateHighlighter(replacement, profile);
}
}
示例14: createCommitTextEditor
import com.intellij.openapi.fileTypes.FileTypes; //导入依赖的package包/类
/**
* Creates a text editor appropriate for creating commit messages.
*
* @param project project this commit message editor is intended for
* @param forceSpellCheckOn if false, {@link com.intellij.openapi.vcs.VcsConfiguration#CHECK_COMMIT_MESSAGE_SPELLING} will control
* whether or not the editor has spell check enabled
* @return a commit message editor
*/
public static EditorTextField createCommitTextEditor(final Project project, boolean forceSpellCheckOn) {
Set<EditorCustomization> features = new HashSet<EditorCustomization>();
VcsConfiguration configuration = VcsConfiguration.getInstance(project);
if (configuration != null) {
boolean enableSpellChecking = forceSpellCheckOn || configuration.CHECK_COMMIT_MESSAGE_SPELLING;
ContainerUtil.addIfNotNull(features, SpellCheckingEditorCustomizationProvider.getInstance().getCustomization(enableSpellChecking));
features.add(new RightMarginEditorCustomization(configuration.USE_COMMIT_MESSAGE_MARGIN, configuration.COMMIT_MESSAGE_MARGIN_SIZE));
features.add(WrapWhenTypingReachesRightMarginCustomization.getInstance(configuration.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN));
} else {
ContainerUtil.addIfNotNull(features, SpellCheckingEditorCustomizationProvider.getInstance().getEnabledCustomization());
features.add(new RightMarginEditorCustomization(false, -1));
}
features.add(SoftWrapsEditorCustomization.ENABLED);
features.add(AdditionalPageAtBottomEditorCustomization.DISABLED);
EditorTextFieldProvider service = ServiceManager.getService(project, EditorTextFieldProvider.class);
return service.getEditorField(FileTypes.PLAIN_TEXT.getLanguage(), project, features);
}
示例15: createEditorField
import com.intellij.openapi.fileTypes.FileTypes; //导入依赖的package包/类
private static EditorTextField createEditorField(final Project project, final int defaultLines) {
final EditorTextFieldProvider service = ServiceManager.getService(project, EditorTextFieldProvider.class);
final EditorTextField editorField;
final Set<EditorCustomization> editorFeatures = ContainerUtil.newHashSet();
ContainerUtil.addIfNotNull(editorFeatures, SpellCheckingEditorCustomizationProvider.getInstance().getEnabledCustomization());
if (defaultLines == 1) {
editorFeatures.add(HorizontalScrollBarEditorCustomization.DISABLED);
editorFeatures.add(OneLineEditorCustomization.ENABLED);
} else {
editorFeatures.add(SoftWrapsEditorCustomization.ENABLED);
}
editorField = service.getEditorField(FileTypes.PLAIN_TEXT.getLanguage(), project, editorFeatures);
final int height = editorField.getFontMetrics(editorField.getFont()).getHeight();
editorField.getComponent().setMinimumSize(new Dimension(100, (int)(height * 1.3)));
return editorField;
}