• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DummyHolder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: findCodeFragment

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@NotNull
public static PsiElement findCodeFragment(@NotNull PsiElement element) {
  PsiElement codeFragment = element;
  PsiElement parent = codeFragment.getParent();
  while (parent != null) {
    if (parent instanceof PsiDirectory
        || parent instanceof PsiMethod
        || parent instanceof PsiField || parent instanceof PsiClassInitializer
        || parent instanceof DummyHolder
        || parent instanceof PsiLambdaExpression) {
      break;
    }
    codeFragment = parent;
    parent = parent.getParent();
  }
  return codeFragment;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ControlFlowUtil.java


示例2: testMergeWhenEmptyElementAfterWhitespaceIsLastChild

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
public void testMergeWhenEmptyElementAfterWhitespaceIsLastChild() throws Throwable {
  myBuilder = createBuilder(" foo bar");
  parseWhenEmptyElementAfterWhitespaceIsLastChild();
  final ASTNode tree = myBuilder.getTreeBuilt();
  new DummyHolder(getPsiManager(), (TreeElement)tree, null);

  myBuilder = createBuilder("  bar", tree);
  parseWhenEmptyElementAfterWhitespaceIsLastChild();
  DebugUtil.startPsiModification(null);
  try {
    myBuilder.getTreeBuilt();
    fail();
  }
  catch (BlockSupport.ReparsedSuccessfullyException e) {
    e.getDiffLog().performActualPsiChange(tree.getPsi().getContainingFile());
  }
  finally {
    DebugUtil.finishPsiModification();
  }

  assertEquals("  bar", tree.getText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PsiBuilderTest.java


示例3: createElementFromText

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@Nullable
public PsiElement createElementFromText(@Nullable final String text,
                                        @NotNull final Language language,
                                        @NotNull final IElementType type,
                                        @Nullable final PsiElement context) {
  if (text == null) return null;
  final DummyHolder result = DummyHolderFactory.createHolder(myManager, language, context);
  final FileElement holder = result.getTreeElement();

  final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
  if (parserDefinition == null) {
    throw new AssertionError("No parser definition for " + language);
  }
  final Project project = myManager.getProject();
  final Lexer lexer = parserDefinition.createLexer(project);
  final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, holder, lexer, language, text);
  final ASTNode node = parserDefinition.createParser(project).parse(type, builder);
  holder.rawAddChildren((TreeElement)node);
  markGenerated(result);
  return node.getPsi();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PsiFileFactoryImpl.java


示例4: loadTree

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@NotNull
static PsiElement loadTree(@NotNull PsiElement host, @NotNull PsiFile containingFile) {
  if (containingFile instanceof DummyHolder) {
    PsiElement context = containingFile.getContext();
    if (context != null) {
      PsiFile topFile = context.getContainingFile();
      topFile.getNode();  //load tree
      TextRange textRange = host.getTextRange().shiftRight(context.getTextRange().getStartOffset());

      PsiElement inLoadedTree =
        PsiTreeUtil.findElementOfClassAtRange(topFile, textRange.getStartOffset(), textRange.getEndOffset(), host.getClass());
      if (inLoadedTree != null) {
        host = inLoadedTree;
      }
    }
  }
  return host;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:InjectedLanguageUtil.java


示例5: findCodeFragment

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
public static PsiElement findCodeFragment(PsiElement element) {
  PsiElement codeFragment = element;
  PsiElement parent = codeFragment.getParent();
  while (parent != null) {
    if (parent instanceof PsiDirectory
        || parent instanceof PsiMethod
        || parent instanceof PsiField || parent instanceof PsiClassInitializer
        || parent instanceof DummyHolder
        || parent instanceof PsiLambdaExpression) {
      break;
    }
    codeFragment = parent;
    parent = parent.getParent();
  }
  return codeFragment;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:ControlFlowUtil.java


示例6: testMergeWhenEmptyElementAfterWhitespaceIsLastChild

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
public void testMergeWhenEmptyElementAfterWhitespaceIsLastChild() throws Throwable {
  myBuilder = createBuilder(" foo bar");
  parseWhenEmptyElementAfterWhitespaceIsLastChild();
  final ASTNode tree = myBuilder.getTreeBuilt();
  new DummyHolder(getPsiManager(), (TreeElement)tree, null);

  myBuilder = createBuilder("  bar", tree);
  parseWhenEmptyElementAfterWhitespaceIsLastChild();
  try {
    myBuilder.getTreeBuilt();
    fail();
  }
  catch (BlockSupport.ReparsedSuccessfullyException e) {
    e.getDiffLog().performActualPsiChange(tree.getPsi().getContainingFile());
  }

  assertEquals("  bar", tree.getText());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:PsiBuilderTest.java


示例7: createElementFromText

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@Nullable
public PsiElement createElementFromText(@Nullable final String text,
                                        @Nonnull final Language language,
                                        @Nonnull final LanguageVersion languageVersion,
                                        @Nonnull final IElementType type,
                                        @Nullable final PsiElement context) {
  if (text == null) return null;
  final DummyHolder result = DummyHolderFactory.createHolder(myManager, language, context);
  final FileElement holder = result.getTreeElement();

  final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
  if (parserDefinition == null) {
    throw new AssertionError("No parser definition for " + language);
  }
  final Project project = myManager.getProject();
  final Lexer lexer = parserDefinition.createLexer(languageVersion);
  final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, holder, lexer, language, languageVersion, text);
  final ASTNode node = parserDefinition.createParser(languageVersion).parse(type, builder, languageVersion);
  holder.rawAddChildren((TreeElement)node);
  markGenerated(result);
  return node.getPsi();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:PsiFileFactoryImpl.java


示例8: loadTree

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@Nonnull
static PsiElement loadTree(@Nonnull PsiElement host, @Nonnull PsiFile containingFile) {
  if (containingFile instanceof DummyHolder) {
    PsiElement context = containingFile.getContext();
    if (context != null) {
      PsiFile topFile = context.getContainingFile();
      topFile.getNode();  //load tree
      TextRange textRange = host.getTextRange().shiftRight(context.getTextRange().getStartOffset());

      PsiElement inLoadedTree =
              PsiTreeUtil.findElementOfClassAtRange(topFile, textRange.getStartOffset(), textRange.getEndOffset(), host.getClass());
      if (inLoadedTree != null) {
        host = inLoadedTree;
      }
    }
  }
  return host;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:InjectedLanguageUtil.java


示例9: createCatchSection

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@NotNull
@Override
public PsiCatchSection createCatchSection(@NotNull final PsiType exceptionType, @NotNull final String exceptionName, @Nullable final PsiElement context) throws IncorrectOperationException
{
	if(!(exceptionType instanceof PsiClassType || exceptionType instanceof PsiDisjunctionType))
	{
		throw new IncorrectOperationException("Unexpected type:" + exceptionType);
	}

	@NonNls final String text = "catch (" + exceptionType.getCanonicalText(true) + " " + exceptionName + ") {}";
	final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, CATCH_SECTION, level(context)), context);
	final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
	if(!(element instanceof PsiCatchSection))
	{
		throw new IncorrectOperationException("Incorrect catch section '" + text + "'. Parsed element: " + element);
	}

	final Project project = myManager.getProject();
	final JavaPsiImplementationHelper helper = JavaPsiImplementationHelper.getInstance(project);
	helper.setupCatchBlock(exceptionName, context, (PsiCatchSection) element);
	final CodeStyleManager styleManager = CodeStyleManager.getInstance(project);
	final PsiCatchSection catchSection = (PsiCatchSection) styleManager.reformat(element);

	GeneratedMarkerVisitor.markGenerated(catchSection);
	return catchSection;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:PsiElementFactoryImpl.java


示例10: createEmptyPsiField

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
protected PsiElement createEmptyPsiField() {
    final String text = "<undefined>";
    final IElementType type = CsvTypes.FIELD;
    final Project project = this.element.getProject();
    final PsiManager psiManager = PsiManager.getInstance(project);
    final DummyHolder dummyHolder = DummyHolderFactory.createHolder(psiManager, null);
    final FileElement fileElement = dummyHolder.getTreeElement();
    final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(CsvLanguage.INSTANCE);
    final Lexer lexer = parserDefinition.createLexer(project);
    final PsiBuilder psiBuilder = PsiBuilderFactory.getInstance().createBuilder(project, fileElement, lexer, CsvLanguage.INSTANCE, text);
    final ASTNode node = parserDefinition.createParser(project).parse(type, psiBuilder);
    fileElement.rawAddChildren((com.intellij.psi.impl.source.tree.TreeElement)node);
    return node.getPsi();
}
 
开发者ID:SeeSharpSoft,项目名称:intellij-csv-validator,代码行数:15,代码来源:CsvStructureViewElement.java


示例11: createAnnotationFromText

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@NotNull
@Override
public PsiAnnotation createAnnotationFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
  final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, ANNOTATION, level(context)), context);
  final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
  if (!(element instanceof PsiAnnotation)) {
    throw new IncorrectOperationException("Incorrect annotation '" + text + "'");
  }
  return (PsiAnnotation)element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PsiJavaParserFacadeImpl.java


示例12: createFieldFromText

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@NotNull
@Override
public PsiField createFieldFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
  final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, DECLARATION, level(context)), context);
  final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
  if (!(element instanceof PsiField)) {
    throw new IncorrectOperationException("Incorrect field '" + text + "'");
  }
  return (PsiField)element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PsiJavaParserFacadeImpl.java


示例13: createMethodFromText

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@NotNull
@Override
public PsiMethod createMethodFromText(@NotNull final String text, @Nullable final PsiElement context, final LanguageLevel level) throws IncorrectOperationException {
  final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, DECLARATION, level), context);
  final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
  if (!(element instanceof PsiMethod)) {
    throw newException("Incorrect method '" + text + "'", holder);
  }
  return (PsiMethod)element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PsiJavaParserFacadeImpl.java


示例14: createParameterFromText

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@NotNull
@Override
public PsiParameter createParameterFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
  final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, PARAMETER, level(context)), context);
  final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
  if (!(element instanceof PsiParameter)) {
    throw new IncorrectOperationException("Incorrect parameter '" + text + "'");
  }
  return (PsiParameter)element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PsiJavaParserFacadeImpl.java


示例15: createResourceFromText

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@NotNull
@Override
public PsiResourceVariable createResourceFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
  final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, RESOURCE, level(context)), context);
  final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
  if (!(element instanceof PsiResourceVariable)) {
    throw new IncorrectOperationException("Incorrect resource '" + text + "'");
  }
  return (PsiResourceVariable)element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PsiJavaParserFacadeImpl.java


示例16: createTypeElementFromText

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@NotNull
@Override
public PsiTypeElement createTypeElementFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
  final LanguageLevel level = level(context);
  final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, TYPE, level), context);
  final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
  if (!(element instanceof PsiTypeElement)) {
    throw new IncorrectOperationException("Incorrect type '" + text + "' (" + level + ")");
  }
  return (PsiTypeElement)element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:PsiJavaParserFacadeImpl.java


示例17: createReferenceFromText

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@NotNull
@Override
public PsiJavaCodeReferenceElement createReferenceFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
  final boolean isStaticImport = context instanceof PsiImportStaticStatement &&
                                 !((PsiImportStaticStatement)context).isOnDemand();
  final boolean mayHaveDiamonds = context instanceof PsiNewExpression &&
                                  PsiUtil.getLanguageLevel(context).isAtLeast(LanguageLevel.JDK_1_7);
  final JavaParserUtil.ParserWrapper wrapper = isStaticImport ? STATIC_IMPORT_REF : mayHaveDiamonds ? DIAMOND_REF : REFERENCE;
  final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, wrapper, level(context)), context);
  final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
  if (!(element instanceof PsiJavaCodeReferenceElement)) {
    throw new IncorrectOperationException("Incorrect reference '" + text + "'");
  }
  return (PsiJavaCodeReferenceElement)element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:PsiJavaParserFacadeImpl.java


示例18: createCodeBlockFromText

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@NotNull
@Override
public PsiCodeBlock createCodeBlockFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
  final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, CODE_BLOCK, level(context), true), context);
  final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
  if (!(element instanceof PsiCodeBlock)) {
    throw new IncorrectOperationException("Incorrect code block '" + text + "'");
  }
  return (PsiCodeBlock)element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PsiJavaParserFacadeImpl.java


示例19: createStatementFromText

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@NotNull
@Override
public PsiStatement createStatementFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
  final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, STATEMENT, level(context)), context);
  final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
  if (!(element instanceof PsiStatement)) {
    throw new IncorrectOperationException("Incorrect statement '" + text + "'");
  }
  return (PsiStatement)element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PsiJavaParserFacadeImpl.java


示例20: createExpressionFromText

import com.intellij.psi.impl.source.DummyHolder; //导入依赖的package包/类
@NotNull
@Override
public PsiExpression createExpressionFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
  final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, EXPRESSION, level(context)), context);
  final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
  if (!(element instanceof PsiExpression)) {
    throw new IncorrectOperationException("Incorrect expression '" + text + "'");
  }
  return (PsiExpression)element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PsiJavaParserFacadeImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GetApplicationAttemptReportRequestProtoOrBuilder类代码示例发布时间:2022-05-22
下一篇:
Java ContainerController类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap