當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。