本文整理匯總了Java中com.intellij.openapi.fileTypes.FileTypeManager.getInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java FileTypeManager.getInstance方法的具體用法?Java FileTypeManager.getInstance怎麽用?Java FileTypeManager.getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.fileTypes.FileTypeManager
的用法示例。
在下文中一共展示了FileTypeManager.getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: configureByText
import com.intellij.openapi.fileTypes.FileTypeManager; //導入方法依賴的package包/類
@Override
public PsiFile configureByText(@NotNull final FileType fileType, @NotNull @NonNls final String text) {
assertInitialized();
final String extension = fileType.getDefaultExtension();
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
if (fileTypeManager.getFileTypeByExtension(extension) != fileType) {
new WriteCommandAction(getProject()) {
@Override
protected void run(@NotNull Result result) throws Exception {
fileTypeManager.associateExtension(fileType, extension);
}
}.execute();
}
final String fileName = "aaa." + extension;
return configureByText(fileName, text);
}
示例2: PsiVFSListener
import com.intellij.openapi.fileTypes.FileTypeManager; //導入方法依賴的package包/類
public PsiVFSListener(Project project) {
myProject = project;
myFileTypeManager = FileTypeManager.getInstance();
myProjectRootManager = ProjectRootManager.getInstance(project);
myManager = (PsiManagerImpl) PsiManager.getInstance(project);
myFileManager = (FileManagerImpl) myManager.getFileManager();
myConnection = project.getMessageBus().connect(project);
StartupManager.getInstance(project).registerPreStartupActivity(new Runnable() {
@Override
public void run() {
myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, new MyModuleRootListener());
myConnection.subscribe(FileTypeManager.TOPIC, new FileTypeListener.Adapter() {
@Override
public void fileTypesChanged(@NotNull FileTypeEvent e) {
myFileManager.processFileTypesChanged();
}
});
myConnection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new MyFileDocumentManagerAdapter());
myFileManager.markInitialized();
}
});
}
示例3: getSelectedVcsFile
import com.intellij.openapi.fileTypes.FileTypeManager; //導入方法依賴的package包/類
@Nullable
public VirtualFile getSelectedVcsFile() {
final RepositoryTreeNode node = getSelectedNode();
if (node == null) return null;
DirectoryEntry entry = node.getSVNDirEntry();
if (entry == null || !entry.isFile()) {
return null;
}
String name = entry.getName();
FileTypeManager manager = FileTypeManager.getInstance();
if (entry.getName().lastIndexOf('.') > 0 && !manager.getFileTypeByFileName(name).isBinary()) {
SVNURL url = node.getURL();
final SvnFileRevision revision = new SvnFileRevision(myVCS, SVNRevision.UNDEFINED, SVNRevision.HEAD, url.toString(),
entry.getAuthor(), entry.getDate(), null, null);
return new VcsVirtualFile(node.getSVNDirEntry().getName(), revision, VcsFileSystem.getInstance());
} else {
return null;
}
}
示例4: isJavaSourceFile
import com.intellij.openapi.fileTypes.FileTypeManager; //導入方法依賴的package包/類
public static boolean isJavaSourceFile(@NotNull Project project, @NotNull VirtualFile file) {
FileTypeManager fileTypeManager = FileTypeManager.getInstance();
if (file.isDirectory() || file.getFileType() != StdFileTypes.JAVA || fileTypeManager.isFileIgnored(file)) {
return false;
}
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
return fileIndex.isUnderSourceRootOfType(file, JavaModuleSourceRootTypes.SOURCES) || fileIndex.isInLibrarySource(file);
}
示例5: testChangeIgnoreList
import com.intellij.openapi.fileTypes.FileTypeManager; //導入方法依賴的package包/類
public void testChangeIgnoreList() throws Exception {
VirtualFile newDir = createChildDirectory(myModule1Dir, "newDir");
assertInProject(newDir);
final FileTypeManagerEx fileTypeManager = (FileTypeManagerEx)FileTypeManager.getInstance();
final String list = fileTypeManager.getIgnoredFilesList();
final String list1 = list + ";" + "newDir";
try {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
fileTypeManager.setIgnoredFilesList(list1);
}
});
assertNotInProject(newDir);
}
finally {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
fileTypeManager.setIgnoredFilesList(list);
}
});
assertInProject(newDir);
}
}
示例6: suggestRoots
import com.intellij.openapi.fileTypes.FileTypeManager; //導入方法依賴的package包/類
/**
* Scan directory and detect java source roots within it. The source root is detected as the following:
* <ol>
* <li>It contains at least one Java file.</li>
* <li>Java file is located in the sub-folder that matches package statement in the file.</li>
* </ol>
*
* @param dir a directory to scan
* @param progressIndicator
* @return a list of found source roots within directory. If no source roots are found, a empty list is returned.
*/
@NotNull
public static List<VirtualFile> suggestRoots(@NotNull VirtualFile dir, @NotNull final ProgressIndicator progressIndicator) {
if (!dir.isDirectory()) {
return ContainerUtil.emptyList();
}
final FileTypeManager typeManager = FileTypeManager.getInstance();
final ArrayList<VirtualFile> foundDirectories = new ArrayList<VirtualFile>();
try {
VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor() {
@NotNull
@Override
public Result visitFileEx(@NotNull VirtualFile file) {
progressIndicator.checkCanceled();
if (file.isDirectory()) {
if (typeManager.isFileIgnored(file) || StringUtil.startsWithIgnoreCase(file.getName(), "testData")) {
return SKIP_CHILDREN;
}
}
else {
FileType type = typeManager.getFileTypeByFileName(file.getName());
if (StdFileTypes.JAVA == type) {
VirtualFile root = suggestRootForJavaFile(file);
if (root != null) {
foundDirectories.add(root);
return skipTo(root);
}
}
}
return CONTINUE;
}
});
}
catch (ProcessCanceledException ignore) { }
return foundDirectories;
}
示例7: RootDetectionProcessor
import com.intellij.openapi.fileTypes.FileTypeManager; //導入方法依賴的package包/類
public RootDetectionProcessor(File baseDir, final ProjectStructureDetector[] detectors) {
myBaseDir = getCanonicalDir(baseDir);
myDetectors = detectors;
//noinspection unchecked
myDetectedRoots = new List[myDetectors.length];
myTypeManager = FileTypeManager.getInstance();
myProgressIndicator = ProgressManager.getInstance().getProgressIndicator();
}
示例8: accept
import com.intellij.openapi.fileTypes.FileTypeManager; //導入方法依賴的package包/類
public boolean accept(File file) {
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
final String name = file.getName();
return !fileTypeManager.isFileIgnored(name)
&& fileTypeManager.getFileTypeByFileName(name) != StdFileTypes.IDEA_PROJECT
&& fileTypeManager.getFileTypeByFileName(name) != StdFileTypes.IDEA_MODULE
&& fileTypeManager.getFileTypeByFileName(name) != StdFileTypes.IDEA_WORKSPACE
;
}
示例9: isIgnoredOrUnderIgnoredDirectory
import com.intellij.openapi.fileTypes.FileTypeManager; //導入方法依賴的package包/類
private static boolean isIgnoredOrUnderIgnoredDirectory(final VirtualFile file) {
if (isIgnoredByBuild(file)) {
return true;
}
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
VirtualFile current = file.getParent();
while (current != null) {
if (fileTypeManager.isFileIgnored(current)) {
return true;
}
current = current.getParent();
}
return false;
}
示例10: processFileRecursivelyWithoutIgnored
import com.intellij.openapi.fileTypes.FileTypeManager; //導入方法依賴的package包/類
public static void processFileRecursivelyWithoutIgnored(@NotNull final VirtualFile root, @NotNull final Processor<VirtualFile> processor) {
final FileTypeManager ftm = FileTypeManager.getInstance();
processFilesRecursively(root, processor, new Convertor<VirtualFile, Boolean>() {
public Boolean convert(final VirtualFile vf) {
return ! ftm.isFileIgnored(vf);
}
});
}
示例11: addAndRemoveFileType
import com.intellij.openapi.fileTypes.FileTypeManager; //導入方法依賴的package包/類
static void addAndRemoveFileType() {
FileType foo = new FakeFileType() {
@Override
public boolean isMyFileType(@NotNull VirtualFile file) {
return true;
}
@NotNull
@Override
public String getName() {
return "foo";
}
@NotNull
@Override
public String getDescription() {
return "";
}
};
FileTypeIndex index = new FileTypeIndex(FileTypeManager.getInstance());
int version = index.getVersion();
try {
FileTypeManagerEx.getInstanceEx().registerFileType(foo);
assertNotSame(version, index.getVersion());
}
finally {
FileTypeManagerEx.getInstanceEx().unregisterFileType(foo);
}
}
示例12: collectReadOnlyFiles
import com.intellij.openapi.fileTypes.FileTypeManager; //導入方法依賴的package包/類
public static void collectReadOnlyFiles(final VirtualFile vFile, final Collection<VirtualFile> list) {
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
VfsUtilCore.visitChildrenRecursively(vFile, new VirtualFileVisitor(VirtualFileVisitor.NO_FOLLOW_SYMLINKS) {
@Override
public boolean visitFile(@NotNull VirtualFile file) {
final boolean ignored = fileTypeManager.isFileIgnored(file);
if (! file.isWritable() && ! ignored) {
list.add(file);
}
return ! ignored;
}
});
}
示例13: isSchemaSourceFile
import com.intellij.openapi.fileTypes.FileTypeManager; //導入方法依賴的package包/類
@Contract("_, null -> false")
public static boolean isSchemaSourceFile(@NotNull Project project, @Nullable VirtualFile file) {
if (file == null) return false;
FileTypeManager fileTypeManager = FileTypeManager.getInstance();
if (file.isDirectory() || fileTypeManager.isFileIgnored(file)) {
return false;
}
return fileUnderSources(project, file);
}
示例14: getFileType
import com.intellij.openapi.fileTypes.FileTypeManager; //導入方法依賴的package包/類
@Override
@NotNull
public FileType getFileType() {
VirtualFile file = getVirtualFile();
FileTypeManager manager = FileTypeManager.getInstance();
return file != null ? manager.getFileTypeByFile(file) : manager.getFileTypeByFileName(getName());
}
示例15: DirtBuilder
import com.intellij.openapi.fileTypes.FileTypeManager; //導入方法依賴的package包/類
public DirtBuilder(final VcsGuess guess) {
myGuess = guess;
myDirs = MultiMap.createSet();
myFiles = MultiMap.createSet();
myEverythingDirty = false;
myFileTypeManager = FileTypeManager.getInstance();
}