本文整理匯總了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);
}