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


Java PsiStructureViewFactory类代码示例

本文整理汇总了Java中com.intellij.lang.PsiStructureViewFactory的典型用法代码示例。如果您正苦于以下问题:Java PsiStructureViewFactory类的具体用法?Java PsiStructureViewFactory怎么用?Java PsiStructureViewFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PsiStructureViewFactory类属于com.intellij.lang包,在下文中一共展示了PsiStructureViewFactory类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createBaseLanguageStructureView

import com.intellij.lang.PsiStructureViewFactory; //导入依赖的package包/类
@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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TemplateLanguageStructureViewBuilder.java

示例2: createBaseLanguageStructureView

import com.intellij.lang.PsiStructureViewFactory; //导入依赖的package包/类
@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());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:TemplateLanguageStructureViewBuilder.java

示例3: getStructureViewBuilderForExtensions

import com.intellij.lang.PsiStructureViewFactory; //导入依赖的package包/类
@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;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:19,代码来源:XmlStructureViewBuilderFactory.java

示例4: getStructureViewBuilder

import com.intellij.lang.PsiStructureViewFactory; //导入依赖的package包/类
@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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:JavaClsStructureViewBuilderProvider.java

示例5: getStructureViewBuilder

import com.intellij.lang.PsiStructureViewFactory; //导入依赖的package包/类
@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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:JavaClsStructureViewBuilderProvider.java

示例6: getStructureViewBuilder

import com.intellij.lang.PsiStructureViewFactory; //导入依赖的package包/类
@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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:LanguageFileTypeStructureViewBuilderProvider.java

示例7: findMember

import com.intellij.lang.PsiStructureViewFactory; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:GotoClassAction.java

示例8: getStructureViewBuilderForExtensions

import com.intellij.lang.PsiStructureViewFactory; //导入依赖的package包/类
@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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:XmlStructureViewBuilderFactory.java

示例9: getStructureViewBuilder

import com.intellij.lang.PsiStructureViewFactory; //导入依赖的package包/类
@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);
    }
  };
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:JavaClsStructureViewBuilderProvider.java

示例10: findMember

import com.intellij.lang.PsiStructureViewFactory; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:38,代码来源:GotoClassAction.java

示例11: getStructureViewBuilder

import com.intellij.lang.PsiStructureViewFactory; //导入依赖的package包/类
@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);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:12,代码来源:LanguageFileTypeStructureViewBuilderProvider.java

示例12: findMember

import com.intellij.lang.PsiStructureViewFactory; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:37,代码来源:GotoClassAction.java


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