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