use of com.intellij.lang.LighterASTNode in project intellij-community by JetBrains.
the class JavaParameterElementType method createStub.
@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, false);
}
use of com.intellij.lang.LighterASTNode in project intellij-community by JetBrains.
the class JavaRequiresStatementElementType method createStub.
@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);
}
use of com.intellij.lang.LighterASTNode in project intellij-community by JetBrains.
the class LambdaExpressionElementType method formatTypeParameters.
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('>');
}
use of com.intellij.lang.LighterASTNode in project intellij-community by JetBrains.
the class LambdaExpressionElementType method formatParameterList.
private static void formatParameterList(@NotNull LighterAST tree, @NotNull LighterASTNode parameterList, StringBuilder buf) {
final List<LighterASTNode> children = tree.getChildren(parameterList);
boolean isFirstParameter = true;
boolean appendCloseBracket = false;
for (final LighterASTNode node : children) {
final IElementType tokenType = node.getTokenType();
if (tokenType == JavaTokenType.LPARENTH) {
buf.append('(');
appendCloseBracket = true;
} else if (tokenType == JavaStubElementTypes.PARAMETER) {
if (!isFirstParameter) {
buf.append(", ");
}
formatParameter(tree, node, buf);
if (isFirstParameter) {
isFirstParameter = false;
}
}
}
if (appendCloseBracket)
buf.append(')');
}
use of com.intellij.lang.LighterASTNode in project intellij-community by JetBrains.
the class LightTreeUtil method getChildrenOfType.
@NotNull
public static List<LighterASTNode> getChildrenOfType(@NotNull LighterAST tree, @NotNull LighterASTNode node, @NotNull IElementType type) {
List<LighterASTNode> result = null;
List<LighterASTNode> children = tree.getChildren(node);
for (int i = 0, size = children.size(); i < size; ++i) {
LighterASTNode child = children.get(i);
if (child.getTokenType() == type) {
if (result == null)
result = new SmartList<>();
result.add(child);
}
}
return result != null ? result : Collections.<LighterASTNode>emptyList();
}
Aggregations