use of com.intellij.lang.LighterASTNode in project Perl5-IDEA by Camelcade.
the class TemplateToolkitParserUtil method parseDirective.
public static boolean parseDirective(PsiBuilder b, int l) {
IElementType tokenType = b.getTokenType();
boolean r = false;
LighterASTNode latestDoneMarker = null;
PsiBuilder.Marker outerMarker = b.mark();
boolean isAfterSemi = tokenType != TT2_OPEN_TAG && tokenType != TT2_OUTLINE_TAG && isAfterSemi(b);
if (isAfterSemi || tokenType == TT2_OPEN_TAG) {
if (!isAfterSemi) {
b.advanceLexer();
}
if (TemplateToolkitParser.directive(b, l)) {
latestDoneMarker = b.getLatestDoneMarker();
}
if (latestDoneMarker == null || latestDoneMarker.getTokenType() != MACRO_DIRECTIVE) {
PsiBuilder.Marker m = null;
while (!b.eof()) {
if (isBlockEndMarker(b)) {
break;
}
if (m == null) {
m = b.mark();
}
b.advanceLexer();
}
if (m != null) {
m.error(PerlBundle.message("ttk2.unexpected.token"));
}
consumeToken(b, TT2_SEMI);
consumeToken(b, TT2_CLOSE_TAG);
}
r = true;
} else if (tokenType == TT2_OUTLINE_TAG) {
b.advanceLexer();
if (TemplateToolkitParser.directive(b, l)) {
latestDoneMarker = b.getLatestDoneMarker();
}
if (latestDoneMarker == null || latestDoneMarker.getTokenType() != MACRO_DIRECTIVE) {
PsiBuilder.Marker m = null;
while (!b.eof()) {
if (b.getTokenType() == TT2_HARD_NEWLINE) {
break;
}
if (m == null) {
m = b.mark();
}
b.advanceLexer();
}
if (m != null) {
m.error("ttk2.unexpected.token");
}
// parseHardNewLine(b, l); // fixme this breaks lastMarker mechanism, need to figure out something
if (b.getTokenType() == TT2_HARD_NEWLINE) {
// this is irreversable change, so not sure it's a good idea
b.remapCurrentToken(TokenType.WHITE_SPACE);
b.advanceLexer();
}
}
r = true;
}
processMarkers(b, l, latestDoneMarker, outerMarker);
return r;
}
use of com.intellij.lang.LighterASTNode in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoParserUtil method isBuiltin.
public static boolean isBuiltin(@NotNull PsiBuilder builder_, @SuppressWarnings("UnusedParameters") int level) {
LighterASTNode marker = builder_.getLatestDoneMarker();
if (marker == null)
return false;
String text = String.valueOf(builder_.getOriginalText().subSequence(marker.getStartOffset(), marker.getEndOffset())).trim();
return "make".equals(text) || "new".equals(text);
}
use of com.intellij.lang.LighterASTNode in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoParserUtil method prevIsType.
public static boolean prevIsType(@NotNull PsiBuilder builder_, @SuppressWarnings("UnusedParameters") int level) {
LighterASTNode marker = builder_.getLatestDoneMarker();
IElementType type = marker != null ? marker.getTokenType() : null;
return type == GoTypes.ARRAY_OR_SLICE_TYPE || type == GoTypes.MAP_TYPE || type == GoTypes.STRUCT_TYPE;
}
Aggregations