use of com.intellij.lang.LighterASTNode in project intellij-community by JetBrains.
the class JavaUsesStatementElementType method createStub.
@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);
}
use of com.intellij.lang.LighterASTNode in project intellij-community by JetBrains.
the class LambdaExpressionElementType method formatParameter.
private static void formatParameter(@NotNull LighterAST tree, @NotNull LighterASTNode parameter, StringBuilder buf) {
final List<LighterASTNode> children = tree.getChildren(parameter);
for (LighterASTNode node : children) {
final IElementType tokenType = node.getTokenType();
if (tokenType == JavaElementType.TYPE) {
formatType(tree, node, buf);
buf.append(' ');
} else if (tokenType == JavaTokenType.IDENTIFIER) {
buf.append(RecordUtil.intern(tree.getCharTable(), node));
}
}
}
use of com.intellij.lang.LighterASTNode in project intellij-community by JetBrains.
the class FileLocalResolver method resolveLocally.
/**
* @param ref reference node
* @return a resolve result corresponding to a local variable, parameter or field that the given reference resolves to.
*/
@NotNull
public LightResolveResult resolveLocally(@NotNull LighterASTNode ref) {
final String refName = JavaLightTreeUtil.getNameIdentifierText(myTree, ref);
if (refName == null)
return LightResolveResult.UNKNOWN;
if (!canResolveToLocalVariable(myTree, ref))
return LightResolveResult.NON_LOCAL;
boolean passedClass = false;
LighterASTNode lastParent = ref;
while (true) {
LighterASTNode scope = myTree.getParent(lastParent);
if (scope == null)
return LightResolveResult.NON_LOCAL;
for (LighterASTNode var : getDeclarations(scope, lastParent)) {
if (refName.equals(JavaLightTreeUtil.getNameIdentifierText(myTree, var))) {
if (passedClass)
return var.getTokenType() == FIELD ? LightResolveResult.NON_LOCAL : LightResolveResult.UNKNOWN;
return LightResolveResult.resolved(var);
}
}
lastParent = scope;
passedClass |= scope.getTokenType() == CLASS || scope.getTokenType() == ANONYMOUS_CLASS;
}
}
use of com.intellij.lang.LighterASTNode in project Perl5-IDEA by Camelcade.
the class TemplateToolkitParserUtil method parseMacroBody.
public static boolean parseMacroBody(PsiBuilder b, int l) {
boolean r = false;
LighterASTNode latestDoneMarker = null;
PsiBuilder.Marker outerMarker = b.mark();
if (TemplateToolkitParser.directive(b, l)) {
latestDoneMarker = b.getLatestDoneMarker();
PsiBuilder.Marker m = null;
while (!b.eof()) {
if (isEndMarker(b)) {
break;
}
if (m == null) {
m = b.mark();
}
b.advanceLexer();
}
if (m != null) {
m.error(PerlBundle.message("ttk2.unexpected.token"));
}
consumeToken(b, TT2_HARD_NEWLINE);
consumeToken(b, TT2_SEMI);
consumeToken(b, TT2_CLOSE_TAG);
r = true;
}
processMarkers(b, l, latestDoneMarker, outerMarker);
return r;
}
use of com.intellij.lang.LighterASTNode in project Perl5-IDEA by Camelcade.
the class TemplateToolkitParserUtil method parseSwitchBlockContent.
public static boolean parseSwitchBlockContent(PsiBuilder b, int l) {
PsiBuilder.Marker branchMarker = null;
while (!b.eof()) {
PsiBuilder.Marker currentMarker = b.mark();
if (TemplateToolkitParser.element(b, l)) {
LighterASTNode latestDoneMarker = b.getLatestDoneMarker();
if (latestDoneMarker != null) {
if (latestDoneMarker.getTokenType() == END_DIRECTIVE) {
if (branchMarker != null) {
branchMarker.doneBefore(CASE_BLOCK, currentMarker);
branchMarker.setCustomEdgeTokenBinders(WhitespacesBinders.DEFAULT_LEFT_BINDER, WhitespacesBinders.GREEDY_RIGHT_BINDER);
}
branchMarker = null;
currentMarker.drop();
break;
} else if (latestDoneMarker.getTokenType() == CASE_DIRECTIVE) {
if (branchMarker != null) {
branchMarker.doneBefore(CASE_BLOCK, currentMarker);
branchMarker.setCustomEdgeTokenBinders(WhitespacesBinders.DEFAULT_LEFT_BINDER, WhitespacesBinders.GREEDY_RIGHT_BINDER);
}
branchMarker = currentMarker.precede();
}
}
}
currentMarker.drop();
}
if (branchMarker != null) {
branchMarker.done(CASE_BLOCK);
branchMarker.setCustomEdgeTokenBinders(WhitespacesBinders.DEFAULT_LEFT_BINDER, WhitespacesBinders.GREEDY_RIGHT_BINDER);
}
return true;
}
Aggregations