本文整理汇总了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;
}
示例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;
}
示例3: createFile
import com.intellij.extapi.psi.PsiFileBase; //导入依赖的package包/类
@Override
public PsiFile createFile(FileViewProvider viewProvider)
{
return new PsiFileBase(viewProvider, CGLanguage.INSTANCE)
{
};
}
示例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);
}