本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}