use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class MasqueradingPsiBuilderAdapter method synchronizePositions.
/**
* @param exact if true then positions should be equal;
* else delegate should be behind, not including exactly all foreign (skipped) or whitespace tokens
*/
private void synchronizePositions(boolean exact) {
final PsiBuilder delegate = getDelegate();
if (myLexPosition >= myShrunkSequence.size() || delegate.eof()) {
myLexPosition = myShrunkSequence.size();
while (!delegate.eof()) {
delegate.advanceLexer();
}
return;
}
if (delegate.getCurrentOffset() > myShrunkSequence.get(myLexPosition).realStart) {
LOG.error("delegate is ahead of my builder!");
return;
}
final int keepUpPosition = getKeepUpPosition(exact);
while (!delegate.eof()) {
final int delegatePosition = delegate.getCurrentOffset();
if (delegatePosition < keepUpPosition) {
delegate.advanceLexer();
} else {
break;
}
}
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class RegExpParser method parseBranch.
/**
* BRANCH ::= ATOM BRANCH | ""
*/
private boolean parseBranch(PsiBuilder builder) {
final PsiBuilder.Marker marker = builder.mark();
if (!parseAtom(builder)) {
final IElementType token = builder.getTokenType();
if (token == RegExpTT.GROUP_END || token == RegExpTT.UNION || token == null) {
// empty branches are allowed
marker.done(RegExpElementTypes.BRANCH);
return true;
}
marker.drop();
return false;
}
//noinspection StatementWithEmptyBody
while (parseAtom(builder)) {
}
marker.done(RegExpElementTypes.BRANCH);
return true;
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class RegExpParser method parseCharacterRange.
private void parseCharacterRange(PsiBuilder builder) {
final PsiBuilder.Marker rangeMarker = builder.mark();
parseCharacter(builder);
if (builder.getTokenType() == RegExpTT.MINUS) {
final PsiBuilder.Marker minusMarker = builder.mark();
builder.advanceLexer();
final IElementType t = builder.getTokenType();
if (RegExpTT.CHARACTERS.contains(t) || t == RegExpTT.NAMED_CHARACTER) {
minusMarker.drop();
parseCharacter(builder);
rangeMarker.done(RegExpElementTypes.CHAR_RANGE);
} else {
if (t == RegExpTT.CLASS_END) {
// [a-]
rangeMarker.drop();
minusMarker.done(RegExpElementTypes.CHAR);
} else if (t == RegExpTT.CLASS_BEGIN) {
// [a-[b]]\
rangeMarker.drop();
minusMarker.done(RegExpElementTypes.CHAR);
parseClassdef(builder);
} else {
minusMarker.drop();
builder.error("Illegal character range");
rangeMarker.done(RegExpElementTypes.CHAR_RANGE);
}
}
} else {
rangeMarker.drop();
}
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class StandardHeaderParser method parse.
@Override
public void parse(@NotNull PsiBuilder builder) {
PsiBuilder.Marker marker = builder.mark();
while (!builder.eof() && !ManifestParser.HEADER_END_TOKENS.contains(builder.getTokenType())) {
IElementType lastToken = builder.getTokenType();
builder.advanceLexer();
if (lastToken == ManifestTokenType.NEWLINE && builder.getTokenType() != ManifestTokenType.SIGNIFICANT_SPACE) {
break;
}
}
marker.done(ManifestElementType.HEADER_VALUE_PART);
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class ManifestParser method parseHeader.
private void parseHeader(PsiBuilder builder) {
PsiBuilder.Marker header = builder.mark();
String headerName = builder.getTokenText();
assert headerName != null : "[" + builder.getOriginalText() + "]@" + builder.getCurrentOffset();
builder.advanceLexer();
if (builder.getTokenType() == ManifestTokenType.COLON) {
builder.advanceLexer();
if (!expect(builder, ManifestTokenType.SIGNIFICANT_SPACE)) {
builder.error(ManifestBundle.message("manifest.whitespace.expected"));
}
HeaderParser headerParser = notNull(myRepository.getHeaderParser(headerName), StandardHeaderParser.INSTANCE);
headerParser.parse(builder);
} else {
PsiBuilder.Marker marker = builder.mark();
consumeHeaderValue(builder);
marker.error(ManifestBundle.message("manifest.colon.expected"));
}
header.done(ManifestElementType.HEADER);
}
Aggregations