|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jmlspecs.jmldoc.jmldoc_142.JmlHTML
This class contains functions to generate html, fitting in with javadoc comments, that documents jml annotations. The current implementation requires that a javadoc file already exist; the code here will insert additional html into the existing javadoc files. It is ok to run this operation of inserting additional html multiple times since the inserted material is marked and removed prior to inserting regenerated material.
An improved implementation will generate the html from scratch, by calling appropriate methods in the javadoc implementation, potentially as a doclet. Note that the current implementation requires that javadoc be runnable on the file; thus the files must be legal java, without mjc extensions.
Not currently implemented:
reading of spec/.jml files (and refines clauses and files)
implement weakly, jml_var_assertion, static_initializer, initializer
model programs
Other comments and bugs:
Better wrapping of long specs: mostly ok, but would like to have hanging indents
format specifications: can we get rid of blank lines near {| and |}?
Add comments, javadoc comments, specifications to this code
Better error reporting when a ; is missing from a jml spec.
Interleave parsing and jml generation
How to record http: links in the docpath and associate them with packages - use multiple -link options ?
Resolve all ??? comments in the code, and these comments here.
The <- does not appear very elegantly (also _ and \ )
Loosen up the syntactic requirements on PRE JML (as tags)
sort out the finding of target html files (package-lists etc.)
find a better way to find information from CClass objects rather than having
to find the JmlTypeDeclaration (and parse the relevant file)
CAUTION: There are static values that are not protected. If any thought is given
to multi-threading the generation of html, some work will need to be done here.
| Nested Class Summary | |
static class |
JmlHTML.IntPair
This class holds a pair of integers, used here to mark the start and (one past the) end of a section of a text string. |
static class |
JmlHTML.IntString
This class holds an integer and a String, corresponding to a position at which to insert text, and the text to be inserted at that position. |
| Field Summary | |
private static String |
adjustedDestination
This gives the absolute path of the destination for generated html files. |
private static String |
alternateSuffix
A second suffix for html files that should be tried. |
private String |
classSpecsTitle
|
protected File |
currentFile
|
protected String |
currentFilePath
|
private static String |
eol
The string that terminates lines on this platform. |
private static String |
jmlbegin
Used to begin any section of material added to an HTML file. |
private static String |
jmlcomment1
|
private static String |
jmlcomment2
|
private static String |
jmlend
Used to end any section of material added to an HTML file. |
private static String |
newsuffix
This string is used as a suffix for the new html file, temporarily; Once the file is complete it is moved on top of the old one. |
private static String |
oldsuffix
This string is used as a suffix for the backup files - the original html files before begin altered by adding jml annotations. |
private static JmldocOptions |
options
This is a cached value of the options object supplied here from Main. |
private boolean |
printedClassSpecsHeader
|
private static String |
suffix
The value of the suffix that javadoc uses on this platform for html files, with the leading period. |
private static boolean |
useDollar
This field is true if html files generated by javadoc use dollar signs to separate components in the names of HTML files for inner classes (this is not the same as using dollar signs in .class files). |
| Constructor Summary | |
JmlHTML(JmldocOptions opt)
|
|
| Method Summary | |
void |
addLink(CClass container,
JmlStoreRefExpression sre,
JmldocFieldSubWriter fsw,
SpecWriter sw)
|
protected boolean |
checkFile(String dp,
boolean useD,
String cp,
String suf)
This function checks whether a html file exists with a name constructed from the given class name (cp), and the given settings of the destination directory (dp), useDollar (useD) and suffix to use (suf). |
(package private) static boolean |
checkModifiers(long mods)
This function compares the argument to the privacy level set in the command-line options ; it returns true if the argument is enabled to be printed per the option. |
protected void |
classSpecs(JmlTypeDeclaration jmltype,
StringBuffer sb,
boolean inherited,
String title)
This method generates the html describing the specifications of class/interface jmltype. |
protected boolean |
findFile(String cpath,
String packageRoot)
This function finds an html file for the given class name (cpath) and directory containing the package root (packageRoot). |
(package private) static JmlMethodDeclaration |
findMatchingMethod(JmlTypeDeclaration jt,
JmlMethodDeclaration jm)
Looks for method jm in class/interface jt; returns null if not found, otherwise returns the corresponding JmlMethodDeclaration. |
void |
findSections(String fileString,
String begin,
String end,
ArrayList extracts)
This function finds all occurrences of text in 'fileString' bracketed by the given begin and end Strings. |
void |
findSections(String fileString,
String begin,
ArrayList extracts)
This function finds all occurrences of the string begin in 'fileString' . |
protected String |
generateClassSpecification(JmlTypeDeclaration jmltype,
com.sun.tools.doclets.standard.HtmlStandardWriter writer)
This generates the full html insert for the class level specifications, including those for any super classes and including the leading jmlbegin and jmlend strings. |
String |
generateFieldSpecification(JFieldDeclarationType jm,
JmldocFieldSubWriter fsw)
|
String |
generateMethodSpecification(JmlMethodDeclaration jm,
CClass cclass,
String sig,
com.sun.tools.doclets.standard.HtmlStandardWriter writer)
|
(package private) static List |
getAllInterfaces(CClass cc)
The result is a List of CClassType objects containing all the interfaces, with no duplicates. |
private static void |
getAllInterfaces(CClassType[] ints,
List interfaces)
This function adds to 'interfaces' any interfaces implemented by the classes or interfaces in 'ints'. |
protected void |
insertFieldSpecs(JmlTypeDeclaration jmltype,
String fileString,
ArrayList insertions)
This method generates the html text for the specifications of the fields for type jmlType, with reference to the original file content in fileString. |
protected void |
insertMethodSpecs(JmlMethodDeclaration jm,
String fileString,
ArrayList insertions,
String sig,
JmlTypeDeclaration jmltype)
This method generates the specification text for the method jm with signature string sig belonging to class jmltype, and with reference to the original html file in fileString. |
protected void |
insertMethodSpecs(JmlTypeDeclaration jmltype,
String fileString,
ArrayList insertions)
This method generates the html text for the specifications of the methods for type jmlType, with reference to the original file content in fileString. |
protected void |
insertSpecification(StringBuffer s,
JmlMethodSpecification jms)
This method actually generates a string representing the given JmlMethodSpecification and appends it to the given StringBuffer. |
void |
jmlize(CompilerPassEnterable tree)
This is the entry point into these routines for adding html material representing the jml annotations to an html file. |
(package private) void |
jmlize(JTypeDeclarationType jtype,
String packageRoot)
This method generates the html file for the class represented by 'jtype'. |
protected void |
jmlizeFile(File f,
JTypeDeclarationType jtype)
This method inserts into the given File all the jml annotations corresponding to the given JTypeDeclarationType. |
String |
linkString(CClass cclass,
boolean fullname,
com.sun.tools.doclets.standard.HtmlStandardWriter writer)
This function generates a String giving the name of the class corresponding to 'cclass'; if an html file can be located for this class, then the string consists of an HTML link reference to that class. |
(package private) static String |
makeSig(JmlMethodDeclaration m,
JmlTypeDeclaration jmltype)
This function returns a String giving the signature of a method - the method name and fully qualified argument types, but not formal parameter names. |
void |
printClassSpecsFooter(StringBuffer classspec)
|
void |
printClassSpecsHeader(StringBuffer classspec,
boolean inherited,
String title)
|
void |
printClassSpecsHeaderInherited(StringBuffer classspec,
String title)
|
void |
printClassSpecsHeaderMain(StringBuffer classspec)
|
void |
printClassSpecsHeaderShort(StringBuffer classspec)
|
protected boolean |
superSpecification(StringBuffer s,
CClass sclass,
JmlMethodDeclaration jm,
String sig,
boolean isclass,
com.sun.tools.doclets.standard.HtmlStandardWriter writer)
Generates the html for any specifications for the method 'jm' in the super class 'sclass'. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static final String eol
private static final String jmlbegin
private static final String jmlend
private static final String jmlcomment1
private static final String jmlcomment2
private static final String oldsuffix
private static final String newsuffix
private static JmldocOptions options
private static String adjustedDestination
private static boolean useDollar
private static String suffix
private static String alternateSuffix
protected File currentFile
protected String currentFilePath
private final String classSpecsTitle
private boolean printedClassSpecsHeader
| Constructor Detail |
public JmlHTML(JmldocOptions opt)
| Method Detail |
public void jmlize(CompilerPassEnterable tree)
throws Exception
Exception
void jmlize(JTypeDeclarationType jtype,
String packageRoot)
throws Exception
Exceptionstatic boolean checkModifiers(long mods)
protected boolean checkFile(String dp,
boolean useD,
String cp,
String suf)
protected boolean findFile(String cpath,
String packageRoot)
public void findSections(String fileString,
String begin,
String end,
ArrayList extracts)
throws Exception
Exception
public void findSections(String fileString,
String begin,
ArrayList extracts)
throws Exception
Exception
protected void classSpecs(JmlTypeDeclaration jmltype,
StringBuffer sb,
boolean inherited,
String title)
public void printClassSpecsHeader(StringBuffer classspec,
boolean inherited,
String title)
public void printClassSpecsHeaderMain(StringBuffer classspec)
public void printClassSpecsHeaderShort(StringBuffer classspec)
public void printClassSpecsHeaderInherited(StringBuffer classspec,
String title)
public void printClassSpecsFooter(StringBuffer classspec)
protected void jmlizeFile(File f,
JTypeDeclarationType jtype)
throws Exception
Exception
protected String generateClassSpecification(JmlTypeDeclaration jmltype,
com.sun.tools.doclets.standard.HtmlStandardWriter writer)
static List getAllInterfaces(CClass cc)
private static void getAllInterfaces(CClassType[] ints,
List interfaces)
static String makeSig(JmlMethodDeclaration m,
JmlTypeDeclaration jmltype)
static JmlMethodDeclaration findMatchingMethod(JmlTypeDeclaration jt,
JmlMethodDeclaration jm)
protected void insertMethodSpecs(JmlTypeDeclaration jmltype,
String fileString,
ArrayList insertions)
throws Exception
Exception
protected void insertFieldSpecs(JmlTypeDeclaration jmltype,
String fileString,
ArrayList insertions)
throws Exception
Exception
public String generateFieldSpecification(JFieldDeclarationType jm,
JmldocFieldSubWriter fsw)
public void addLink(CClass container,
JmlStoreRefExpression sre,
JmldocFieldSubWriter fsw,
SpecWriter sw)
protected void insertMethodSpecs(JmlMethodDeclaration jm,
String fileString,
ArrayList insertions,
String sig,
JmlTypeDeclaration jmltype)
throws Exception
Exception
public String generateMethodSpecification(JmlMethodDeclaration jm,
CClass cclass,
String sig,
com.sun.tools.doclets.standard.HtmlStandardWriter writer)
protected boolean superSpecification(StringBuffer s,
CClass sclass,
JmlMethodDeclaration jm,
String sig,
boolean isclass,
com.sun.tools.doclets.standard.HtmlStandardWriter writer)
protected void insertSpecification(StringBuffer s,
JmlMethodSpecification jms)
public String linkString(CClass cclass,
boolean fullname,
com.sun.tools.doclets.standard.HtmlStandardWriter writer)
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||