Java源码示例:com.intellij.lexer.LexerPosition
示例1
@NotNull
@Override
public LexerPosition getCurrentPosition() {
final int start = getTokenStart();
final int state = getState();
return new LexerPosition() {
@Override
public int getOffset() {
return start;
}
@Override
public int getState() {
return state;
}
};
}
示例2
@Override
public void restore(@NotNull final LexerPosition position) {
final int prefixLength = prefix.length();
final int newOffset = position.getOffset() - prefixLength;
if (newOffset == 0) {
this.afterPrefix = false;
}
if (newOffset < myDelegate.getBufferEnd()) {
this.delegateEOF = false;
this.afterEOF = false;
}
myDelegate.restore(new LexerPosition() {
@Override
public int getOffset() {
return newOffset;
}
@Override
public int getState() {
return position.getState();
}
});
}
示例3
public void load(@Nonnull final com.igormaznitsa.mindmap.model.parser.MindMapLexer.LexerPosition position) {
if (this.pos == null) {
this.pos = position.makeCopy();
} else {
this.pos.set(position);
}
}
示例4
@Override
public void restore(LexerPosition position) {
final Position p = (Position)position;
myBaseLexer.restore(p.getBasePosition());
final LexerPosition templatePos = p.getTemplatePosition();
if (templatePos != null && templatePos.getOffset() < myTemplateLexer.getBufferEnd()) {
myTemplateLexer.restore(templatePos);
}
else {
setupTemplateToken();
}
}
示例5
@Nonnull
@Override
public LexerPosition getCurrentPosition() {
this.pos.load(this.delegate.getCurrentPosition());
return this.pos;
}
示例6
@Override
public void restore(@Nonnull LexerPosition position) {
this.pos.save(this.delegate.getCurrentPosition());
}
示例7
public void save(@Nonnull final com.igormaznitsa.mindmap.model.parser.MindMapLexer.LexerPosition position) {
position.set(this.pos);
}
示例8
@NotNull
@Override
public synchronized LexerPosition getCurrentPosition() {
return super.getCurrentPosition();
}
示例9
@Override
public synchronized void restore(@NotNull LexerPosition position) {
super.restore(position);
}
示例10
@Override
public IElementType merge(final IElementType mergeToken, final Lexer originalLexer)
{
if(!ourMergeSet.contains(mergeToken))
{
return mergeToken;
}
while(true)
{
IElementType currentToken = originalLexer.getTokenType();
if(currentToken == null)
{
break;
}
// we need merge two docs if one line between
if(mergeToken == CSharpTokensImpl.LINE_DOC_COMMENT && currentToken == CSharpTokens.WHITE_SPACE)
{
LexerPosition currentPosition = originalLexer.getCurrentPosition();
originalLexer.advance();
boolean docIsNext = originalLexer.getTokenType() == CSharpTokensImpl.LINE_DOC_COMMENT;
originalLexer.restore(currentPosition);
if(docIsNext)
{
currentToken = CSharpTokensImpl.LINE_DOC_COMMENT;
}
else
{
break;
}
}
if(currentToken != mergeToken)
{
break;
}
originalLexer.advance();
}
return mergeToken;
}
示例11
public Position(LexerPosition templatePosition, LexerPosition jspPosition) {
myTemplatePosition = templatePosition;
myBasePosition = jspPosition;
}
示例12
public LexerPosition getTemplatePosition() {
return myTemplatePosition;
}
示例13
public LexerPosition getBasePosition() {
return myBasePosition;
}
示例14
@Override
public LexerPosition getCurrentPosition() {
return new Position(myTemplateLexer.getCurrentPosition(), myBaseLexer.getCurrentPosition());
}