Package codeanalysis.text
Class SourceText
java.lang.Object
codeanalysis.text.SourceText
Represents source code to be compiled.
It consists of a list of text lines and the entire text.
- Version:
- 1.0
- Author:
- Siyabend Urun
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSourceText(String text) Initializes a new instance of the SourceText class with the specified text. -
Method Summary
Modifier and TypeMethodDescriptioncharcharAt(int position) Retrieves the character at the specified position.static SourceTextCreates a new instance of the SourceText class with the specified text.intgetLineIndex(int position) Retrieves line index of the character at the specified position.getLines()Retrieves the list of text lines.intlength()Retrieves the character length of the source code.toString()Retrieves the string representation of the source code.toString(int start, int end) Retrieves the string representation of the source code between the specified positions.Retrieves string representation of the source code between the specified text spans.
-
Constructor Details
-
SourceText
Initializes a new instance of the SourceText class with the specified text.- Parameters:
text- The text of the source code.
-
-
Method Details
-
getLineIndex
public int getLineIndex(int position) Retrieves line index of the character at the specified position.- Parameters:
position- The position of the character.- Returns:
- The line index.
-
charAt
public char charAt(int position) Retrieves the character at the specified position.- Parameters:
position- The position of the character.- Returns:
- The character.
-
length
public int length()Retrieves the character length of the source code.- Returns:
- The character length.
-
from
Creates a new instance of the SourceText class with the specified text.- Parameters:
text- The text of the source code.- Returns:
- The new instance of the SourceText class.
-
getLines
Retrieves the list of text lines. The list is created by parsing the source code.- Returns:
- The list of text lines.
-
toString
Retrieves the string representation of the source code. -
toString
Retrieves the string representation of the source code between the specified positions.- Parameters:
start- The start position of the text.end- The end position of the text.- Returns:
- The text between the specified positions.
-
toString
Retrieves string representation of the source code between the specified text spans.- Parameters:
span- The text span.- Returns:
- The text between the specified text spans.
-