本文整理汇总了Java中com.intellij.openapi.fileEditor.FileEditorManager.openTextEditor方法的典型用法代码示例。如果您正苦于以下问题:Java FileEditorManager.openTextEditor方法的具体用法?Java FileEditorManager.openTextEditor怎么用?Java FileEditorManager.openTextEditor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.fileEditor.FileEditorManager
的用法示例。
在下文中一共展示了FileEditorManager.openTextEditor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: overrideOrImplement
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
public static List<PsiGenerationInfo<PsiMethod>> overrideOrImplement(PsiClass psiClass, @NotNull PsiMethod baseMethod) throws IncorrectOperationException {
FileEditorManager fileEditorManager = FileEditorManager.getInstance(baseMethod.getProject());
List<PsiGenerationInfo<PsiMethod>> results = new ArrayList<PsiGenerationInfo<PsiMethod>>();
try {
List<PsiGenerationInfo<PsiMethod>> prototypes = convert2GenerationInfos(overrideOrImplementMethod(psiClass, baseMethod, false));
if (prototypes.isEmpty()) return null;
PsiSubstitutor substitutor = TypeConversionUtil.getSuperClassSubstitutor(baseMethod.getContainingClass(), psiClass, PsiSubstitutor.EMPTY);
PsiElement anchor = getDefaultAnchorToOverrideOrImplement(psiClass, baseMethod, substitutor);
results = GenerateMembersUtil.insertMembersBeforeAnchor(psiClass, anchor, prototypes);
return results;
}
finally {
PsiFile psiFile = psiClass.getContainingFile();
Editor editor = fileEditorManager.openTextEditor(new OpenFileDescriptor(psiFile.getProject(), psiFile.getVirtualFile()), true);
if (editor != null && !results.isEmpty()) {
results.get(0).positionCaret(editor, true);
editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
}
}
}
示例2: createEditor
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
protected Editor createEditor(@NotNull VirtualFile file) {
final FileEditorManager instance = FileEditorManager.getInstance(myProject);
if (file.getFileType().isBinary()) return null;
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
Editor editor = instance.openTextEditor(new OpenFileDescriptor(myProject, file, 0), false);
((EditorImpl)editor).setCaretActive();
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
DaemonCodeAnalyzer.getInstance(getProject()).restart();
return editor;
}
示例3: addDependency
import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
@Override
public void addDependency(Module module, String artifact) {
Project project = module.getProject();
BlazeProjectData blazeProjectData =
BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (blazeProjectData == null) {
return;
}
AndroidResourceModuleRegistry registry = AndroidResourceModuleRegistry.getInstance(project);
TargetIdeInfo targetIdeInfo = blazeProjectData.targetMap.get(registry.getTargetKey(module));
if (targetIdeInfo == null || targetIdeInfo.buildFile == null) {
return;
}
// TODO: automagically edit deps instead of just opening the BUILD file?
// Need to translate Gradle coordinates into blaze targets.
// Will probably need to hardcode for each dependency.
FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
PsiElement buildTargetPsi =
BuildReferenceManager.getInstance(project).resolveLabel(targetIdeInfo.key.label);
if (buildTargetPsi != null) {
// If we can find a PSI for the target,
// then we can jump straight to the target in the build file.
fileEditorManager.openTextEditor(
new OpenFileDescriptor(
project,
buildTargetPsi.getContainingFile().getVirtualFile(),
buildTargetPsi.getTextOffset()),
true);
} else {
// If not, just the build file is good enough.
File buildIoFile = blazeProjectData.artifactLocationDecoder.decode(targetIdeInfo.buildFile);
VirtualFile buildVirtualFile =
VirtualFileSystemProvider.findFileByIoFileRefreshIfNeeded(buildIoFile);
if (buildVirtualFile != null) {
fileEditorManager.openFile(buildVirtualFile, true);
}
}
}