本文整理汇总了Java中com.intellij.util.FileContentUtil类的典型用法代码示例。如果您正苦于以下问题:Java FileContentUtil类的具体用法?Java FileContentUtil怎么用?Java FileContentUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileContentUtil类属于com.intellij.util包,在下文中一共展示了FileContentUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeImpl
import com.intellij.util.FileContentUtil; //导入依赖的package包/类
private static void invokeImpl(Project project, Editor editor, PsiFile file) {
final PsiFile psiFile = InjectedLanguageUtil.findInjectedPsiNoCommit(file, editor.getCaretModel().getOffset());
if (psiFile == null) return;
final PsiLanguageInjectionHost host = InjectedLanguageManager.getInstance(project).getInjectionHost(psiFile);
if (host == null) return;
final LanguageInjectionSupport support = psiFile.getUserData(LanguageInjectionSupport.SETTINGS_EDITOR);
if (support == null) return;
try {
if (!support.editInjectionInPlace(host)) {
ShowSettingsUtil.getInstance().editConfigurable(project, new InjectionsSettingsUI(project, Configuration.getProjectInstance(project)));
}
}
finally {
FileContentUtil.reparseFiles(project, Collections.<VirtualFile>emptyList(), true);
}
}
示例2: invokeImpl
import com.intellij.util.FileContentUtil; //导入依赖的package包/类
public static void invokeImpl(Project project, Editor editor, PsiFile file, Injectable injectable) {
final PsiLanguageInjectionHost host = findInjectionHost(editor, file);
if (host == null) return;
if (defaultFunctionalityWorked(host, injectable.getId())) return;
try {
Language language = injectable.toLanguage();
for (LanguageInjectionSupport support : InjectorUtils.getActiveInjectionSupports()) {
if (support.isApplicableTo(host) && support.addInjectionInPlace(language, host)) {
return;
}
}
if (TemporaryPlacesRegistry.getInstance(project).getLanguageInjectionSupport().addInjectionInPlace(language, host)) {
HintManager.getInstance().showInformationHint(editor, StringUtil.escapeXml(language.getDisplayName()) + " was temporarily injected");
}
}
finally {
if (injectable.getLanguage() != null) { // no need for reference injection
FileContentUtil.reparseFiles(project, Collections.<VirtualFile>emptyList(), true);
}
else {
((PsiModificationTrackerImpl)PsiManager.getInstance(project).getModificationTracker()).incCounter();
DaemonCodeAnalyzer.getInstance(project).restart();
}
}
}
示例3: reparseProjectFiles
import com.intellij.util.FileContentUtil; //导入依赖的package包/类
public static void reparseProjectFiles(@NotNull final Project project) {
Task.Backgroundable task = new Task.Backgroundable(project, HaxeBundle.message("haxe.project.reparsing"), false) {
public void run(@NotNull ProgressIndicator indicator) {
final Collection<VirtualFile> haxeFiles = new ArrayList<VirtualFile>();
final VirtualFile baseDir = project.getBaseDir();
if (baseDir != null) {
FileBasedIndex.getInstance().iterateIndexableFiles(new ContentIterator() {
public boolean processFile(VirtualFile file) {
if (HaxeFileType.HAXE_FILE_TYPE == file.getFileType()) {
haxeFiles.add(file);
}
return true;
}
}, project, indicator);
}
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
public void run() {
FileContentUtil.reparseFiles(project, haxeFiles, !project.isDefault());
}
}, ModalityState.NON_MODAL);
}
};
ProgressManager.getInstance().run(task);
}
示例4: testReplaceFile
import com.intellij.util.FileContentUtil; //导入依赖的package包/类
public void testReplaceFile() throws IOException {
VirtualFile vfile = myRoot.createChildData(this, "X.java");
VfsUtil.saveText(vfile, "public class X { public int X; }");
PsiClass aClass = myJavaFacade.findClass("X", GlobalSearchScope.allScope(getProject()));
assertNotNull(aClass);
assertTrue(aClass.isValid());
SmartPsiElementPointer classp = createPointer(aClass);
SmartPsiElementPointer filep = createPointer(aClass.getContainingFile());
FileContentUtil.reparseFiles(myProject, Collections.<VirtualFile>singleton(vfile), true);
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
assertFalse(aClass.isValid());
PsiElement element = classp.getElement();
assertNotNull(element);
assertTrue(element instanceof PsiClass);
assertTrue(element.isValid());
assertEquals(vfile, element.getContainingFile().getVirtualFile());
element = filep.getElement();
assertNotNull(element);
assertTrue(element instanceof PsiFile);
assertTrue(element.isValid());
assertEquals(vfile, element.getContainingFile().getVirtualFile());
}
示例5: setLanguage
import com.intellij.util.FileContentUtil; //导入依赖的package包/类
public void setLanguage(Language language) {
if (!(virtualFile instanceof LightVirtualFile)) {
throw new UnsupportedOperationException();
}
((LightVirtualFile)virtualFile).setLanguage(language);
((LightVirtualFile)virtualFile).setContent(getDocument(), getDocument().getText(), false);
FileContentUtil.reparseFiles(project, Collections.singletonList(virtualFile), false);
}
示例6: apply
import com.intellij.util.FileContentUtil; //导入依赖的package包/类
@Override
public void apply() throws ConfigurationException {
if (myDocstringFormatComboBox.getSelectedItem() != myDocumentationSettings.getFormat()) {
DaemonCodeAnalyzer.getInstance(myProject).restart();
}
if (analyzeDoctest.isSelected() != myDocumentationSettings.isAnalyzeDoctest()) {
final List<VirtualFile> files = Lists.newArrayList();
ProjectRootManager.getInstance(myProject).getFileIndex().iterateContent(new ContentIterator() {
@Override
public boolean processFile(VirtualFile fileOrDir) {
if (!fileOrDir.isDirectory() && PythonFileType.INSTANCE.getDefaultExtension().equals(fileOrDir.getExtension())) {
files.add(fileOrDir);
}
return true;
}
});
FileContentUtil.reparseFiles(myProject, Lists.newArrayList(files), false);
}
myModel.apply();
myDocumentationSettings.setFormat((DocStringFormat)myDocstringFormatComboBox.getSelectedItem());
final ReSTService reSTService = ReSTService.getInstance(myModule);
reSTService.setWorkdir(myWorkDir.getText());
if (txtIsRst.isSelected() != reSTService.txtIsRst()) {
reSTService.setTxtIsRst(txtIsRst.isSelected());
reparseFiles(Collections.singletonList(PlainTextFileType.INSTANCE.getDefaultExtension()));
}
myDocumentationSettings.setAnalyzeDoctest(analyzeDoctest.isSelected());
PyPackageRequirementsSettings.getInstance(myModule).setRequirementsPath(myRequirementsPathField.getText());
DaemonCodeAnalyzer.getInstance(myProject).restart();
}
示例7: afterRootsChanged
import com.intellij.util.FileContentUtil; //导入依赖的package包/类
public void afterRootsChanged(@NotNull final Project project) {
Set<Sdk> updatedSdks = new HashSet<Sdk>();
final Module[] modules = ModuleManager.getInstance(project).getModules();
boolean needReparseOpenFiles = false;
for (Module module : modules) {
if (isPythonModule(module)) {
Sdk newSdk = PythonSdkType.findPythonSdk(module);
if (myModuleSdks.containsKey(module)) {
Sdk oldSdk = myModuleSdks.get(module);
if ((newSdk != null || oldSdk != null) && newSdk != oldSdk) {
needReparseOpenFiles = true;
}
}
myModuleSdks.put(module, newSdk);
if (newSdk != null && !updatedSdks.contains(newSdk)) {
updatedSdks.add(newSdk);
updateSdkLanguageLevel(project, newSdk);
}
}
}
if (needReparseOpenFiles) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (project.isDisposed()) {
return;
}
FileContentUtil.reparseFiles(project, Collections.<VirtualFile>emptyList(), true);
}
});
}
}
示例8: reparseFile
import com.intellij.util.FileContentUtil; //导入依赖的package包/类
public static void reparseFile (final PsiFile file) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override public void run() {
FileContentUtil.reparseFiles(file.getProject(), Collections.singletonList(file.getVirtualFile()), true);
}
});
}
示例9: testReplaceFile
import com.intellij.util.FileContentUtil; //导入依赖的package包/类
public void testReplaceFile() throws IOException {
VirtualFile vfile = myRoot.createChildData(this, "X.java");
VfsUtil.saveText(vfile, "public class X { public int X; }");
PsiClass aClass = myJavaFacade.findClass("X", GlobalSearchScope.allScope(getProject()));
assertNotNull(aClass);
assertTrue(aClass.isValid());
SmartPsiElementPointer classp = SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(aClass);
SmartPsiElementPointer filep = SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(aClass.getContainingFile());
FileContentUtil.reparseFiles(myProject, Collections.<VirtualFile>singleton(vfile), true);
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
assertFalse(aClass.isValid());
PsiElement element = classp.getElement();
assertNotNull(element);
assertTrue(element instanceof PsiClass);
assertTrue(element.isValid());
assertEquals(vfile, element.getContainingFile().getVirtualFile());
element = filep.getElement();
assertNotNull(element);
assertTrue(element instanceof PsiFile);
assertTrue(element.isValid());
assertEquals(vfile, element.getContainingFile().getVirtualFile());
}
示例10: shouldNotProcess
import com.intellij.util.FileContentUtil; //导入依赖的package包/类
private boolean shouldNotProcess(VirtualFileEvent e) {
return isProjectClosed() || !LocalHistory.getInstance().isUnderControl(e.getFile()) || !myIsInsideCommand
|| FileContentUtil.FORCE_RELOAD_REQUESTOR.equals(e.getRequestor());
}
示例11: reparseFiles
import com.intellij.util.FileContentUtil; //导入依赖的package包/类
@Override
public void reparseFiles(@NotNull Collection<VirtualFile> files, boolean includeOpenFiles) {
FileContentUtil.reparseFiles(myProject, files, includeOpenFiles);
}
示例12: invokeImpl
import com.intellij.util.FileContentUtil; //导入依赖的package包/类
public static void invokeImpl(Project project, Editor editor, final PsiFile file, Injectable injectable) {
final PsiLanguageInjectionHost host = findInjectionHost(editor, file);
if (host == null) return;
if (defaultFunctionalityWorked(host, injectable.getId())) return;
try {
host.putUserData(FIX_KEY, null);
Language language = injectable.toLanguage();
for (LanguageInjectionSupport support : InjectorUtils.getActiveInjectionSupports()) {
if (support.isApplicableTo(host) && support.addInjectionInPlace(language, host)) {
return;
}
}
if (TemporaryPlacesRegistry.getInstance(project).getLanguageInjectionSupport().addInjectionInPlace(language, host)) {
final Processor<PsiLanguageInjectionHost> data = host.getUserData(FIX_KEY);
String text = StringUtil.escapeXml(language.getDisplayName()) + " was temporarily injected.";
if (data != null) {
if (!ApplicationManager.getApplication().isUnitTestMode()) {
final SmartPsiElementPointer<PsiLanguageInjectionHost> pointer =
SmartPointerManager.getInstance(project).createSmartPsiElementPointer(host);
final TextRange range = host.getTextRange();
HintManager.getInstance().showQuestionHint(editor, text + "<br>Do you want to insert annotation? " + KeymapUtil
.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_INTENTION_ACTIONS)),
range.getStartOffset(), range.getEndOffset(), new QuestionAction() {
@Override
public boolean execute() {
return data.process(pointer.getElement());
}
});
}
}
else {
HintManager.getInstance().showInformationHint(editor, text);
}
}
}
finally {
if (injectable.getLanguage() != null) { // no need for reference injection
FileContentUtil.reparseFiles(project, Collections.<VirtualFile>emptyList(), true);
}
else {
((PsiModificationTrackerImpl)PsiManager.getInstance(project).getModificationTracker()).incCounter();
DaemonCodeAnalyzer.getInstance(project).restart();
}
}
}
示例13: createFileFromTemplate
import com.intellij.util.FileContentUtil; //导入依赖的package包/类
@Nullable
private VirtualFile createFileFromTemplate(@Nullable final Project project, String url, final String templateName, final boolean forceNew) {
final LocalFileSystem fileSystem = LocalFileSystem.getInstance();
final File file = new File(VfsUtil.urlToPath(url));
VirtualFile existingFile = fileSystem.refreshAndFindFileByIoFile(file);
if (existingFile != null) {
existingFile.refresh(false, false);
if (!existingFile.isValid()) {
existingFile = null;
}
}
if (existingFile != null && !forceNew) {
return existingFile;
}
try {
String text = getText(templateName);
final VirtualFile childData;
if (existingFile == null || existingFile.isDirectory()) {
final VirtualFile virtualFile;
if (!FileUtil.createParentDirs(file) ||
(virtualFile = fileSystem.refreshAndFindFileByIoFile(file.getParentFile())) == null) {
throw new IOException(IdeBundle.message("error.message.unable.to.create.file", file.getPath()));
}
childData = virtualFile.createChildData(this, file.getName());
}
else {
childData = existingFile;
}
FileContentUtil.setFileText(project, childData, text);
return childData;
}
catch (final IOException e) {
LOG.info(e);
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
Messages.showErrorDialog(IdeBundle.message("message.text.error.creating.deployment.descriptor", e.getLocalizedMessage()),
IdeBundle.message("message.text.creating.deployment.descriptor"));
}
});
}
return null;
}
示例14: setLanguage
import com.intellij.util.FileContentUtil; //导入依赖的package包/类
public void setLanguage(Language language) {
myVirtualFile.setLanguage(language);
myVirtualFile.setContent(myEditorDocument, myEditorDocument.getText(), false);
FileContentUtil.reparseFiles(myProject, Collections.<VirtualFile>singletonList(myVirtualFile), false);
myFile = ObjectUtils.assertNotNull(PsiManager.getInstance(myProject).findFile(myVirtualFile));
}
示例15: reparseFiles
import com.intellij.util.FileContentUtil; //导入依赖的package包/类
@Override
public void reparseFiles(@Nonnull Collection<VirtualFile> files, boolean includeOpenFiles) {
FileContentUtil.reparseFiles(myProject, files, includeOpenFiles);
}