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


Java PsiFileBase类代码示例

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


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

示例1: dynamically

import com.intellij.extapi.psi.PsiFileBase; //导入依赖的package包/类
/**
 * Finds injected language in expression
 *
 * @param expression  where to find
 * @param classToFind class that represents language we look for
 * @param <T>         class that represents language we look for
 * @return instance of class that represents language we look for or null of not found
 */
@Nullable
@SuppressWarnings("unchecked") // We check types dynamically (using isAssignableFrom)
public static <T extends PsiFileBase> T findInjectedFile(@NotNull final PsiElement expression,
                                                         @NotNull final Class<T> classToFind) {
  final List<Pair<PsiElement, TextRange>> files =
    InjectedLanguageManager.getInstance(expression.getProject()).getInjectedPsiFiles(expression);
  if (files == null) {
    return null;
  }
  for (final Pair<PsiElement, TextRange> fileInfo : files) {
    final PsiElement injectedFile = fileInfo.first;
    if (classToFind.isAssignableFrom(injectedFile.getClass())) {
      return (T)injectedFile;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:InjectedLanguageUtil.java

示例2: dynamically

import com.intellij.extapi.psi.PsiFileBase; //导入依赖的package包/类
/**
 * Finds injected language in expression
 *
 * @param expression  where to find
 * @param classToFind class that represents language we look for
 * @param <T>         class that represents language we look for
 * @return instance of class that represents language we look for or null of not found
 */
@Nullable
@SuppressWarnings("unchecked") // We check types dynamically (using isAssignableFrom)
public static <T extends PsiFileBase> T findInjectedFile(@Nonnull final PsiElement expression,
                                                         @Nonnull final Class<T> classToFind) {
  final List<Pair<PsiElement, TextRange>> files =
          InjectedLanguageManager.getInstance(expression.getProject()).getInjectedPsiFiles(expression);
  if (files == null) {
    return null;
  }
  for (final Pair<PsiElement, TextRange> fileInfo : files) {
    final PsiElement injectedFile = fileInfo.first;
    if (classToFind.isAssignableFrom(injectedFile.getClass())) {
      return (T)injectedFile;
    }
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:InjectedLanguageUtil.java

示例3: createFile

import com.intellij.extapi.psi.PsiFileBase; //导入依赖的package包/类
@Override
public PsiFile createFile(FileViewProvider viewProvider)
{
	return new PsiFileBase(viewProvider, CGLanguage.INSTANCE)
	{
	};
}
 
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:8,代码来源:CGParserDefinition.java

示例4: parseFile

import com.intellij.extapi.psi.PsiFileBase; //导入依赖的package包/类
@RequiredReadAction
private static <T extends PsiElement> T parseFile(CharSequence text, Project project, Class<T> clazz, IElementType elementType)
{
	LightVirtualFile virtualFile = new LightVirtualFile("dummy.cs", CSharpFileType.INSTANCE, text, System.currentTimeMillis());
	SingleRootFileViewProvider viewProvider = new SingleRootFileViewProvider(PsiManager.getInstance(project), virtualFile, false);

	PsiFileBase file = new PsiFileBase(viewProvider, CSharpLanguage.INSTANCE)
	{
		{
			init(elementType, elementType);
		}
	};

	return PsiTreeUtil.findChildOfType(file, clazz);
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:16,代码来源:CSharpFileFactory.java


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