Remove helma.doc package and DocApplication functionality.
This commit is contained in:
parent
2ea2823a35
commit
6d3f6c3165
15 changed files with 0 additions and 1754 deletions
|
@ -1,147 +0,0 @@
|
|||
/*
|
||||
* Helma License Notice
|
||||
*
|
||||
* The contents of this file are subject to the Helma License
|
||||
* Version 2.0 (the "License"). You may not use this file except in
|
||||
* compliance with the License. A copy of the License is available at
|
||||
* http://adele.helma.org/download/helma/license.txt
|
||||
*
|
||||
* Copyright 1998-2003 Helma Software. All Rights Reserved.
|
||||
*
|
||||
* $RCSfile$
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
package helma.doc;
|
||||
|
||||
import helma.framework.core.Application;
|
||||
import helma.framework.core.Prototype;
|
||||
import helma.main.Server;
|
||||
import helma.util.ResourceProperties;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DocApplication extends DocElement {
|
||||
|
||||
Application app;
|
||||
HashSet excluded;
|
||||
|
||||
/**
|
||||
* Creates a new DocApplication object.
|
||||
*
|
||||
*/
|
||||
public DocApplication(Application app) {
|
||||
super(app.getName(), APPLICATION);
|
||||
this.app = app;
|
||||
readProps();
|
||||
}
|
||||
|
||||
/**
|
||||
* reads the app.properties file and parses for helma.excludeDocs
|
||||
*/
|
||||
private void readProps() {
|
||||
ResourceProperties appProps = app.getProperties();
|
||||
|
||||
excluded = new HashSet();
|
||||
addExclude("cvs");
|
||||
addExclude(".docs");
|
||||
|
||||
String excludeProps = appProps.getProperty("helma.excludeDocs");
|
||||
|
||||
if (excludeProps != null) {
|
||||
StringTokenizer tok = new StringTokenizer(excludeProps, ",");
|
||||
|
||||
while (tok.hasMoreTokens()) {
|
||||
String str = tok.nextToken().trim();
|
||||
|
||||
addExclude(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param str ...
|
||||
*/
|
||||
public void addExclude(String str) {
|
||||
excluded.add(str.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param name ...
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
public boolean isExcluded(String name) {
|
||||
return (excluded.contains(name.toLowerCase()));
|
||||
}
|
||||
|
||||
/**
|
||||
* reads all prototypes and files of the application
|
||||
*/
|
||||
public void readApplication() throws IOException {
|
||||
readProps();
|
||||
children.clear();
|
||||
|
||||
Iterator it = app.getPrototypes().iterator();
|
||||
// Iterator it = app.getRepositories().iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
|
||||
Prototype proto = (Prototype) it.next();
|
||||
proto.checkForUpdates();
|
||||
DocPrototype pt = new DocPrototype(proto, this);
|
||||
addChild(pt);
|
||||
pt.readFiles();
|
||||
|
||||
for (Iterator i = children.values().iterator(); i.hasNext();) {
|
||||
((DocPrototype) i.next()).checkInheritance();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
public DocElement[] listFunctions() {
|
||||
Vector allFunctions = new Vector();
|
||||
|
||||
for (Iterator i = children.values().iterator(); i.hasNext();) {
|
||||
DocElement proto = (DocElement) i.next();
|
||||
|
||||
allFunctions.addAll(proto.children.values());
|
||||
}
|
||||
|
||||
Collections.sort(allFunctions, new DocComparator(DocComparator.BY_NAME, this));
|
||||
|
||||
return (DocElement[]) allFunctions.toArray(new DocElement[allFunctions.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* from helma.framework.IPathElement, overridden with "api"
|
||||
* to work in manage-application
|
||||
*/
|
||||
public String getElementName() {
|
||||
return "api";
|
||||
}
|
||||
|
||||
/**
|
||||
* from helma.framework.IPathElement, overridden with
|
||||
* Server.getServer() to work in manage-application
|
||||
*/
|
||||
public Object getParentElement() {
|
||||
Server s = helma.main.Server.getServer();
|
||||
|
||||
return s.getApplication(this.name);
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
* Helma License Notice
|
||||
*
|
||||
* The contents of this file are subject to the Helma License
|
||||
* Version 2.0 (the "License"). You may not use this file except in
|
||||
* compliance with the License. A copy of the License is available at
|
||||
* http://adele.helma.org/download/helma/license.txt
|
||||
*
|
||||
* Copyright 1998-2003 Helma Software. All Rights Reserved.
|
||||
*
|
||||
* $RCSfile$
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
package helma.doc;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DocComparator implements Comparator {
|
||||
public static final int BY_TYPE = 0;
|
||||
public static final int BY_NAME = 1;
|
||||
int mode;
|
||||
DocElement docEl;
|
||||
|
||||
/**
|
||||
* Creates a new DocComparator object.
|
||||
*
|
||||
* @param mode ...
|
||||
* @param docEl ...
|
||||
*/
|
||||
public DocComparator(int mode, DocElement docEl) {
|
||||
this.mode = mode;
|
||||
this.docEl = docEl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new DocComparator object.
|
||||
*
|
||||
* @param docEl ...
|
||||
*/
|
||||
public DocComparator(DocElement docEl) {
|
||||
this.mode = 0;
|
||||
this.docEl = docEl;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param obj1 ...
|
||||
* @param obj2 ...
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
public int compare(Object obj1, Object obj2) {
|
||||
DocElement e1 = (DocElement) obj1;
|
||||
DocElement e2 = (DocElement) obj2;
|
||||
|
||||
if ((mode == BY_TYPE) && (e1.getType() > e2.getType())) {
|
||||
return 1;
|
||||
} else if ((mode == BY_TYPE) && (e1.getType() < e2.getType())) {
|
||||
return -1;
|
||||
} else {
|
||||
return e1.name.compareTo(e2.name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param obj ...
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
DocElement el = (DocElement) obj;
|
||||
|
||||
if (el.name.equals(docEl.name) && (el.getType() == docEl.getType())) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,361 +0,0 @@
|
|||
/*
|
||||
* Helma License Notice
|
||||
*
|
||||
* The contents of this file are subject to the Helma License
|
||||
* Version 2.0 (the "License"). You may not use this file except in
|
||||
* compliance with the License. A copy of the License is available at
|
||||
* http://adele.helma.org/download/helma/license.txt
|
||||
*
|
||||
* Copyright 1998-2003 Helma Software. All Rights Reserved.
|
||||
*
|
||||
* $RCSfile$
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
package helma.doc;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public abstract class DocElement {
|
||||
public static final int APPLICATION = 0;
|
||||
public static final int PROTOTYPE = 1;
|
||||
public static final int ACTION = 2;
|
||||
public static final int TEMPLATE = 3;
|
||||
public static final int FUNCTION = 4;
|
||||
public static final int MACRO = 5;
|
||||
public static final int SKIN = 6;
|
||||
public static final int PROPERTIES = 7;
|
||||
|
||||
// above constants are used as array indices
|
||||
public static final String[] typeNames = {
|
||||
"Application", "Prototype", "Action",
|
||||
"Template", "Function", "Macro", "Skin",
|
||||
"Properties"
|
||||
};
|
||||
|
||||
// identifiers of this element
|
||||
String name;
|
||||
int type;
|
||||
DocElement parent = null;
|
||||
Map children = new HashMap();
|
||||
|
||||
// content
|
||||
String content = "";
|
||||
String comment = "";
|
||||
List tags = new Vector();
|
||||
List parameters = new Vector();
|
||||
|
||||
protected DocElement(String name, int type) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* the simple name of the element
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
public String getTypeName() {
|
||||
return typeNames[type];
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the comment string, empty string if no comment is set.
|
||||
*/
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* the actual content of the doc element (the function body, the properties
|
||||
* list, the file list etc.
|
||||
*/
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param rawContent ...
|
||||
*/
|
||||
public void addTag(String rawContent) {
|
||||
if (tags == null) {
|
||||
tags = new Vector();
|
||||
}
|
||||
|
||||
try {
|
||||
DocTag tag = DocTag.parse(rawContent);
|
||||
|
||||
tags.add(tag);
|
||||
} catch (DocException doc) {
|
||||
debug(doc.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* list all tags
|
||||
*/
|
||||
public DocTag[] listTags() {
|
||||
return (DocTag[]) tags.toArray(new DocTag[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* filter the tags according to their type
|
||||
*/
|
||||
public DocTag[] listTags(String type) {
|
||||
Vector retval = new Vector();
|
||||
|
||||
for (int i = 0; i < tags.size(); i++) {
|
||||
if (((DocTag) tags.get(i)).getType().equals(type)) {
|
||||
retval.add(tags.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
return (DocTag[]) retval.toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param param ...
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
public boolean hasParameter(String param) {
|
||||
return parameters.contains(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* the list of parameters
|
||||
*/
|
||||
public String[] listParameters() {
|
||||
return (String[]) parameters.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* add a string to the parameters-list
|
||||
*/
|
||||
protected void addParameter(String param) {
|
||||
parameters.add(param);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* parse rawComment, render DocTags
|
||||
*/
|
||||
void parseComment(String rawComment) {
|
||||
try {
|
||||
rawComment = rawComment.trim();
|
||||
StringTokenizer tok = new StringTokenizer(rawComment, "\n", true);
|
||||
int BLANK = 0;
|
||||
int TEXT = 1;
|
||||
int TAGS = 2;
|
||||
boolean lastEmpty = false;
|
||||
int mode = BLANK;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
while (tok.hasMoreTokens()) {
|
||||
String line = Util.chopDelimiters(tok.nextToken().trim());
|
||||
|
||||
if ("".equals(line)) {
|
||||
// if we've already had text, store that this line was empty
|
||||
lastEmpty = (mode != BLANK);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// if we come here the first time, start with TEXT mode
|
||||
mode = (mode == BLANK) ? TEXT : mode;
|
||||
|
||||
// check if we have a new tag
|
||||
if (DocTag.isTagStart(line)) {
|
||||
// if we appended to comment text until now, store that ...
|
||||
if (mode == TEXT) {
|
||||
comment = buf.toString();
|
||||
}
|
||||
|
||||
// if we appended to a tag, store that ...
|
||||
if (mode == TAGS) {
|
||||
addTag(buf.toString());
|
||||
}
|
||||
|
||||
// reset buffer
|
||||
buf = new StringBuffer();
|
||||
mode = TAGS;
|
||||
}
|
||||
|
||||
// append to current buffer
|
||||
if (lastEmpty) {
|
||||
buf.append("\n");
|
||||
}
|
||||
|
||||
buf.append(line);
|
||||
buf.append(" ");
|
||||
lastEmpty = false;
|
||||
}
|
||||
|
||||
// store the last element, if there was at least one element ...
|
||||
if (mode == TEXT) {
|
||||
comment = buf.toString().trim();
|
||||
} else if (mode == TAGS) {
|
||||
addTag(buf.toString());
|
||||
}
|
||||
} catch (RuntimeException rt) {
|
||||
debug("parse error in " + name + ": " + rt.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param parent ...
|
||||
*/
|
||||
public void setParent(DocElement parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param child ...
|
||||
*/
|
||||
public void addChild(DocElement child) {
|
||||
if (child == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
children.put(child.getElementName(), child);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
public int countChildren() {
|
||||
return children.size();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
public Map getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an array of doc elements, sorted by their name
|
||||
*/
|
||||
public DocElement[] listChildren() {
|
||||
String[] keys = (String[]) children.keySet().toArray(new String[0]);
|
||||
|
||||
Arrays.sort(keys);
|
||||
|
||||
DocElement[] arr = new DocElement[keys.length];
|
||||
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
arr[i] = (DocElement) children.get(keys[i]);
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* walks up the tree and tries to find a DocApplication object
|
||||
*/
|
||||
public DocApplication getDocApplication() {
|
||||
DocElement el = this;
|
||||
|
||||
while (el != null) {
|
||||
if (el instanceof DocApplication) {
|
||||
return (DocApplication) el;
|
||||
}
|
||||
|
||||
el = (DocElement) el.getParentElement();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* from helma.framework.IPathElement. Elements are named
|
||||
* like this: typename_name
|
||||
*/
|
||||
public String getElementName() {
|
||||
return typeNames[type].toLowerCase() + "_" + name;
|
||||
}
|
||||
|
||||
/**
|
||||
* from helma.framework.IPathElement. Retrieves a child from the
|
||||
* children map.
|
||||
*/
|
||||
public DocElement getChildElement(String name) {
|
||||
try {
|
||||
return (DocElement) children.get(name);
|
||||
} catch (ClassCastException cce) {
|
||||
debug(cce.toString());
|
||||
cce.printStackTrace();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* from helma.framework.IPathElement. Returns the parent object
|
||||
* of this instance if assigned.
|
||||
*/
|
||||
public Object getParentElement() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* from helma.framework.IPathElement. Prototypes are assigned like
|
||||
* this: "doc" + typename (e.g. docapplication, docprototype etc)
|
||||
*/
|
||||
public java.lang.String getPrototype() {
|
||||
return "doc" + typeNames[type].toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
public String toString() {
|
||||
return "[" + typeNames[type] + " " + name + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param msg ...
|
||||
*/
|
||||
public static void debug(String msg) {
|
||||
System.out.println(msg);
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Helma License Notice
|
||||
*
|
||||
* The contents of this file are subject to the Helma License
|
||||
* Version 2.0 (the "License"). You may not use this file except in
|
||||
* compliance with the License. A copy of the License is available at
|
||||
* http://adele.helma.org/download/helma/license.txt
|
||||
*
|
||||
* Copyright 1998-2003 Helma Software. All Rights Reserved.
|
||||
*
|
||||
* $RCSfile$
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
package helma.doc;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DocException extends Exception {
|
||||
|
||||
/**
|
||||
* Creates a new DocException object.
|
||||
*
|
||||
* @param msg ...
|
||||
*/
|
||||
public DocException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new DocException object.
|
||||
*
|
||||
* @param msg the exception message
|
||||
* @param t the cause
|
||||
*/
|
||||
public DocException(String msg, Throwable t) {
|
||||
super(msg, t);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,300 +0,0 @@
|
|||
/*
|
||||
* Helma License Notice
|
||||
*
|
||||
* The contents of this file are subject to the Helma License
|
||||
* Version 2.0 (the "License"). You may not use this file except in
|
||||
* compliance with the License. A copy of the License is available at
|
||||
* http://adele.helma.org/download/helma/license.txt
|
||||
*
|
||||
* Copyright 1998-2003 Helma Software. All Rights Reserved.
|
||||
*
|
||||
* $RCSfile$
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
package helma.doc;
|
||||
|
||||
import helma.framework.repository.Resource;
|
||||
import helma.util.StringUtils;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.mozilla.javascript.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DocFunction extends DocResourceElement {
|
||||
|
||||
private int startLine;
|
||||
|
||||
protected DocFunction(String name, Resource res, DocElement parent, int type, int lineno) {
|
||||
super(name, res, type);
|
||||
this.parent = parent;
|
||||
this.startLine = lineno;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new independent DocFunction object of type ACTION
|
||||
*/
|
||||
public static DocFunction newAction(Resource res) throws IOException {
|
||||
return newAction(res, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new DocFunction object of type ACTION connected to another DocElement
|
||||
*/
|
||||
public static DocFunction newAction(Resource res, DocElement parent) throws IOException {
|
||||
String name = res.getBaseName();
|
||||
String[] lines = StringUtils.splitLines(res.getContent());
|
||||
DocFunction func = new DocFunction(name, res, parent, ACTION, 1);
|
||||
String rawComment = "";
|
||||
Token[] tokens = parseTokens(res);
|
||||
rawComment = Util.extractString(lines, getPoint(tokens[0]), getPoint(tokens[1]));
|
||||
rawComment = Util.chopComment (rawComment);
|
||||
func.parseComment(rawComment);
|
||||
func.content = res.getContent();
|
||||
return func;
|
||||
}
|
||||
|
||||
/**
|
||||
* reads a function file and creates independent DocFunction objects of type FUNCTION
|
||||
*/
|
||||
public static DocFunction[] newFunctions(Resource res) throws IOException {
|
||||
return newFunctions(res, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* reads a function file and creates DocFunction objects of type FUNCTION
|
||||
* connected to another DocElement.
|
||||
*/
|
||||
public static DocFunction[] newFunctions(Resource res, DocElement parent)
|
||||
throws IOException {
|
||||
String[] lines = StringUtils.splitLines(res.getContent());
|
||||
Token[] tokens = parseTokens(res);
|
||||
List list = new ArrayList();
|
||||
scanFunctions(lines, tokens, list, res, parent, 0, tokens.length);
|
||||
return (DocFunction[]) list.toArray(new DocFunction[0]);
|
||||
}
|
||||
|
||||
private static void scanFunctions(String[] lines, Token[] tokens, List list,
|
||||
Resource res, DocElement parent, int start, int end) {
|
||||
// Token token = null;
|
||||
Token lastToken = new Token(Token.EMPTY, "", 0, 0);
|
||||
// Point marker;
|
||||
|
||||
String lastNameString = null;
|
||||
String functionName = null;
|
||||
String context = null;
|
||||
String comment = "";
|
||||
|
||||
for (int i = start; i < end - 1; i++) {
|
||||
|
||||
// store the position of the last token
|
||||
Point marker = getPoint(lastToken);
|
||||
// now get a new token
|
||||
Token token = tokens[i];
|
||||
// flag for dropping private functions
|
||||
boolean dropFunction = false;
|
||||
|
||||
if (token.type == Token.EOL) {
|
||||
|
||||
String c = Util.extractString(lines, marker, getPoint(token));
|
||||
if (c.startsWith("/**"))
|
||||
comment = c;
|
||||
|
||||
} else if (token.type == Token.LC) {
|
||||
|
||||
// when we come across a left brace outside of a function,
|
||||
// we store the current string of the stream, it might be
|
||||
// a function object declaration
|
||||
// e.g. HttpClient = { func1:function()...}
|
||||
context = token.string;
|
||||
|
||||
} else if (token.type == Token.RC && context != null) {
|
||||
|
||||
// when we come across a right brace outside of a function,
|
||||
// we reset the current context cache
|
||||
context = null;
|
||||
|
||||
} else if (token.type == Token.THIS) {
|
||||
|
||||
if (parent instanceof DocFunction)
|
||||
lastNameString = parent.getName() + ".prototype";
|
||||
// this may be the start of a name chain declaring a function
|
||||
// e.g. Number.prototype.functionName = function() { }
|
||||
// marker = getPoint(token);
|
||||
// marker.x -= (5);
|
||||
|
||||
} else if (token.type == Token.NAME) {
|
||||
|
||||
// store all names, the last one before a function
|
||||
// declaration may be used as its name
|
||||
|
||||
if (lastToken.type != Token.DOT) {
|
||||
|
||||
lastNameString = token.string;
|
||||
|
||||
// this may be the start of a name chain declaring a function
|
||||
// e.g. Number.prototype.functionName = function() { }
|
||||
marker = getPoint(token);
|
||||
marker.x -= (token.string.length() + 1);
|
||||
|
||||
} else {
|
||||
|
||||
// token in front of the name was a dot, so we connect the
|
||||
// names that way
|
||||
lastNameString += "." + token.string;
|
||||
|
||||
}
|
||||
|
||||
} else if (token.type == Token.FUNCTION) {
|
||||
|
||||
// store the end of the function word
|
||||
Point p = getPoint(token);
|
||||
|
||||
// look at the next token:
|
||||
Token peekToken = tokens[i + 1];
|
||||
|
||||
// depending of the style of the declaration we already have all we need
|
||||
// or need to fetch the name from the next token:
|
||||
if (peekToken.type == Token.NAME) {
|
||||
|
||||
// if the token after FUNCTION is NAME, it's the usual function
|
||||
// declaration like this: function abc() {}
|
||||
|
||||
// set the pointer for the start of the actual function body
|
||||
// to the letter f of the function word
|
||||
marker = p;
|
||||
marker.x -= 9;
|
||||
|
||||
// set stream to next token, so that name of the
|
||||
// function is the stream's current string
|
||||
token = tokens[++i];
|
||||
functionName = token.string;
|
||||
} else {
|
||||
|
||||
// it's a different kind of function declaration.
|
||||
// the function name is the last found NAME-token
|
||||
// if context is set, prepend it to the function name
|
||||
functionName = (context != null) ? context + "." + lastNameString : lastNameString;
|
||||
|
||||
}
|
||||
|
||||
DocFunction theFunction = null;
|
||||
if (!dropFunction) {
|
||||
// create the function object
|
||||
DocElement par = parent instanceof DocFunction ? parent.parent : parent;
|
||||
theFunction = newFunction (functionName, res, par, token.lineno + 1);
|
||||
theFunction.parseComment (comment);
|
||||
list.add (theFunction);
|
||||
}
|
||||
// reset comment
|
||||
comment = "";
|
||||
|
||||
// subloop on the tokenstream: find the parameters of a function
|
||||
while (i < end && token.type != Token.RP) {
|
||||
token = tokens[++i];
|
||||
if (token.type == Token.NAME && theFunction.type == FUNCTION) {
|
||||
// add names of parameter only for functions, not for macros or actions
|
||||
theFunction.addParameter (token.string);
|
||||
}
|
||||
}
|
||||
|
||||
// subloop on the tokenstream: find the closing right bracket of the function
|
||||
token = tokens[++i];
|
||||
int j = i + 1;
|
||||
int level = (token.type == Token.LC) ? 1 : 0;
|
||||
while (i < end && level > 0) {
|
||||
// regular expression syntax is troublesome for the TokenStream
|
||||
// we don't need them here, so we just ignore such an error
|
||||
try {
|
||||
token = tokens[++i];
|
||||
} catch(Exception anything) {
|
||||
continue;
|
||||
}
|
||||
if (token.type == Token.LC) {
|
||||
level++;
|
||||
} else if (token.type == Token.RC) {
|
||||
level--;
|
||||
}
|
||||
}
|
||||
|
||||
if (dropFunction)
|
||||
continue;
|
||||
|
||||
// parse function body for nested functions
|
||||
scanFunctions(lines, tokens, list, res, theFunction, j, i);
|
||||
// set the function body, starting at the beginning of the first line
|
||||
marker.x = 0;
|
||||
theFunction.content = Util.extractString(lines, marker, getPoint(token));
|
||||
|
||||
} // end if
|
||||
|
||||
lastToken = token;
|
||||
|
||||
} // end while
|
||||
|
||||
}
|
||||
|
||||
private static DocFunction newFunction (String funcName, Resource res, DocElement parent, int lineno) {
|
||||
if (funcName.endsWith("_action")) {
|
||||
return new DocFunction(funcName, res, parent, ACTION, lineno);
|
||||
} else if (funcName.endsWith("_macro")) {
|
||||
return new DocFunction(funcName, res, parent, MACRO, lineno);
|
||||
} else {
|
||||
return new DocFunction(funcName, res, parent, FUNCTION, lineno);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a rhino token stream for a given file.
|
||||
* @param res the JS Resource
|
||||
* @return a TokenStream wrapper
|
||||
* @throws java.io.IOException if an I/O exception was raised
|
||||
*/
|
||||
protected static Token[] parseTokens(Resource res) throws IOException {
|
||||
Reader reader = new InputStreamReader(res.getInputStream());
|
||||
CompilerEnvirons compilerEnv = new CompilerEnvirons();
|
||||
compilerEnv.initFromContext(Context.getCurrentContext());
|
||||
compilerEnv.setGenerateDebugInfo(true);
|
||||
compilerEnv.setGeneratingSource(true);
|
||||
compilerEnv.setOptimizationLevel(-1);
|
||||
ErrorReporter errorReporter = Context.getCurrentContext().getErrorReporter();
|
||||
Parser parser = new Parser(compilerEnv, errorReporter);
|
||||
return parser.parseTokens(reader, res.getName(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pointer to the current position in the TokenStream
|
||||
* @param token the TokenStream
|
||||
* @return the current position
|
||||
*/
|
||||
protected static Point getPoint (Token token) {
|
||||
return new Point (token.offset, token.lineno);
|
||||
}
|
||||
|
||||
/**
|
||||
* from helma.framework.IPathElement. All macros, templates, actions etc
|
||||
* have the same prototype.
|
||||
*/
|
||||
public java.lang.String getPrototype() {
|
||||
return "docfunction";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first line of this function within the containing resource.
|
||||
* @return the first line of the function
|
||||
*/
|
||||
public int getStartLine() {
|
||||
return startLine;
|
||||
}
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
* Helma License Notice
|
||||
*
|
||||
* The contents of this file are subject to the Helma License
|
||||
* Version 2.0 (the "License"). You may not use this file except in
|
||||
* compliance with the License. A copy of the License is available at
|
||||
* http://adele.helma.org/download/helma/license.txt
|
||||
*
|
||||
* Copyright 1998-2003 Helma Software. All Rights Reserved.
|
||||
*
|
||||
* $RCSfile$
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
package helma.doc;
|
||||
|
||||
import helma.util.ResourceProperties;
|
||||
import helma.framework.repository.Resource;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Documentation around a properties file
|
||||
*/
|
||||
public class DocProperties extends DocResourceElement {
|
||||
|
||||
ResourceProperties props;
|
||||
String elementName;
|
||||
|
||||
protected DocProperties(Resource res, ResourceProperties props,
|
||||
int index, DocElement parent)
|
||||
throws IOException {
|
||||
super(res.getShortName(), res, PROPERTIES);
|
||||
|
||||
this.parent = parent;
|
||||
this.props = props;
|
||||
this.comment = resource.getName();
|
||||
this.content = resource.getContent();
|
||||
this.elementName = name + "_" + index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying properties
|
||||
*
|
||||
* @return the properties
|
||||
*/
|
||||
public ResourceProperties getProperties() {
|
||||
return props;
|
||||
}
|
||||
|
||||
public String getElementName() {
|
||||
return elementName;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the comment string, empty string if no comment is set.
|
||||
*/
|
||||
public String getComment() {
|
||||
return resource.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
public Properties getMappings() {
|
||||
Properties childProps = new Properties();
|
||||
|
||||
for (Enumeration e = props.keys(); e.hasMoreElements();) {
|
||||
String key = (String) e.nextElement();
|
||||
String value = props.getProperty(key);
|
||||
|
||||
if (value.startsWith("collection") || value.startsWith("object") ||
|
||||
value.startsWith("mountpoint")) {
|
||||
String prototype = value.substring(value.indexOf("(") + 1,
|
||||
value.indexOf(")")).trim();
|
||||
|
||||
childProps.setProperty(key, prototype);
|
||||
}
|
||||
}
|
||||
|
||||
return childProps;
|
||||
}
|
||||
|
||||
/**
|
||||
* from helma.framework.IPathElement. Use the same prototype as functions etc.
|
||||
*/
|
||||
public java.lang.String getPrototype() {
|
||||
return "docfunction";
|
||||
}
|
||||
}
|
|
@ -1,136 +0,0 @@
|
|||
/*
|
||||
* Helma License Notice
|
||||
*
|
||||
* The contents of this file are subject to the Helma License
|
||||
* Version 2.0 (the "License"). You may not use this file except in
|
||||
* compliance with the License. A copy of the License is available at
|
||||
* http://adele.helma.org/download/helma/license.txt
|
||||
*
|
||||
* Copyright 1998-2003 Helma Software. All Rights Reserved.
|
||||
*
|
||||
* $RCSfile$
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
package helma.doc;
|
||||
|
||||
import helma.framework.repository.Resource;
|
||||
import helma.framework.core.Prototype;
|
||||
import helma.util.ResourceProperties;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DocPrototype extends DocElement {
|
||||
|
||||
DocPrototype parentPrototype = null;
|
||||
Prototype proto;
|
||||
|
||||
/**
|
||||
* creates a prototype based on a prototype of the application
|
||||
*
|
||||
* @param proto
|
||||
* @param parent
|
||||
*/
|
||||
protected DocPrototype(Prototype proto, DocElement parent) {
|
||||
super(proto.getName(), PROTOTYPE);
|
||||
this.parent = parent;
|
||||
this.proto = proto;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks the type.properites for _extend values and connected a possible
|
||||
* parent prototype with this prototype. this can't be successfull at construction
|
||||
* time but only -after- all prototypes are parsed and attached to a parent
|
||||
* DocApplication object.
|
||||
*/
|
||||
public void checkInheritance() {
|
||||
// hopobject is the top prototype:
|
||||
if (name.equals("hopobject")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// check for "_extends" in the the type.properties
|
||||
String ext = proto.getTypeProperties().getProperty("_extends");
|
||||
|
||||
if ((ext != null) && (parent != null)) {
|
||||
// try to get the prototype if available
|
||||
parentPrototype = (DocPrototype) parent.getChildElement("prototype_" + ext);
|
||||
}
|
||||
|
||||
if ((parentPrototype == null) && (parent != null) && !name.equals("global")) {
|
||||
// if no _extend was set, get the hopobject prototype
|
||||
parentPrototype = (DocPrototype) parent.getChildElement("prototype_hopobject");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return this prototype's parent prototype
|
||||
*
|
||||
* @return this prototype's parent prototype
|
||||
*/
|
||||
public DocPrototype getParentPrototype() {
|
||||
return parentPrototype;
|
||||
}
|
||||
|
||||
/**
|
||||
* runs through the prototype directory and parses all helma files
|
||||
*/
|
||||
public void readFiles() throws IOException {
|
||||
children.clear();
|
||||
|
||||
Iterator it = proto.getCodeResources();
|
||||
|
||||
while (it.hasNext()) {
|
||||
Resource res = (Resource) it.next();
|
||||
|
||||
String name = res.getShortName();
|
||||
if (getDocApplication().isExcluded(name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
if (name.endsWith(".hac")) {
|
||||
addChild(DocFunction.newAction(res, this));
|
||||
} else if (name.endsWith(".js")) {
|
||||
DocElement[] elements = DocFunction.newFunctions(res, this);
|
||||
|
||||
for (int j = 0; j < elements.length; j++) {
|
||||
addChild(elements[j]);
|
||||
}
|
||||
}
|
||||
} catch (Throwable err) {
|
||||
proto.getApplication().logError("Couldn't parse file " + res, err);
|
||||
}
|
||||
}
|
||||
|
||||
it = proto.getSkinResources();
|
||||
|
||||
while (it.hasNext()) {
|
||||
Resource res = (Resource) it.next();
|
||||
|
||||
String name = res.getShortName();
|
||||
if (getDocApplication().isExcluded(name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
addChild(DocSkin.newInstance(res, this));
|
||||
}
|
||||
|
||||
ResourceProperties props = proto.getTypeProperties();
|
||||
it = props.getResources();
|
||||
|
||||
int index = 0;
|
||||
while (it.hasNext()) {
|
||||
Resource res = (Resource) it.next();
|
||||
if (res.exists()) {
|
||||
addChild(new DocProperties(res, props, index++, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
* Helma License Notice
|
||||
*
|
||||
* The contents of this file are subject to the Helma License
|
||||
* Version 2.0 (the "License"). You may not use this file except in
|
||||
* compliance with the License. A copy of the License is available at
|
||||
* http://adele.helma.org/download/helma/license.txt
|
||||
*
|
||||
* Copyright 1998-2003 Helma Software. All Rights Reserved.
|
||||
*
|
||||
* $RCSfile$
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
package helma.doc;
|
||||
|
||||
import helma.framework.repository.Repository;
|
||||
import helma.framework.repository.Resource;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public abstract class DocRepositoryElement extends DocElement {
|
||||
|
||||
protected Repository repos;
|
||||
|
||||
// a default file that is read as comment for applications
|
||||
// and prototypes if found in their directories
|
||||
public static final String[] DOCFILES = {
|
||||
"doc.html", "doc.htm", "app.html",
|
||||
"app.htm", "prototype.html",
|
||||
"prototype.htm", "index.html", "index.htm"
|
||||
};
|
||||
|
||||
protected DocRepositoryElement(String name, Repository repos, int type) throws IOException {
|
||||
super(name, type);
|
||||
this.repos = repos;
|
||||
checkCommentFiles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a string describing this element's location
|
||||
*
|
||||
* @return lstring representation of the element's repository
|
||||
*/
|
||||
public String toString() {
|
||||
return repos.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return absolute path to location of element
|
||||
* (directory for apps and prototypes, file for
|
||||
* methods and properties files)
|
||||
*/
|
||||
public Repository getRepository() {
|
||||
return repos;
|
||||
}
|
||||
|
||||
|
||||
private void checkCommentFiles() throws IOException {
|
||||
if (repos == null) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < DOCFILES.length; i++) {
|
||||
Resource res = repos.getResource(DOCFILES[i]);
|
||||
|
||||
if (res.exists()) {
|
||||
String rawComment = res.getContent();
|
||||
parseComment(rawComment);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Helma License Notice
|
||||
*
|
||||
* The contents of this file are subject to the Helma License
|
||||
* Version 2.0 (the "License"). You may not use this file except in
|
||||
* compliance with the License. A copy of the License is available at
|
||||
* http://adele.helma.org/download/helma/license.txt
|
||||
*
|
||||
* Copyright 1998-2003 Helma Software. All Rights Reserved.
|
||||
*
|
||||
* $RCSfile$
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
package helma.doc;
|
||||
|
||||
import helma.framework.repository.Resource;
|
||||
|
||||
/**
|
||||
* abstract class for extracting doc information from files.
|
||||
* not used at the moment but left in for further extensions-
|
||||
*/
|
||||
public abstract class DocResourceElement extends DocElement {
|
||||
|
||||
protected Resource resource;
|
||||
|
||||
protected DocResourceElement(String name, Resource res, int type) {
|
||||
super(name, type);
|
||||
this.resource = res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a string describing this element's location
|
||||
*
|
||||
* @return string representation of the element's resource
|
||||
*/
|
||||
public String toString() {
|
||||
return resource.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the line number this element starts in. Defaults to 0.
|
||||
* @return the first line of this element within its resource
|
||||
*/
|
||||
public int getStartLine() {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
/*
|
||||
* Helma License Notice
|
||||
*
|
||||
* The contents of this file are subject to the Helma License
|
||||
* Version 2.0 (the "License"). You may not use this file except in
|
||||
* compliance with the License. A copy of the License is available at
|
||||
* http://adele.helma.org/download/helma/license.txt
|
||||
*
|
||||
* Copyright 1998-2003 Helma Software. All Rights Reserved.
|
||||
*
|
||||
* $RCSfile$
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
package helma.doc;
|
||||
|
||||
import helma.framework.repository.Resource;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DocSkin extends DocResourceElement {
|
||||
|
||||
protected DocSkin(String name, Resource res, DocElement parent) throws IOException {
|
||||
super(name, res, SKIN);
|
||||
this.parent = parent;
|
||||
content = res.getContent();
|
||||
parseHandlers();
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new independent DocSkin object
|
||||
*/
|
||||
public static DocSkin newInstance(Resource res) throws IOException {
|
||||
return newInstance(res, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new DocSkin object connected to another DocElement
|
||||
*/
|
||||
public static DocSkin newInstance(Resource res, DocElement parent) throws IOException {
|
||||
String skinname = res.getBaseName();
|
||||
return new DocSkin(skinname, res, parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the source code of the skin and
|
||||
* extracts all included macros. code taken
|
||||
* from helma.framework.core.Skin
|
||||
* @see helma.framework.core.Skin
|
||||
*/
|
||||
private void parseHandlers() {
|
||||
ArrayList partBuffer = new ArrayList();
|
||||
char[] source = content.toCharArray();
|
||||
int sourceLength = source.length;
|
||||
|
||||
for (int i = 0; i < (sourceLength - 1); i++) {
|
||||
if ((source[i] == '<') && (source[i + 1] == '%')) {
|
||||
// found macro start tag
|
||||
int j = i + 2;
|
||||
|
||||
// search macro end tag
|
||||
while ((j < (sourceLength - 1)) &&
|
||||
((source[j] != '%') || (source[j + 1] != '>'))) {
|
||||
j++;
|
||||
}
|
||||
|
||||
if (j > (i + 2)) {
|
||||
String str = (new String(source, i + 2, j - i)).trim();
|
||||
|
||||
if (str.endsWith("%>")) {
|
||||
str = str.substring(0, str.length() - 2);
|
||||
}
|
||||
|
||||
if (str.startsWith("//")) {
|
||||
parseComment(str);
|
||||
} else {
|
||||
if (str.indexOf(" ") > -1) {
|
||||
str = str.substring(0, str.indexOf(" "));
|
||||
}
|
||||
|
||||
if ((str.indexOf(".") > -1) &&
|
||||
(str.startsWith("param.") || str.startsWith("response.") ||
|
||||
str.startsWith("request.") || str.startsWith("session.")) &&
|
||||
!partBuffer.contains(str)) {
|
||||
partBuffer.add(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i = j + 1;
|
||||
}
|
||||
}
|
||||
|
||||
String[] strArr = (String[]) partBuffer.toArray(new String[0]);
|
||||
|
||||
Arrays.sort(strArr);
|
||||
|
||||
for (int i = 0; i < strArr.length; i++) {
|
||||
addParameter(strArr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* from helma.framework.IPathElement. Use the same prototype as functions etc.
|
||||
*/
|
||||
public java.lang.String getPrototype() {
|
||||
return "docfunction";
|
||||
}
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
/*
|
||||
* Helma License Notice
|
||||
*
|
||||
* The contents of this file are subject to the Helma License
|
||||
* Version 2.0 (the "License"). You may not use this file except in
|
||||
* compliance with the License. A copy of the License is available at
|
||||
* http://adele.helma.org/download/helma/license.txt
|
||||
*
|
||||
* Copyright 1998-2003 Helma Software. All Rights Reserved.
|
||||
*
|
||||
* $RCSfile$
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
package helma.doc;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final class DocTag {
|
||||
|
||||
// the tag name
|
||||
private String type;
|
||||
|
||||
// the name of the parameter
|
||||
private String name;
|
||||
|
||||
// the actual comment
|
||||
private String text;
|
||||
|
||||
private DocTag(String type, String name, String text) {
|
||||
this.type = type;
|
||||
this.name = (name != null) ? name.trim() : "";
|
||||
this.text = (text != null) ? text.trim() : "";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param rawTag ...
|
||||
*
|
||||
* @return ...
|
||||
*
|
||||
* @throws DocException ...
|
||||
*/
|
||||
public static DocTag parse(String rawTag) throws DocException {
|
||||
StringTokenizer tok = new StringTokenizer(rawTag.trim());
|
||||
String name = "";
|
||||
String type = "";
|
||||
StringBuffer comment = new StringBuffer ();
|
||||
try {
|
||||
type = matchTagName(tok.nextToken().substring (1));
|
||||
} catch (NoSuchElementException nsee) {
|
||||
throw new DocException ("invalid tag: " + rawTag);
|
||||
}
|
||||
try {
|
||||
if (isTagWithName(type)) {
|
||||
name = tok.nextToken();
|
||||
}
|
||||
while (tok.hasMoreTokens()) {
|
||||
comment.append (" ").append(tok.nextToken());
|
||||
}
|
||||
} catch (NoSuchElementException nsee) { // ignore
|
||||
}
|
||||
return new DocTag (type, name, comment.toString());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param rawTag a line from a helmadoc comment
|
||||
* @return true if the line represents a tag
|
||||
*/
|
||||
public static boolean isTagStart(String rawTag) {
|
||||
if (rawTag.trim().startsWith("@"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* match tags where we want different names to be valid
|
||||
* as one and the same tag
|
||||
* @param tagName original name
|
||||
* @return modified name if tag was matched
|
||||
*/
|
||||
public static String matchTagName(String tagName) {
|
||||
if ("returns".equals(tagName)) {
|
||||
return "return";
|
||||
} else if ("arg".equals(tagName)) {
|
||||
return "param";
|
||||
} else {
|
||||
return tagName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean isTagWithName(String tagName) {
|
||||
if ("param".equals (tagName))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return ...
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer ("[@" + type);
|
||||
if (name!=null && !"".equals(name))
|
||||
buf.append (" ").append(name);
|
||||
if (text!=null && !"".equals(text))
|
||||
buf.append (" ").append(text);
|
||||
return buf.toString() + "]";
|
||||
}
|
||||
}
|
|
@ -1,148 +0,0 @@
|
|||
/*
|
||||
* Helma License Notice
|
||||
*
|
||||
* The contents of this file are subject to the Helma License
|
||||
* Version 2.0 (the "License"). You may not use this file except in
|
||||
* compliance with the License. A copy of the License is available at
|
||||
* http://adele.helma.org/download/helma/license.txt
|
||||
*
|
||||
* Copyright 1998-2003 Helma Software. All Rights Reserved.
|
||||
*
|
||||
* $RCSfile$
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
package helma.doc;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.io.*;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final class Util {
|
||||
/**
|
||||
* chops a string from comment-delimiters
|
||||
*
|
||||
* @param line a line of raw text
|
||||
*
|
||||
* @return chopped string
|
||||
*/
|
||||
public static String chopDelimiters(String line) {
|
||||
line = line.trim();
|
||||
if (line == null) {
|
||||
return null;
|
||||
}
|
||||
if (line.endsWith("*/")) {
|
||||
line = line.substring(0, line.length() - 2);
|
||||
}
|
||||
if (line.startsWith("/**")) {
|
||||
line = line.substring(3).trim();
|
||||
} else if (line.startsWith("/*")) {
|
||||
line = line.substring(2).trim();
|
||||
} else if (line.startsWith("*")) {
|
||||
line = line.substring(1).trim();
|
||||
} else if (line.startsWith("//")) {
|
||||
line = line.substring(2).trim();
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
/**
|
||||
* chops anything that comes after a closing comment tag
|
||||
*
|
||||
* @param comment the raw comment
|
||||
*
|
||||
* @return chopped comment
|
||||
*/
|
||||
public static String chopComment (String comment) {
|
||||
int idx = comment.indexOf ("*/");
|
||||
if (idx>0) {
|
||||
return comment.substring (0, idx+2);
|
||||
} else {
|
||||
return comment;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a part of a file defined by two points from a String array
|
||||
* @param lines an array of lines
|
||||
* @param start of string to extract defined by column x and row y
|
||||
* @param end of string to extract
|
||||
* @return string
|
||||
*/
|
||||
public static String extractString (String[] lines, Point start, Point end) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
int to = Math.min(end.y + 1, lines.length);
|
||||
for (int i = start.y; i < to; i++) {
|
||||
int from = (i == start.y) ? start.x : 0;
|
||||
if (from < 0 || from > lines[i].length()) {
|
||||
System.err.println("Start index " + from + " out of range [0.." +
|
||||
lines[i].length() + "]");
|
||||
from = 0;
|
||||
}
|
||||
if (i == end.y && end.x < lines[i].length())
|
||||
buf.append(lines[i].substring(from, end.x));
|
||||
else
|
||||
buf.append(lines[i].substring(from));
|
||||
buf.append("\n");
|
||||
}
|
||||
return buf.toString().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a part of a file defined by two points from a String array
|
||||
* @param lines an array of lines
|
||||
* @param start of string to extract defined by column x and row y
|
||||
* @param end of string to extract
|
||||
* @return string
|
||||
*/
|
||||
public static String extractString (String[] lines, int start, int end) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
int to = Math.min(end + 1, lines.length);
|
||||
for (int i = start; i < to; i++) {
|
||||
buf.append(lines[i]);
|
||||
buf.append("\n");
|
||||
}
|
||||
return buf.toString().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* method to debug file/stream-handling with Point objects. extracts the line p
|
||||
* points to and prints it with a pointer to the given column
|
||||
*
|
||||
* @param sourceFile
|
||||
* @param p x-value is used for column, y for row
|
||||
* @param debugStr string prefixed to output
|
||||
*/
|
||||
public static void debugLineFromFile (File sourceFile, Point p, String debugStr) {
|
||||
try {
|
||||
BufferedReader in = new BufferedReader(new FileReader(sourceFile));
|
||||
String line = "";
|
||||
int ct = 0;
|
||||
while (line != null) {
|
||||
line = in.readLine ();
|
||||
if (line==null) {
|
||||
System.out.println ("eof reached");
|
||||
break;
|
||||
}
|
||||
if (ct==p.y) {
|
||||
System.out.println (debugStr + ": " + line);
|
||||
for (int i=0; i<(debugStr.length()+1+p.x); i++) {
|
||||
System.out.print (" ");
|
||||
}
|
||||
System.out.println ("^");
|
||||
break;
|
||||
}
|
||||
ct++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -24,7 +24,6 @@ import helma.main.Server;
|
|||
import helma.objectmodel.*;
|
||||
import helma.objectmodel.db.*;
|
||||
import helma.util.*;
|
||||
import helma.doc.DocApplication;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
|
@ -1416,19 +1415,6 @@ public final class Application implements Runnable {
|
|||
return null;
|
||||
}
|
||||
|
||||
public DocApplication getDoc() {
|
||||
RequestEvaluator eval = null;
|
||||
try {
|
||||
eval = getEvaluator();
|
||||
return eval.scriptingEngine.getDoc();
|
||||
} catch (Exception xcept) {
|
||||
logError("Error in getDoc() for " + name, xcept);
|
||||
return null;
|
||||
} finally {
|
||||
releaseEvaluator(eval);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,7 +19,6 @@ package helma.scripting;
|
|||
import helma.framework.repository.Resource;
|
||||
import helma.framework.core.Application;
|
||||
import helma.framework.core.RequestEvaluator;
|
||||
import helma.doc.DocApplication;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -156,14 +155,6 @@ public interface ScriptingEngine {
|
|||
*/
|
||||
public String toString(Object obj);
|
||||
|
||||
/**
|
||||
* Get an IPathElement that offers introspection services into the application.
|
||||
* If this method returns null, no introspection is available for this kind of engine.
|
||||
* In order to be compatible with the standard Helma management application, this
|
||||
* class should be compatible with helma.doc.DocApplication.
|
||||
*/
|
||||
public DocApplication getDoc();
|
||||
|
||||
/**
|
||||
* Provide object serialization for this engine's scripted objects. If no special
|
||||
* provisions are required, this method should just wrap the stream with an
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package helma.scripting.rhino;
|
||||
|
||||
import helma.doc.DocApplication;
|
||||
import helma.extensions.ConfigurationException;
|
||||
import helma.extensions.HelmaExtension;
|
||||
import helma.framework.*;
|
||||
|
@ -69,9 +68,6 @@ public class RhinoEngine implements ScriptingEngine {
|
|||
// thread local engine registry
|
||||
static ThreadLocal engines = new ThreadLocal();
|
||||
|
||||
// the introspector that provides documentation for this application
|
||||
DocApplication doc = null;
|
||||
|
||||
/**
|
||||
* Zero argument constructor.
|
||||
*/
|
||||
|
@ -504,21 +500,6 @@ public class RhinoEngine implements ScriptingEngine {
|
|||
return obj.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an introspector to this engine.
|
||||
*/
|
||||
public DocApplication getDoc() {
|
||||
if (doc == null) {
|
||||
try {
|
||||
doc = new DocApplication(app);
|
||||
doc.readApplication();
|
||||
} catch (IOException x) {
|
||||
throw new RuntimeException(x.toString(), x);
|
||||
}
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide object serialization for this engine's scripted objects. If no special
|
||||
* provisions are required, this method should just wrap the stream with an
|
||||
|
|
Loading…
Add table
Reference in a new issue