com.intellij.psi.util.PsiTreeUtil#getDeepestFirst ( )源码实例Demo

下面列出了com.intellij.psi.util.PsiTreeUtil#getDeepestFirst ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: idea-php-typo3-plugin   文件: FluidTypeResolver.java
/**
 * Get the "for IN" variable identifier as separated string
 * <p>
 * {% for car in "cars" %}
 * {% for car in "cars"|length %}
 * {% for car in "cars.test" %}
 */
@NotNull
public static Collection<String> getForTagIdentifierAsString(XmlTag forTag) {
    XmlAttribute each = forTag.getAttribute("each");
    if (each == null || each.getValueElement() == null) {
        return ContainerUtil.emptyList();
    }

    PsiElement fluidElement = FluidUtil.retrieveFluidElementAtPosition(each.getValueElement());
    if (fluidElement == null) {
        return Collections.emptyList();
    }

    PsiElement deepestFirst = PsiTreeUtil.getDeepestFirst(fluidElement);

    return FluidTypeResolver.formatPsiTypeName(deepestFirst);
}
 
源代码2 项目: intellij-plugin-v4   文件: TokenVocabResolver.java
/**
 * If this reference is the value of a {@code tokenVocab} option, returns the corresponding
 * grammar file.
 */
@Nullable
public static PsiFile resolveTokenVocabFile(GrammarElementRefNode reference) {
	PsiElement optionValue = PsiTreeUtil.findFirstParent(reference, TokenVocabResolver::isOptionValue);

	if (optionValue != null) {
		PsiElement option = optionValue.getParent();

		if (option != null) {
			PsiElement optionName = PsiTreeUtil.getDeepestFirst(option);

			if (optionName.getText().equals("tokenVocab")) {
				return findRelativeFile(reference.getText(), reference.getContainingFile());
			}
		}
	}

	return null;
}
 
源代码3 项目: antlr4-intellij-adaptor   文件: Trees.java
public static PsiElement createLeafFromText(Project project, Language language, PsiElement context,
											String text, IElementType type)
{
	PsiFileFactoryImpl factory = (PsiFileFactoryImpl) PsiFileFactory.getInstance(project);
	PsiElement el = factory.createElementFromText(text, language, type, context);
	if ( el==null ) return null;
	return PsiTreeUtil.getDeepestFirst(el); // forces parsing of file!!
	// start rule depends on root passed in
}
 
源代码4 项目: intellij-plugin-v4   文件: MyPsiUtils.java
public static PsiElement createLeafFromText(Project project, PsiElement context,
											String text, IElementType type)
{
	PsiFileFactoryImpl factory = (PsiFileFactoryImpl)PsiFileFactory.getInstance(project);
	PsiElement el = factory.createElementFromText(text,
												  ANTLRv4Language.INSTANCE,
												  type,
												  context);
	return PsiTreeUtil.getDeepestFirst(el); // forces parsing of file!!
	// start rule depends on root passed in
}