当前位置: 首页>>代码示例>>Java>>正文


Java DummyHolder.getTreeElement方法代码示例

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


在下文中一共展示了DummyHolder.getTreeElement方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: newException

import com.intellij.psi.impl.source.DummyHolder; //导入方法依赖的package包/类
private static IncorrectOperationException newException(final String msg, final DummyHolder holder) {
  final FileElement root = holder.getTreeElement();
  if (root instanceof JavaDummyElement) {
    final Throwable cause = ((JavaDummyElement)root).getParserError();
    if (cause != null) {
      return new IncorrectOperationException(msg, cause);
    }
  }
  return new IncorrectOperationException(msg);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PsiJavaParserFacadeImpl.java

示例5: createSingleLeafElement

import com.intellij.psi.impl.source.DummyHolder; //导入方法依赖的package包/类
@NotNull
public static LeafElement createSingleLeafElement(@NotNull IElementType type, CharSequence buffer, int startOffset, int endOffset, CharTable table, PsiManager manager, PsiFile originalFile) {
  DummyHolder dummyHolder = DummyHolderFactory.createHolder(manager, table, type.getLanguage());
  dummyHolder.setOriginalFile(originalFile);

  FileElement holderElement = dummyHolder.getTreeElement();
  
  LeafElement newElement = ASTFactory.leaf(type, holderElement.getCharTable().intern(
    buffer, startOffset, endOffset));
  holderElement.rawAddChildren(newElement);
  CodeEditUtil.setNodeGenerated(newElement, true);
  return newElement;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:Factory.java

示例6: copyToElement

import com.intellij.psi.impl.source.DummyHolder; //导入方法依赖的package包/类
public static TreeElement copyToElement(PsiElement original) {
  final DummyHolder holder = DummyHolderFactory.createHolder(original.getManager(), null, original.getLanguage());
  final FileElement holderElement = holder.getTreeElement();
  final TreeElement treeElement = generateTreeElement(original, holderElement.getCharTable(), original.getManager());
  //  TreeElement treePrev = treeElement.getTreePrev(); // This is hack to support bug used in formater
  holderElement.rawAddChildren(treeElement);
  TreeUtil.clearCaches(holderElement);
  //  treeElement.setTreePrev(treePrev);
  saveIndentationToCopy((TreeElement)original.getNode(), treeElement);
  return treeElement;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ChangeUtil.java

示例7: newException

import com.intellij.psi.impl.source.DummyHolder; //导入方法依赖的package包/类
private static IncorrectOperationException newException(final String msg, final DummyHolder holder) {
  final FileElement root = holder.getTreeElement();
  if (root instanceof JavaDummyElement) {
    final Throwable cause = ((JavaDummyElement)root).getParserError();
    if (cause != null) {
      return new IncorrectOperationException(msg) {
        @Override public Throwable getCause() { return cause; }
      };
    }
  }
  return new IncorrectOperationException(msg);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:PsiJavaParserFacadeImpl.java

示例8: createSingleLeafElement

import com.intellij.psi.impl.source.DummyHolder; //导入方法依赖的package包/类
public static LeafElement createSingleLeafElement(IElementType type, CharSequence buffer, int startOffset, int endOffset, CharTable table, PsiManager manager, PsiFile originalFile) {
  DummyHolder dummyHolder = DummyHolderFactory.createHolder(manager, table, type.getLanguage());
  dummyHolder.setOriginalFile(originalFile);

  FileElement holderElement = dummyHolder.getTreeElement();
  
  LeafElement newElement = ASTFactory.leaf(type, holderElement.getCharTable().intern(
    buffer, startOffset, endOffset));
  holderElement.rawAddChildren(newElement);
  CodeEditUtil.setNodeGenerated(newElement, true);
  return newElement;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:Factory.java

示例9: createSingleLeafElement

import com.intellij.psi.impl.source.DummyHolder; //导入方法依赖的package包/类
@Nonnull
public static LeafElement createSingleLeafElement(@Nonnull IElementType type, CharSequence buffer, int startOffset, int endOffset, CharTable table, PsiManager manager, PsiFile originalFile) {
  DummyHolder dummyHolder = DummyHolderFactory.createHolder(manager, table, type.getLanguage());
  dummyHolder.setOriginalFile(originalFile);

  FileElement holderElement = dummyHolder.getTreeElement();

  LeafElement newElement = ASTFactory.leaf(type, holderElement.getCharTable().intern(
          buffer, startOffset, endOffset));
  holderElement.rawAddChildren(newElement);
  CodeEditUtil.setNodeGenerated(newElement, true);
  return newElement;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:14,代码来源:Factory.java

示例10: newException

import com.intellij.psi.impl.source.DummyHolder; //导入方法依赖的package包/类
private static IncorrectOperationException newException(final String msg, final DummyHolder holder)
{
	final FileElement root = holder.getTreeElement();
	if(root instanceof JavaDummyElement)
	{
		final Throwable cause = ((JavaDummyElement) root).getParserError();
		if(cause != null)
		{
			return new IncorrectOperationException(msg, cause);
		}
	}
	return new IncorrectOperationException(msg);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:14,代码来源:PsiJavaParserFacadeImpl.java

示例11: parse

import com.intellij.psi.impl.source.DummyHolder; //导入方法依赖的package包/类
public ASTNode parse() {
  final PsiBuilder.Marker root = myBuilder.mark();

  if (myRootType == XML_MARKUP_DECL) {
    parseTopLevelMarkupDecl();
    root.done(myRootType);
    return myBuilder.getTreeBuilt();
  }

  PsiBuilder.Marker document = null;
  if (myRootType == DTD_FILE) {
    document = myBuilder.mark();
    parseProlog();
  } 

  switch (myContextType) {
    case GENERIC_XML:
      parseGenericXml();
      break;
    case ELEMENT_CONTENT_SPEC:
      doParseContentSpec(true);
      break;
    case ATTLIST_SPEC:
      parseAttlistContent();
      break;
    case ATTR_VALUE:
      parseAttrValue();
    case ATTRIBUTE_SPEC:
      parseAttributeContentSpec();
      break;
    case ENTITY_DECL_CONTENT:
      parseEntityDeclContent();
      break;
    case ENUMERATED_TYPE:
      parseEnumeratedTypeContent();
      break;
  }

  while(!myBuilder.eof()) myBuilder.advanceLexer();
  if (document != null) document.done(XML_DOCUMENT);
  root.done(myRootType);
  ASTNode astNode = myBuilder.getTreeBuilt();

  if (myRootType != DTD_FILE) {
    PsiFile file = myBuilder.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY);
    if (file != null) {
      final DummyHolder result = DummyHolderFactory.createHolder(file.getManager(), DTDLanguage.INSTANCE, file);
      final FileElement holder = result.getTreeElement();
      holder.rawAddChildren((TreeElement)astNode);
    }
  }

  return astNode;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:55,代码来源:DtdParsing.java

示例12: parse

import com.intellij.psi.impl.source.DummyHolder; //导入方法依赖的package包/类
public ASTNode parse() {
  final PsiBuilder.Marker root = myBuilder.mark();

  if (myRootType == XML_MARKUP_DECL) {
    parseTopLevelMarkupDecl();
    root.done(myRootType);
    return myBuilder.getTreeBuilt();
  }

  PsiBuilder.Marker document = null;
  if (myRootType == DTD_FILE) {
    document = myBuilder.mark();
    parseProlog();
  } 

  switch (myContextType) {
    case GENERIC_XML:
      parseGenericXml();
      break;
    case ELEMENT_CONTENT_SPEC:
      parseElementContentSpec();
      break;
    case ATTLIST_SPEC:
      parseAttlistContent();
      break;
    case ATTR_VALUE:
      parseAttrValue();
    case ATTRIBUTE_SPEC:
      parseAttributeContentSpec();
      break;
    case ENTITY_DECL_CONTENT:
      parseEntityDeclContent();
      break;
    case ENUMERATED_TYPE:
      parseEnumeratedTypeContent();
      break;
  }

  while(!myBuilder.eof()) myBuilder.advanceLexer();
  if (document != null) document.done(XML_DOCUMENT);
  root.done(myRootType);
  ASTNode astNode = myBuilder.getTreeBuilt();

  if (myRootType != DTD_FILE) {
    PsiFile file = myBuilder.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY);
    if (file != null) {
      final DummyHolder result = DummyHolderFactory.createHolder(file.getManager(), DTDLanguage.INSTANCE, file);
      final FileElement holder = result.getTreeElement();
      holder.rawAddChildren((TreeElement)astNode);
    }
  }

  return astNode;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:55,代码来源:DtdParsing.java


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