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