com.intellij.extapi.psi.PsiFileBase Java Examples
The following examples show how to use
com.intellij.extapi.psi.PsiFileBase.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InjectedLanguageUtil.java From consulo with Apache License 2.0 | 6 votes |
/** * 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; }
Example #2
Source File: CGParserDefinition.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Override public PsiFile createFile(FileViewProvider viewProvider) { return new PsiFileBase(viewProvider, CGLanguage.INSTANCE) { }; }
Example #3
Source File: CSharpFileFactory.java From consulo-csharp with Apache License 2.0 | 5 votes |
@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); }