com.togethersoft.sca.core
Interface IProject


public interface IProject

A project is a set of source files from which the AST model is built. It also contains some additional information such as classpath required to build the project.

This interface is not intended to be implemented by clients.


Method Summary
 void addSourceBase(ISourceBase sourceBase)
          Adds a source file location.
 void deepUpdate(AstCompilationUnit file)
          Builds the deep AST model for the types containing in the specified file.
 void enableAssert(boolean enabled)
          Specifies whether the assertion statements introduced in JDK 1.4 will be recognized.
 java.lang.String getClasspath()
          Returns class path string for the project.
 long getFileSize(java.lang.String filename)
          Returns the size (in bytes) of the file with the specified name.
 ILog getLog()
          Returns the log object for this project.
 AstModel getModel()
          Returns the AST model of this project.
 java.lang.String getProjectName()
          Returns the name of this project.
 ISourceBase[] getSourceBases()
          Returns an array of source file locations.
 java.lang.String[] getSourceFiles()
          Returns an array of files in the project.
 int getTabSize()
          Returns the tab size for source files in this project.
 long getTimestamp(java.lang.String filename)
          Returns the timestamp for the specified file.
 boolean isAssertEnabled()
          Indicates whether the assertion statements introduced in JDK 1.4 are recognized.
 java.io.Reader openFile(java.lang.String filename)
          Returns the reader for the specified file.
 void setClasspath(java.lang.String classpath)
          Sets classpath for the project.
 void setProjectName(java.lang.String projectName)
          Sets the name of this project.
 void setTabSize(int tabSize)
          Sets the tab size for source files in this project.
 void update(boolean shallowModel, JobControl jobControl)
          Processes the source files and builds the AST model.
 void write()
          Saves the current AST model on a disk.
 

Method Detail

addSourceBase

public void addSourceBase(ISourceBase sourceBase)
Adds a source file location.

deepUpdate

public void deepUpdate(AstCompilationUnit file)
Builds the deep AST model for the types containing in the specified file.
Parameters:
file - specifies whether shallow AST model will be built.

enableAssert

public void enableAssert(boolean enabled)
Specifies whether the assertion statements introduced in JDK 1.4 will be recognized.
Parameters:
enabled - if true, then assert will be recognized as a keyword.

getClasspath

public java.lang.String getClasspath()
Returns class path string for the project. If getClasspath returns null, the default class path is used.

getFileSize

public long getFileSize(java.lang.String filename)
Returns the size (in bytes) of the file with the specified name. Returns -1 if the file does not exist, or I/O error has occurred.

getLog

public ILog getLog()
Returns the log object for this project. Messages produced for this project are sent to the project's log. These are messages produced by operations performed on the project (such as model build or saving to the local file system), and messages generated by code inspectors which analyze it.

getModel

public AstModel getModel()
Returns the AST model of this project. If update was not called for the project, getModel will return null.

getProjectName

public java.lang.String getProjectName()
Returns the name of this project.

getSourceBases

public ISourceBase[] getSourceBases()
Returns an array of source file locations.

getSourceFiles

public java.lang.String[] getSourceFiles()
Returns an array of files in the project.

getTabSize

public int getTabSize()
Returns the tab size for source files in this project.

getTimestamp

public long getTimestamp(java.lang.String filename)
Returns the timestamp for the specified file. Returns -1, if the file with the specified name does not exist.

isAssertEnabled

public boolean isAssertEnabled()
Indicates whether the assertion statements introduced in JDK 1.4 are recognized.

openFile

public java.io.Reader openFile(java.lang.String filename)
Returns the reader for the specified file. A file with the specified name is searched for in all source locations in this project.

Returns null, if the file with the specified name does not exist.

See Also:
ISourceBase

setClasspath

public void setClasspath(java.lang.String classpath)
Sets classpath for the project. A classpath is defined in the same manner as the Java CLASSPATH environment variable, for example .;d:/jdk1.3/jre/lib/rt.jar;d:/antlr/lib/antlrall.jar.

setProjectName

public void setProjectName(java.lang.String projectName)
Sets the name of this project.

setTabSize

public void setTabSize(int tabSize)
Sets the tab size for source files in this project.

update

public void update(boolean shallowModel,
                   JobControl jobControl)
Processes the source files and builds the AST model. The project is updated incrementally, i.e. only source files that have been changed since last update are processed.

Depending on the shallowModel parameter value, shallow or deep AST model will be built. Shallow AST model contains the top-level declarations only. The top-level declarations are top-level and nested types and their members. Deep AST model includes method, constructor, and class initializer bodies as well.

As opposed to shallow model, deep model provides full information about language constructs. However, it requires more memory and CPU time to build.

The main concern of selection between deep and shallow model is performance issues. Regardless of the value of the shallowModel parameter, the AST model users have full access to the entire model since deep model is built on demand in a transparent manner. However, building both shallow and deep models will introduce additional overhead. Thus, only code inspectors that do not analyze method bodies should request shallow model.

Parameters:
shallowModel - specifies whether shallow AST model will be built.

write

public void write()
Saves the current AST model on a disk.