当前位置: 首页>>代码示例>>Java>>正文


Java FileEditorManager.openTextEditor方法代码示例

本文整理汇总了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);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:OverrideImplementUtil.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:CodeInsightTestCase.java

示例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);
    }
  }
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:40,代码来源:BlazeBuildSystemService.java


注:本文中的com.intellij.openapi.fileEditor.FileEditorManager.openTextEditor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。