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


Java LightTreeUtil.getChildrenOfType方法代码示例

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


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

示例1: formatTypeParameters

import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
private static void formatTypeParameters(LighterAST tree, LighterASTNode typeParameters, StringBuilder buf)
{
	final List<LighterASTNode> children = LightTreeUtil.getChildrenOfType(tree, typeParameters, JavaElementType.TYPE);
	if(children.isEmpty())
	{
		return;
	}
	buf.append('<');
	for(int i = 0; i < children.size(); i++)
	{
		LighterASTNode child = children.get(i);
		formatType(tree, child, buf);
		if(i != children.size() - 1)
		{
			buf.append(", ");
		}
	}
	buf.append('>');
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:20,代码来源:LambdaExpressionElementType.java

示例2: getMethodName

import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
@Nullable
private static String getMethodName(LighterAST lighterAst, @NotNull LighterASTNode call, IElementType elementType)
{
	if(elementType == NEW_EXPRESSION || elementType == ANONYMOUS_CLASS)
	{
		final List<LighterASTNode> refs = LightTreeUtil.getChildrenOfType(lighterAst, call, JAVA_CODE_REFERENCE);
		if(refs.isEmpty())
		{
			return null;
		}
		final LighterASTNode lastRef = refs.get(refs.size() - 1);
		return JavaLightTreeUtil.getNameIdentifierText(lighterAst, lastRef);
	}

	LOG.assertTrue(elementType == METHOD_CALL_EXPRESSION);
	final LighterASTNode methodReference = lighterAst.getChildren(call).get(0);
	if(methodReference.getTokenType() == REFERENCE_EXPRESSION)
	{
		return JavaLightTreeUtil.getNameIdentifierText(lighterAst, methodReference);
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:JavaNullMethodArgumentIndex.java

示例3: getTexts

import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
private static String[] getTexts(LighterAST tree, LighterASTNode node) {
  List<LighterASTNode> refs = LightTreeUtil.getChildrenOfType(tree, node, JavaElementType.JAVA_CODE_REFERENCE);
  String[] texts = ArrayUtil.newStringArray(refs.size());
  for (int i = 0; i < refs.size(); i++) {
    texts[i] = LightTreeUtil.toFilteredString(tree, refs.get(i), null);
  }
  return texts;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JavaClassReferenceListElementType.java

示例4: getTexts

import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
@NotNull
private static String[] getTexts(@NotNull LighterAST tree, @NotNull LighterASTNode node)
{
	List<LighterASTNode> refs = LightTreeUtil.getChildrenOfType(tree, node, JavaElementType.JAVA_CODE_REFERENCE);
	String[] texts = ArrayUtil.newStringArray(refs.size());
	for(int i = 0; i < refs.size(); i++)
	{
		texts[i] = LightTreeUtil.toFilteredString(tree, refs.get(i), null);
	}
	return texts;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:12,代码来源:JavaClassReferenceListElementType.java

示例5: createStub

import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
@Override
public PsiMethodStub createStub(final LighterAST tree, final LighterASTNode node, final StubElement parentStub) {
  String name = null;
  boolean isConstructor = true;
  boolean isVarArgs = false;
  boolean isDeprecatedByComment = false;
  boolean hasDeprecatedAnnotation = false;
  boolean hasDocComment = false;
  String defValueText = null;

  boolean expectingDef = false;
  for (final LighterASTNode child : tree.getChildren(node)) {
    final IElementType type = child.getTokenType();
    if (type == JavaDocElementType.DOC_COMMENT) {
      hasDocComment = true;
      isDeprecatedByComment = RecordUtil.isDeprecatedByDocComment(tree, child);
    }
    else if (type == JavaElementType.MODIFIER_LIST) {
      hasDeprecatedAnnotation = RecordUtil.isDeprecatedByAnnotation(tree, child);
    }
    else if (type == JavaElementType.TYPE) {
      isConstructor = false;
    }
    else if (type == JavaTokenType.IDENTIFIER) {
      name = RecordUtil.intern(tree.getCharTable(), child);
    }
    else if (type == JavaElementType.PARAMETER_LIST) {
      final List<LighterASTNode> params = LightTreeUtil.getChildrenOfType(tree, child, JavaElementType.PARAMETER);
      if (!params.isEmpty()) {
        final LighterASTNode pType = LightTreeUtil.firstChildOfType(tree, params.get(params.size() - 1), JavaElementType.TYPE);
        if (pType != null) {
          isVarArgs = (LightTreeUtil.firstChildOfType(tree, pType, JavaTokenType.ELLIPSIS) != null);
        }
      }
    }
    else if (type == JavaTokenType.DEFAULT_KEYWORD) {
      expectingDef = true;
    }
    else if (expectingDef && !ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET.contains(type) &&
             type != JavaTokenType.SEMICOLON && type != JavaElementType.CODE_BLOCK) {
      defValueText = LightTreeUtil.toFilteredString(tree, child, null);
      break;
    }
  }

  TypeInfo typeInfo = isConstructor ? TypeInfo.createConstructorType() : TypeInfo.create(tree, node, parentStub);
  boolean isAnno = (node.getTokenType() == JavaElementType.ANNOTATION_METHOD);
  byte flags = PsiMethodStubImpl.packFlags(isConstructor, isAnno, isVarArgs, isDeprecatedByComment, hasDeprecatedAnnotation, hasDocComment);

  return new PsiMethodStubImpl(parentStub, name, typeInfo, flags, defValueText);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:52,代码来源:JavaMethodElementType.java

示例6: packModifierList

import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
public static int packModifierList(@NotNull LighterAST tree, @NotNull LighterASTNode modList, @NotNull StubElement parent) {
  int packed = 0;

  final LighterASTNode modListOwner = tree.getParent(modList);
  if (modListOwner != null && modListOwner.getTokenType() == parent.getStubType()) {
    final StubElement grandParent = parent.getParentStub();
    if (parent instanceof PsiClassStub) {
      if (grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
        packed |= ModifierFlags.PUBLIC_MASK;
        packed |= ModifierFlags.STATIC_MASK;
      }
      if (((PsiClassStub)parent).isInterface()) {
        packed |= ModifierFlags.ABSTRACT_MASK;
        if (grandParent instanceof PsiClassStub) {
          packed |= ModifierFlags.STATIC_MASK;
        }
      }
      else if (((PsiClassStub)parent).isEnum()) {
        if (!(grandParent instanceof PsiFileStub)) {
          packed |= ModifierFlags.STATIC_MASK;
        }

        boolean isFinal = true;
        final List<LighterASTNode> enumConstants = LightTreeUtil.getChildrenOfType(tree, modListOwner, JavaElementType.ENUM_CONSTANT);
        for (final LighterASTNode constant : enumConstants) {
          if (LightTreeUtil.firstChildOfType(tree, constant, JavaElementType.ENUM_CONSTANT_INITIALIZER) != null) {
            isFinal = false;
            break;
          }
        }
        if (isFinal) {
          packed |= ModifierFlags.FINAL_MASK;
        }

        final List<LighterASTNode> methods = LightTreeUtil.getChildrenOfType(tree, modListOwner, JavaElementType.METHOD);
        for (final LighterASTNode method : methods) {
          final LighterASTNode mods = LightTreeUtil.requiredChildOfType(tree, method, JavaElementType.MODIFIER_LIST);
          if (LightTreeUtil.firstChildOfType(tree, mods, JavaTokenType.ABSTRACT_KEYWORD) != null) {
            packed |= ModifierFlags.ABSTRACT_MASK;
            break;
          }
        }
      }
    }
    else if (parent instanceof PsiMethodStub) {
      if (grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
        packed |= ModifierFlags.PUBLIC_MASK;
        packed |= ModifierFlags.ABSTRACT_MASK;
      }
    }
    else if (parent instanceof PsiFieldStub) {
      if (parent.getStubType() == JavaElementType.ENUM_CONSTANT ||
          grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
        packed |= ModifierFlags.PUBLIC_MASK;
        packed |= ModifierFlags.STATIC_MASK;
        packed |= ModifierFlags.FINAL_MASK;
      }
    }
  }

  for (final LighterASTNode child : tree.getChildren(modList)) {
    final int flag = ModifierFlags.KEYWORD_TO_MODIFIER_FLAG_MAP.get(child.getTokenType());
    if (flag != 0) {
      packed |= flag;
    }
  }

  if ((packed & ModifierFlags.DEFENDER_MASK) != 0) {
    packed &= ~ModifierFlags.ABSTRACT_MASK;
  }

  if ((packed & (ModifierFlags.PRIVATE_MASK | ModifierFlags.PROTECTED_MASK | ModifierFlags.PUBLIC_MASK)) == 0) {
    packed |= ModifierFlags.PACKAGE_LOCAL_MASK;
  }

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

示例7: createStub

import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
@Override
public PsiMethodStub createStub(final LighterAST tree, final LighterASTNode node, final StubElement parentStub) {
  String name = null;
  boolean isConstructor = true;
  boolean isVarArgs = false;
  boolean isDeprecatedByComment = false;
  boolean hasDeprecatedAnnotation = false;
  String defValueText = null;

  boolean expectingDef = false;
  for (final LighterASTNode child : tree.getChildren(node)) {
    final IElementType type = child.getTokenType();
    if (type == JavaDocElementType.DOC_COMMENT) {
      isDeprecatedByComment = RecordUtil.isDeprecatedByDocComment(tree, child);
    }
    else if (type == JavaElementType.MODIFIER_LIST) {
      hasDeprecatedAnnotation = RecordUtil.isDeprecatedByAnnotation(tree, child);
    }
    else if (type == JavaElementType.TYPE) {
      isConstructor = false;
    }
    else if (type == JavaTokenType.IDENTIFIER) {
      name = RecordUtil.intern(tree.getCharTable(), child);
    }
    else if (type == JavaElementType.PARAMETER_LIST) {
      final List<LighterASTNode> params = LightTreeUtil.getChildrenOfType(tree, child, JavaElementType.PARAMETER);
      if (params.size() > 0) {
        final LighterASTNode pType = LightTreeUtil.firstChildOfType(tree, params.get(params.size() - 1), JavaElementType.TYPE);
        if (pType != null) {
          isVarArgs = (LightTreeUtil.firstChildOfType(tree, pType, JavaTokenType.ELLIPSIS) != null);
        }
      }
    }
    else if (type == JavaTokenType.DEFAULT_KEYWORD) {
      expectingDef = true;
    }
    else if (expectingDef && !ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET.contains(type) &&
             type != JavaTokenType.SEMICOLON && type != JavaElementType.CODE_BLOCK) {
      defValueText = LightTreeUtil.toFilteredString(tree, child, null);
      break;
    }
  }

  TypeInfo typeInfo = isConstructor ? TypeInfo.createConstructorType() : TypeInfo.create(tree, node, parentStub);
  boolean isAnno = (node.getTokenType() == JavaElementType.ANNOTATION_METHOD);
  byte flags = PsiMethodStubImpl.packFlags(isConstructor, isAnno, isVarArgs, isDeprecatedByComment, hasDeprecatedAnnotation);

  return new PsiMethodStubImpl(parentStub, StringRef.fromString(name), typeInfo, flags, StringRef.fromString(defValueText));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:50,代码来源:JavaMethodElementType.java

示例8: createStub

import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
@Override
public PsiMethodStub createStub(final LighterAST tree, final LighterASTNode node, final StubElement parentStub)
{
	String name = null;
	boolean isConstructor = true;
	boolean isVarArgs = false;
	boolean isDeprecatedByComment = false;
	boolean hasDeprecatedAnnotation = false;
	boolean hasDocComment = false;
	String defValueText = null;

	boolean expectingDef = false;
	for(final LighterASTNode child : tree.getChildren(node))
	{
		final IElementType type = child.getTokenType();
		if(type == JavaDocElementType.DOC_COMMENT)
		{
			hasDocComment = true;
			isDeprecatedByComment = RecordUtil.isDeprecatedByDocComment(tree, child);
		}
		else if(type == JavaElementType.MODIFIER_LIST)
		{
			hasDeprecatedAnnotation = RecordUtil.isDeprecatedByAnnotation(tree, child);
		}
		else if(type == JavaElementType.TYPE)
		{
			isConstructor = false;
		}
		else if(type == JavaTokenType.IDENTIFIER)
		{
			name = RecordUtil.intern(tree.getCharTable(), child);
		}
		else if(type == JavaElementType.PARAMETER_LIST)
		{
			final List<LighterASTNode> params = LightTreeUtil.getChildrenOfType(tree, child, JavaElementType.PARAMETER);
			if(!params.isEmpty())
			{
				final LighterASTNode pType = LightTreeUtil.firstChildOfType(tree, params.get(params.size() - 1), JavaElementType.TYPE);
				if(pType != null)
				{
					isVarArgs = (LightTreeUtil.firstChildOfType(tree, pType, JavaTokenType.ELLIPSIS) != null);
				}
			}
		}
		else if(type == JavaTokenType.DEFAULT_KEYWORD)
		{
			expectingDef = true;
		}
		else if(expectingDef && !ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET.contains(type) &&
				type != JavaTokenType.SEMICOLON && type != JavaElementType.CODE_BLOCK)
		{
			defValueText = LightTreeUtil.toFilteredString(tree, child, null);
			break;
		}
	}

	TypeInfo typeInfo = isConstructor ? TypeInfo.createConstructorType() : TypeInfo.create(tree, node, parentStub);
	boolean isAnno = (node.getTokenType() == JavaElementType.ANNOTATION_METHOD);
	byte flags = PsiMethodStubImpl.packFlags(isConstructor, isAnno, isVarArgs, isDeprecatedByComment, hasDeprecatedAnnotation, hasDocComment);

	return new PsiMethodStubImpl(parentStub, name, typeInfo, flags, defValueText);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:63,代码来源:JavaMethodElementType.java

示例9: getExpressionChildren

import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
@NotNull
public static List<LighterASTNode> getExpressionChildren(@NotNull LighterAST tree, @NotNull LighterASTNode node)
{
	return LightTreeUtil.getChildrenOfType(tree, node, ElementType.EXPRESSION_BIT_SET);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:6,代码来源:JavaLightTreeUtil.java


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