org.jrubyparser
Class SourcePosition

java.lang.Object
  extended by org.jrubyparser.SourcePosition
All Implemented Interfaces:
Serializable

public class SourcePosition
extends Object
implements Serializable

Position within a source.

See Also:
Serialized Form

Constructor Summary
SourcePosition()
          Creates a default source position - required for serialization.
SourcePosition(String file, int startLine, int endLine)
          Creates a new source position.
SourcePosition(String file, int startLine, int endLine, int startOffset, int endOffset)
          Creates a new source position.
 
Method Summary
 void adjustStartOffset(int relativeValue)
           
static SourcePosition combinePosition(SourcePosition firstPos, SourcePosition secondPos)
          Not used in interpreter Creates a new position the encloses both parameter positions.
 boolean equals(Object object)
           
 SourcePosition fromBeginning(int length)
           
 SourcePosition fromEnd(int length)
           
 int getEndLine()
           
 int getEndOffset()
           
 String getFile()
           
 int getStartLine()
           
 int getStartOffset()
           
 int hashCode()
          Something we can use for identity in hashing, etc...
 boolean isEmpty()
          Is this a place-holder element for things like a zero-arg listnode? These elements get added to the AST for that jruby-parser's rewriting can add arguments after the tree is constructed.
 boolean isWithin(int offset)
           
 SourcePosition makeEmptyPositionAfterThis()
          Make a new SourcePosition instance which will be the index starting at the end of this one of 0 length.
 SourcePosition makeEmptyPositionBeforeThis()
           
 String toString()
           
 SourcePosition union(SourcePosition other)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SourcePosition

public SourcePosition()
Creates a default source position - required for serialization.


SourcePosition

public SourcePosition(String file,
                      int startLine,
                      int endLine)
Creates a new source position.

Parameters:
file - location of the source (must not be null)
endLine - what line within the source

SourcePosition

public SourcePosition(String file,
                      int startLine,
                      int endLine,
                      int startOffset,
                      int endOffset)
Creates a new source position.

Parameters:
file - location of the source (must not be null)
line - what line within the source
Method Detail

getFile

public String getFile()

getStartLine

public int getStartLine()

getEndLine

public int getEndLine()

equals

public boolean equals(Object object)
Overrides:
equals in class Object
Parameters:
object - the object which should be compared
Returns:
simple Object.equals() implementation

hashCode

public int hashCode()
Something we can use for identity in hashing, etc...

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

adjustStartOffset

public void adjustStartOffset(int relativeValue)

getStartOffset

public int getStartOffset()

getEndOffset

public int getEndOffset()

isWithin

public boolean isWithin(int offset)

isEmpty

public boolean isEmpty()
Is this a place-holder element for things like a zero-arg listnode? These elements get added to the AST for that jruby-parser's rewriting can add arguments after the tree is constructed.


union

public SourcePosition union(SourcePosition other)

fromEnd

public SourcePosition fromEnd(int length)

fromBeginning

public SourcePosition fromBeginning(int length)

combinePosition

public static SourcePosition combinePosition(SourcePosition firstPos,
                                             SourcePosition secondPos)
Not used in interpreter Creates a new position the encloses both parameter positions.

Parameters:
the - positions providing the boundaries for the new position.

makeEmptyPositionAfterThis

public SourcePosition makeEmptyPositionAfterThis()
Make a new SourcePosition instance which will be the index starting at the end of this one of 0 length. This is so that empty arg lists know where to start when you use the rewriter to add arguments to an empty arg list.


makeEmptyPositionBeforeThis

public SourcePosition makeEmptyPositionBeforeThis()


Copyright © 2013. All Rights Reserved.