edu.rice.cs.drjava.project
Class ProjectFileParser

java.lang.Object
  extended by edu.rice.cs.drjava.project.ProjectFileParserFacade
      extended by edu.rice.cs.drjava.project.ProjectFileParser

public class ProjectFileParser
extends ProjectFileParserFacade

This parser uses the s-expression parser defined in the util pacakge. The SExp tree given by the parser is interpreted into a ProjectFileIR that is given to the user. This class must also deal with different versions of the project file.

If at some point new information is to be stored in the project file, the following places in the code that need to changed:

  • If the new information pertains to a document, the DocFile class should be augmented to store the new info.
  • The interface for the DocumentInfoGetter should be expanded to allow for the new data to be retrieved.
  • Add a new clause to the else-if ladder in the FilePropertyVisitor.
  • Add the new information to the DocFile form the DocumentInfoGetter in the ProjectFileBuilder's addSourceDocument method.

    If the change is at the top level, you must modify the evaluateExpression method in this parser and add the corresponding methods to the ProjectFileIR, ProjectFileIRImpl, and ProjectFileBuilder


    Nested Class Summary
    private  class ProjectFileParser.BookmarkListVisitor
              Parses out a list of bookmark nodes.
    private static class ProjectFileParser.BookmarkPropertyVisitor
              Traverses the list of expressions found after "bookmark" tag and returns the DocumentRegion described by those properties.
    private  class ProjectFileParser.BreakpointListVisitor
              Parses out a list of breakpoint nodes.
    private static class ProjectFileParser.BreakpointPropertyVisitor
              Traverses the list of expressions found after "breakpoint" tag and returns the Breakpoint described by those properties.
    private static class ProjectFileParser.DocFileListVisitor
              Parses out a list of file nodes.
    private static class ProjectFileParser.DocFilePropertyVisitor
              Traverses the list of expressions found after "file" tag and returns the DocFile described by those properties.
    private static class ProjectFileParser.NameVisitor
              Retrieves the name of a node.
    private static class ProjectFileParser.NumberVisitor
              Retrieves the number of a node.
    private static class ProjectFileParser.PathListVisitor
              Parses out a list of path nodes into a list of Strings.
    private static class ProjectFileParser.PrivateProjectException
               
    private static class ProjectFileParser.WatchListVisitor
              Parses out a list of watch names into a list of watches.
     
    Field Summary
    private  String _parent
               
    private  String _srcFileBase
               
    (package private)  ProjectFileParser.BookmarkListVisitor bookmarkListVisitor
               
    (package private)  ProjectFileParser.BreakpointListVisitor breakpointListVisitor
               
    static ProjectFileParser ONLY
              Singleton instance of ProjectFileParser
     
    Fields inherited from class edu.rice.cs.drjava.project.ProjectFileParserFacade
    _projectFile, _xmlProjectFile
     
    Constructor Summary
    private ProjectFileParser()
               
     
    Method Summary
    private  void evaluateExpression(SEList e, ProjectFileIR pfir, ProjectFileParser.DocFileListVisitor flv)
              Given a top-level s-expression, this method checks the name of the node and configures the given pfir appropriately.
     ProjectFileIR parse(File projFile)
               
    (package private)  FileRegion parseBookmark(SExp s, String pathRoot)
              Parses out the labeled node (a non-empty list) into a bookmark.
    (package private)  DebugBreakpointData parseBreakpoint(SExp s, String pathRoot)
              Parses out the labeled node (a non-empty list) into a breakpoint.
    (package private)  DocFile parseFile(SExp s, String pathRoot)
              Parses out the labeled node (a non-empty list) into a DocFile.
    private  String parseFileName(SExp s)
               
    private  int parseInt(SExp s)
               
    private  Pair<Integer,Integer> parseIntPair(SExp s)
               
    private  String parseStringNode(SExp n)
              Takes input of form "(str str)" and returns the second string.
     
    Methods inherited from class edu.rice.cs.drjava.project.ProjectFileParserFacade
    fixup
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    ONLY

    public static final ProjectFileParser ONLY
    Singleton instance of ProjectFileParser


    _parent

    private String _parent

    _srcFileBase

    private String _srcFileBase

    breakpointListVisitor

    ProjectFileParser.BreakpointListVisitor breakpointListVisitor

    bookmarkListVisitor

    ProjectFileParser.BookmarkListVisitor bookmarkListVisitor
    Constructor Detail

    ProjectFileParser

    private ProjectFileParser()
    Method Detail

    parse

    public ProjectFileIR parse(File projFile)
                        throws IOException,
                               FileNotFoundException,
                               MalformedProjectFileException
    Overrides:
    parse in class ProjectFileParserFacade
    Parameters:
    projFile - the file to parse
    Returns:
    the project file IR
    Throws:
    IOException
    FileNotFoundException
    MalformedProjectFileException

    evaluateExpression

    private void evaluateExpression(SEList e,
                                    ProjectFileIR pfir,
                                    ProjectFileParser.DocFileListVisitor flv)
                             throws IOException
    Given a top-level s-expression, this method checks the name of the node and configures the given pfir appropriately. If the expression is empty, it is ignored.

    Parameters:
    e - the top-level s-expression to check
    pfir - the ProjectFileIR to update
    Throws:
    IOException

    parseFile

    DocFile parseFile(SExp s,
                      String pathRoot)
    Parses out the labeled node (a non-empty list) into a DocFile. The node must have the "file" label on it.

    Parameters:
    s - the non-empty list expression
    Returns:
    the DocFile described by this s-expression

    parseFileName

    private String parseFileName(SExp s)

    parseInt

    private int parseInt(SExp s)

    parseIntPair

    private Pair<Integer,Integer> parseIntPair(SExp s)

    parseStringNode

    private String parseStringNode(SExp n)
    Takes input of form "(str str)" and returns the second string.


    parseBreakpoint

    DebugBreakpointData parseBreakpoint(SExp s,
                                        String pathRoot)
    Parses out the labeled node (a non-empty list) into a breakpoint. The node must have the "breakpoint" label on it.

    Parameters:
    s - the non-empty list expression
    Returns:
    the breakpoint described by this s-expression

    parseBookmark

    FileRegion parseBookmark(SExp s,
                             String pathRoot)
    Parses out the labeled node (a non-empty list) into a bookmark. The node must have the "bookmark" label on it.

    Parameters:
    s - the non-empty list expression
    Returns:
    the bookmark described by this s-expression