Java 类com.intellij.lang.PsiStructureViewFactory 实例源码

项目:intellij-ce-playground    文件:TemplateLanguageStructureViewBuilder.java   
@Nullable
private StructureViewComposite.StructureViewDescriptor createBaseLanguageStructureView(final FileEditor fileEditor, final Language language) {
  if (!myVirtualFile.isValid()) return null;

  final FileViewProvider viewProvider = getViewProvider();
  if (viewProvider == null) return null;

  final PsiFile dataFile = viewProvider.getPsi(language);
  if (dataFile == null || !isAcceptableBaseLanguageFile(dataFile)) return null;

  final PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(language);
  if (factory == null) return null;

  final StructureViewBuilder builder = factory.getStructureViewBuilder(dataFile);
  if (builder == null) return null;

  StructureView structureView = builder.createStructureView(fileEditor, myProject);
  return new StructureViewComposite.StructureViewDescriptor(IdeBundle.message("tab.structureview.baselanguage.view", language.getDisplayName()), structureView, findFileType(language).getIcon());
}
项目:tools-idea    文件:TemplateLanguageStructureViewBuilder.java   
@Nullable
private StructureViewComposite.StructureViewDescriptor createBaseLanguageStructureView(final FileEditor fileEditor, final Language language) {
  if (!myVirtualFile.isValid()) return null;

  final TemplateLanguageFileViewProvider viewProvider = getViewProvider();
  if (viewProvider == null) return null;

  final PsiFile dataFile = viewProvider.getPsi(language);
  if (dataFile == null || !isAcceptableBaseLanguageFile(dataFile)) return null;

  final PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(language);
  if (factory == null) return null;

  final StructureViewBuilder builder = factory.getStructureViewBuilder(dataFile);
  if (builder == null) return null;

  StructureView structureView = builder.createStructureView(fileEditor, myProject);
  return new StructureViewComposite.StructureViewDescriptor(IdeBundle.message("tab.structureview.baselanguage.view", language.getDisplayName()), structureView, findFileType(language).getIcon());
}
项目:consulo    文件:TemplateLanguageStructureViewBuilder.java   
@Nullable
private StructureViewComposite.StructureViewDescriptor createBaseLanguageStructureView(final FileEditor fileEditor, final Language language) {
  if (!myVirtualFile.isValid()) return null;

  final TemplateLanguageFileViewProvider viewProvider = getViewProvider();
  if (viewProvider == null) return null;

  final PsiFile dataFile = viewProvider.getPsi(language);
  if (dataFile == null || !isAcceptableBaseLanguageFile(dataFile)) return null;

  final PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(language);
  if (factory == null) return null;

  final StructureViewBuilder builder = factory.getStructureViewBuilder(dataFile);
  if (builder == null) return null;

  StructureView structureView = builder.createStructureView(fileEditor, myProject);
  return new StructureViewComposite.StructureViewDescriptor(IdeBundle.message("tab.structureview.baselanguage.view", language.getDisplayName()), structureView, findFileType(language).getIcon());
}
项目:consulo-xml    文件:XmlStructureViewBuilderFactory.java   
@Nullable
private static StructureViewBuilder getStructureViewBuilderForExtensions(final PsiFile psiFile)
{
    for(Language language : XMLLanguage.INSTANCE.getLanguageExtensionsForFile(psiFile))
    {
        PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(language);
        if(factory == null)
        {
            continue;
        }
        final StructureViewBuilder builder = factory.getStructureViewBuilder(psiFile);
        if(builder != null)
        {
            return builder;
        }
    }
    return null;
}
项目:consulo-java    文件:JavaClsStructureViewBuilderProvider.java   
@Override
@Nullable
public StructureViewBuilder getStructureViewBuilder(@NotNull FileType fileType, @NotNull VirtualFile file, @NotNull Project project)
{
    if(fileType == JavaClassFileType.INSTANCE)
    {
        PsiFile psiFile = PsiManager.getInstance(project).findFile(file);

        if(psiFile instanceof PsiCompiledFile)
        {
            psiFile = ((PsiCompiledFile) psiFile).getDecompiledPsiFile();
        }

        if(psiFile != null)
        {
            PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(psiFile.getLanguage());
            if(factory != null)
            {
                return factory.getStructureViewBuilder(psiFile);
            }
        }
    }

    return null;
}
项目:intellij-ce-playground    文件:JavaClsStructureViewBuilderProvider.java   
@Override
@Nullable
public StructureViewBuilder getStructureViewBuilder(@NotNull FileType fileType, @NotNull VirtualFile file, @NotNull Project project) {
  final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);

  if (fileType == JavaClassFileType.INSTANCE && psiFile != null) {
    Language language = psiFile.getLanguage();
    if (language != JavaLanguage.INSTANCE) {
      PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(language);
      if (factory != null) {
        return factory.getStructureViewBuilder(psiFile);
      }
    }
  }

  if (psiFile instanceof PsiClassOwner) {
    return new TreeBasedStructureViewBuilder() {
      @Override
      @NotNull
      public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
        return new JavaFileTreeModel((PsiClassOwner)psiFile, editor);
      }
    };
  }

  return null;
}
项目:intellij-ce-playground    文件:LanguageFileTypeStructureViewBuilderProvider.java   
@Override
@Nullable
public StructureViewBuilder getStructureViewBuilder(@NotNull final FileType fileType, @NotNull final VirtualFile file, @NotNull final Project project) {
  if (!(fileType instanceof LanguageFileType)) return null;

  final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
  if (psiFile == null) return null;

  final PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(psiFile.getLanguage());
  return factory == null ?  null : factory.getStructureViewBuilder(psiFile);
}
项目:intellij-ce-playground    文件:GotoClassAction.java   
@Nullable
private static Navigatable findMember(String pattern, PsiElement psiElement, VirtualFile file) {
  final PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(psiElement.getLanguage());
  final StructureViewBuilder builder = factory == null ? null : factory.getStructureViewBuilder(psiElement.getContainingFile());
  final FileEditor[] editors = FileEditorManager.getInstance(psiElement.getProject()).getEditors(file);
  if (builder == null || editors.length == 0) {
    return null;
  }

  final StructureView view = builder.createStructureView(editors[0], psiElement.getProject());
  try {
    final StructureViewTreeElement element = findElement(view.getTreeModel().getRoot(), psiElement, 4);
    if (element == null) {
      return null;
    }

    final MinusculeMatcher matcher = new MinusculeMatcher(pattern, NameUtil.MatchingCaseSensitivity.NONE);
    int max = Integer.MIN_VALUE;
    Object target = null;
    for (TreeElement treeElement : element.getChildren()) {
      if (treeElement instanceof StructureViewTreeElement) {
        String presentableText = treeElement.getPresentation().getPresentableText();
        if (presentableText != null) {
          final int degree = matcher.matchingDegree(presentableText);
          if (degree > max) {
            max = degree;
            target = ((StructureViewTreeElement)treeElement).getValue();
          }
        }
      }
    }
    return target instanceof Navigatable ? (Navigatable)target : null;
  }
  finally {
    Disposer.dispose(view);
  }
}
项目:intellij-ce-playground    文件:XmlStructureViewBuilderFactory.java   
@Nullable
private static StructureViewBuilder getStructureViewBuilderForExtensions(final PsiFile psiFile) {
  for (Language language : XMLLanguage.INSTANCE.getLanguageExtensionsForFile(psiFile)) {
    PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(language);
    if (factory == null) continue;
    final StructureViewBuilder builder = factory.getStructureViewBuilder(psiFile);
    if (builder != null) {
      return builder;
    }
  }
  return null;
}
项目:tools-idea    文件:JavaClsStructureViewBuilderProvider.java   
@Override
@Nullable
public StructureViewBuilder getStructureViewBuilder(@NotNull final FileType fileType, @NotNull final VirtualFile file, @NotNull final Project project) {

  final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);

  final ContentBasedFileSubstitutor[] processors = Extensions.getExtensions(ContentBasedFileSubstitutor.EP_NAME);
  for (ContentBasedFileSubstitutor processor : processors) {
    if (processor.isApplicable(project, file)) {
      final Language language = processor.obtainLanguageForFile(file);
      if (language != null) {
        final PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(language);
        if (factory != null) return factory.getStructureViewBuilder(psiFile);
      }
    }
  }

  final PsiJavaFile javaFile = (PsiJavaFile)psiFile;
  if (javaFile == null) return null;
  return new TreeBasedStructureViewBuilder() {
    @Override
    @NotNull
    public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
      return new JavaFileTreeModel(javaFile, editor);
    }
  };
}
项目:tools-idea    文件:LanguageFileTypeStructureViewBuilderProvider.java   
@Override
@Nullable
public StructureViewBuilder getStructureViewBuilder(@NotNull final FileType fileType, @NotNull final VirtualFile file, @NotNull final Project project) {
  if (!(fileType instanceof LanguageFileType)) return null;

  final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
  if (psiFile == null) return null;

  final PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(psiFile.getLanguage());
  return factory == null ?  null : factory.getStructureViewBuilder(psiFile);
}
项目:tools-idea    文件:GotoClassAction.java   
@Nullable private static Navigatable findMember(String pattern, PsiElement psiElement, VirtualFile file) {
  final PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(psiElement.getLanguage());
  final StructureViewBuilder builder = factory == null ? null : factory.getStructureViewBuilder(psiElement.getContainingFile());
  final FileEditor[] editors = FileEditorManager.getInstance(psiElement.getProject()).getEditors(file);
  if (builder == null || editors.length == 0) {
    return null;
  }

  final StructureView view = builder.createStructureView(editors[0], psiElement.getProject());
  try {
    final StructureViewTreeElement element = findElement(view.getTreeModel().getRoot(), psiElement, 4);
    if (element == null) {
      return null;
    }

    final MinusculeMatcher matcher = new MinusculeMatcher(pattern, NameUtil.MatchingCaseSensitivity.NONE);
    int max = Integer.MIN_VALUE;
    Object target = null;
    for (TreeElement treeElement : element.getChildren()) {
      if (treeElement instanceof StructureViewTreeElement) {
        final ItemPresentation presentation = treeElement.getPresentation();
        String presentableText = presentation == null ? null : presentation.getPresentableText();
        if (presentableText != null) {
          final int degree = matcher.matchingDegree(presentableText);
          if (degree > max) {
            max = degree;
            target = ((StructureViewTreeElement)treeElement).getValue();
          }
        }
      }
    }
    return target instanceof Navigatable ? (Navigatable)target : null;
  }
  finally {
    Disposer.dispose(view);
  }
}
项目:tools-idea    文件:XmlStructureViewBuilderFactory.java   
@Nullable
private static StructureViewBuilder getStructureViewBuilderForExtensions(final PsiFile psiFile) {
  for (Language language : XMLLanguage.INSTANCE.getLanguageExtensionsForFile(psiFile)) {
    PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(language);
    if (factory == null) continue;
    final StructureViewBuilder builder = factory.getStructureViewBuilder(psiFile);
    if (builder != null) {
      return builder;
    }
  }
  return null;
}
项目:consulo    文件:LanguageFileTypeStructureViewBuilderProvider.java   
@Override
@Nullable
public StructureViewBuilder getStructureViewBuilder(@Nonnull final FileType fileType, @Nonnull final VirtualFile file, @Nonnull final Project project) {
  if (!(fileType instanceof LanguageFileType)) return null;

  final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
  if (psiFile == null) return null;

  final PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(psiFile.getLanguage());
  return factory == null ?  null : factory.getStructureViewBuilder(psiFile);
}
项目:consulo    文件:GotoClassAction.java   
@Nullable
private static Navigatable findMember(String pattern, PsiElement psiElement, VirtualFile file) {
  final PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(psiElement.getLanguage());
  final StructureViewBuilder builder = factory == null ? null : factory.getStructureViewBuilder(psiElement.getContainingFile());
  final FileEditor[] editors = FileEditorManager.getInstance(psiElement.getProject()).getEditors(file);
  if (builder == null || editors.length == 0) {
    return null;
  }

  final StructureView view = builder.createStructureView(editors[0], psiElement.getProject());
  try {
    final StructureViewTreeElement element = findElement(view.getTreeModel().getRoot(), psiElement, 4);
    if (element == null) {
      return null;
    }
    final MinusculeMatcher matcher = NameUtil.buildMatcher(pattern).build();
    int max = Integer.MIN_VALUE;
    Object target = null;
    for (TreeElement treeElement : element.getChildren()) {
      if (treeElement instanceof StructureViewTreeElement) {
        String presentableText = treeElement.getPresentation().getPresentableText();
        if (presentableText != null) {
          final int degree = matcher.matchingDegree(presentableText);
          if (degree > max) {
            max = degree;
            target = ((StructureViewTreeElement)treeElement).getValue();
          }
        }
      }
    }
    return target instanceof Navigatable ? (Navigatable)target : null;
  }
  finally {
    Disposer.dispose(view);
  }
}