org.makumba.analyser.engine
Class SourceSyntaxPoints

java.lang.Object
  extended by org.makumba.analyser.engine.SourceSyntaxPoints

public class SourceSyntaxPoints
extends Object

The collection of syntax points in a source file gathered from a source analysis.

Version:
$Id: SourceSyntaxPoints.java 5157 2010-05-18 22:18:13Z rosso_nero $
Author:
Cristian Bogdan

Nested Class Summary
static interface SourceSyntaxPoints.PreprocessorClient
           
 
Field Summary
(package private)  SourceSyntaxPoints.PreprocessorClient client
           
(package private)  String content
          The content, where comments are replaced by whitespace and include directives are replaced by included text
(package private)  File file
          The path of the analyzed file
(package private)  ArrayList<Integer> fileBeginningIndexes
          The file beginnings, added in occuring order.
(package private)  ArrayList<SourceSyntaxPoints> fileBeginnings
           
(package private)  long lastChanged
          The timestamp of the analyzed file.
(package private)  ArrayList<SyntaxPoint> lineBeginnings
          The line beginnings, added in occuring order
(package private)  int offset
          offset in the including file
(package private)  String originalText
          The original text
(package private)  SourceSyntaxPoints parent
          the parent, in which we are included
(package private)  TreeSet<SyntaxPoint> syntaxPoints
          The syntax points, sorted
 
Constructor Summary
SourceSyntaxPoints(File f, SourceSyntaxPoints.PreprocessorClient cl)
          The constructor inserts syntax points (begin and end) for every line in a text, and does preprocessing (uncomments text, includes other text).
SourceSyntaxPoints(File f, SourceSyntaxPoints.PreprocessorClient cl, SourceSyntaxPoints parent, String includeDirective, int offset)
          The constructor inserts syntax points (begin and end) for every line in a text, and does preprocessing (uncomments text, includes other text).
 
Method Summary
 SyntaxPoint.End addSyntaxPoints(int start, int end, String type, Object extra)
          Creates a beginning and end syntaxPoint for a syntax entity, and adds these to the collection of points.
(package private)  SyntaxPoint.End addSyntaxPoints1(int start, int end, String type, Object extra)
           
(package private)  SyntaxPoint.End addSyntaxPointsCommon(int start, int end, String type, Object extra)
          Creates begin- and end- syntaxpoints (but without setting the line and column fields) at given location and with given info, and adds them to the collection.
(package private)  void addSyntaxPointsLine(int start, int end, String type, Object extra)
          Creates begin- and end- syntaxpoints for a full line in text.
 void discardPoints()
           
(package private)  void findLineBreaks()
          Finds the line breaks in the string
(package private)  SourceSyntaxPoints findSourceFile(int position)
          Finds the source file that contains the given syntax point
(package private)  String getContent()
           
 File getFile()
           
 String getLineText(int n)
          Gets the text of the line n.
 SyntaxPoint[] getSyntaxPoints()
          Returns the syntaxPoints.
(package private)  void include()
          Includes a file into the current content
 void include(File f, int position, String includeDirective)
          Includes the given file, at the given position, included by the given directive
(package private)  String readFile(String includeDirective)
          Reads the content of the JSP file into a string.
(package private)  void setLineAndColumn(SyntaxPoint point)
          Fills in the Line and Column for the given SyntaxPoint, based on the collection of lineBeginnings syntaxPoints.
 String toString()
           
(package private)  void treatLiterals(int patternIndex)
          Treat literals, to be specific creates a syntax point for them and then replaces their content.
(package private)  boolean unchanged()
          Checks if the file changed on the disk since it was last analysed.
(package private)  void unComment(int patternIndex)
          Treats comments, to be specific creates a syntax point for them and then replaces their content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

file

File file
The path of the analyzed file


client

SourceSyntaxPoints.PreprocessorClient client

lastChanged

long lastChanged
The timestamp of the analyzed file. If it is found newer on disk, the cached object is discarded.


syntaxPoints

TreeSet<SyntaxPoint> syntaxPoints
The syntax points, sorted


lineBeginnings

ArrayList<SyntaxPoint> lineBeginnings
The line beginnings, added in occuring order


fileBeginningIndexes

ArrayList<Integer> fileBeginningIndexes
The file beginnings, added in occuring order. When file F includes file I, I begins, then F begins again


fileBeginnings

ArrayList<SourceSyntaxPoints> fileBeginnings

originalText

String originalText
The original text


content

String content
The content, where comments are replaced by whitespace and include directives are replaced by included text


offset

int offset
offset in the including file


parent

SourceSyntaxPoints parent
the parent, in which we are included

Constructor Detail

SourceSyntaxPoints

public SourceSyntaxPoints(File f,
                          SourceSyntaxPoints.PreprocessorClient cl)
The constructor inserts syntax points (begin and end) for every line in a text, and does preprocessing (uncomments text, includes other text). Most syntax colourers need to do specific operations at every line.

Parameters:
f - the parsed file
cl - the preprocessor

SourceSyntaxPoints

public SourceSyntaxPoints(File f,
                          SourceSyntaxPoints.PreprocessorClient cl,
                          SourceSyntaxPoints parent,
                          String includeDirective,
                          int offset)
The constructor inserts syntax points (begin and end) for every line in a text, and does preprocessing (uncomments text, includes other text). Most syntax colourers need to do specific operations at every line.

Parameters:
f - the parsed file
cl - the preprocessor
parent - the parent in which we are included
includeDirective - the include directive
offset - the offset at which the inclusion takes place
Method Detail

toString

public String toString()
Overrides:
toString in class Object

findLineBreaks

void findLineBreaks()
Finds the line breaks in the string


getLineText

public String getLineText(int n)
Gets the text of the line n. This will not work after discardSyntaxPoints because both the text of the file and the syntax points are gone, to spare memory.

Parameters:
n - the line number
Returns:
A String containing the text at the indicated line

include

void include()
Includes a file into the current content


include

public void include(File f,
                    int position,
                    String includeDirective)
Includes the given file, at the given position, included by the given directive

Parameters:
f - the file to be included
position - the position of the included file
includeDirective - the directive calling for the inclusion

unComment

void unComment(int patternIndex)
Treats comments, to be specific creates a syntax point for them and then replaces their content.

Parameters:
patternIndex - the index at which the comment is stored

treatLiterals

void treatLiterals(int patternIndex)
Treat literals, to be specific creates a syntax point for them and then replaces their content.

Parameters:
patternIndex - the index at which the literal is stored

addSyntaxPoints

public SyntaxPoint.End addSyntaxPoints(int start,
                                       int end,
                                       String type,
                                       Object extra)
Creates a beginning and end syntaxPoint for a syntax entity, and adds these to the collection of points.

Parameters:
start - the starting position
end - the end position
type - String stating the type of syntax point
extra - any extra info (for example the object created at the syntax point
See Also:
addSyntaxPointsCommon(int start, int end, String type, Object extra)

addSyntaxPoints1

SyntaxPoint.End addSyntaxPoints1(int start,
                                 int end,
                                 String type,
                                 Object extra)

setLineAndColumn

void setLineAndColumn(SyntaxPoint point)
Fills in the Line and Column for the given SyntaxPoint, based on the collection of lineBeginnings syntaxPoints.

Parameters:
point - the syntax point to be filled in

findSourceFile

SourceSyntaxPoints findSourceFile(int position)
Finds the source file that contains the given syntax point

Parameters:
position - position of the syntax point

addSyntaxPointsCommon

SyntaxPoint.End addSyntaxPointsCommon(int start,
                                      int end,
                                      String type,
                                      Object extra)
Creates begin- and end- syntaxpoints (but without setting the line and column fields) at given location and with given info, and adds them to the collection.

Parameters:
start - the starting position
end - the end position
type - String stating the type of syntax point
extra - any extra info (for example the object created at the syntax point
Returns:
the created SyntaxPoint.End
See Also:
addSyntaxPoints(int, int, String, Object)

addSyntaxPointsLine

void addSyntaxPointsLine(int start,
                         int end,
                         String type,
                         Object extra)
Creates begin- and end- syntaxpoints for a full line in text.

Parameters:
start - the starting position
end - the end position
type - String stating the type of syntax point
extra - any extra info (for example the object created at the syntax point

unchanged

boolean unchanged()
Checks if the file changed on the disk since it was last analysed.

Returns:
false if unchanged, true otherwise

readFile

String readFile(String includeDirective)
Reads the content of the JSP file into a string.

Parameters:
includeDirective - the directive by which this file has been included
Returns:
A String containing a JSP file

getContent

String getContent()

getSyntaxPoints

public SyntaxPoint[] getSyntaxPoints()
Returns the syntaxPoints.

Returns:
An array of SyntaxPoints

discardPoints

public void discardPoints()

getFile

public File getFile()