org.jruby.lexer.yacc
Interface ISourcePosition

All Known Implementing Classes:
ISeqPosition, SourcePosition

public interface ISourcePosition

This interface is the combination of two needs: 1) A Ruby interpreter position (for warnings and errors). The interpreter only cares about filename and endLine. 2) A IDE position (offsets for showing ranges of grammatical elements). The offsets represent positions 'between' characters. So a variable 'abc' has a startOffset of 0 and an endOffset of 3 ( 0a1b2c3 ).


Method Summary
 void adjustStartOffset(int relativeValue)
          Modify startOffset by a relativeValue.
 int getEndLine()
          Which is the last(end) line that this source position occurs on (zero-based)
 int getEndOffset()
          Get offset (relative to beginning of source file) immediately after the last character represented by this source position
 java.lang.String getFile()
          Which file does this source position live in?
 int getStartLine()
          Which is the first(start) line that this source position occurs on (zero-based)
 int getStartOffset()
          Get offset (relative to beginning of source file) immediately before first character represented by this source position.
 ISourcePosition union(ISourcePosition position)
          Calculates the logical union of the two positions and creates a new resulting position
 

Method Detail

getFile

public java.lang.String getFile()
Which file does this source position live in?

Returns:
name of the source file.

getStartLine

public int getStartLine()
Which is the first(start) line that this source position occurs on (zero-based)

Returns:

getEndLine

public int getEndLine()
Which is the last(end) line that this source position occurs on (zero-based)

Returns:
the line

adjustStartOffset

public void adjustStartOffset(int relativeValue)
Modify startOffset by a relativeValue. At times our grammar and lexer do not give us the exact positions we need so we need to manually tweak position. The bummer of this is this requires ISourcePosition implementations are mutable.

Parameters:
relativeValue - to nudge startOffset up or down

getStartOffset

public int getStartOffset()
Get offset (relative to beginning of source file) immediately before first character represented by this source position.

Returns:
the offset

getEndOffset

public int getEndOffset()
Get offset (relative to beginning of source file) immediately after the last character represented by this source position

Returns:
the offset

union

public ISourcePosition union(ISourcePosition position)
Calculates the logical union of the two positions and creates a new resulting position

Parameters:
position - to be unioned against this position
Returns:
a new position


Copyright © 2002-2007 JRuby Team. All Rights Reserved.