本文整理汇总了Java中com.intellij.psi.impl.source.tree.LightTreeUtil类的典型用法代码示例。如果您正苦于以下问题:Java LightTreeUtil类的具体用法?Java LightTreeUtil怎么用?Java LightTreeUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LightTreeUtil类属于com.intellij.psi.impl.source.tree包,在下文中一共展示了LightTreeUtil类的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: 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('>');
}
示例3: 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;
}
示例4: isDeprecatedByDocComment
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入依赖的package包/类
public static boolean isDeprecatedByDocComment(@NotNull LighterAST tree, @NotNull LighterASTNode comment)
{
String text = LightTreeUtil.toFilteredString(tree, comment, null);
if(text.contains(DEPRECATED_TAG))
{
JavaDocLexer lexer = new JavaDocLexer(LanguageLevel.HIGHEST);
lexer.start(text);
IElementType token;
while((token = lexer.getTokenType()) != null)
{
if(token == JavaDocTokenType.DOC_TAG_NAME && DEPRECATED_TAG.equals(lexer.getTokenText()))
{
return true;
}
lexer.advance();
}
}
return false;
}
示例5: 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);
}
示例6: 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());
}
示例7: findCallsWithNulls
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入依赖的package包/类
@NotNull
private static Set<LighterASTNode> findCallsWithNulls(LighterAST lighterAst, int[] nullOffsets)
{
Set<LighterASTNode> calls = new HashSet<>();
for(int offset : nullOffsets)
{
LighterASTNode leaf = LightTreeUtil.findLeafElementAt(lighterAst, offset);
LighterASTNode literal = leaf == null ? null : lighterAst.getParent(leaf);
if(isNullLiteral(lighterAst, literal))
{
LighterASTNode exprList = lighterAst.getParent(literal);
if(exprList != null && exprList.getTokenType() == EXPRESSION_LIST)
{
ContainerUtil.addIfNotNull(calls, LightTreeUtil.getParentOfType(lighterAst, exprList, CALL_TYPES, ElementType.MEMBER_BIT_SET));
}
}
}
return calls;
}
示例8: 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;
}
示例9: 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;
}
示例10: encodeInitializer
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入依赖的package包/类
private static String encodeInitializer(final LighterAST tree, final LighterASTNode initializer) {
final IElementType type = initializer.getTokenType();
if (type == JavaElementType.NEW_EXPRESSION || type == JavaElementType.METHOD_CALL_EXPRESSION) {
return PsiFieldStub.INITIALIZER_NOT_STORED;
}
if (initializer.getEndOffset() - initializer.getStartOffset() > INITIALIZER_LENGTH_LIMIT) {
return PsiFieldStub.INITIALIZER_TOO_LONG;
}
return LightTreeUtil.toFilteredString(tree, initializer, null);
}
示例11: 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;
}
示例12: createStub
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入依赖的package包/类
@Override
public PsiParameterStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
TypeInfo typeInfo = TypeInfo.create(tree, node, parentStub);
LighterASTNode id = LightTreeUtil.requiredChildOfType(tree, node, JavaTokenType.IDENTIFIER);
String name = RecordUtil.intern(tree.getCharTable(), id);
return new PsiParameterStubImpl(parentStub, name, typeInfo, typeInfo.isEllipsis);
}
示例13: createStub
import com.intellij.psi.impl.source.tree.LightTreeUtil; //导入依赖的package包/类
@Override
public PsiParameterStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
TypeInfo typeInfo = TypeInfo.create(tree, node, parentStub);
LighterASTNode id = LightTreeUtil.requiredChildOfType(tree, node, ID_TYPES);
String name = RecordUtil.intern(tree.getCharTable(), id);
return new PsiParameterStubImpl(parentStub, name, typeInfo, typeInfo.isEllipsis);
}
示例14: 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);
}
示例15: 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);
}