本文整理汇总了Java中com.intellij.psi.impl.source.tree.LightTreeUtil.firstChildOfType方法的典型用法代码示例。如果您正苦于以下问题:Java LightTreeUtil.firstChildOfType方法的具体用法?Java LightTreeUtil.firstChildOfType怎么用?Java LightTreeUtil.firstChildOfType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.impl.source.tree.LightTreeUtil
的用法示例。
在下文中一共展示了LightTreeUtil.firstChildOfType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isDeprecatedByAnnotation
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
public static boolean isDeprecatedByAnnotation(@NotNull LighterAST tree, @NotNull LighterASTNode modList) {
for (final LighterASTNode child : tree.getChildren(modList)) {
if (child.getTokenType() == JavaElementType.ANNOTATION) {
final LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, child, JavaElementType.JAVA_CODE_REFERENCE);
if (ref != null) {
final LighterASTNode id = LightTreeUtil.firstChildOfType(tree, ref, JavaTokenType.IDENTIFIER);
if (id != null) {
final String name = intern(tree.getCharTable(), id);
if (DEPRECATED_ANNOTATION_NAME.equals(name)) return true;
}
}
}
}
return false;
}
示例2: isDeprecatedByAnnotation
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
public static boolean isDeprecatedByAnnotation(@NotNull LighterAST tree, @NotNull LighterASTNode modList)
{
for(final LighterASTNode child : tree.getChildren(modList))
{
if(child.getTokenType() == JavaElementType.ANNOTATION)
{
final LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, child, JavaElementType.JAVA_CODE_REFERENCE);
if(ref != null)
{
final LighterASTNode id = LightTreeUtil.firstChildOfType(tree, ref, JavaTokenType.IDENTIFIER);
if(id != null)
{
final String name = intern(tree.getCharTable(), id);
if(DEPRECATED_ANNOTATION_NAME.equals(name))
{
return true;
}
}
}
}
}
return false;
}
示例3: createStubForFile
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
@NotNull
@Override
protected StubElement createStubForFile(@NotNull PsiFile file, @NotNull LighterAST tree)
{
if(!(file instanceof PsiJavaFile))
{
return super.createStubForFile(file, tree);
}
String refText = "";
LighterASTNode pkg = LightTreeUtil.firstChildOfType(tree, tree.getRoot(), JavaElementType.PACKAGE_STATEMENT);
if(pkg != null)
{
LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, pkg, JavaElementType.JAVA_CODE_REFERENCE);
if(ref != null)
{
refText = JavaSourceUtil.getReferenceText(tree, ref);
}
}
return new PsiJavaFileStubImpl((PsiJavaFile) file, refText, null, false);
}
示例4: calcData
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
@Nullable
private static MethodData calcData(LighterAST tree, LighterASTNode method)
{
LighterASTNode body = LightTreeUtil.firstChildOfType(tree, method, JavaElementType.CODE_BLOCK);
if(body == null)
{
return null;
}
List<LighterASTNode> statements = ContractInferenceInterpreter.getStatements(body, tree);
List<PreContract> contracts = new ContractInferenceInterpreter(tree, method, body).inferContracts(statements);
NullityInference.NullityInferenceVisitor nullityVisitor = new NullityInference.NullityInferenceVisitor(tree, body);
PurityInference.PurityInferenceVisitor purityVisitor = new PurityInference.PurityInferenceVisitor(tree, body);
for(LighterASTNode statement : statements)
{
walkMethodBody(tree, statement, it ->
{
nullityVisitor.visitNode(it);
purityVisitor.visitNode(it);
});
}
return createData(body, contracts, nullityVisitor.getResult(), purityVisitor.getResult());
}
示例5: getNullParameterIndices
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
@Nullable
private static IntArrayList getNullParameterIndices(LighterAST lighterAst, @NotNull LighterASTNode methodCall)
{
final LighterASTNode node = LightTreeUtil.firstChildOfType(lighterAst, methodCall, EXPRESSION_LIST);
if(node == null)
{
return null;
}
final List<LighterASTNode> parameters = JavaLightTreeUtil.getExpressionChildren(lighterAst, node);
IntArrayList indices = new IntArrayList(1);
for(int idx = 0; idx < parameters.size(); idx++)
{
if(isNullLiteral(lighterAst, parameters.get(idx)))
{
indices.add(idx);
}
}
return indices;
}
示例6: createStub
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
@Override
public PsiProvidesStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub)
{
LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, node, JavaElementType.JAVA_CODE_REFERENCE);
String refText = ref != null ? JavaSourceUtil.getReferenceText(tree, ref) : null;
return new PsiProvidesStatementStubImpl(parentStub, refText);
}
示例7: createStub
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
@Override
public PsiUsesStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub)
{
LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, node, JavaElementType.JAVA_CODE_REFERENCE);
String refText = ref != null ? JavaSourceUtil.getReferenceText(tree, ref) : null;
return new PsiUsesStatementStubImpl(parentStub, refText);
}
示例8: createStub
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
@Override
public PsiRequiresStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub)
{
LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, node, JavaElementType.MODULE_REFERENCE);
String refText = ref != null ? JavaSourceUtil.getReferenceText(tree, ref) : null;
return new PsiRequiresStatementStubImpl(parentStub, refText);
}
示例9: getArgList
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
@Nullable
@Contract("_,null->null")
public static List<LighterASTNode> getArgList(@NotNull LighterAST tree, @Nullable LighterASTNode call)
{
LighterASTNode anonClass = LightTreeUtil.firstChildOfType(tree, call, ANONYMOUS_CLASS);
LighterASTNode exprList = LightTreeUtil.firstChildOfType(tree, anonClass != null ? anonClass : call, EXPRESSION_LIST);
return exprList == null ? null : getExpressionChildren(tree, exprList);
}
示例10: getNameIdentifierText
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
@Nullable
@Contract("_,null->null")
public static String getNameIdentifierText(@NotNull LighterAST tree, @Nullable LighterASTNode idOwner)
{
LighterASTNode id = LightTreeUtil.firstChildOfType(tree, idOwner, JavaTokenType.IDENTIFIER);
return id != null ? RecordUtil.intern(tree.getCharTable(), id) : null;
}
示例11: 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);
}
示例12: 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;
}
示例13: createStub
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入方法依赖的package包/类
@Override
public PropertyStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
LighterASTNode keyNode = LightTreeUtil.firstChildOfType(tree, node, PropertiesTokenTypes.KEY_CHARACTERS);
String key = intern(tree.getCharTable(), keyNode);
return new PropertyStubImpl(parentStub, key);
}
示例14: 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));
}
示例15: 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);
}