@@ -0,0 +1,24 @@ | |||
# AspectJ | |||
## Building | |||
AspectJ has a multi module maven build. Although various modules produce intermediate results, the key artifacts at the end of the build are: | |||
* `aspectjrt` - the AspectJ runtime | |||
* `aspectjweaver` - the AspectJ weaver | |||
* `aspectjtools` - the AspectJ compiler | |||
These are the artifacts published to maven central for each release. In addition there is an installer that can be run with `java -jar` to install AspectJ onto Windows/Mac/Linux. This installer is produced by the installer sub module. | |||
In the root of a cloned AspectJ simply run: | |||
`./mvnw clean install` | |||
This will build all the modules, run all the tests and install the key artifacts in your local repository. | |||
## Running the tests in eclipse | |||
Once you have imported all the projects using `m2e`, there is a special module called `run-all-junit-tests` and within that a `RunTheseBeforeYouCommitTests` class that can be run with the JUnit launcher. This will execute all the tests in each module plus the compiler tests in the `tests` module. | |||
@@ -1,2 +0,0 @@ | |||
@@ -1,13 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<classpath> | |||
<classpathentry kind="src" path="ajdoc-src"/> | |||
<classpathentry kind="src" path="ajdoc-testsrc"/> | |||
<classpathentry kind="src" path="testing-src"/> | |||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | |||
<classpathentry kind="lib" path="/lib/junit/junit.jar" sourcepath="/lib/junit/junit-src.jar"/> | |||
<classpathentry kind="lib" path="/lib/ant/lib/ant.jar" sourcepath="/lib/ant/ant-src.zip"/> | |||
<classpathentry kind="lib" path="/lib/regexp/jakarta-regexp-1.2.jar"/> | |||
<classpathentry kind="src" path="/testing"/> | |||
<classpathentry kind="src" path="/util"/> | |||
<classpathentry kind="output" path="bin"/> | |||
</classpath> |
@@ -1,19 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<projectDescription> | |||
<name>aspectj-attic</name> | |||
<comment></comment> | |||
<projects> | |||
<project>testing</project> | |||
<project>util</project> | |||
</projects> | |||
<buildSpec> | |||
<buildCommand> | |||
<name>org.eclipse.jdt.core.javabuilder</name> | |||
<arguments> | |||
</arguments> | |||
</buildCommand> | |||
</buildSpec> | |||
<natures> | |||
<nature>org.eclipse.jdt.core.javanature</nature> | |||
</natures> | |||
</projectDescription> |
@@ -1,98 +0,0 @@ | |||
-------------- Problems: | |||
---- todo FIX output HTML is using "introduction" as labels. | |||
- use "[Summary|Details] of [fields|methods|constructors] declared for target types" | |||
("target" rather than "other" since they may be defined on self?) | |||
- see also top index links: | |||
- super introductions... | |||
solution: change doclet resources | |||
---- FIXED comments not displayed for inter-type declarations in the aspects | |||
solution: IntroducedDocImpl.java sets source location for the dec from the introduced dec | |||
> dec.setSourceLocation(introducedDec.getSourceLocation()); // PR790, 712 | |||
---- PARTIAL FIX: synthetic constructors are shown in the javadoc | |||
solution: post-process to remove unadvised constructors with same source location as parent class | |||
See ClassDocImpl.java | |||
problem with the solution: does not remove synthetic constructors on aspects?? | |||
(only if they advise themselves?) | |||
---- FIXED class cast exception trying to print introduced Constructor parameters | |||
solution: | |||
diff -r1.5 IntroducedDocImpl.java | |||
105c107 | |||
< makeParameters(((MethodDocImpl)cs[i]). | |||
--- | |||
> makeParameters(((ConstructorDocImpl)cs[i]). | |||
---- introduced constructor names use the name of the declaring aspect, not the target | |||
solution: | |||
diff -r1.4 ConstructorDocImpl.java | |||
53c56,58 | |||
< return containingClass().name(); | |||
--- | |||
> String qname = getQualifiedName(); | |||
> return (null != qname ? qname : containingClass().name()); | |||
---- ok: in aspect docs, inter-type declarations targeting the aspect work as expected, | |||
with both the inter-type declaration and the aspect-declared member documented. | |||
---- ajc prints out declare-warnings when compiling for ajdoc | |||
---- in aspect docs, links out to affected classes not printed for introduced constructors | |||
essentially, the name of the constructor (should) differ for each target. sigh. | |||
- identifier should be the FQN of the aspect plus the type pattern and signature of the constructor. | |||
(parm signature - result, throws not required) | |||
- display label in the aspect should be the identifier | |||
-> currently is the name of the aspect plus () | |||
- display label in affected classes should be the name of the affected class and the parm signature | |||
-> c | |||
---- in target docs, links back to declaring aspects for introduced constructors fail | |||
(iff parms?) | |||
---- in target docs, summaries of members declared by aspects do not list initial comment line. | |||
---- is aspect docs, members declared on target types are displayed only with the member name, | |||
not the typepattern. | |||
see IntroducedDocImpl.java name() | |||
public String name() { | |||
// when using qualified name, unable to find links aout to targets | |||
// return (null != qualifiedName ? qualifiedName : dec().getId()); // XXX | |||
// when using id, only get simple name | |||
return dec().getId(); | |||
} | |||
==> get caller to use printedName as label | |||
UNFIXABLE - caller is sun doclet, and we only give it the member as parameter. | |||
We do control the names of the links out, but not the name of the member in the class, | |||
except to override qualifiedName, which causes the links out to fail (because | |||
IntroducedDocImpl.createTargets() uses MemberDocImpl.weakEquals() to discover | |||
all introduced members in other types to find out if they were introduced by this | |||
declaration (awful!), and [Method|Field|Member]DocImpl.weakEquals() implementations | |||
use name() - using qualifiedName() would result in false positives for any field | |||
in a target class). Overriding name() also causes other things to fail because it is | |||
used as an id. Even changing the name during the lifecycle seems risky. There's | |||
not a clean separation between the type name and the name as displayed. | |||
---- in target class docs, introduced member links back to declaring aspect | |||
have the member name as their label; should have the aspect type. | |||
---- bad fix: references to declaration targets lost and incomplete html thereafter | |||
is a result of modifying name() or qualifiedName() of memberDoc | |||
-------------- Background: | |||
?? | |||
declaration target - Introduced | |||
declaration source - Introduction | |||
@@ -1,87 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
import com.sun.javadoc.Type; | |||
/** | |||
* Documentation for a piece of advice. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface AdviceDoc extends ExecutableMemberDoc, | |||
com.sun.javadoc.ExecutableMemberDoc { | |||
/** | |||
* Returns <code>true</code> if the advice is <code>abstract</code>. | |||
* | |||
* @return <code>true</code> if the advice is <code>abstract</code>. | |||
*/ | |||
public boolean isAbstract(); | |||
/** | |||
* Returns a {@link #AspectDoc} representing the aspect | |||
* that is overriden by this advice. | |||
* | |||
* @return a AspectDoc representing the aspect | |||
* that is overriden by this advice. | |||
*/ | |||
public AspectDoc overriddenAspect(); | |||
/** | |||
* Returns the return type of this advice -- it may be null. | |||
* | |||
* @return the return type of this advice -- it may be null. | |||
*/ | |||
public Type returnType(); | |||
/** | |||
* Returns the array of docs this advice crosscuts. | |||
* | |||
* @return an array of docs this advice crosscuts. | |||
*/ | |||
public com.sun.javadoc.ExecutableMemberDoc[] crosscuts(); | |||
/** | |||
* Returns <code>true</code> if this is <code>throwing</code> advice. | |||
* | |||
* @return <code>true</code> if this is <code>throwing</code> advice. | |||
*/ | |||
public boolean isThrowing(); | |||
/** | |||
* Returns <code>true</code> if this is <code>returning</code> advice. | |||
* | |||
* @return <code>true</code> if this is <code>returning</code> advice. | |||
*/ | |||
public boolean isReturning(); | |||
/** | |||
* Returns the extra formal type that's the optional type | |||
* to <code>after returning</code> or <code>after throwing</code> | |||
* advice. | |||
* | |||
* @return an instance of Type that represents the the extra formal type | |||
* that's the optional type to <code>after returning</code> or | |||
* <code>after throwing</code> advice. | |||
*/ | |||
public Type extraType(); | |||
} |
@@ -1,83 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* Represents an aspectj aspect and extends | |||
* <code>ClassDoc</code> to provide the extra aspectj-only | |||
* information not present in that interface. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface AspectDoc extends ClassDoc { //, com.sun.javadoc.ClassDoc { | |||
/** | |||
* Return advice in aspect. | |||
* | |||
* @return an array of AdviceDoc for representing the | |||
* visible advice in this aspect. | |||
*/ | |||
public AdviceDoc[] advice(); | |||
/** | |||
* Return aspects that are dominated by this aspect. | |||
* | |||
* @return an array of AspectDoc for representing the | |||
* aspects that are dominated by this aspect. | |||
*/ | |||
public AspectDoc[] dominatees(); | |||
/** | |||
* Return aspects that dominate this aspect. | |||
* | |||
* @return an array of AspectDoc for representing the | |||
* aspects that dominate this aspect. | |||
*/ | |||
public AspectDoc[] dominators(); | |||
/** | |||
* Return the introductions made by this aspect on other types. | |||
* | |||
* @return an array of IntroductionDoc for representing the | |||
* introductions made on other types. | |||
*/ | |||
public IntroductionDoc[] introductions(); | |||
/** | |||
* Return the of clauses that describe this aspect. | |||
* | |||
* @return an array of OfClauseDoc for representing the | |||
* of clauses that describe this aspect. | |||
*/ | |||
public OfClauseDoc ofClause(); | |||
/** | |||
* Returns <code>true</code> if this aspects dominates | |||
* the passed in aspect. | |||
* | |||
* @param other an AspectDoc that represents another | |||
* aspect in this world. | |||
* @return <code>true</code> if this aspects dominates | |||
* the passed in aspect. | |||
*/ | |||
public boolean dominates(AspectDoc other); | |||
} |
@@ -1,58 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* Represents a class in the aspectj-world. The difference | |||
* between this and one in the javac-world, is that a class | |||
* may have pointcuts and introductions. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface ClassDoc extends com.sun.javadoc.ClassDoc, | |||
ProgramElementDoc, Type { | |||
/** | |||
* Returns the pointcuts this class declares. | |||
* | |||
* @return an array of PointcutDoc representing the | |||
* pointcuts declared by this class. | |||
*/ | |||
public PointcutDoc[] pointcuts(); | |||
/** | |||
* Returns the introductions made by other aspects that | |||
* affect the type hierarchy of this class. | |||
* | |||
* @return an array of IntroducedSuperDoc representing the | |||
* introductions affecting the type hierarchy of | |||
* this class. | |||
*/ | |||
public IntroducedSuperDoc[] introducers(); | |||
/** | |||
* Return <code>true</code> if this is an aspect. | |||
* | |||
* @return <code>true</code> is this is an aspect. | |||
*/ | |||
public boolean isAspect(); | |||
} |
@@ -1,31 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* An empty extension of com.sun.javadoc.ConstructorDoc. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface ConstructorDoc extends com.sun.javadoc.ConstructorDoc, | |||
ExecutableMemberDoc { | |||
} |
@@ -1,45 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* The abstract base class of all Doc classes in the | |||
* aspectj-world. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface Doc extends com.sun.javadoc.Doc { | |||
/** | |||
* Returns <code>true</code> if this Doc is advice. | |||
* | |||
* @return <code>true</code> is this Doc is advice. | |||
*/ | |||
public boolean isAdvice(); | |||
/** | |||
* Returns <code>true</code> if this Doc is a pointcut. | |||
* | |||
* @return <code>true</code> is this Doc is a pointcut. | |||
*/ | |||
public boolean isPointcut(); | |||
} |
@@ -1,41 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* Represents and executable member in the aspectj-world. | |||
* The only difference between this and one in the javac-world | |||
* is that these members can have advice on them | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface ExecutableMemberDoc extends com.sun.javadoc.ExecutableMemberDoc, | |||
MemberDoc { | |||
/** | |||
* Returns the advice placed on this member. | |||
* | |||
* @return an array of AdviceDoc representing the | |||
* advice placed on this member. | |||
*/ | |||
public AdviceDoc[] advice(); | |||
} |
@@ -1,30 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* An empty extension of com.sun.javadoc.FieldDoc. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface FieldDoc extends com.sun.javadoc.FieldDoc, MemberDoc { | |||
} |
@@ -1,37 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* Represents the introduction of a member onto a ClassDoc. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface IntroducedDoc extends IntroductionDoc { | |||
/** | |||
* Returns the member introduced on {@link #targets()}. | |||
* | |||
* @return the MemberDoc that was introduced. | |||
*/ | |||
public MemberDoc member(); | |||
} |
@@ -1,50 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* Represents the introduction of a class-extension or | |||
* interface-implementation (e.g. +extends or +implements) | |||
* onto a ClassDoc. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface IntroducedSuperDoc extends IntroductionDoc { | |||
/** | |||
* Returns the types that are introduced. | |||
* | |||
* @return an array of Type representing the classes or | |||
* aspects that the target ClassDocs now implement | |||
* or extend. | |||
*/ | |||
public Type[] types(); | |||
/** | |||
* Returns <code>true</code> is this is a '+implements' | |||
* introduction. | |||
* | |||
* @return <code>true</code> is this is a '+implements' | |||
* introduction. | |||
*/ | |||
public boolean isImplements(); | |||
} |
@@ -1,38 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* Represents an introduction with >= 0 target ClassDocs. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface IntroductionDoc extends MemberDoc { | |||
/** | |||
* Returns the targets that this introduction affects. | |||
* | |||
* @return an array of ClassDoc representing the | |||
* classes/aspects this introduction affects. | |||
*/ | |||
public ClassDoc[] targets(); | |||
} |
@@ -1,43 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* A class or aspect member in the aspectj-world, the difference | |||
* between this and a javac-world member is that if this member | |||
* was introduced by an aspect, it has a reference to that | |||
* introduction. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface MemberDoc extends com.sun.javadoc.MemberDoc, | |||
ProgramElementDoc { | |||
/** | |||
* Returns the introduction that placed this member on this class | |||
* if is exists -- this <b>can</b> be <code>null</code>. | |||
* | |||
* @return the introduction that placed this member on this class | |||
* if is exists -- this <b>can</b> be <code>null</code>. | |||
*/ | |||
public IntroducedDoc introduced(); | |||
} |
@@ -1,32 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* An empty exntension to com.sun.javadoc.MethodDoc. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface MethodDoc extends com.sun.javadoc.MethodDoc, | |||
ExecutableMemberDoc { | |||
} |
@@ -1,79 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* Represents an of clause describing an aspect. | |||
* This declaration also contains constants to be used to | |||
* identify different OfClauseDocs. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface OfClauseDoc { | |||
/** | |||
* A typesafe-enum describing the possible kinds | |||
* of OfClauseDocs. | |||
*/ | |||
public final static class Kind { | |||
/** Internal representation. */ | |||
private final String kind; | |||
/** | |||
* Don't allow any other's to call this. | |||
* | |||
* @param kind The internal String representation. | |||
*/ | |||
private Kind(String kind) { this.kind = kind; } | |||
/** | |||
* Represents an 'of eachcflow(..)' clause. | |||
*/ | |||
public final static Kind EACH_CFLOW = new Kind("echocflow(..)"); | |||
/** | |||
* Represents an 'of eachJVM()' clause. | |||
*/ | |||
public final static Kind EACH_JVM = new Kind("eachJVM()"); | |||
/** | |||
* Represents an 'of eachobject(..)' clause. | |||
*/ | |||
public final static Kind EACH_OBJECT = new Kind("eachObject()"); | |||
/** | |||
* Returns a short representation of the kind. | |||
* | |||
* @return a short representation of the kind. | |||
*/ | |||
public String toString() { return kind; } | |||
} | |||
/** | |||
* Returns the appropriate constant defined in Kind. | |||
* | |||
* @return the appropriate constant defined in Kind. | |||
* @see Kind | |||
*/ | |||
public Kind kind(); | |||
} |
@@ -1,42 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* Representat an 'of eachobject(..)' clause, thought currently | |||
* out of the language, it could make a comeback. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface OfEachObjectDoc extends OfClauseDoc { | |||
/** | |||
* Returns the classes for which an instance of | |||
* this aspect will be made for each. | |||
* | |||
* @return an array of com.sun.javadoc.ClassDoc representing | |||
* the classes for which an instance of | |||
* this aspect will be made for each. | |||
*/ | |||
//public com.sun.javadoc.ClassDoc[] instances(); | |||
public ClassDoc[] instances(); | |||
} |
@@ -1,40 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* An extension of com.sun.javadoc.PackageDoc to add aspects. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface PackageDoc extends com.sun.javadoc.PackageDoc, | |||
Doc | |||
{ | |||
/** | |||
* Returns the aspects in this package. | |||
* | |||
* @return an array of AspectDoc representing the | |||
* aspects in this package. | |||
*/ | |||
public AspectDoc[] aspects(); | |||
} |
@@ -1,24 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
public interface ParamTag extends com.sun.javadoc.ParamTag {} |
@@ -1,24 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
public interface Parameter extends com.sun.javadoc.Parameter {} |
@@ -1,61 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.Type; | |||
/** | |||
* Represents a pointcut in the aspectj-world. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface PointcutDoc extends ExecutableMemberDoc, | |||
com.sun.javadoc.ExecutableMemberDoc | |||
{ | |||
/** | |||
* Returns the resulting type of this pointcut. | |||
* | |||
* @return an instance of Type representing the type | |||
* this pointcut returns. | |||
*/ | |||
public Type resultType(); | |||
/** | |||
* The nearest class in which this pointcut was defined. | |||
* | |||
* @return an instanceof ClassDoc representing the | |||
* nearst class in which this pointcut was | |||
* defined. | |||
*/ | |||
public ClassDoc overriddenClass(); | |||
/** | |||
* Returns <code>true</code> if this pointcut | |||
* is <code>abstract</code>. | |||
* | |||
* @return <code>true</code> if this pointcut | |||
* is <code>abstract</code>. | |||
*/ | |||
public boolean isAbstract(); | |||
} |
@@ -1,31 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* An empty extension of com.sun.javadoc.ProgramElementDoc. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface ProgramElementDoc extends com.sun.javadoc.ProgramElementDoc, | |||
Doc { | |||
} |
@@ -1,31 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* An empty extension of com.sun.javadoc.RootDoc. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface RootDoc extends com.sun.javadoc.RootDoc, | |||
Doc { | |||
} |
@@ -1,24 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
public interface SeeTag extends com.sun.javadoc.SeeTag {} |
@@ -1,24 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
public interface SerialFieldTag extends com.sun.javadoc.SerialFieldTag {} |
@@ -1,24 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
public interface Tag extends com.sun.javadoc.Tag {} |
@@ -1,24 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
public interface ThrowsTag extends com.sun.javadoc.ThrowsTag {} |
@@ -1,31 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.ajdoc; | |||
/** | |||
* An empty extension of com.sun.javadoc.RootDoc. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface Type extends com.sun.javadoc.Type { | |||
} |
@@ -1,197 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
//package com.sun.tools.doclets.standard; | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.tools.doclets.standard.AbstractSubWriter; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.Doc; | |||
import com.sun.javadoc.ExecutableMemberDoc; | |||
import com.sun.javadoc.ProgramElementDoc; | |||
import com.sun.tools.doclets.standard.ClassUseWriter; | |||
import com.sun.tools.doclets.standard.ExecutableMemberSubWriter; | |||
import com.sun.tools.doclets.standard.SubWriterHolderWriter; | |||
import java.util.List; | |||
import java.util.SortedSet; | |||
/** | |||
* Allows for access to protected and package-protected (OK | |||
* sometimes private) members in classes in the package | |||
* com.sun.tools.doclets... | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public class Access { | |||
public static void printSummaryType(AbstractSubWriter mw, | |||
ProgramElementDoc member) { | |||
Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, | |||
mw.del(), | |||
"printSummaryType", | |||
new Class[]{ProgramElementDoc.class}, | |||
new Object[]{member}); | |||
} | |||
public static void printSummaryLink(AbstractSubWriter mw, | |||
ClassDoc cd, | |||
ProgramElementDoc member) { | |||
Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, | |||
mw.del(), | |||
"printSummaryLink", | |||
new Class[]{ClassDoc.class, | |||
ProgramElementDoc.class}, | |||
new Object[]{cd, member}); | |||
} | |||
public static void printInheritedSummaryLink(AbstractSubWriter mw, | |||
ClassDoc cd, | |||
ProgramElementDoc member) { | |||
Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, | |||
mw.del(), | |||
"printInheritedSummaryLink", | |||
new Class[]{ClassDoc.class, | |||
ProgramElementDoc.class}, | |||
new Object[]{cd, member}); | |||
} | |||
public static void printHeader(AbstractSubWriter mw, | |||
ClassDoc cd) { | |||
Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, | |||
mw.del(), | |||
"printHeader", | |||
new Class[]{ClassDoc.class}, | |||
new Object[]{cd}); | |||
} | |||
public static void printBodyHtmlEnd(AbstractSubWriter mw, | |||
ClassDoc cd) { | |||
Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, | |||
mw.del(), | |||
"printBodyHtmlEnd", | |||
new Class[]{ClassDoc.class}, | |||
new Object[]{cd}); | |||
} | |||
public static void printMember(AbstractSubWriter mw, | |||
ProgramElementDoc elem) { | |||
Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, | |||
mw.del(), | |||
"printMember", | |||
new Class[]{ProgramElementDoc.class}, | |||
new Object[]{elem}); | |||
} | |||
public static void printDeprecatedLink(AbstractSubWriter mw, | |||
ProgramElementDoc member) { | |||
Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, | |||
mw.del(), | |||
"printDeprecatedLink", | |||
new Class[]{ProgramElementDoc.class}, | |||
new Object[]{member}); | |||
} | |||
public static void printNavSummaryLink(AbstractSubWriter mw, | |||
ClassDoc cd, | |||
boolean link) { | |||
Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, | |||
mw.del(), | |||
"printNavSummaryLink", | |||
new Class[]{ClassDoc.class, | |||
boolean.class}, | |||
new Object[]{cd, new Boolean(link)}); | |||
} | |||
public static void printNavDetailLink(AbstractSubWriter mw, | |||
boolean link) { | |||
Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, | |||
mw.del(), | |||
"printNavDetailLink", | |||
new Class[]{boolean.class}, | |||
new Object[]{new Boolean(link)}); | |||
} | |||
public static void printTags(AbstractSubWriter mw, | |||
ProgramElementDoc member) { | |||
Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, | |||
mw.del(), | |||
"printTags", | |||
new Class[]{ProgramElementDoc.class}, | |||
new Object[]{member}); | |||
} | |||
public static void printDeprecatedAPI(AbstractSubWriter mw, | |||
List deprmembers, | |||
String headingKey) { | |||
Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, | |||
mw.del(), | |||
"printDeprecatedAPI", | |||
new Class[]{List.class, String.class}, | |||
new Object[]{deprmembers, headingKey}); | |||
} | |||
public static void printParameters(ExecutableMemberSubWriter mw, | |||
ExecutableMemberDoc member) { | |||
Util.invoke(com.sun.tools.doclets.standard.ExecutableMemberSubWriter.class, | |||
mw, | |||
"printParameters", | |||
new Class[]{ExecutableMemberDoc.class}, | |||
new Object[]{member}); | |||
} | |||
public static void printUseInfo(AbstractSubWriter mw, | |||
Object mems, | |||
String heading) { | |||
printUseInfo(mw.del(), mems, heading); | |||
} | |||
public static void printUseInfo | |||
(com.sun.tools.doclets.standard.AbstractSubWriter mw, | |||
Object mems, | |||
String heading) { | |||
if (mw != null) { | |||
Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, | |||
mw, | |||
"printUseInfo", | |||
new Class[]{Object.class, String.class}, | |||
new Object[]{mems, heading}); | |||
} | |||
} | |||
public static void printCommentDef(AbstractSubWriter mw, Doc doc) { | |||
Util.invoke(SubWriterHolderWriter.class, | |||
writer(mw), | |||
"printCommentDef", | |||
new Class[]{Doc.class}, | |||
new Object[]{doc}); | |||
} | |||
public static SubWriterHolderWriter writer(AbstractSubWriter mw) { | |||
return (SubWriterHolderWriter) | |||
Util.access(com.sun.tools.doclets.standard.AbstractSubWriter.class, | |||
mw, "writer"); | |||
} | |||
public static SortedSet pkgSet(ClassUseWriter writer) { | |||
return (SortedSet)Util.access(ClassUseWriter.class, | |||
writer, | |||
"pkgSet"); | |||
} | |||
public static ClassDoc classdoc(ClassUseWriter writer) { | |||
return (ClassDoc)Util.access(ClassUseWriter.class, | |||
writer, | |||
"classdoc"); | |||
} | |||
public static void print(com.sun.tools.doclets.standard.AbstractSubWriter mw, | |||
String str) { | |||
Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, | |||
mw, | |||
"print", | |||
new Class[]{String.class}, | |||
new Object[]{str}); | |||
} | |||
} |
@@ -1,178 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.compiler.base.ast.Modifiers; | |||
import org.aspectj.compiler.base.ast.FieldDec; | |||
import org.aspectj.compiler.base.ast.TypeDec; | |||
import org.aspectj.compiler.base.ast.NameType; | |||
import org.aspectj.compiler.base.ast.CodeDec; | |||
import org.aspectj.compiler.crosscuts.ast.PointcutDec; | |||
/** | |||
* This utility tells whether a declaration is accessible | |||
* based on its access modifiers (and that of its declaring | |||
* class, if it is a member (i.e., including inner classes). | |||
* <p><u>Instantiation and subclassing</u>: | |||
* The constants should suffice for most uses, but subclassing | |||
* is permitted if you need to implement new functionality or | |||
* make new instances. | |||
*/ | |||
public abstract class AccessChecker { | |||
// constants open doCanAccess to public to permit direct use | |||
/** return true only for public elements */ | |||
public static final AccessChecker PUBLIC = new AccessChecker("public") { | |||
public boolean doCanAccess(Modifiers mods, Object object) { | |||
return mods.isPublic(); | |||
} | |||
}; | |||
/** return true for public and protected elements */ | |||
public static final AccessChecker PROTECTED = new AccessChecker("protected") { | |||
public boolean doCanAccess(Modifiers mods, Object object) { | |||
return mods.isPublic() || mods.isProtected(); | |||
} | |||
}; | |||
/** return true unless private elements */ | |||
public static final AccessChecker PACKAGE = new AccessChecker("package") { | |||
public boolean doCanAccess(Modifiers mods, Object object) { | |||
return !mods.isPrivate(); | |||
} | |||
}; | |||
/** return true for all elements */ | |||
public static final AccessChecker PRIVATE = new AccessChecker("private") { | |||
public boolean doCanAccess(Modifiers mods, Object object) { | |||
return true; | |||
} | |||
}; | |||
/** lowercase option without - */ | |||
protected final String optionName; | |||
/** | |||
* Encourage use of static constants by prohibiting construction | |||
* but permit new subclasses. | |||
* Subclasses should ensure optionName is lowercase and | |||
* doCanAccess is public if need be. | |||
*/ | |||
protected AccessChecker(String optionName){ | |||
this.optionName = optionName; | |||
} | |||
/** @return true if modifiers permitted for self and declaring type */ | |||
public boolean canAccess(FieldDec dec) { | |||
if (null == dec) return false; | |||
if (!canAccess(dec.getModifiers(), dec)) { | |||
return false; | |||
} else { | |||
return canAccess(dec.getBytecodeTypeDec()); | |||
} | |||
} | |||
/** @return true if modifiers permitted for self and declaring type */ | |||
public boolean canAccess(CodeDec dec) { | |||
if (null == dec) return false; | |||
if (!canAccess(dec.getModifiers(), dec)) { | |||
return false; | |||
} else { | |||
return canAccess(dec.getBytecodeTypeDec()); | |||
} | |||
} | |||
/** @return true if modifiers permitted for self and declaring type */ | |||
public boolean canAccess(PointcutDec dec) { | |||
if (null == dec) return false; | |||
if (!canAccess(dec.getModifiers(), dec)) { | |||
return false; | |||
} else { | |||
return canAccess(dec.getBytecodeTypeDec()); | |||
} | |||
} | |||
/** decode dec modifiers and return whether access is permitted | |||
* Access is permitted if it is permitted to the dec. | |||
* The caller must prohibit access when displaying in the aspect | |||
* (i.e., <code>canAccess(dec.getLexicalType())</code> or in | |||
* the target class | |||
* (i.e., <code>canAccess(dec.getDeclaringType())</code>) | |||
* and to the enclosing lexical type (i.e,. the enclosing aspect). | |||
*/ | |||
/* | |||
public boolean canAccess(IntroducedDec dec) { // todo: users | |||
if (null == dec) return false; | |||
if (!canAccess(dec.getModifiers(), dec)) { | |||
return false; | |||
} else { | |||
return canAccess(dec.getLexicalType()); | |||
} | |||
} | |||
*/ | |||
/** @return true if modifiers permitted for self and any enclosing type */ | |||
public boolean canAccess(TypeDec dec) { | |||
if (null == dec) return false; | |||
boolean result = canAccess(dec.getModifiers(), dec); | |||
if (result) { | |||
// avoiding NPE in getEnclosingInstanceTypeDec | |||
NameType outerType = dec.getEnclosingInstanceType(); | |||
TypeDec outer = (null == outerType? null | |||
: outerType.getTypeDec()); // todo: typeDec? | |||
result = ((null == outer) || canAccess(outer)); | |||
} | |||
return result; | |||
} | |||
/** | |||
* This is called from <code>canAccess</code> to log any results | |||
* of <code>doCanAccess</code> | |||
* and should return the result or a principled variant thereof. | |||
*/ | |||
protected boolean canAccessLog(Modifiers mods, Object object, | |||
boolean result) { | |||
return result; | |||
} | |||
/** | |||
* Check whether client has access to the object | |||
* based on the modifiers. | |||
* @param object the Object with the modifier flags - may be null | |||
* @param modifiers the Modifiers to check | |||
* @return false if modifiers are null or true if access is permitted | |||
*/ | |||
// todo: object unused but useful for logging | |||
public final boolean canAccess(Modifiers mods, Object object) { | |||
boolean result = (null == mods? false : doCanAccess(mods, object)); | |||
return canAccessLog(mods, object, result); | |||
} | |||
/** @return lowercase variant of option name (e.g., "private" for -private) */ | |||
public final String getOption() { return optionName; } | |||
/** @return UPPERCASE variant of option name (e.g., "PRIVATE" for -private) */ | |||
public final String toString() { return optionName.toUpperCase(); } | |||
/** subclasses implement semantics here. */ | |||
abstract protected boolean doCanAccess(Modifiers mods, Object object); | |||
} |
@@ -1,199 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.ajdoc.AdviceDoc; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import org.aspectj.ajdoc.ClassDoc; | |||
import org.aspectj.ajdoc.ExecutableMemberDoc; | |||
import org.aspectj.compiler.base.ast.CodeDec; | |||
import org.aspectj.compiler.base.ast.FormalDec; | |||
import org.aspectj.compiler.base.ast.NameType; | |||
import org.aspectj.compiler.base.ast.TypeDec; | |||
import org.aspectj.compiler.crosscuts.ast.AdviceDec; | |||
import org.aspectj.compiler.crosscuts.ast.AfterReturningAdviceDec; | |||
import org.aspectj.compiler.crosscuts.ast.AfterThrowingAdviceDec; | |||
import org.aspectj.compiler.crosscuts.ast.AroundAdviceDec; | |||
import com.sun.javadoc.Type; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Set; | |||
public class AdviceDocImpl extends CodeDocImpl implements AdviceDoc { | |||
/** Crosscuts this advice affects. */ | |||
private final Collection crosscuts; | |||
/** | |||
* Constructrs an AdviceDoc with the containing ClassDoc | |||
* and underlying AdviceDec. | |||
* | |||
* @param containingClass containing ClassDoc. | |||
* @param adviceDec underlying AdviceDec. | |||
*/ | |||
public AdviceDocImpl(ClassDoc containingClass, AdviceDec adviceDec) { | |||
super(containingClass, adviceDec); | |||
crosscuts = createCrosscuts(); | |||
} | |||
/** | |||
* Returns the underlying Dec -- an AdviceDec. | |||
* | |||
* @return the underlying Dec -- an AdviceDec. | |||
*/ | |||
protected AdviceDec adviceDec() { | |||
return (AdviceDec)codeDec(); | |||
} | |||
/** | |||
* Return the ExecutableMemberDocs this advice crosscuts. | |||
* | |||
* @return an array of ExecutableMemberDocs representing | |||
* the members this advice crosscuts. | |||
*/ | |||
public com.sun.javadoc.ExecutableMemberDoc[] crosscuts() { | |||
return (ExecutableMemberDoc[])crosscuts.toArray | |||
(new ExecutableMemberDoc[crosscuts.size()]); | |||
} | |||
/** | |||
* Returns <code>null</code>, because advice can't override | |||
* other advice. | |||
* | |||
* @return <code>null</code>, because advice can't override | |||
* other advice. | |||
*/ | |||
public AspectDoc overriddenAspect() { | |||
return null; | |||
} | |||
/** | |||
* Returns the return type of the advice -- it may be null. | |||
* | |||
* @return the return type of the advice -- it may be null. | |||
*/ | |||
public com.sun.javadoc.Type returnType() { | |||
if (adviceDec() instanceof AroundAdviceDec) { | |||
return TypeImpl.getInstance(adviceDec().getReturnType()); | |||
} else { | |||
return null; | |||
} | |||
} | |||
/** | |||
* Returns <code>true</code>. | |||
* | |||
* @return <code>true</code>. | |||
*/ | |||
public boolean isAdvice() { | |||
return true; | |||
} | |||
/** | |||
* Returns <code>true</code> if this advice is <code>abstract</code>. | |||
* | |||
* @return <code>true</code> if this advice is <code>abstract</code>. | |||
*/ | |||
public boolean isAbstract() { | |||
return adviceDec().isAbstract(); | |||
} | |||
/** | |||
* Returns <code>true</code> if this is <code>throwing</code> advice. | |||
* | |||
* @return <code>true</code> if this is <code>throwing</code> advice. | |||
*/ | |||
public boolean isThrowing() { | |||
return adviceDec() instanceof AfterThrowingAdviceDec; | |||
} | |||
/** | |||
* Returns <code>true</code> if this is <code>returning</code> advice. | |||
* | |||
* @return <code>true</code> if this is <code>returning</code> advice. | |||
*/ | |||
public boolean isReturning() { | |||
return adviceDec() instanceof AfterReturningAdviceDec; | |||
} | |||
/** | |||
* Returns the extra formal type that's the optional type | |||
* to <code>after returning</code> or <code>after throwing</code> | |||
* advice. | |||
* | |||
* @return an instance of Type that represents the the extra formal type | |||
* that's the optional type to <code>after returning</code> or | |||
* <code>after throwing</code> advice. | |||
*/ | |||
public Type extraType() { | |||
FormalDec fd = adviceDec().getExtraFormal(); | |||
if (fd != null) { | |||
return TypeImpl.getInstance(fd.getType()); | |||
} | |||
return null; | |||
} | |||
/** | |||
* Returns a Collection of CodeDocImpl representing the | |||
* crosscuts the underlying TypeDec declares. | |||
* | |||
* @return a Collection of CodeDocImpl representing the | |||
* crosscuts the underlying TypeDec declares. | |||
*/ | |||
private Collection createCrosscuts() { | |||
Set affects = ajc().getCorrespondences().getAffects(adviceDec()); | |||
if (affects.size() < 1) return Collections.EMPTY_LIST; | |||
List list = new ArrayList(); | |||
for (Iterator i = affects.iterator(); i.hasNext();) { | |||
Object o = i.next(); | |||
if (o instanceof CodeDec) { | |||
CodeDec cdec = (CodeDec)o; | |||
TypeDec owner = ((NameType)cdec.getDeclaringType()).getTypeDec(); | |||
ClassDocImpl cd = ClassDocImpl.getInstance(owner); | |||
CodeDocImpl cdoc = cd.docForDec(cdec); | |||
if (cdoc != null) { // todo: silent introduced members | |||
list.add(cdoc); | |||
} | |||
} | |||
} | |||
return list; | |||
} | |||
/** | |||
* Returns the simple name of this advice. Need to override | |||
* this so we don't print afterThrowing or afterReturning. | |||
* | |||
* @return one of after, before, around. | |||
*/ | |||
public String name() { | |||
if (isThrowing() || isReturning()) return "after"; | |||
return super.name(); | |||
} | |||
} |
@@ -1,384 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.compiler.base.CompilerErrors; | |||
import org.aspectj.compiler.base.ExitRequestException; | |||
import org.aspectj.compiler.base.InternalCompilerError; | |||
import com.sun.javadoc.RootDoc; | |||
import java.io.FileNotFoundException; | |||
import java.io.IOException; | |||
import java.io.PrintWriter; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
/** | |||
* Front-end for ajdoc. | |||
* | |||
*/ | |||
public class Ajdoc extends AjdocCompiler { | |||
private final static int VERBOSE = 1; | |||
private final static int WARNINGS = 4; | |||
private DocletProxy docletProxy; | |||
private RootDocMaker rootDocMaker; | |||
private String source = null; | |||
private String extdirs = null; | |||
private String locale = null; | |||
private String encoding = null; | |||
private String sourcepath = null; | |||
private String classpath = null; | |||
private String bootclasspath = null; | |||
private int verbosity = WARNINGS; | |||
private List filenamesAndPackages = new ArrayList(); | |||
private List options = new ArrayList(); | |||
public Ajdoc(String programName) { | |||
super(programName); | |||
} | |||
public Ajdoc() { | |||
this("ajdoc"); | |||
} | |||
/** | |||
* Programmatic entry into this compiler that | |||
* uses the error printer to catch internal errors. | |||
* | |||
* @param args Command line arguments. | |||
* @return <code>0</code> for a successful document. | |||
*/ | |||
public int execute(String[] args) { | |||
try { | |||
return doc(args) && err.getNumErrors() == 0 ? 0 : 1; | |||
} catch (ExitRequestException exit) { | |||
return exit.getValue(); | |||
} catch (CompilerErrors err) { | |||
return err.errors; // report error already printed by ajc | |||
} catch (InternalCompilerError error) { // cf ajc.Main | |||
handleInternalError(error.uncaughtThrowable); | |||
error.showWhere(new PrintWriter(System.err)); | |||
return -2; | |||
} catch (Exception e) { | |||
e.printStackTrace(System.err); | |||
err.internalError("internal_msg", e); | |||
return 1; | |||
} | |||
} | |||
/** copied from ajc.Main */ | |||
public void handleInternalError(Throwable uncaughtThrowable) { | |||
System.err.println("An internal error occured in Ajdoc invocation of AspectJ-" | |||
+getCompiler().getVersion()); | |||
System.err.println(uncaughtThrowable.toString()); | |||
uncaughtThrowable.printStackTrace(System.err); | |||
System.err.println(); | |||
} | |||
/** | |||
* Programmatic entry into this compiler that | |||
* doesn't use the error printer to catch internal errors. | |||
* | |||
* @param args Command line arguments. | |||
* @return <code>true</code> for a succesful run. | |||
*/ | |||
public boolean doc(String[] args) { | |||
long start = System.currentTimeMillis(); | |||
if (args == null) { | |||
err.error("internal_error", "Arguments cannot be null"); | |||
return false; | |||
} | |||
try { | |||
args = expandAndCreateDoclet(args); | |||
} catch (FileNotFoundException e) { | |||
err.error("file_not_found_exception", e.getMessage()); | |||
return false; | |||
} catch (IOException e) { | |||
err.error("io_exception", e.getMessage()); | |||
return false; | |||
} | |||
for (int i = 0; i < args.length;) { | |||
String arg = args[i++]; | |||
if (arg.equals("-overview")) { | |||
set(args, i++); | |||
} else if (arg.equals("-public")) { | |||
set(arg); | |||
if (filter != null) { | |||
err.error("argument_already_seen", arg); | |||
} else { | |||
setFilter(AccessChecker.PUBLIC, arg); | |||
} | |||
} else if (arg.equals("-protected")) { | |||
set(arg); | |||
if (filter != null) { | |||
err.error("argument_already_seen", arg); | |||
} else { | |||
setFilter(AccessChecker.PROTECTED, arg); | |||
} | |||
} else if (arg.equals("-package")) { | |||
set(arg); | |||
if (filter != null) { | |||
err.error("argument_already_seen", arg); | |||
} else { | |||
setFilter(AccessChecker.PACKAGE, arg); | |||
} | |||
} else if (arg.equals("-private")) { | |||
set(arg); | |||
if (filter != null) { | |||
err.error("argument_already_seen", arg); | |||
} else { | |||
setFilter(AccessChecker.PRIVATE, arg); | |||
} | |||
} else if (arg.equals("-help")) { | |||
usage(0); | |||
} else if (arg.equals("-sourcepath")) { | |||
if (sourcepath != null) { | |||
usage("argument_already_seen", arg); | |||
} | |||
sourcepath = set(args, i++); | |||
}else if (arg.equals("-classpath")) { | |||
if (classpath != null) { | |||
usage("argument_already_seen", arg); | |||
} | |||
classpath = set(args, i++); | |||
}else if (arg.equals("-bootclasspath")) { | |||
if (bootclasspath != null) { | |||
usage("argument_already_seen", arg); | |||
} | |||
bootclasspath = set(args, i++); | |||
}else if (arg.equals("-source")) { | |||
if (source != null) { | |||
usage("argument_already_seen", arg); | |||
} | |||
source = set(args, i++); | |||
} else if (arg.equals("-extdirs")) { | |||
if (extdirs != null) { | |||
usage("argument_already_seen", arg); | |||
} | |||
extdirs = set(args, i++); | |||
} else if (arg.equals("-verbose")) { | |||
set(arg); | |||
verbosity |= VERBOSE; | |||
} else if (arg.equals("-locale")) { | |||
if (locale != null) { | |||
usage("argument_already_seen", arg); | |||
} | |||
set(args, i++); | |||
} else if (arg.equals("-encoding")) { | |||
if (encoding != null) { | |||
usage("argument_already_seen", arg); | |||
} | |||
encoding = set(args, i++); | |||
} else if (arg.equals("-compiler")) { | |||
err.warning("usage_help", "-compiler option ignored"); | |||
} else if (arg.equals("-debug")) { | |||
err.warning("usage_help", "-debug option disabled"); | |||
} else if (arg.startsWith("-J")) { // todo unsupported? | |||
if (arg.length() == 2) continue; | |||
String rest = arg.substring(2); | |||
int ieq = rest.indexOf('='); | |||
String key, val; | |||
if (ieq != -1) { | |||
key = rest.substring(0, ieq); | |||
val = rest.substring(ieq+1); | |||
} else { | |||
key = rest; | |||
val = ""; | |||
} | |||
System.setProperty(key, val); | |||
} else if (arg.startsWith("-")) { | |||
int optionLength = docletProxy.optionLength(arg); | |||
if (optionLength < 0) { | |||
exit(); | |||
} else if (optionLength == 0) { | |||
usage("invalid_flag", arg); | |||
} else if (optionLength > args.length) { | |||
usage("requires_argument", arg, optionLength+""); | |||
} else { | |||
List iargs = new ArrayList(); | |||
iargs.add(arg); | |||
for (int j = 0; j < optionLength-1; j++) { | |||
iargs.add(args[i++]); | |||
} | |||
set((String[])iargs.toArray(new String[iargs.size()])); | |||
} | |||
} else { | |||
filenamesAndPackages.add(arg); | |||
} | |||
} | |||
if (locale == null) { | |||
locale = ""; | |||
} | |||
if (sourcepath == null) { | |||
sourcepath = "."; | |||
} | |||
try { | |||
if (!docletProxy.validOptions(options, err)) { | |||
exit(1); | |||
} | |||
} catch (IOException e) { | |||
e.printStackTrace(System.err); | |||
err.internalError("internal_msg", e); | |||
return false; | |||
} | |||
if (filenamesAndPackages.size() < 1) { | |||
usage("No_packages_or_classes_specified"); | |||
return false; | |||
} | |||
RootDoc rootDoc = null; | |||
boolean good = true; | |||
try { | |||
rootDoc = makeRootDoc(sourcepath, | |||
classpath, | |||
bootclasspath, | |||
extdirs, | |||
verbosity, | |||
encoding, | |||
locale, | |||
source, | |||
filenamesAndPackages, | |||
options, | |||
err, | |||
programName, | |||
getFilter()); | |||
} catch (CannotMakeRootDocException e) { | |||
err.error("cant_create_root_doc_ex", "AjdocCompiler", e.getMessage()); | |||
exit(1); | |||
good = false; | |||
} | |||
good &= rootDoc != null; | |||
if (good) { | |||
err.notice("generating_docs"); | |||
try { | |||
good &= docletProxy.start(rootDoc); | |||
} catch (IOException e) { | |||
e.printStackTrace(System.err); | |||
err.internalError("internal_msg", e); | |||
return false; | |||
} | |||
} | |||
if ((verbosity & VERBOSE) != 0) { | |||
err.notice("done_in", Long.toString(System.currentTimeMillis()-start)); | |||
} | |||
return good; | |||
} | |||
private void usage(String key, String s0, String s1) { | |||
err.error(key, s0, s1); | |||
usage(1); | |||
} | |||
private void usage(String key, String s0) { | |||
usage(key,s0,""); | |||
} | |||
private void usage(String key) { | |||
usage(key,""); | |||
} | |||
private void usage() { | |||
err.notice("usage_help", programName); | |||
if (docletProxy != null) { docletProxy.optionLength("-help"); } | |||
} | |||
private void usage(int exit) { | |||
usage(); | |||
exit(exit); | |||
} | |||
protected String[] expandAndCreateDoclet(String[] args) throws IOException { | |||
List list = new ArrayList(); | |||
docletProxy = DocletProxy.DEFAULT; | |||
for (int i = 0; i < args.length;) { | |||
String arg = args[i++]; | |||
if (arg == null || arg.length() < 1) continue; | |||
if (arg.charAt(0) == '@') { | |||
expandAtFile(arg.substring(1), list); | |||
} else if (arg.equals("-argfile")) { | |||
if (check(args, i)) { | |||
expandAtFile(args[i++], list); | |||
} | |||
} else if (arg.equals("-doclet")) { | |||
err.warning("usage_help", "-doclet option ignored"); | |||
} else if (arg.equals("-docletpath")) { | |||
err.warning("usage_help", "-docletpath option ignored"); | |||
} else if (arg.equals("-standard")) { | |||
docletProxy = DocletProxy.STANDARD; | |||
} else { | |||
list.add(arg); | |||
} | |||
} | |||
return (String[])list.toArray(new String[list.size()]); | |||
} | |||
private static boolean check(String[] args, int i) { | |||
return i >= 0 && i < args.length; | |||
} | |||
private String set(String[] args, int i) { | |||
String arg = null; | |||
if (check(args, i)) { | |||
arg = args[i]; | |||
set(args[i-1], arg); | |||
} else { | |||
err.internalError("internal_error", | |||
new ArrayIndexOutOfBoundsException(i)); | |||
} | |||
return arg; | |||
} | |||
private void set(String opt) { | |||
set(new String[]{opt}); | |||
} | |||
private void set(String opt, String arg) { | |||
set(new String[]{opt, arg}); | |||
} | |||
private void set(String[] opts) { | |||
options.add(opts); | |||
} | |||
protected void internalCompile(List filenames) { | |||
super.internalCompile(filenames); | |||
} | |||
private final void exit() { | |||
exit(0); | |||
} | |||
private void exit(int exit) { | |||
throw new ExitRequestException(exit); | |||
} | |||
private static String classname(Object o) { | |||
return o != null ? o.getClass().getName() : "null"; | |||
} | |||
} |
@@ -1,605 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.compiler.base.AbstractCompilerPass; | |||
import org.aspectj.compiler.base.ErrorHandler; | |||
import org.aspectj.compiler.base.ast.CompilationUnit; | |||
import org.aspectj.compiler.base.ast.Dec; | |||
import org.aspectj.compiler.base.ast.Decs; | |||
import org.aspectj.compiler.base.ast.TypeDec; | |||
import org.aspectj.compiler.base.ast.World; | |||
import org.aspectj.compiler.crosscuts.AspectJCompiler; | |||
import com.sun.javadoc.DocErrorReporter; | |||
import com.sun.javadoc.RootDoc; | |||
import java.io.BufferedReader; | |||
import java.io.File; | |||
import java.io.FileFilter; | |||
import java.io.FileReader; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.HashMap; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import java.util.StringTokenizer; | |||
/** | |||
* Extension of the AspectJCompiler to provide | |||
* functionality for creating documentation. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public class AjdocCompiler extends AspectJCompiler implements RootDocMaker { | |||
/** The name of the program. */ | |||
protected final String programName; | |||
/** The error printer we use. */ | |||
protected final ErrPrinter err; | |||
/** | |||
* Construct a new ajdoc compile with the | |||
* error handler <code>errorHandler</code> and | |||
* name <code>programName</code> | |||
* | |||
* @param errorHandler the error handler. | |||
* @param programName the name of the program. | |||
*/ | |||
public AjdocCompiler(ErrorHandler errorHandler, String programName) { | |||
super(errorHandler); | |||
getOptions().preprocess = true; | |||
getOptions().nocomments = true; | |||
(errorHandler = err = | |||
new ErrPrinter(this.programName = programName)). | |||
setCompiler(this); | |||
} | |||
/** | |||
* Construct a new ajdoc compile with the | |||
* name <code>programName</code>. | |||
* | |||
* @param programName the name of the program. | |||
*/ | |||
public AjdocCompiler(String programName) { | |||
this(null, programName); | |||
} | |||
/** | |||
* Returns the ErrPrinter currently used. | |||
* | |||
* @return the ErrPrinter currently used. | |||
*/ | |||
public ErrPrinter err() { | |||
return err; | |||
} | |||
/** The packages found on the command line. */ | |||
private Set pkgnames = new HashSet(); | |||
/** The classes found on the command line and from files. */ | |||
private Set classnames = new HashSet(); | |||
/** The source files on the command line. */ | |||
private Set files = new HashSet(); | |||
/** The list of source files to compile. */ | |||
protected final List srcfiles = new ArrayList(); | |||
/** The list of filenames that came from user-specified source files. */ | |||
protected List srcSrcfilenames = new ArrayList(); | |||
/** The list of filenames that came from user-specified packages. */ | |||
protected List pkgSrcfilenames = new ArrayList(); | |||
/** The list of filenames that came from user-specified classes. */ | |||
protected List clsSrcfilenames = new ArrayList(); | |||
/** The source path with which to search. */ | |||
protected final List sourcepaths = new ArrayList(); | |||
{ | |||
sourcepaths.add(new File(".")); | |||
} | |||
/** The list of filenames that came from user-specified classes. */ | |||
protected AccessChecker filter; | |||
/** | |||
* Create the RootDoc. | |||
*/ | |||
public RootDoc makeRootDoc(String sourcepath, | |||
String classpath, | |||
String bootclasspath, | |||
String extdirs, | |||
long flags, | |||
String encoding, | |||
String locale, | |||
String source, | |||
List filenamesAndPackages, | |||
List options, | |||
DocErrorReporter err, | |||
String programName, | |||
AccessChecker filter) | |||
throws CannotMakeRootDocException { | |||
if ((null != filter) && (this.filter != filter)) { | |||
this.filter = filter; | |||
} | |||
if (null == this.filter) { | |||
this.filter = AccessChecker.PROTECTED; | |||
} | |||
if (classpath != null) { | |||
getOptions().classpath = classpath; | |||
} | |||
if (bootclasspath != null) { | |||
getOptions().bootclasspath = bootclasspath; | |||
} | |||
if (extdirs != null) { | |||
getOptions().extdirs = extdirs; | |||
} | |||
if (source != null) { | |||
getOptions().source = source; | |||
} | |||
resolveSourcePath(sourcepath); | |||
resolveFilesAndPackages(filenamesAndPackages); | |||
Collections.sort(pkgSrcfilenames); | |||
Collections.sort(clsSrcfilenames); | |||
Collections.sort(srcSrcfilenames); | |||
srcfiles.addAll(pkgSrcfilenames); | |||
srcfiles.addAll(clsSrcfilenames); | |||
srcfiles.addAll(srcSrcfilenames); | |||
err().notice("starting_internal_compile"); | |||
for (Iterator i = options.iterator(); i.hasNext();) { | |||
String[] opts = (String[])i.next(); | |||
if (opts.length == 1) { | |||
if (opts[0].equals("-verbose")) { | |||
getOptions().verbose = true; | |||
} | |||
} else if (opts.length == 2) { | |||
if (opts[0].equals("-classpath")) { | |||
getOptions().classpath = opts[1]; | |||
} else if (opts[1].equals("-bootclasspath")) { | |||
getOptions().bootclasspath = opts[1]; | |||
} else if (opts[1].equals("-extdirs")) { | |||
getOptions().extdirs = opts[1]; | |||
} | |||
} | |||
} | |||
// Compile the srcfiles - have to add passes first | |||
addPasses(); | |||
internalCompile(srcfiles); | |||
// This is the world with which we create the root | |||
World world = getWorld(); | |||
// Add all the classes found in the source files | |||
// to the list of specified classnames | |||
for (Iterator i = world.getCompilationUnits().iterator(); | |||
i.hasNext();) { | |||
Decs decs = ((CompilationUnit)i.next()).getDecs(); | |||
for (int j = 0, N = decs.size(); j < N; j++) { | |||
Dec dec = decs.get(j); | |||
if (dec instanceof TypeDec) { | |||
classnames.add(((TypeDec)dec).getFullName()); | |||
} | |||
} | |||
} | |||
// Initialize and return the root created | |||
// from the our world | |||
err().notice("creating_root"); | |||
RootDoc result = init(this, (String[][])options.toArray | |||
(new String[options.size()][])); | |||
// do another pass at RootDoc after constructed | |||
com.sun.javadoc.ClassDoc[] cds = result.classes(); | |||
for (int i = 0; i < cds.length; i++) { | |||
if (cds[i] instanceof ClassDocImpl) { | |||
ClassDocImpl cd = (ClassDocImpl) cds[i]; | |||
cd.postProcess(); | |||
} | |||
} | |||
return result; | |||
} | |||
private static AjdocCompiler instance; | |||
{ instance = this; } | |||
public static AjdocCompiler instance() { | |||
return instance; | |||
} | |||
/** | |||
* The entry point to initialize a world created | |||
* from an AspectJCompiler. | |||
* | |||
* @param ajc the compiler. | |||
* @param options the ajdoc options. | |||
* @return a RootDocImpl representing the | |||
* documentation tree. | |||
*/ | |||
public static RootDocImpl init(AspectJCompiler ajc, String[][] options) { | |||
if (ajc == null) return null; //TODO: make empty | |||
World world = ajc.getWorld(); | |||
Collection classnames = null; | |||
Collection pkgnames = null; | |||
if (ajc instanceof AjdocCompiler) { | |||
AjdocCompiler ajdoc = (AjdocCompiler)ajc; | |||
pkgnames = ajdoc.pkgnames; | |||
classnames = ajdoc.classnames; | |||
} | |||
PackageDocImpl.init(ajc); | |||
AccessChecker filter = AccessChecker.PUBLIC; | |||
if (ajc instanceof AjdocCompiler) { | |||
filter = ((AjdocCompiler) ajc).getFilter(); | |||
} | |||
RootDocImpl root = new RootDocImpl(world, | |||
options, | |||
pkgnames, | |||
classnames, | |||
filter); | |||
return root; | |||
} | |||
/** set filter associated with this compiler */ | |||
protected void setFilter(AccessChecker filter, String arg) { | |||
this.filter = filter; | |||
} | |||
/** get filter associated with this compiler */ | |||
public final AccessChecker getFilter() { | |||
return filter; | |||
} | |||
protected final void expandAtFile(String filename, | |||
List args) throws IOException { | |||
BufferedReader in = new BufferedReader(new FileReader(filename)); | |||
String dirfile = new File(filename).getParent(); | |||
File basedir = new File(null == dirfile ? "." : dirfile ) ; | |||
String line; | |||
while ((line = in.readLine()) != null) { | |||
if (line == null || line.length() < 1) continue; | |||
line = line.trim(); | |||
if (line.startsWith("//")) continue; | |||
if (line.startsWith("#")) continue; | |||
if (line.startsWith("@")) { | |||
line = line.substring(1); | |||
File newfile = new File(line); | |||
newfile = newfile.isAbsolute() ? | |||
newfile : new File(basedir, line); | |||
expandAtFile(newfile.getPath(), args); | |||
} else { | |||
File newfile = new File(line); | |||
newfile = newfile.isAbsolute() ? | |||
newfile : new File(basedir, line); | |||
if (newfile.exists()) { | |||
boolean result = maybeAdd(newfile, args); | |||
if (!result) { | |||
// we only support valid filenames, not options | |||
cantResolve(newfile); | |||
} | |||
} else { | |||
boolean addedFile = false; | |||
FileFilter filter = null; | |||
String name = newfile.getName().trim(); | |||
if (name.equals("*.java")) { | |||
filter = new FileFilter() { | |||
public boolean accept(File f) { | |||
return f != null && | |||
f.getName().endsWith(".java"); | |||
} | |||
}; | |||
} else if (name.equals("*.aj")) { | |||
filter = new FileFilter() { | |||
public boolean accept(File f) { | |||
return f != null && | |||
f.getName().endsWith(".java"); | |||
} | |||
}; | |||
} else if (name.equals("*")) { | |||
filter = new FileFilter() { | |||
public boolean accept(File f) { | |||
return f != null && | |||
(f.getName().endsWith(".java") | |||
|| f.getName().endsWith(".aj")); | |||
} | |||
}; | |||
} | |||
if (null != filter) { | |||
File parentDir = newfile.getParentFile(); | |||
File[] javafiles = parentDir.listFiles(filter); | |||
if (javafiles != null) { | |||
for (int i = 0; i < javafiles.length; i++) { | |||
if (maybeAdd(javafiles[i], args)) { | |||
if (!addedFile) addedFile = true; | |||
} else { | |||
cantResolve(javafiles[i]); | |||
} | |||
} | |||
} | |||
} | |||
if (!addedFile) { | |||
if (isValidPkg(line)) { | |||
args.add(line); | |||
} else { | |||
cantResolve(newfile); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
in.close(); | |||
} | |||
protected final void cantResolve(File f) { | |||
err().error("cant_resolve_file", f.getAbsolutePath()); | |||
} | |||
private void resolveSourcePath(String sourcepath) { | |||
if (sourcepath != null) { | |||
sourcepaths.remove(0); | |||
for (StringTokenizer t = new StringTokenizer(sourcepath, | |||
File.pathSeparator); | |||
t.hasMoreTokens();) { | |||
File path = new File(t.nextToken().trim()); | |||
if (path.exists() && path.isDirectory()) { | |||
sourcepaths.add(path); | |||
} | |||
} | |||
// TODO: don't want this, I think ???? | |||
//sourcepaths.add(new File(".")); | |||
} | |||
} | |||
private void resolveFilesAndPackages(List filenamesAndPackages) { | |||
Collection pkgnamesFromCmd = new HashSet(); | |||
for (Iterator i = filenamesAndPackages.iterator(); i.hasNext();) { | |||
String str = (String)i.next(); | |||
File file = new File(str); | |||
if (/*file.isAbsolute() &&*/ maybeAdd(file, srcSrcfilenames)) { | |||
addFile(file); | |||
continue; | |||
} else { | |||
for (Iterator j = sourcepaths.iterator(); j.hasNext();) { | |||
File sourcepath = (File)j.next(); | |||
file = new File(sourcepath, str); | |||
if (maybeAdd(file, srcSrcfilenames)) { | |||
addFile(file); | |||
continue; | |||
} | |||
} | |||
} | |||
pkgnamesFromCmd.add(str); | |||
} | |||
for (Iterator i = pkgnamesFromCmd.iterator(); i.hasNext();) { | |||
resolvePackageOrClass((String)i.next()); | |||
} | |||
} | |||
private void resolvePackageOrClass(String pkgOrClassName) { | |||
boolean recurse; | |||
String pkgOrClass = | |||
(recurse = (pkgOrClassName.endsWith(".*"))) ? | |||
pkgOrClassName.substring(0, pkgOrClassName.length()-2) : | |||
pkgOrClassName; | |||
for (Iterator i = sourcepaths.iterator(); i.hasNext();) { | |||
File sourcepath = (File)i.next(); | |||
File possiblePkg = new File(sourcepath, | |||
pkgOrClass.replace | |||
('.', File.separatorChar)); | |||
if (possiblePkg.exists() && possiblePkg.isDirectory()) { | |||
if (recurse) { | |||
File[] dirs = possiblePkg.listFiles | |||
(new FileFilter() { | |||
public boolean accept(File f) { | |||
return f != null && f.isDirectory(); | |||
} | |||
}); | |||
for (int j = 0; j < dirs.length; j++) { | |||
String pkgname = pkgOrClass + '.' + dirs[j].getName(); | |||
resolvePackageOrClass(pkgname + ".*"); | |||
} | |||
} | |||
File[] javafiles = possiblePkg.listFiles | |||
(new FileFilter() { | |||
public boolean accept(File f) { | |||
return f != null && !f.isDirectory(); | |||
} | |||
}); | |||
if (javafiles.length > 0) { | |||
pkgnames.add(pkgOrClass); | |||
} | |||
boolean addedPkg = false; | |||
for (int j = 0; j < javafiles.length; j++) { | |||
if (maybeAdd(javafiles[j], pkgSrcfilenames) && !addedPkg) { | |||
addPkg(pkgOrClass, javafiles[j]); | |||
addedPkg = true; | |||
} | |||
} | |||
break; | |||
} else { | |||
String pkgname = ""; | |||
String classname = pkgOrClass; | |||
int ilastdot = pkgOrClass.lastIndexOf('.'); | |||
if (ilastdot != -1) { | |||
pkgname = pkgOrClass.substring(0, ilastdot). | |||
replace('.', File.separatorChar) + File.separatorChar; | |||
classname = pkgOrClass.substring(ilastdot+1); | |||
} | |||
File file = new File(sourcepath, | |||
pkgname + classname + ".java"); | |||
if (maybeAdd(file, clsSrcfilenames)) { | |||
addClass(pkgOrClass, file); | |||
break; | |||
} | |||
} | |||
} | |||
} | |||
protected final File findFile(String filename, boolean isDir) { | |||
for (Iterator i = sourcepaths.iterator(); i.hasNext();) { | |||
File sourcepath = (File)i.next(); | |||
File file = new File(sourcepath, filename); | |||
if (file.exists() && !(isDir ^ file.isDirectory())) { | |||
return file; | |||
} | |||
} | |||
return null; | |||
} | |||
protected static boolean maybeAddPkg(String pkgname, | |||
Collection pkgnames) { | |||
if (isValidPkg(pkgname)) { | |||
pkgnames.add(pkgname); | |||
return true; | |||
} | |||
return false; | |||
} | |||
protected final Map filesToClassnames = new HashMap(); | |||
protected final void addClass(String classname, File file) { | |||
if (!(maybeAddClass(classname))) { | |||
err().error("invalid_class_name", classname); | |||
} else { | |||
filesToClassnames.put(file.getAbsoluteFile(), classname); | |||
} | |||
} | |||
protected final boolean maybeAddClass(String classname) { | |||
return maybeAddClass(classname, classnames); | |||
} | |||
protected static boolean maybeAddClass(String classname, | |||
Collection classnames) { | |||
if (isValidClass(classname)) { | |||
classnames.add(classname); | |||
return true; | |||
} | |||
return false; | |||
} | |||
protected final static boolean isValidClass(String classname) { | |||
return isValidPkg(classname); | |||
} | |||
protected final Map filesToPkgnames = new HashMap(); | |||
protected final void addPkg(String pkgname, File file) { | |||
if (!maybeAddPkg(pkgname)) { | |||
err().error("invalid_package_name", pkgname); | |||
} else { | |||
filesToPkgnames.put(file.getAbsoluteFile(), pkgname); | |||
} | |||
} | |||
protected final boolean maybeAddPkg(String pkgname) { | |||
return maybeAddPkg(pkgname, pkgnames); | |||
} | |||
protected final Map filesToFilenames = new HashMap(); | |||
protected final void addFile(File file) { | |||
files.add(file); | |||
filesToFilenames.put(file.getAbsoluteFile(), file.getAbsolutePath()); | |||
} | |||
protected static boolean maybeAdd(File file, Collection files) { | |||
if (isValidJavaFile(file)) { | |||
files.add(file.getAbsolutePath()); | |||
return true; | |||
} | |||
return false; | |||
} | |||
protected final static boolean isValidJavaFile(File file) { | |||
return file != null && file.exists() && !file.isDirectory() | |||
&& (file.getName().endsWith(".java") | |||
|| file.getName().endsWith(".aj")) ; | |||
} | |||
protected final static boolean isValidPkg(String pkgname) { | |||
if (pkgname == null) { | |||
return false; | |||
} | |||
if (pkgname.length() < 1) { | |||
return true; | |||
} | |||
if (!Character.isJavaIdentifierStart(pkgname.charAt(0))) { | |||
return false; | |||
} | |||
for (int i = 1; i < pkgname.length(); i++) { | |||
char c = pkgname.charAt(i); | |||
if (c == '.' && i == pkgname.length()-1) { | |||
return false; | |||
} | |||
if (!(c == '.' || Character.isJavaIdentifierPart(c))) { | |||
return false; | |||
} | |||
} | |||
return true; | |||
} | |||
protected void loading(CompilationUnit cu) { | |||
File srcfile = cu.getSourceFile().getAbsoluteFile(); | |||
String pkgname, classname, filename; | |||
if ((pkgname = (String)filesToPkgnames.get(srcfile))!= null) { | |||
AjdocCompiler.this.err().notice | |||
("Loading_source_files_for_package", pkgname); | |||
} else if ((classname = (String)filesToClassnames.get(srcfile)) != null) { | |||
AjdocCompiler.this.err().notice | |||
("Loading_source_file_for_class", classname); | |||
} else if ((filename = (String)filesToFilenames.get(srcfile)) != null) { | |||
AjdocCompiler.this.err().notice | |||
("Loading_source_file", filename); | |||
} | |||
} | |||
protected AbstractCompilerPass createParserPass() { | |||
return new PrintingParserPass(this); | |||
} | |||
protected static class PrintingParserPass extends AspectJCompiler.ParserPass { | |||
public PrintingParserPass(AjdocCompiler jc) { super(jc); } | |||
public void transform(CompilationUnit cu) { | |||
((AjdocCompiler)getCompiler()).loading(cu); | |||
super.transform(cu); | |||
} | |||
} | |||
protected void addPasses() { | |||
passes = new ArrayList(); | |||
addPreSymbolPasses(); | |||
} | |||
} |
@@ -1,300 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.ajdoc.AdviceDoc; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import org.aspectj.ajdoc.IntroductionDoc; | |||
import org.aspectj.ajdoc.OfClauseDoc; | |||
import org.aspectj.compiler.base.ast.Decs; | |||
import org.aspectj.compiler.crosscuts.ast.AdviceDec; | |||
import org.aspectj.compiler.crosscuts.ast.AspectDec; | |||
import org.aspectj.compiler.crosscuts.ast.IntroducedSuperDec; | |||
import com.sun.javadoc.ClassDoc; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
public class AspectDocImpl extends ClassDocImpl implements AspectDoc { | |||
/** Array of AdviceDoc created from this AspectDecs AdviceDecs. */ | |||
private final Collection advice; | |||
/** Array of IntroductionDec created from this AspectDecs introductions. */ | |||
private final Collection introductions; | |||
/** The of clause this aspect has -- may be null. */ | |||
private final OfClauseDoc ofClause; | |||
/** The aspects that dominate this aspect. */ | |||
private final Collection dominators = new ArrayList(); | |||
/** The aspects that are dominated by this aspect. */ | |||
private final Collection dominatees = new ArrayList(); | |||
/** | |||
* Constructs an AspectDoc with the containing ClassDoc | |||
* and underlying AspectDec. | |||
* | |||
* @param containingClass contained ClassDoc. | |||
* @param aspectDec underlying AspectDec. | |||
*/ | |||
public AspectDocImpl(ClassDoc containingClass, AspectDec aspectDec) { | |||
super(containingClass, aspectDec); | |||
introductions = createIntroductions(); | |||
advice = createAdvice(); | |||
ofClause = createOfClause(); | |||
} | |||
/** | |||
* Returns an instance of AdviceDocImpl corresponding to | |||
* the AdviceDec passed in. | |||
* | |||
* @param dec the AdviceDec mapping to the desired | |||
* AdviceDocImpl. | |||
* @return an instance of AdviceDocImpl corresponding to | |||
* the AdviceDec passed in. | |||
*/ | |||
public AdviceDocImpl docForDec(AdviceDec dec) { | |||
for (Iterator i = advice.iterator(); i.hasNext();) { | |||
AdviceDocImpl ad = (AdviceDocImpl)i.next(); | |||
if (ad.dec() == dec) return ad; | |||
} | |||
return null; | |||
} | |||
/** | |||
* Returns an instance of IntroducedSuperDocImpl corresponding to | |||
* the IntroducedSuperDec passed in. | |||
* | |||
* @param dec the IntroducedSuperDec mapping to the | |||
* desired IntroducedSuperDocImpl | |||
* @return an instance of IntroducedSuperDocImpl | |||
* corresponding to the IntroducedSuperDec | |||
* passed in. | |||
*/ | |||
public IntroducedSuperDocImpl introDocForDec(IntroducedSuperDec dec) { | |||
for (Iterator i = introductions.iterator(); i.hasNext();) { | |||
ProgramElementDocImpl id = (ProgramElementDocImpl)i.next(); | |||
if (id.dec() == dec) return (IntroducedSuperDocImpl)id; | |||
} | |||
return null; | |||
} | |||
/** | |||
* Returns the underlying AspectDec. | |||
* | |||
* @return the underlying AspectDec. | |||
*/ | |||
protected AspectDec aspectDec() { | |||
return (AspectDec)typeDec(); | |||
} | |||
/** | |||
* Returns the visible advice in this aspect. | |||
* | |||
* @return an array of AdviceDoc representing the | |||
* visible advice in this aspect. | |||
*/ | |||
public AdviceDoc[] advice() { | |||
return (AdviceDocImpl[])advice.toArray | |||
(new AdviceDocImpl[advice.size()]); | |||
} | |||
/** | |||
* Returns the aspects that are dominated by this aspect. | |||
* | |||
* @return an array of AspectDec representing the aspects | |||
* that are dominated by this aspect. | |||
*/ | |||
public AspectDoc[] dominatees() { | |||
return (AspectDoc[])dominatees.toArray | |||
(new AspectDoc[dominatees.size()]); | |||
} | |||
/** | |||
* Return the aspects that dominate this aspect. | |||
* | |||
* @return an array of AspectDoc representing the aspects | |||
* that dominate this aspect. | |||
*/ | |||
public AspectDoc[] dominators() { | |||
return (AspectDoc[])dominators.toArray | |||
(new AspectDoc[dominators.size()]); | |||
} | |||
/** | |||
* TODO | |||
* Returns the visible introductions of this aspect. | |||
* | |||
* @return an array of IntroductionDoc representing the | |||
* visible introductions in this aspect. | |||
*/ | |||
public IntroductionDoc[] introductions() { | |||
return (IntroductionDocImpl[])introductions.toArray | |||
(new IntroductionDocImpl[introductions.size()]); | |||
} | |||
/** | |||
* Returns the <i>of clause</i> of this aspect. | |||
* | |||
* @return the <i>of clause</i> of this aspect. | |||
*/ | |||
public OfClauseDoc ofClause() { | |||
return ofClause; | |||
} | |||
/** | |||
* Returns <code>true</code>. | |||
* | |||
* @return <code>true</code>. | |||
*/ | |||
public boolean isAspect() { | |||
return true; | |||
} | |||
/** | |||
* Returns <code>true</code> if this aspects dominates | |||
* the passed in aspect. | |||
* | |||
* @param other an AspectDoc that represents another | |||
* aspect in this world. | |||
* @return <code>true</code> if this aspects dominates | |||
* the passed in aspect. | |||
*/ | |||
public boolean dominates(AspectDoc other) { | |||
if (!(other instanceof AspectDocImpl)) { | |||
return false; | |||
} | |||
return aspectDec().dominates(((AspectDocImpl)other).aspectDec()); | |||
} | |||
/** | |||
* Adds a dominates relation from <code>dominator</code> to | |||
* <code>this</code>. For example, somewhere in the code | |||
* the line | |||
* <code> | |||
* aspect dominator dominates this { ... } | |||
* </code> | |||
* exists. | |||
* | |||
* @param dominator an instance of AspectDocImpl that | |||
* dominates this. | |||
*/ | |||
public void addDominator(AspectDoc dominator) { | |||
dominators.add(dominator); | |||
} | |||
/** | |||
* Adds a dominates relation from <code>dominator</code> to | |||
* <code>this</code>. For example, somewhere in the code | |||
* the line | |||
* <code> | |||
* aspect this dominates dominatee { ... } | |||
* </code> | |||
* exists. | |||
* | |||
* @param dominatee an instance of AspectDocImpl that | |||
* is dominated by this. | |||
*/ | |||
public void addDominatee(AspectDoc dominatee) { | |||
dominatees.add(dominatee); | |||
} | |||
/** | |||
* Returns a Collection of IntroductionDocImpl representing | |||
* the introductions declared in this aspect. | |||
* | |||
* @return a Collection of IntroductionDocImpl representing | |||
* the introductions declared in this aspect. | |||
*/ | |||
private Collection createIntroductions() { | |||
Decs decs = aspectDec().getBody(); | |||
if (decs.size() < 1) return Collections.EMPTY_LIST; | |||
Collection list = new HashSet(); | |||
for (Iterator i = decs.getList().iterator(); i.hasNext();) { | |||
Object o = IntroductionDocImpl.getInstance(this, i.next()); | |||
if (o != null) list.add(o); | |||
} | |||
return list; | |||
} | |||
/** | |||
* Returns a Collection of AdviceDocImpl representing | |||
* the advice declared in this aspect. | |||
* | |||
* @return a Collection of AdviceDocImpl representing | |||
* the advice declared in this aspect. | |||
*/ | |||
private Collection createAdvice() { | |||
// pluck the AdviceDec from the list of JpPlannerMakers | |||
List decs = aspectDec().getJpPlannerMakers(); | |||
if (null != decs) { | |||
final int QUIT = 2; | |||
for (int tries = 0; tries < QUIT; tries++) { | |||
try { | |||
for (Iterator i = decs.iterator(); i.hasNext();) { | |||
Object o = i.next(); | |||
if (!(o instanceof AdviceDec)) { | |||
i.remove(); | |||
} | |||
} | |||
tries = QUIT; | |||
} catch (UnsupportedOperationException o) { | |||
if (0 != tries) { | |||
tries = QUIT; | |||
} else { | |||
ArrayList list = new ArrayList(); | |||
list.addAll(decs); | |||
decs = list; | |||
} | |||
} | |||
} | |||
} | |||
if ((null == decs) || (decs.size() < 1)) { | |||
return Collections.EMPTY_LIST; | |||
} | |||
List list = new ArrayList(); | |||
for (Iterator i = decs.iterator(); i.hasNext();) { | |||
list.add(new AdviceDocImpl(this, (AdviceDec)i.next())); | |||
} | |||
return list; | |||
} | |||
/** | |||
* Returns an instance of OfClauseDoc representing | |||
* the of clause declared by this aspect. | |||
* | |||
* @return an instance of OfClauseDoc representing | |||
* the of clause declared by this aspect. | |||
*/ | |||
private OfClauseDoc createOfClause() { | |||
return OfClauseDocImpl.getInstance(aspectDec().getPerClause()); | |||
} | |||
} |
@@ -1,72 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
/** | |||
* A simple wrapper exception to be thrown when we | |||
* can't make a RootDoc. | |||
* | |||
* @see RootDocMaker#makeRootDoc | |||
* @author Jeff Palm | |||
*/ | |||
public class CannotMakeRootDocException extends RuntimeException { | |||
/** | |||
* Constructs an empty exception. | |||
*/ | |||
public CannotMakeRootDocException() { | |||
super(); | |||
} | |||
/** | |||
* Constructs an exception with message <code>message</code> | |||
* and a <code>null</code> contained Throwable | |||
* | |||
* @param message Message to use. | |||
*/ | |||
public CannotMakeRootDocException(String message) { | |||
this(message, null); | |||
} | |||
/** | |||
* Constructs an exception with message <code>message</code> | |||
* an contained Throwable <code>throwable</code>. | |||
* | |||
* @param message Message to use. | |||
* @param throwable Throwable to use. | |||
*/ | |||
public CannotMakeRootDocException(String message, Throwable throwable) { | |||
super((message != null ? message : "") + | |||
(throwable != null ? ":" + throwable : "")); | |||
} | |||
/** | |||
* Constructs an exception with <code>null</code> message | |||
* an contained Throwable <code>throwable</code>. | |||
* | |||
* @param throwable Throwable to use. | |||
*/ | |||
public CannotMakeRootDocException(Throwable t) { | |||
this(null, t); | |||
} | |||
} |
@@ -1,82 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.compiler.base.ast.ASTObject; | |||
import org.aspectj.compiler.base.ast.CodeDec; | |||
import org.aspectj.compiler.base.ast.Dec; | |||
import org.aspectj.compiler.base.ast.DummySourceLocation; | |||
import org.aspectj.compiler.base.ast.Formals; | |||
import org.aspectj.compiler.base.ast.NameType; | |||
import org.aspectj.compiler.base.ast.SourceLocation; | |||
import org.aspectj.compiler.base.ast.TypeDec; | |||
import org.aspectj.compiler.base.ast.TypeDs; | |||
import org.aspectj.compiler.crosscuts.ast.AdviceDec; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Set; | |||
public abstract class CodeDocImpl extends ExecutableMemberDocImpl { | |||
/** The CodeDec to which we delegate. */ | |||
private final CodeDec codeDec; | |||
public CodeDocImpl(com.sun.javadoc.ClassDoc containingClass, CodeDec codeDec) { | |||
super(containingClass); | |||
this.codeDec = codeDec; | |||
} | |||
protected Collection createAdvice() { | |||
Set affectedBy = ajc().getCorrespondences().getAffectedBy(codeDec()); | |||
if (affectedBy.size() < 1) return Collections.EMPTY_LIST; | |||
List list = new ArrayList(); | |||
for (Iterator i = affectedBy.iterator(); i.hasNext();) { | |||
AdviceDec adec = (AdviceDec)i.next(); | |||
TypeDec owner = ((NameType)adec.getDeclaringType()).getTypeDec(); | |||
AspectDocImpl ad = (AspectDocImpl)ClassDocImpl.getInstance(owner); | |||
AdviceDocImpl adoc = ad.docForDec(adec); | |||
list.add(adoc); | |||
} | |||
return list; | |||
} | |||
protected Dec dec() { | |||
return codeDec(); | |||
} | |||
protected Formals getFormals() { | |||
return codeDec().getFormals(); | |||
} | |||
protected TypeDs getThrows() { | |||
return codeDec().getThrows(); | |||
} | |||
protected CodeDec codeDec() { | |||
return codeDec; | |||
} | |||
} | |||
@@ -1,336 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import com.sun.javadoc.Doc; | |||
import com.sun.javadoc.ParamTag; | |||
import com.sun.javadoc.SeeTag; | |||
import com.sun.javadoc.SerialFieldTag; | |||
import com.sun.javadoc.Tag; | |||
import com.sun.javadoc.ThrowsTag; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Locale; | |||
public class Comment { | |||
/** The parsed comment text. */ | |||
private String commentText; | |||
/** The raw comment text. */ | |||
private String rawCommentText; | |||
/** The list of tags. */ | |||
private List tags; | |||
/** The Doc to which the Comment belongs. */ | |||
private Doc doc; | |||
/** The Locale in which this comment resides. */ | |||
private Locale loc; | |||
/** The ErrPrinter used by this Comment to output messages. */ | |||
private ErrPrinter err; | |||
public Comment(Doc doc, String formalComment) { | |||
this(doc, formalComment, ErrPrinter.instance); | |||
} | |||
public Comment(Doc doc, String formalComment, ErrPrinter err) { | |||
this(doc, formalComment, err, Locale.US); | |||
} | |||
public Comment(Doc doc, String formalComment, ErrPrinter err, Locale loc) { | |||
this.rawCommentText = Util.rawCommentText(formalComment); | |||
this.commentText = Util.commentText(rawCommentText); | |||
this.doc = doc; | |||
this.err = err; | |||
this.loc = loc; | |||
} | |||
/** | |||
* Returns the parsed comment text. | |||
* | |||
* @return the parsed comment text. | |||
*/ | |||
public String commentText() { | |||
return commentText; | |||
} | |||
/** | |||
* Returns the full unprocessed text of the comment. | |||
* | |||
* @return the full unprocessed text of the comment. | |||
*/ | |||
public String getRawCommentText() { | |||
return rawCommentText; | |||
} | |||
/** | |||
* Sets the comment text. | |||
* | |||
* @param commentText the new comment text. | |||
*/ | |||
public void setCommentText(String commentText) { | |||
this.commentText = commentText; | |||
} | |||
/** | |||
* Returns the raw comment text. | |||
* | |||
* @return the raw comment text. | |||
*/ | |||
public String rawCommentText() { | |||
return rawCommentText; | |||
} | |||
/** | |||
* Sets the raw comment text. | |||
* | |||
* @param rawCommentText the new raw comment text. | |||
*/ | |||
public void setRawCommentText(String rawCommentText) { | |||
this.rawCommentText = rawCommentText; | |||
} | |||
/** | |||
* Returns all this comment's tags. | |||
* | |||
* @return a List of tags whose elements are Comment instances | |||
*/ | |||
public List getTags() { | |||
if (tags == null) { | |||
tags = findTags(); | |||
} | |||
return tags; | |||
} | |||
/** | |||
* Sets the Doc for this comment. | |||
* | |||
* @param doc the new Doc. | |||
*/ | |||
public void setDoc(Doc doc) { | |||
this.doc = doc; | |||
} | |||
/** | |||
* Returns the Doc for this comment. | |||
* | |||
* @return the Doc for this comment. | |||
*/ | |||
public Doc doc() { | |||
return doc; | |||
} | |||
/** | |||
* Sets the locale for this comment. | |||
* | |||
* @param loc the new locale for this comment. | |||
*/ | |||
public void setLocale(Locale loc) { | |||
this.loc = loc; | |||
} | |||
/** | |||
* Returns the Locale for this comment. | |||
* | |||
* @return the Locale for this comment. | |||
*/ | |||
public Locale locale() { | |||
return loc; | |||
} | |||
/** | |||
* Sets the ErrPrinter for this comment. | |||
* | |||
* @param err the new ErrPrinter for this comment. | |||
*/ | |||
public void setErr(ErrPrinter err) { | |||
this.err = err; | |||
} | |||
/** | |||
* Returns the ErrPrinter for this comment. | |||
* | |||
* @return the ErrPrinter for this comment. | |||
*/ | |||
public ErrPrinter err() { | |||
return err; | |||
} | |||
/** | |||
* Initializes the Doc, Locale, and ErrPrinter. | |||
* | |||
* @param doc the new Doc. | |||
* @param loc the new Locale. | |||
* @param err the new ErrPrinter. | |||
*/ | |||
public void init(Doc doc, Locale loc, ErrPrinter err) { | |||
setDoc(doc); | |||
setLocale(loc); | |||
setErr(err); | |||
} | |||
/** | |||
* Returns the comment as an array of Tag. | |||
* | |||
* @return an array of Tag representing the comment. | |||
*/ | |||
public Tag[] inlineTags() { | |||
return Util.inlineTags(doc(), | |||
commentText(), | |||
locale(), | |||
err()); | |||
} | |||
/** | |||
* Returns all tags of the comment whose name equals | |||
* <code>tagname</code>. | |||
* | |||
* @return an array of Tag representing all tags of the | |||
* comment whose name equals <code>tagname</code>. | |||
*/ | |||
public Tag[] tags(String type) { | |||
type = type.startsWith("@") ? type : "@"+type; | |||
List result = new ArrayList(); | |||
Tag tag; | |||
for (Iterator i = getTags().iterator(); i.hasNext();) { | |||
if ((tag = (Tag)i.next()).kind().equals(type)) { | |||
result.add(tag); | |||
} | |||
} | |||
return (Tag[])result.toArray(new Tag[result.size()]); | |||
} | |||
/** | |||
* Returns the param tags describing parameters taken | |||
* by this code. | |||
* | |||
* @return an array of ParamTag representing the | |||
* parameters taken by this code. | |||
*/ | |||
public ParamTag[] paramTags() { | |||
List result = new ArrayList(); | |||
Tag tag; | |||
for (Iterator i = getTags().iterator(); i.hasNext();) { | |||
if ((tag = (Tag)i.next()) instanceof ParamTag) { | |||
result.add((ParamTag)tag); | |||
} | |||
} | |||
return (ParamTag[])result.toArray(new ParamTag[result.size()]); | |||
} | |||
/** | |||
* Returns the see tags of the comment. | |||
* | |||
* @return an array of SeeTag representing the | |||
* see tags of the comment. | |||
*/ | |||
public SeeTag[] seeTags() { | |||
List result = new ArrayList(); | |||
Tag tag; | |||
for (Iterator i = getTags().iterator(); i.hasNext();) { | |||
if ((tag = (Tag)i.next()) instanceof SeeTag) { | |||
result.add((SeeTag)tag); | |||
} | |||
} | |||
return (SeeTag[])result.toArray(new SeeTag[result.size()]); | |||
} | |||
/** | |||
* Returns the serial field tags for this field. | |||
* | |||
* @return an array of SerialFieldTag representing the | |||
* serial field tags for this field. | |||
*/ | |||
public SerialFieldTag[] serialFieldTags() { | |||
List result = new ArrayList(); | |||
Tag tag; | |||
for (Iterator i = getTags().iterator(); i.hasNext();) { | |||
if ((tag = (Tag)i.next()) instanceof SerialFieldTag) { | |||
result.add((SerialFieldTag)tag); | |||
} | |||
} | |||
return (SerialFieldTag[])result.toArray | |||
(new SerialFieldTag[result.size()]); | |||
} | |||
/** | |||
* Returns the throw tags describing exceptions thrown | |||
* declared by this code. | |||
* | |||
* @return an array of ThrowsTag representing the exception | |||
* this code declares to throw. | |||
*/ | |||
public ThrowsTag[] throwsTags() { | |||
List result = new ArrayList(); | |||
Tag tag; | |||
for (Iterator i = getTags().iterator(); i.hasNext();) { | |||
if ((tag = (Tag)i.next()) instanceof ThrowsTag) { | |||
result.add((ThrowsTag)tag); | |||
} | |||
} | |||
return (ThrowsTag[])result.toArray | |||
(new ThrowsTag[result.size()]); | |||
} | |||
/** | |||
* Returns all tags of the comment. | |||
* | |||
* @return an array of Tag representing all | |||
* tags of the comment. | |||
*/ | |||
public Tag[] tags() { | |||
return (Tag[])getTags().toArray | |||
(new Tag[getTags().size()]); | |||
} | |||
/** | |||
* Returns the Tags that comprise the first | |||
* sentence of the comment. | |||
* | |||
* @return an array of Tag representing the first | |||
* sentence of the comment. | |||
*/ | |||
public Tag[] firstSentenceTags() { | |||
return Util.firstSentenceTags(doc(), | |||
commentText(), | |||
locale(), | |||
err()); | |||
} | |||
/** | |||
* Used to lazily initialize the tags of this comment. | |||
* | |||
* @return a List of tags whose elements of Tag instances | |||
* and each represent a tag in this comment. | |||
*/ | |||
private List findTags() { | |||
return Util.findTags(doc(), | |||
rawCommentText(), | |||
locale(), | |||
err()); | |||
} | |||
} |
@@ -1,64 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.compiler.base.ast.ConstructorDec; | |||
import com.sun.javadoc.ClassDoc; | |||
public class ConstructorDocImpl | |||
extends CodeDocImpl | |||
implements org.aspectj.ajdoc.ConstructorDoc { | |||
public ConstructorDocImpl(ClassDoc containingClass, ConstructorDec constructor) { | |||
super(containingClass, constructor); | |||
} | |||
/** | |||
* Returns <code>true</code>. | |||
* | |||
* @return <code>true</code>. | |||
*/ | |||
public boolean isConstructor() { | |||
return true; | |||
} | |||
/** | |||
* Returns the fully-qualified name -- i.e. the | |||
* defining types ID. | |||
* | |||
* @return the fully-qualified name -- i.e. the | |||
* defining types ID. | |||
*/ | |||
public String qualifiedName() { | |||
return containingClass().name(); | |||
} | |||
/** | |||
* Returns the name of this -- i.e. the qualified name. | |||
* | |||
* @return the name of this -- i.e. the qualified name. | |||
*/ | |||
public String name() { | |||
return qualifiedName(); | |||
} | |||
} |
@@ -1,280 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.ajdoc.Doc; | |||
import com.sun.javadoc.SeeTag; | |||
import com.sun.javadoc.Tag; | |||
import java.util.Locale; | |||
public abstract class DocImpl | |||
implements org.aspectj.ajdoc.Doc { | |||
/** Keep track of whether this is included or not. */ | |||
private boolean isIncluded = true; | |||
/** The comment for this Doc. */ | |||
private Comment comment; | |||
/** The error printer for this Doc. */ | |||
private ErrPrinter err; | |||
/** Keep track of whether this is included or not. */ | |||
private boolean isInterface = true; | |||
/** The locale of the object -- default to <code>Locale.US</code>. */ | |||
private Locale locale = Locale.US; //TODO | |||
/** | |||
* Returns the locale. | |||
* | |||
* @return the locale. | |||
*/ | |||
public Locale locale() { //XXX | |||
return locale; | |||
} | |||
public void setErr(ErrPrinter err) { this.err = err; } | |||
public ErrPrinter err() { return ErrPrinter.instance; } | |||
public void setComment(Comment comment) { this.comment = comment; } | |||
public Comment getComment() { return comment; } | |||
/** | |||
* Delegates to {@link Util#compareTo(Object)} to compare | |||
* with another Object. | |||
* | |||
* @return a negative integer, zero, or a positive integer | |||
* as this object is less than, equal to, or greater | |||
* than the specified object based on name. | |||
* @see java.lang.Comparable.compareTo(Object) | |||
*/ | |||
public int compareTo(Object other) { | |||
return other instanceof Doc | |||
? Util.compareTo(this, (Doc)other) | |||
: -1; | |||
} | |||
/** | |||
* Returns the Tags that comprise the first | |||
* sentence of the comment. | |||
* | |||
* @return an array of Tag representing the first | |||
* sentence of the comment. | |||
*/ | |||
public Tag[] firstSentenceTags() { | |||
return getComment() != null | |||
? getComment().firstSentenceTags() | |||
: new Tag[0]; | |||
} | |||
/** | |||
* Returns the full unprocessed text of the comment. | |||
* | |||
* @return the full unprocessed text of the comment. | |||
*/ | |||
public String getRawCommentText() { | |||
return getComment() != null | |||
? getComment().rawCommentText() | |||
: ""; | |||
} | |||
/** | |||
* Sets the full unprocessed text of the comment. | |||
* | |||
* @param rawCommentText the new full unprocessed text of the comment.. | |||
*/ | |||
public void setRawCommentText(String rawCommentText) { | |||
if (getComment() != null) { | |||
getComment().setRawCommentText(rawCommentText); | |||
} | |||
} | |||
/** | |||
* Returns the comment as an array of Tag. | |||
* | |||
* @return an array of Tag representing the comment. | |||
*/ | |||
public Tag[] inlineTags() { | |||
return getComment() != null | |||
? getComment().inlineTags() | |||
: new Tag[0]; | |||
} | |||
/** | |||
* Returns the see tags of the comment. | |||
* | |||
* @return an array of SeeTag representing the | |||
* see tags of the comment. | |||
*/ | |||
public SeeTag[] seeTags() { | |||
return getComment() != null | |||
? getComment().seeTags() | |||
: new SeeTag[0]; | |||
} | |||
/** | |||
* Returns all tags of the comment. | |||
* | |||
* @return an array of Tag representing all | |||
* tags of the comment. | |||
*/ | |||
public Tag[] tags() { | |||
return getComment() != null | |||
? getComment().tags() | |||
: new Tag[0]; | |||
} | |||
/** | |||
* Returns all tags of the comment whose name equals | |||
* <code>tagname</code>. | |||
* | |||
* @return an array of Tag representing all tags of the | |||
* comment whose name equals <code>tagname</code>. | |||
*/ | |||
public Tag[] tags(String tagname) { | |||
return getComment() != null | |||
? getComment().tags(tagname) | |||
: new Tag[0]; | |||
} | |||
/** | |||
* Returns the commext text for non-null comments, | |||
* otherwise the empty String. | |||
* | |||
* @return non-null comment text. | |||
*/ | |||
public String commentText() { | |||
return getComment() != null | |||
? getComment().commentText() | |||
: ""; | |||
} | |||
/** | |||
* Sets <code>isIncluded</code>. | |||
* | |||
* @param isIncluded the new value of <code>isIncluded</code>. | |||
*/ | |||
public void setIncluded(boolean isIncluded) { | |||
this.isIncluded = isIncluded; | |||
} | |||
/** | |||
* Returns <code>false</code> by default. | |||
* | |||
* @return <code>false</code> by default. | |||
*/ | |||
public boolean isClass() { | |||
return false; | |||
} | |||
/** | |||
* Returns <code>false</code> by default. | |||
* | |||
* @return <code>false</code> by default. | |||
*/ | |||
public boolean isConstructor() { | |||
return false; | |||
} | |||
/** | |||
* Returns <code>false</code> by default. | |||
* | |||
* @return <code>false</code> by default. | |||
*/ | |||
public boolean isError() { | |||
return false; | |||
} | |||
/** | |||
* Returns <code>false</code> by default. | |||
* | |||
* @return <code>false</code> by default. | |||
*/ | |||
public boolean isException() { | |||
return false; | |||
} | |||
/** | |||
* Returns <code>false</code> by default. | |||
* | |||
* @return <codealse</code> by default./ | |||
*/ | |||
public boolean isField() { | |||
return false; | |||
} | |||
/** | |||
* Returns <code>isIncluded</code> by default. | |||
* | |||
* @return <codesIncluded</code> by default./ | |||
*/ | |||
public boolean isIncluded() { | |||
return isIncluded; | |||
} | |||
/** | |||
* Returns <code>false</code> by default. | |||
* | |||
* @return <codealse</code> by default./ | |||
*/ | |||
public boolean isInterface() { | |||
return false; | |||
} | |||
/** | |||
* Returns <code>false</code> by default. | |||
* | |||
* @return <codealse</code> by default./ | |||
*/ | |||
public boolean isMethod() { | |||
return false; | |||
} | |||
/** | |||
* Returns <code>false</code> by default. | |||
* | |||
* @return <codealse</code> by default./ | |||
*/ | |||
public boolean isOrdinaryClass() { | |||
return false; | |||
} | |||
/** | |||
* Returns <code>false</code> by default. | |||
* | |||
* @return <codealse</code> by default./ | |||
*/ | |||
public boolean isPointcut() { | |||
return false; | |||
} | |||
/** | |||
* Returns <code>false</code> by default. | |||
* | |||
* @return <codealse</code> by default./ | |||
*/ | |||
public boolean isAdvice() { | |||
return false; | |||
} | |||
} |
@@ -1,145 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.tools.doclets.standard.AbstractStandard; | |||
import org.aspectj.tools.doclets.standard.Standard; | |||
import com.sun.javadoc.DocErrorReporter; | |||
import com.sun.javadoc.RootDoc; | |||
import java.io.IOException; | |||
import java.util.List; | |||
/** | |||
*/ | |||
public interface DocletProxy { | |||
public static final DocletProxy STANDARD | |||
= JavadocStandardProxy.SINGLETON; | |||
public static final DocletProxy DEFAULT | |||
= StandardProxy.SINGLETON; | |||
public int optionLength(String arg); | |||
public boolean start(RootDoc root) | |||
throws IOException; | |||
public boolean validOptions(List options, DocErrorReporter handler) | |||
throws IOException; | |||
} | |||
/** | |||
* This proxy delegates to Standard singleton, | |||
* but delays alerts about it being unavailable until first use | |||
*/ | |||
class StandardProxy implements DocletProxy { | |||
public static final DocletProxy SINGLETON = new StandardProxy(); | |||
private StandardProxy() { } | |||
/** check and delegate to standard */ | |||
public int optionLength(String arg) { | |||
return Standard.optionLength(arg); | |||
} | |||
/** check and delegate to standard */ | |||
public boolean validOptions(List options, DocErrorReporter handler) | |||
throws IOException { | |||
return AbstractStandard.validOptions(docletOptions(options), handler); | |||
} | |||
// todo: validate that this is the expected format for doclet options | |||
protected String[][] docletOptions(List options) { | |||
if ((null == options) || (1 > options.size())) { | |||
return new String[][]{}; | |||
} | |||
Object[] ra = options.toArray(); | |||
String[] strs = new String[ra.length]; | |||
for (int i = 0; i < ra.length; i++) { | |||
strs[i] = (null == ra[i] ? null : ra[i].toString()); | |||
} | |||
return new String[][] {strs}; | |||
} | |||
/** check and delegate to standard */ | |||
public boolean start(RootDoc root) throws IOException { | |||
return Standard.start(root); | |||
} | |||
} // StandardProxy | |||
/** | |||
* This proxy delegates to javadoc Standard singleton. | |||
*/ | |||
class JavadocStandardProxy implements DocletProxy { | |||
public static final DocletProxy SINGLETON = new JavadocStandardProxy(); | |||
private JavadocStandardProxy() { } | |||
/** check and delegate to standard */ | |||
public int optionLength(String arg) { | |||
return com.sun.tools.doclets.standard.Standard.optionLength(arg); | |||
} | |||
/** check and delegate to standard */ | |||
public boolean validOptions(List options, DocErrorReporter handler) | |||
throws IOException { | |||
return com.sun.tools.doclets.standard.Standard.validOptions(docletOptions(options), handler); | |||
} | |||
// todo: validate that this is the expected format for doclet options | |||
protected String[][] docletOptions(List options) { | |||
if ((null == options) || (1 > options.size())) { | |||
return new String[][]{}; | |||
} | |||
Object[] ra = options.toArray(); | |||
String[] strs = new String[ra.length]; | |||
for (int i = 0; i < ra.length; i++) { | |||
strs[i] = (null == ra[i] ? null : ra[i].toString()); | |||
} | |||
return new String[][] {strs}; | |||
} | |||
/** check and delegate to standard */ | |||
public boolean start(RootDoc root) throws IOException { | |||
return com.sun.tools.doclets.standard.Standard.start(root); | |||
} | |||
} // JavadocStandardProxy | |||
/** Wrap a Throwable as a RuntimeException | |||
* This will render stack trace as the delegate stack trace, | |||
* notwithstanding any call to fillInStackTrace. | |||
class ExceptionWrapper extends RuntimeException { | |||
Throwable delegate; | |||
public ExceptionWrapper(Throwable t) { | |||
delegate = (null == t ? new Error("null") : t); | |||
} | |||
public void printStackTrace() { | |||
delegate.printStackTrace(); | |||
} | |||
public void printStackTrace(PrintStream stream) { | |||
delegate.printStackTrace(stream); | |||
} | |||
public void printStackTrace(PrintWriter stream) { | |||
delegate.printStackTrace(stream); | |||
} | |||
public String getMessage() { | |||
return delegate.getMessage(); | |||
} | |||
public String getLocalizedMessage() { | |||
return delegate.getLocalizedMessage(); | |||
} | |||
public Throwable fillInStackTrace() { | |||
return delegate.fillInStackTrace(); | |||
} | |||
} | |||
*/ |
@@ -1,627 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.compiler.base.ErrorHandler; | |||
import org.aspectj.compiler.base.InternalCompilerError; | |||
import com.sun.javadoc.DocErrorReporter; | |||
import java.io.PrintWriter; | |||
import java.lang.reflect.InvocationTargetException; | |||
import java.text.MessageFormat; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.MissingResourceException; | |||
import java.util.ResourceBundle; | |||
/** | |||
* A class to handler errors in ajdoc. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public class ErrPrinter | |||
extends ErrorHandler | |||
implements DocErrorReporter | |||
{ | |||
/** The global instance that anyone can use. */ | |||
public final static ErrPrinter instance = new ErrPrinter(); | |||
private String programName; | |||
private PrintWriter out; | |||
private PrintWriter err; | |||
private ResourceBundle bundle; | |||
private List keys = new ArrayList(); | |||
private List msgs = new ArrayList(); | |||
static int cnt = 0; | |||
/** | |||
* Construct with program name <code>programName</code> | |||
* and printstreams <code>err</code> and <code>out</code>. | |||
* | |||
* @param programName program name. | |||
* @param err error stream. | |||
* @param out output stream. | |||
*/ | |||
public ErrPrinter(String programName, | |||
PrintWriter err, | |||
PrintWriter out) { | |||
super(err); | |||
this.programName = programName; | |||
this.err = err; | |||
this.out = out; | |||
try { | |||
bundle = ResourceBundle.getBundle | |||
("org.aspectj.tools.ajdoc.resources.ajdoc"); | |||
} catch (MissingResourceException e) { | |||
throw new Error("Can't find ajdoc.properties: " + e); | |||
} | |||
} | |||
/** | |||
* Construct with program name <code>programName</code> | |||
* and printstreams <code>System.err</code> and <code>System.out</code> | |||
* | |||
* @param programName program name. | |||
*/ | |||
public ErrPrinter(String programName) { | |||
this(programName, | |||
new PrintWriter(System.err, true), | |||
new PrintWriter(System.out, true)); | |||
} | |||
/** | |||
* Construct with program name <code>"ajdoc"</code> | |||
* and printstreams <code>System.err</code> and <code>System.out</code> | |||
*/ | |||
public ErrPrinter() { | |||
this("ajdoc"); | |||
} | |||
/** | |||
* Print <code>error</code> and increment the error count. | |||
* | |||
* @param error error message to print. | |||
*/ | |||
public void printError(String error) { | |||
errors++; | |||
err.println(error); | |||
err.flush(); | |||
} | |||
/** | |||
* Print <code>warning</code> and increment the warning count. | |||
* | |||
* @param warning warning message to print. | |||
*/ | |||
public void printWarning(String warning) { | |||
warnings++; | |||
err.println(warning); | |||
err.flush(); | |||
} | |||
/** | |||
* Print <code>notice</code>. | |||
* | |||
* @param notice notice message to print. | |||
*/ | |||
public void printNotice(String notice) { | |||
out.println(notice); | |||
out.flush(); | |||
} | |||
/** | |||
* Returns the number of errors. | |||
* | |||
* @return number of errors. | |||
*/ | |||
public int getNumErrors() { | |||
return errors; | |||
} | |||
/** | |||
* Returns the number of warnings. | |||
* | |||
* @return number of warnings. | |||
*/ | |||
public int getNumWarnings() { | |||
return warnings; | |||
} | |||
/** | |||
* Returns the keys in the resource bundle. | |||
* | |||
* @return keys in the resource bundle. | |||
*/ | |||
public List getKeys() { | |||
return new ArrayList(keys); | |||
} | |||
/** | |||
* Returns the messages in the resource bundle. | |||
* | |||
* @return messages in the resource bundle. | |||
*/ | |||
public List getMsgs() { | |||
return new ArrayList(msgs); | |||
} | |||
/** | |||
* Handles InvocationTargetExceptions. | |||
* | |||
* @param e the exception. | |||
* @param classname the class on which the method was trying | |||
* to be invoked. | |||
* @param methodName the name of the method trying to be invoked. | |||
* @return the exception. | |||
*/ | |||
public synchronized Throwable invocationTargetException | |||
(InvocationTargetException e, | |||
String classname, | |||
String methodName) { | |||
Throwable t = e.getTargetException(); | |||
if (t != null) { | |||
if (t instanceof OutOfMemoryError) { | |||
error("out_of_memory"); | |||
} else { | |||
error("exception_thrown", "", classname, methodName, t+""); | |||
t.printStackTrace(); | |||
} | |||
} | |||
return t != null ? t : e; | |||
} | |||
/** | |||
* Handles an internal error. | |||
* | |||
* @param key key of the message to use. | |||
* @param t exception thrown. | |||
*/ | |||
public synchronized void internalError(String key, Throwable t) { | |||
internalError(key, "", t); | |||
} | |||
/** | |||
* Handles an internal error. | |||
* | |||
* @param key key of the message to use. | |||
* @param s0 first argument in the message. | |||
* @param t exception thrown. | |||
*/ | |||
public synchronized void internalError(String key, String s0, Throwable t) { | |||
if (t instanceof InternalCompilerError) { | |||
t = ((InternalCompilerError)t).uncaughtThrowable; | |||
} | |||
error(key, s0, t != null ? t.getMessage() : ""); | |||
if (t != null) t.printStackTrace(); | |||
internalError(t, null); | |||
} | |||
/** | |||
* Prints an error message for key <code>key</code> | |||
* ,and returns the number of errors. | |||
* | |||
* @param key key of the message. | |||
* @return number of errors. | |||
*/ | |||
public final int error(String key) { | |||
printError(text(key)); | |||
return errors; | |||
} | |||
/** | |||
* Prints an error message for key <code>key</code> | |||
* and argument <code>s0</code>, | |||
* and returns the number of errors. | |||
* | |||
* @param key key of the message. | |||
* @param s0 argument to message. | |||
* @return number of errors. | |||
*/ | |||
public final int error(String key, String s0) { | |||
printError(text(key,s0)); | |||
return errors; | |||
} | |||
/** | |||
* Prints an error message for key <code>key</code> | |||
* and arguments <code>s0,s1</code>, | |||
* and returns the number of errors. | |||
* | |||
* @param key key of the message. | |||
* @param s0 argument to message. | |||
* @param s1 argument to message. | |||
* @return number of errors. | |||
*/ | |||
public final int error(String key, String s0, String s1) { | |||
printError(text(key,s0,s1)); | |||
return errors; | |||
} | |||
/** | |||
* Prints an error message for key <code>key</code> | |||
* and arguments <code>s0,s1,s2</code>, | |||
* and returns the number of errors. | |||
* | |||
* @param key key of the message. | |||
* @param s0 argument to message. | |||
* @param s1 argument to message. | |||
* @param s2 argument to message. | |||
* @return number of errors. | |||
*/ | |||
public final int error(String key, String s0, String s1, | |||
String s2) { | |||
printError(text(key,s0,s1,s2)); | |||
return errors; | |||
} | |||
/** | |||
* Prints an error message for key <code>key</code> | |||
* and arguments <code>s0,s1,s2,cookieMonster</code>, | |||
* and returns the number of errors. | |||
* | |||
* @param key key of the message. | |||
* @param s0 argument to message. | |||
* @param s1 argument to message. | |||
* @param s2 argument to message. | |||
* @param cookieMonster argument to message. | |||
* @return number of errors. | |||
*/ | |||
public final int error(String key, String s0, String s1, | |||
String s2, String cookieMonster) { | |||
printError(text(key,s0,s1,s2,cookieMonster)); | |||
return errors; | |||
} | |||
/** | |||
* Handles the thrown exception <code>t</code> | |||
* with message key <code>key</code>, and returns | |||
* the number of errors. | |||
* | |||
* @param t thrown exception. | |||
* @param key message key. | |||
* @return number of errors. | |||
*/ | |||
public final int ex(Throwable t, String key) { | |||
error(key); | |||
if (t != null) t.printStackTrace(); | |||
return errors; | |||
} | |||
/** | |||
* Handles the thrown exception <code>t</code> | |||
* with message key <code>key</code> and | |||
* argument <code>s0</code>, and returns | |||
* the number of errors. | |||
* | |||
* @param t thrown exception. | |||
* @param key message key. | |||
* @param s0 argument to message. | |||
* @return number of errors. | |||
*/ | |||
public final int ex(Throwable t, String key, String s0) { | |||
error(key,s0); | |||
if (t != null) t.printStackTrace(); | |||
return errors; | |||
} | |||
/** | |||
* Handles the thrown exception <code>t</code> | |||
* with message key <code>key</code> and | |||
* arguments <code>s0,s1</code>, and returns | |||
* the number of errors. | |||
* | |||
* @param t thrown exception. | |||
* @param key message key. | |||
* @param s0 argument to message. | |||
* @param s1 argument to message. | |||
* @return number of errors. | |||
*/ | |||
public final int ex(Throwable t, String key, String s0, String s1) { | |||
error(key,s0,s1); | |||
if (t != null) t.printStackTrace(); | |||
return errors; | |||
} | |||
/** | |||
* Handles the thrown exception <code>t</code> | |||
* with message key <code>key</code> and | |||
* arguments <code>s0,s1,s2</code>, and returns | |||
* the number of errors. | |||
* | |||
* @param t thrown exception. | |||
* @param key message key. | |||
* @param s0 argument to message. | |||
* @param s1 argument to message. | |||
* @param s2 argument to message. | |||
* @return number of errors. | |||
*/ | |||
public final int ex(Throwable t, String key, String s0, String s1, | |||
String s2) { | |||
error(key,s0,s1,s2); | |||
if (t != null) t.printStackTrace(); | |||
return errors; | |||
} | |||
/** | |||
* Handles the thrown exception <code>t</code> | |||
* with message key <code>key</code> and | |||
* arguments <code>s0,s1,s2,snuffulufugus</code>, and returns | |||
* the number of errors. | |||
* | |||
* @param t thrown exception. | |||
* @param key message key. | |||
* @param s0 argument to message. | |||
* @param s1 argument to message. | |||
* @param s2 argument to message. | |||
* @param snuffulufugus argument to message. | |||
* @return number of errors. | |||
*/ | |||
public final int ex(Throwable t, String key, String s0, String s1, | |||
String s2, String snuffulufugus) { | |||
error(key,s0,s1,s2,snuffulufugus); | |||
if (t != null) t.printStackTrace(); | |||
return errors; | |||
} | |||
/** | |||
* Prints the warning with key <code>key</code> | |||
* and returns the number of warnings. | |||
* | |||
* @param key message key. | |||
* @return number of warnings. | |||
*/ | |||
public final int warning(String key) { | |||
printWarning(text(key)); | |||
return warnings; | |||
} | |||
/** | |||
* Prints the warning with key <code>key</code> and | |||
* argument <code>s0</code>, | |||
* and returns the number of warnings. | |||
* | |||
* @param key message key. | |||
* @param s0 argument to message. | |||
* @return number of warnings. | |||
*/ | |||
public final int warning(String key, String s0) { | |||
printWarning(text(key,s0)); | |||
return warnings; | |||
} | |||
/** | |||
* Prints the warning with key <code>key</code> and | |||
* arguments <code>s0,s1</code>, | |||
* and returns the number of warnings. | |||
* | |||
* @param key message key. | |||
* @param s0 argument to message. | |||
* @param s1 argument to message. | |||
* @return number of warnings. | |||
*/ | |||
public final int warning(String key, String s0, String s1) { | |||
printWarning(text(key,s0,s1)); | |||
return warnings; | |||
} | |||
/** | |||
* Prints the warning with key <code>key</code> and | |||
* arguments <code>s0,s1,s2</code>, | |||
* and returns the number of warnings. | |||
* | |||
* @param key message key. | |||
* @param s0 argument to message. | |||
* @param s1 argument to message. | |||
* @param s2 argument to message. | |||
* @return number of warnings. | |||
*/ | |||
public final int warning(String key, String s0, String s1, | |||
String s2) { | |||
printWarning(text(key,s0,s1,s2)); | |||
return warnings; | |||
} | |||
/** | |||
* Prints the warning with key <code>key</code> and | |||
* arguments <code>s0,s1,s2,josefStalin</code>, | |||
* and returns the number of warnings. | |||
* | |||
* @param key message key. | |||
* @param s0 argument to message. | |||
* @param s1 argument to message. | |||
* @param s2 argument to message. | |||
* @param josefStalin argument to message. | |||
* @return number of warnings. | |||
*/ | |||
public final int warning(String key, String s0, String s1, | |||
String s2, String josefStalin) { | |||
printWarning(text(key,s0,s1,s2,josefStalin)); | |||
return warnings; | |||
} | |||
/** | |||
* Print a notice with message key <code>key</code>. | |||
* | |||
* @param key message key. | |||
*/ | |||
public final void notice(String key) { | |||
printNotice(text(key)); | |||
} | |||
/** | |||
* Print a notice with message key <code>key</code> | |||
* and argument <code>s0</code>. | |||
* | |||
* @param key message key. | |||
* @param s0 argument to message. | |||
*/ | |||
public final void notice(String key, String s0) { | |||
printNotice(text(key,s0)); | |||
} | |||
/** | |||
* Print a notice with message key <code>key</code> | |||
* and arguments <code>s0,s1</code>. | |||
* | |||
* @param key message key. | |||
* @param s0 argument to message. | |||
* @param s1 argument to message. | |||
*/ | |||
public final void notice(String key, String s0, String s1) { | |||
printNotice(text(key,s0,s1)); | |||
} | |||
/** | |||
* Print a notice with message key <code>key</code> | |||
* and arguments <code>s0,s1,s2</code>. | |||
* | |||
* @param key message key. | |||
* @param s0 argument to message. | |||
* @param s1 argument to message. | |||
* @param s2 argument to message. | |||
*/ | |||
public final void notice(String key, String s0, String s1, | |||
String s2) { | |||
printNotice(text(key,s0,s1,s2)); | |||
} | |||
/** | |||
* Print a notice with message key <code>key</code> | |||
* and arguments <code>s0,s1,s2,bigbird</code>. | |||
* | |||
* @param key message key. | |||
* @param s0 argument to message. | |||
* @param s1 argument to message. | |||
* @param s2 argument to message. | |||
* @param bigbird argument to message. | |||
*/ | |||
public final void notice(String key, String s0, String s1, | |||
String s2, String bigbird) { | |||
printNotice(text(key,s0,s1,s2,bigbird)); | |||
} | |||
/** | |||
* Returns the String for message key <code>key</code>. | |||
* | |||
* @return String for message | |||
* key <code>key</code>. | |||
*/ | |||
protected final String text(String key) { | |||
return text(key, ""); | |||
} | |||
/** | |||
* Returns the String for message key <code>key</code> | |||
* and argument <code>s0</code> | |||
* | |||
* @param s0 argument to message. | |||
* @return String for message | |||
* key <code>key</code>. | |||
*/ | |||
protected final String text(String key, String s0) { | |||
return text(key, s0, ""); | |||
} | |||
/** | |||
* Returns the String for message key <code>key</code> | |||
* and arguments <code>s0,s1</code> | |||
* | |||
* @param s0 argument to message. | |||
* @param s1 argument to message. | |||
* @return String for message | |||
* key <code>key</code>. | |||
*/ | |||
protected final String text(String key, String s0, String s1) { | |||
return text(key, s0, s1, ""); | |||
} | |||
/** | |||
* Returns the String for message key <code>key</code> | |||
* and arguments <code>s0,s1,s2</code> | |||
* | |||
* @param s0 argument to message. | |||
* @param s1 argument to message. | |||
* @param s2 argument to message. | |||
* @return String for message | |||
* key <code>key</code>. | |||
*/ | |||
protected final String text(String key, String s0, String s1, | |||
String s2) { | |||
return text(key, s0, s1, s2, ""); | |||
} | |||
/** | |||
* Returns the String for message key <code>key</code> | |||
* and arguments <code>s0,s1,s2,oscarTheGrouch</code> | |||
* | |||
* @param s0 argument to message. | |||
* @param s1 argument to message. | |||
* @param s2 argument to message. | |||
* @param oscarTheGrouch argument to message. | |||
* @return String for message | |||
* key <code>key</code>. | |||
*/ | |||
protected final String text(String key, String s0, String s1, | |||
String s2, String oscarTheGrouch) { | |||
return text(key, new String[]{s0,s1,s2,oscarTheGrouch}); | |||
} | |||
/** | |||
* Returns the String for the message key <code>key</code> | |||
* with arguments contained in <code>args</code>. | |||
* | |||
* @param key message key. | |||
* @param args array of arguments to substitute. | |||
* @return String for message with key | |||
* <code>key</code> and arguments | |||
* <code>args</code> | |||
*/ | |||
protected final String text(String key, String[] args) { | |||
String msg = MessageFormat.format(string(key), args); | |||
msgs.add(msg); | |||
return msg; | |||
} | |||
/** | |||
* Returns the String with message <code>key</code>. | |||
* | |||
* @param key message key. | |||
* @return String for message with key <code>key</code>. | |||
*/ | |||
protected final String string(String key) { | |||
keys.add(key); | |||
try { | |||
return bundle.getString(key); | |||
} catch (MissingResourceException e) { | |||
throw new Error("Can't find " + key + " in " + bundle); | |||
} | |||
} | |||
PrintWriter getErr() { | |||
return err; | |||
} | |||
PrintWriter getOut() { | |||
return out; | |||
} | |||
} |
@@ -1,307 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.ajdoc.AdviceDoc; | |||
import org.aspectj.compiler.base.ast.Formals; | |||
import org.aspectj.compiler.base.ast.NameType; | |||
import org.aspectj.compiler.base.ast.TypeDs; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.ExecutableMemberDoc; | |||
import com.sun.javadoc.ParamTag; | |||
import com.sun.javadoc.Parameter; | |||
import com.sun.javadoc.ThrowsTag; | |||
import java.lang.reflect.Modifier; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.List; | |||
public abstract class ExecutableMemberDocImpl | |||
extends MemberDocImpl | |||
implements ExecutableMemberDoc { | |||
/* | |||
* These three fields should be final, but can't because | |||
* they contain calls to abstract methods that aren't | |||
* valid until after the subclasses constructor is run. | |||
* To compensate the accessor methods lazily evaluate | |||
* them, and these methods are final. | |||
*/ | |||
/** The collection of advice placed on each ExecutableMemberDoc. */ | |||
private Collection advice; | |||
/** The List of parameters. */ | |||
private Collection parameters; | |||
/** The List of thrown exceptions. */ | |||
private Collection thrownExceptions; | |||
/** The full signature. */ | |||
private String signature; | |||
/** The flat signature. */ | |||
private String flatSignature; | |||
/** | |||
* Constructs a new Doc with the enclosing ClassDoc. | |||
* | |||
* @param containingClass enclosing ClassDoc. | |||
*/ | |||
public ExecutableMemberDocImpl(ClassDoc containingClass) { | |||
super(containingClass); | |||
} | |||
/** | |||
* Returns a non-null Collection of AdviceDoc | |||
* representing the advice placed on the underlying Dec. | |||
* | |||
* @return a non-null Collection of AdviceDoc | |||
* representing the advice placed on the | |||
* underlying Dec. | |||
*/ | |||
protected abstract Collection createAdvice(); | |||
/** | |||
* Returns the Formals of the underlying Dec. | |||
* | |||
* @return the Formals of the underlying Dec. | |||
*/ | |||
protected abstract Formals getFormals(); | |||
/** | |||
* Returns the TypeDs representing the exceptions | |||
* thrown by the underlying Dec. | |||
* | |||
* @return the TypeDs representing the exceptions | |||
* thrown by the underlying Dec. | |||
*/ | |||
protected abstract TypeDs getThrows(); | |||
/** | |||
* Converts the passed in Formals to a Collection of | |||
* Parameter and sets our parameters to this value. | |||
* | |||
* @param formals the Formals to use. | |||
*/ | |||
public void makeParameters(Formals formals) { | |||
parameters = createParameters(formals); | |||
} | |||
/** | |||
* Converts the passed in TypeDs to a Collection of | |||
* ClassDoc and sets our thrownExceptions to this value. | |||
* | |||
* @param thrown the TypeDs to use. | |||
*/ | |||
public void makeThrownExceptions(TypeDs thrown) { | |||
thrownExceptions = createThrownExceptions(thrown); | |||
} | |||
/** | |||
* Returns the advice affecting this member. | |||
* | |||
* @return an array of AdviceDoc representing the advice | |||
* affecting this member. | |||
*/ | |||
public final AdviceDoc[] advice() { | |||
if (advice == null) advice = createAdvice(); | |||
return (AdviceDoc[])advice.toArray(new AdviceDoc[advice.size()]); | |||
} | |||
/** | |||
* Returns the exceptions this code declares to throw. | |||
* | |||
* @return an array of ClassDoc representing the exceptions | |||
* this code declares to throw. | |||
*/ | |||
public final ClassDoc[] thrownExceptions() { | |||
if (thrownExceptions == null) makeThrownExceptions(getThrows()); | |||
return (ClassDoc[])thrownExceptions.toArray | |||
(new ClassDoc[thrownExceptions.size()]); | |||
} | |||
/** | |||
* Returns the parameters taken by this code. | |||
* | |||
* @return an array of Parameter representing the | |||
* parameters this code takes. | |||
*/ | |||
public final Parameter[] parameters() { | |||
if (parameters == null) makeParameters(getFormals()); | |||
return (Parameter[])parameters.toArray | |||
(new Parameter[parameters.size()]); | |||
} | |||
/** | |||
* Returns the flat signature. | |||
* | |||
* @return the flat signature with all types unqualified. | |||
*/ | |||
public String flatSignature() { | |||
if (flatSignature == null) { | |||
flatSignature = Util.flatSignature(parameters()); | |||
} | |||
return flatSignature; | |||
} | |||
/** | |||
* Returns the full signature. | |||
* | |||
* @return the full signature with all types qualified. | |||
*/ | |||
public String signature() { | |||
if (signature == null) { | |||
signature = Util.signature(parameters()); | |||
} | |||
return signature; | |||
} | |||
/** | |||
* Returns <code>true</code> if this code is <code>synchronized</code>. | |||
* | |||
* @return <code>true</code> if this code is <code>synchronized</code>. | |||
*/ | |||
public boolean isSynchronized() { | |||
//return getModifiers().isSynchronized(); | |||
return Modifier.isSynchronized(modifierSpecifier()); | |||
} | |||
/** | |||
* Returns <code>true</code>if this code is <code>native</code>. | |||
* | |||
* @return <code>true</code>if this code is <code>native</code>. | |||
*/ | |||
public boolean isNative() { | |||
//return (modifierSpecifier() & Modifiers.NATIVE) != 0; | |||
return Modifier.isNative(modifierSpecifier()); | |||
} | |||
/** | |||
* Returns the throw tags describing exceptions thrown | |||
* declared by this code. | |||
* | |||
* @return an array of ThrowsTag representing the exception | |||
* this code declares to throw. | |||
*/ | |||
public ThrowsTag[] throwsTags() { | |||
return getComment().throwsTags(); | |||
} | |||
/** | |||
* Returns the param tags describing parameters taken | |||
* by this code. | |||
* | |||
* @return an array of ParamTag representing the | |||
* parameters taken by this code. | |||
*/ | |||
public ParamTag[] paramTags() { | |||
return getComment().paramTags(); | |||
} | |||
/** | |||
* Returns the simple name followed the parameters | |||
* enclosed in parens. | |||
* | |||
* @return the simple name followed the parameters | |||
* enclosed in parens. | |||
*/ | |||
public String toString() { | |||
StringBuffer sb = new StringBuffer(name()); | |||
sb.append('('); | |||
Parameter[] params = parameters(); | |||
for (int i = 0, N = params.length; i < N; i++) { | |||
if (i > 0) sb.append(","); | |||
sb.append(params[i].type().qualifiedTypeName()); | |||
sb.append(params[i].type().dimension()); | |||
} | |||
sb.append(')'); | |||
return sb.toString(); | |||
} | |||
/** | |||
* Returns a Collection of Parameter corresponding to | |||
* the Formals passed in. | |||
* | |||
* @param formals the Formals to use. | |||
* @return a Collection of Parameter corresponding to | |||
* the Formals passed in. | |||
*/ | |||
private Collection createParameters(Formals formals) { | |||
if (formals == null) return Collections.EMPTY_LIST; | |||
List list = new ArrayList(formals.size()); | |||
for (int i = 0, N = formals.size(); i < N; i++) { | |||
list.add(new ParameterImpl(formals.get(i))); | |||
} | |||
return list; | |||
} | |||
/** | |||
* Returns a Collection of ClassDoc corresponding to | |||
* the TypeDs passed in. | |||
* | |||
* @param thrown the TypeDs to use | |||
* @return a Collection of ClassDoc corresponding to | |||
* the TypeDs passed in. | |||
*/ | |||
private Collection createThrownExceptions(TypeDs typeds) { | |||
if (typeds == null) return Collections.EMPTY_LIST; | |||
List list = new ArrayList(typeds.size()); | |||
for (int i = 0, N = typeds.size(); i < N; i++) { | |||
list.add(ClassDocImpl.getInstance | |||
(((NameType)typeds.get(i).getType()).getTypeDec())); | |||
} | |||
return list; | |||
} | |||
/** | |||
* Returns <code>true</code> if the passed in Object is | |||
* an ExecutableMemberDocImpl, its name equals ours, and | |||
* its parameters <code>equals</code> ours. | |||
* | |||
* @return equality based on name and parameters. | |||
*/ | |||
public boolean weakEquals(Object md) { | |||
if (!(md instanceof ExecutableMemberDocImpl)) { | |||
return false; | |||
} | |||
ExecutableMemberDocImpl emdi = (ExecutableMemberDocImpl)md; | |||
if (!name().equals(emdi.name())) { | |||
return false; | |||
} | |||
Parameter[] ourPds = this.parameters(); | |||
Parameter[] edsPds = emdi.parameters(); | |||
if (ourPds.length != edsPds.length) { | |||
return false; | |||
} | |||
for (int i = 0, N = ourPds.length; i < N; i++) { | |||
if (!ourPds[i].equals(edsPds[i])) { | |||
return false; | |||
} | |||
} | |||
return true; | |||
} | |||
} |
@@ -1,140 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.compiler.base.ast.Dec; | |||
import org.aspectj.compiler.base.ast.FieldDec; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.SerialFieldTag; | |||
import java.lang.reflect.Modifier; | |||
public class FieldDocImpl | |||
extends MemberDocImpl | |||
implements org.aspectj.ajdoc.FieldDoc { | |||
/** The FieldDec that corresponds to this FieldDoc. */ | |||
private final FieldDec field; | |||
/** | |||
* The type of this field. This can't be set initially | |||
* because the compiler doesn't resolve the types for | |||
* introductions, yet, so we have to allow others to set it. | |||
*/ | |||
private org.aspectj.compiler.base.ast.Type type; | |||
/** | |||
* Sets the org.apectj.compiler.base.ast.Type used to return | |||
* the com.sun.javadoc.Type. | |||
* | |||
* @param type the new org.aspectj.compiler.base.ast.Type used | |||
* to find the com.sun.javadoc.Type. | |||
* @hack This is only needed because of unresolved | |||
* introduced fields. | |||
*/ | |||
public void setType(org.aspectj.compiler.base.ast.Type type) { | |||
this.type = type; | |||
} | |||
public FieldDocImpl(ClassDoc containingClass, FieldDec field) { | |||
super(containingClass); | |||
this.field = field; | |||
setType(field.getType()); | |||
} | |||
protected Dec dec() { | |||
return field; | |||
} | |||
protected FieldDec fieldDec() { | |||
return field; | |||
} | |||
/** | |||
* Returns <code>true</code>. | |||
* | |||
* @return <code>true</code>. | |||
*/ | |||
public boolean isField() { | |||
return true; | |||
} | |||
/** | |||
* Returns the type of this field. | |||
* | |||
* @return the type of this field. | |||
*/ | |||
public com.sun.javadoc.Type type() { | |||
return TypeImpl.getInstance(type); | |||
} | |||
/** | |||
* Return <code>true</code> is this field is <code>volatile</code>. | |||
* | |||
* @return <code>true</code> is this field is <code>volatile</code>. | |||
*/ | |||
public boolean isVolatile() { | |||
return Modifier.isVolatile(modifierSpecifier()); | |||
} | |||
/** | |||
* Return <code>true</code> is this field is <code>transient</code>. | |||
* | |||
* @return <code>true</code> is this field is <code>transient</code>. | |||
*/ | |||
public boolean isTransient() { | |||
return Modifier.isTransient(modifierSpecifier()); | |||
} | |||
/** | |||
* Returns the serial field tags for this field. | |||
* | |||
* @return an array of SerialFieldTag representing the | |||
* serial field tags for this field. | |||
*/ | |||
public SerialFieldTag[] serialFieldTags() { | |||
return getComment().serialFieldTags(); | |||
} | |||
/** | |||
* Returns the name of the field. | |||
* | |||
* @return the name of the field. | |||
*/ | |||
public String toString() { | |||
return name(); | |||
} | |||
/** | |||
* Returns <code>true</code> is <code>md</code> is a | |||
* FieldDocImpl and has the same name. | |||
* | |||
* @return <code>true</code> is <code>md</code> is a | |||
* FieldDocImpl and has the same name. | |||
*/ | |||
public boolean weakEquals(Object md) { | |||
if (!(md instanceof FieldDocImpl)) return false; | |||
return name().equals(((FieldDocImpl)md).name()); | |||
} | |||
} |
@@ -1,219 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.compiler.base.ast.ConstructorDec; | |||
import org.aspectj.compiler.base.ast.Dec; | |||
import org.aspectj.compiler.base.ast.FieldDec; | |||
import org.aspectj.compiler.base.ast.MethodDec; | |||
import org.aspectj.compiler.base.ast.Type; | |||
import org.aspectj.compiler.base.ast.TypeDec; | |||
import org.aspectj.compiler.crosscuts.ast.PointcutDec; | |||
import java.util.ArrayList; | |||
/** | |||
* Factory collection with Type-specific "add" methods which | |||
* checks if ..Dec should be included and if so constructs and adds. | |||
* A Dec should be included if AccessChecker.canAccess({Dec variants}) | |||
* and the type is the same (if type is specified). | |||
* This consolidates construction of DocImpl for classes and class members. | |||
*/ | |||
public class FilteredDecList extends ArrayList { | |||
final protected AccessChecker filter ; | |||
final protected ClassDocImpl classDocImpl ; | |||
final protected Type declaringType ; | |||
/** | |||
* Create a declaration list enforced by a filter and | |||
* optionally a ClassDocImpl. If the ClassDocImpl is not null, | |||
* then you cannot add members outside its type; if it is null, | |||
* attempting to add members has undefined results. (You may | |||
* still create ClassDoc.) | |||
* @param filter the AccessChecker used to test for inclusion | |||
* (use AccessChecker.PUBLIC if null) | |||
* @param type the classDocImpl used to construct added members | |||
* and ensure they are declared in this type | |||
* (ignore test if null) | |||
*/ | |||
FilteredDecList(AccessChecker filter, ClassDocImpl classDocImpl) { | |||
this.filter = (null != filter ? filter | |||
: AccessChecker.PUBLIC); | |||
this.classDocImpl = classDocImpl; | |||
TypeDec td = (null == classDocImpl? null | |||
: classDocImpl.typeDec()); | |||
this.declaringType = (null == td? null : td.getType()); | |||
} | |||
/** | |||
* Check for match with our type (if set) | |||
* @param dec the Dec to get the incoming declaring type from | |||
* @return true unless our type is set and does not equals dec declaring type | |||
*/ | |||
protected final boolean sameType(Dec dec) { | |||
Type other = (null == dec ? null : dec.getDeclaringType()); | |||
boolean result = ((null != dec) | |||
&& ((declaringType == null) | |||
|| declaringType.equals(other))) ; | |||
/* | |||
System.err.println("sameType("+dec+") " + declaringType | |||
+ " ?= " + other); | |||
if (!result) { | |||
System.err.println("false FilteredDecList.sameType(" + dec | |||
+ ") us " + declaringType); | |||
} | |||
*/ | |||
return result; | |||
} | |||
/** | |||
* Implements policy on incoming TypeDec. | |||
* @param dec the TypeDec to check | |||
* @throws IllegalArgumentException if null == dec | |||
*/ | |||
protected void checkDec(Dec dec) { | |||
if (null == dec) throw new IllegalArgumentException("null dec"); | |||
} | |||
/** | |||
* Construct and add inner class from dec | |||
* if outer is included and dec should be included. | |||
* @param outer the ClassDocImpl which encloses this dec | |||
* @param dec the TypeDec for the inner class to add to this list, enclosed by outer | |||
* @return false if dec is null or true if added | |||
* @throws IllegalArgumentException if outer is null or dec is null | |||
*/ | |||
public boolean add(ClassDocImpl outer, TypeDec dec) { | |||
checkDec(dec); | |||
if (null == outer) throw new IllegalArgumentException("null outer"); | |||
if ((filter.canAccess(outer.typeDec()) && filter.canAccess(dec))) { | |||
ClassDocImpl doc = ClassDocImpl.getInstance(outer, dec); | |||
if (null != doc) { | |||
doc.setIncluded(true); | |||
return add((Object) doc); | |||
} | |||
} | |||
denied(outer, dec); | |||
return false; | |||
} | |||
/** | |||
* Add ClassDocImpl if dec should be included | |||
* and ClassDocImpl.getInstance(..) returns something. | |||
* Also sets the included property to true; | |||
* @param dec the TypeDec for the class to add | |||
* @return false if dec is null or true if added | |||
* @throws IllegalArgumentException if outer is null or dec is null | |||
*/ | |||
public boolean add(TypeDec dec) { | |||
checkDec(dec); | |||
if (filter.canAccess(dec)) { | |||
ClassDocImpl doc = ClassDocImpl.getInstance(dec); | |||
if (null != doc) { | |||
doc.setIncluded(true); | |||
return add((Object) doc); | |||
} | |||
} | |||
denied(dec); | |||
return false; | |||
} | |||
/** | |||
* Add MethodDocImpl to this list if dec should be included | |||
* @param dec the MethodDoc for the method to add | |||
* @return true if added | |||
* @throws IllegalArgumentException if dec is null | |||
*/ | |||
public boolean add(MethodDec dec) { | |||
checkDec(dec); | |||
if (sameType(dec) && filter.canAccess(dec)) { | |||
return add((Object) new MethodDocImpl(classDocImpl, dec)); | |||
} | |||
denied(dec); | |||
return false; | |||
} | |||
/** | |||
* Add ConstructorDocImpl to this list if dec should be included | |||
* @param dec the ConstructorDoc for the constructor to add | |||
* @return true if added | |||
* @throws IllegalArgumentException if dec is null | |||
*/ | |||
public boolean add(ConstructorDec dec) { | |||
checkDec(dec); | |||
if (sameType(dec) && filter.canAccess(dec)) { | |||
return add((Object) new ConstructorDocImpl(classDocImpl, dec)); | |||
} | |||
denied(dec); | |||
return false; | |||
} | |||
/** | |||
* Add FieldDocImpl to this list if dec should be included | |||
* @param dec the FieldDoc for the field to add | |||
* @return true if added | |||
* @throws IllegalArgumentException if dec is null | |||
*/ | |||
public boolean add(FieldDec dec) { | |||
checkDec(dec); | |||
if (sameType(dec) && filter.canAccess(dec)) { | |||
return add((Object) new FieldDocImpl(classDocImpl, dec)); | |||
} | |||
denied(dec); | |||
return false; | |||
} | |||
/** | |||
* Add PointcutDocImpl to this list if dec should be included | |||
* @param dec the PointcutDoc for the pointcut to add | |||
* @return true if added | |||
* @throws IllegalArgumentException if dec is null | |||
*/ | |||
public boolean add(PointcutDec dec) { | |||
checkDec(dec); | |||
if (sameType(dec) && filter.canAccess(dec)) { | |||
return add((Object) new PointcutDocImpl(classDocImpl, dec)); | |||
} | |||
denied(dec); | |||
return false; | |||
} | |||
/** | |||
* Called when some dec and outer is denied addition. | |||
* Currently does nothing. | |||
* @param outer the ClassDocImpl which encloses this dec | |||
* @param dec the TypeDec for the inner class to add to this list, enclosed by outer | |||
*/ | |||
protected void denied(ClassDocImpl outer, TypeDec dec) { | |||
// System.err.println(this + " denied " + o + " with " + p); | |||
} | |||
/** | |||
* signalled when some dec is denied addition. | |||
* Currently does nothing. | |||
* @param dec the Dec denied addition | |||
*/ | |||
protected void denied(Dec dec) { | |||
// System.err.println(this + " denied " + o); | |||
} | |||
} // class FilteredDecList | |||
@@ -1,169 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.ajdoc.ClassDoc; | |||
import org.aspectj.ajdoc.IntroducedDoc; | |||
import org.aspectj.ajdoc.MemberDoc; | |||
import org.aspectj.compiler.base.ast.ConstructorDec; | |||
import org.aspectj.compiler.base.ast.Dec; | |||
import org.aspectj.compiler.base.ast.FieldDec; | |||
import org.aspectj.compiler.base.ast.MethodDec; | |||
import org.aspectj.compiler.base.ast.TypeDec; | |||
import org.aspectj.compiler.crosscuts.ast.GenTypeName; | |||
import org.aspectj.compiler.crosscuts.ast.IntroducedDec; | |||
import java.util.Iterator; | |||
import java.util.Set; | |||
public class IntroducedDocImpl extends IntroductionDocImpl implements IntroducedDoc { | |||
/** The introduction to which we delegate. */ | |||
private final IntroducedDec introducedDec; | |||
/** The member this introduction introduced. */ | |||
private final MemberDocImpl member; | |||
public IntroducedDocImpl(com.sun.javadoc.ClassDoc containingClass, | |||
IntroducedDec introducedDec) { | |||
super(containingClass); | |||
this.introducedDec = introducedDec; // used by findMember | |||
(member = findMember()).setIntroduced(this); | |||
createTargets(); | |||
} | |||
protected Dec dec() { | |||
return introducedDec; | |||
} | |||
protected void createTargets() { | |||
/* | |||
* HACK: | |||
* Because the compiler doesn't resolve the types | |||
* of introductions, yet, we have to set the introduced | |||
* doc (member) with the appropriate fields, whether it's a | |||
* - field | |||
* - method | |||
* - constructor | |||
*/ | |||
Set affects = ajc().getCorrespondences().getAffects(introducedDec); | |||
if (affects.size() < 1) return; | |||
nextType: | |||
for (Iterator it = affects.iterator(); it.hasNext();) { | |||
Object o = it.next(); | |||
if (o instanceof TypeDec) { | |||
TypeDec owner = (TypeDec)o; | |||
ClassDoc cd = ClassDocImpl.getInstance(owner); | |||
com.sun.javadoc.FieldDoc[] fs = cd.fields(); | |||
for (int i = 0; i < fs.length; i++) { | |||
if (member.weakEquals(fs[i])) { // XXX weakEquals is unimplemented | |||
((FieldDocImpl)fs[i]).setIntroduced(this); | |||
addTarget(cd); | |||
((FieldDocImpl)member).setType(((FieldDocImpl)fs[i]). | |||
fieldDec().getType()); | |||
// why fixup only fields? | |||
continue nextType; | |||
} | |||
} | |||
com.sun.javadoc.MethodDoc[] ms = cd.methods(); | |||
for (int i = 0; i < ms.length; i++) { | |||
if (member.weakEquals(ms[i])) { | |||
((MethodDocImpl)ms[i]).setIntroduced(this); | |||
addTarget(cd); | |||
((MethodDocImpl)member).setType(((MethodDocImpl)ms[i]). | |||
codeDec().getResultTypeD(). | |||
getType()); | |||
((ExecutableMemberDocImpl)member). | |||
makeParameters(((MethodDocImpl)ms[i]). | |||
codeDec().getFormals()); | |||
continue nextType; | |||
} | |||
} | |||
com.sun.javadoc.ConstructorDoc[] cs = cd.constructors(); | |||
for (int i = 0; i < cs.length; i++) { | |||
if (member.weakEquals(cs[i])) { | |||
((ConstructorDocImpl)cs[i]).setIntroduced(this); | |||
addTarget(cd); | |||
((ExecutableMemberDocImpl)member). | |||
makeParameters(((ConstructorDocImpl)cs[i]). | |||
codeDec().getFormals()); | |||
continue nextType; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
public MemberDoc member() { | |||
return member; | |||
} | |||
/** | |||
* Returns the name of the member introduction. | |||
* | |||
* @return the name. | |||
*/ | |||
public String name() { // XXX unused? | |||
Dec indec = introducedDec.getDec(); | |||
if (indec != null) { | |||
return "" + indec.getId(); // XXX | |||
} else { | |||
return ""; | |||
} | |||
} | |||
private MemberDocImpl findMember() { | |||
Dec dec = introducedDec.getDec(); | |||
// fix applied all, though bug was only in methods and constructors | |||
// verified working in all, including fields | |||
dec.setSourceLocation(introducedDec.getSourceLocation()); // PR790, 712 | |||
//TODO: a little hacky now | |||
if (dec instanceof FieldDec) { | |||
return new FieldDocImpl(containingClass(), | |||
(FieldDec)dec); | |||
} else if (dec instanceof ConstructorDec) { | |||
return new ConstructorDocImpl(containingClass(), | |||
(ConstructorDec)dec); | |||
} else if (dec instanceof MethodDec) { | |||
return new MethodDocImpl(containingClass(), | |||
(MethodDec)dec); | |||
} else { | |||
return null; | |||
} | |||
// should print type pattern for type of introduced member, | |||
// but it messes up source/target associations | |||
// GenTypeName gtn = introducedDec.getTargets(); | |||
// if (null != gtn) { | |||
// name = gtn.toShortString() + name; | |||
// } | |||
} | |||
/** | |||
* Returns the toString() of the member. | |||
* | |||
* @return the toString() of the member. | |||
*/ | |||
public String toString() { | |||
return member.toString(); | |||
} | |||
} |
@@ -1,103 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.ajdoc.IntroducedSuperDoc; | |||
import org.aspectj.compiler.base.ast.Dec; | |||
import org.aspectj.compiler.base.ast.TypeDs; | |||
import org.aspectj.compiler.crosscuts.ast.IntroducedSuperDec; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.List; | |||
public class IntroducedSuperDocImpl | |||
extends IntroductionDocImpl | |||
implements IntroducedSuperDoc { | |||
/** The introduction to which we delegate. */ | |||
private final IntroducedSuperDec introducedSuperDec; | |||
/** The types we introduce onto our targets. */ | |||
private final Collection types; | |||
public IntroducedSuperDocImpl(com.sun.javadoc.ClassDoc containingClass, | |||
IntroducedSuperDec introducedSuperDec) { | |||
super(containingClass); | |||
this.introducedSuperDec = introducedSuperDec; | |||
types = createTypes(); | |||
} | |||
protected Dec dec() { | |||
return introducedSuperDec; | |||
} | |||
/** | |||
* Returns <code>true</code> is this introduction | |||
* places <code>implements</code> introductions on its | |||
* targets. | |||
* | |||
* @return <code>true</code> is this introduction | |||
* places <code>implements</code> introductions | |||
* on its targets. | |||
*/ | |||
public boolean isImplements() { | |||
return introducedSuperDec.getIsImplements(); | |||
} | |||
/** | |||
* Returns the types that this introduction introduces | |||
* into it's targets type hierarchy. | |||
* | |||
* @return an array of org.aspectj.ajdoc.Type representing | |||
* the types this introduction has introducted onto | |||
* its targets type hierarchy. | |||
*/ | |||
public org.aspectj.ajdoc.Type[] types() { | |||
return (org.aspectj.ajdoc.Type[])types.toArray | |||
(new org.aspectj.ajdoc.Type[types.size()]); | |||
} | |||
/** | |||
* Returns the name of the type introduction. | |||
* | |||
* @return the name. | |||
*/ | |||
public String name() { if (true) return ""; // XXX unimplemented | |||
return (introducedSuperDec.getTypeDs().size() != 0) | |||
? ((org.aspectj.ajdoc.Type)introducedSuperDec.getTypeDs(). | |||
get(0).getType()).typeName() | |||
: ""; | |||
//TODO: This could fuck us up!!! | |||
} | |||
private final Collection createTypes() { | |||
TypeDs typeds = introducedSuperDec.getTypeDs(); | |||
if (typeds == null) return Collections.EMPTY_LIST; | |||
List list = new ArrayList(); | |||
for (int i = 0, N = typeds.size(); i < N; i++) { | |||
list.add(ClassDocImpl.getInstance(typeds.get(i).getType().getTypeDec())); | |||
} | |||
return list; | |||
} | |||
} |
@@ -1,86 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import org.aspectj.ajdoc.ClassDoc; | |||
import org.aspectj.ajdoc.IntroductionDoc; | |||
import org.aspectj.compiler.crosscuts.ast.IntroducedDec; | |||
import org.aspectj.compiler.crosscuts.ast.IntroducedSuperDec; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
public abstract class IntroductionDocImpl | |||
extends MemberDocImpl | |||
implements IntroductionDoc { | |||
/** Creats a new instance of IntroductionDoc from <code>o</code>. */ | |||
public static IntroductionDocImpl getInstance(AspectDoc ad, Object o) { | |||
return factory.getInstance(ad, o); | |||
} | |||
/** The factory in charge of creating instances of IntroductionDocImpl. */ | |||
private final static Factory factory = new Factory(); | |||
private final Collection targets = new ArrayList(); | |||
public void addTarget(ClassDoc cd) { targets.add(cd); } | |||
protected IntroductionDocImpl(com.sun.javadoc.ClassDoc containingClass) { | |||
super(containingClass); | |||
} | |||
//protected abstract Collection createTargets(); | |||
/** | |||
* Returns the classes that are affected by this introduction. | |||
* | |||
* @return an array of ClassDoc representing the classes | |||
* affected by this introduction. | |||
*/ | |||
public final ClassDoc[] targets() { | |||
//if (targets == null) targets = createTargets(); | |||
return (ClassDoc[])targets.toArray(new ClassDoc[targets.size()]); | |||
} | |||
/** | |||
* The class is in charge of creating | |||
* instances of IntroductionDocImpl. | |||
*/ | |||
private final static class Factory { | |||
public static IntroductionDocImpl getInstance(AspectDoc ad, Object o) { | |||
if (o instanceof IntroducedSuperDec) { | |||
return new IntroducedSuperDocImpl(ad, (IntroducedSuperDec)o); | |||
} | |||
if (o instanceof IntroducedDec) { | |||
return new IntroducedDocImpl(ad, (IntroducedDec)o); | |||
} | |||
return null; | |||
} | |||
} | |||
/** TODO */ | |||
public boolean weakEquals(Object md) { | |||
return false; // TODO | |||
} | |||
} |
@@ -1,112 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
/** | |||
* Entry point for ajdoc. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public class Main { | |||
/** | |||
* value returned from execute(..) | |||
* when the JDK tools are not supported | |||
*/ | |||
public static final int PLATFORM_ERROR = 3; | |||
/** | |||
* Call {@link #execute} and exit with | |||
* its exit code. | |||
* | |||
* @param args Command line arguments. | |||
*/ | |||
public static void main(String[] args) { | |||
System.exit(execute(args)); | |||
} | |||
/** | |||
* Programmatic entry without calling <code>System.exit</code>, | |||
* returning the result of {@link Ajdoc#execute(String[])}. | |||
* | |||
* @param args Command line arguments. | |||
* @return PLATFORM_ERROR if platformErrorMessage() is not null | |||
* or the result of calling {@link Ajdoc#execute(String[])}. | |||
* @throw Error if bad platform - look at message | |||
*/ | |||
public static int execute(String[] args) { | |||
int result = 0; | |||
String platformError = platformErrorMessage(); | |||
if (null != platformError) { | |||
result = PLATFORM_ERROR; | |||
System.err.println(platformError); | |||
} else { | |||
Ajdoc me = new Ajdoc(); | |||
result = me.execute(args); | |||
} | |||
return result; | |||
} | |||
/** | |||
* Generate version error message if we cannot run in this VM | |||
* or using this class path. | |||
* @return null if no error or String describing error otherwise | |||
*/ | |||
public static String platformErrorMessage() { | |||
// todo: stolen from ajc.Main | |||
boolean failed = false; | |||
final String[] versions = new String[] | |||
{ "java.lang.reflect.Proxy" // 1.3: failed if class not found | |||
// permit users to run in 1.4 iff using 1.3 tools.jar | |||
//, "java.lang.CharSequence" // 1.4: failed if class found | |||
}; | |||
for (int i = 0; i < versions.length; i++) { | |||
try { | |||
Class.forName(versions[i]); | |||
failed = (i == 1); | |||
} catch (ClassNotFoundException cnfe) { | |||
failed = (i == 0); | |||
} catch (Error err) { | |||
failed = (i == 0); | |||
} | |||
if (failed) { | |||
String version = "(unknown version)"; | |||
try { version = System.getProperty("java.version"); } | |||
catch (Throwable t) { } // ignore | |||
return "Ajdoc requires J2SE 1.3; not java " + version; | |||
} | |||
} | |||
// now looking for tools.jar | |||
try { | |||
Class.forName("com.sun.javadoc.RootDoc"); // may be version error | |||
Class.forName("com.sun.javadoc.Type"); // not in 1.4 | |||
} catch (ClassNotFoundException cnfe) { | |||
// System.err.println(cnfe.getMessage()); | |||
// cnfe.printStackTrace(System.err); // XXX | |||
return "Requires tools.jar from J2SE 1.3 (not 1.2 or 1.4) be on the class path"; | |||
} catch (Error err) { // probably wrong version of the class | |||
// System.err.println(err.getMessage()); | |||
// err.printStackTrace(System.err); // XXX | |||
return "Requires tools.jar from J2SE 1.3 (not 1.2 or 1.4) be on the class path"; | |||
} | |||
return null; | |||
} | |||
} |
@@ -1,82 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.ajdoc.IntroducedDoc; | |||
import org.aspectj.ajdoc.MemberDoc; | |||
public abstract class MemberDocImpl | |||
extends ProgramElementDocImpl | |||
implements MemberDoc { | |||
/** | |||
* The introduction that introduces this member | |||
* to its enclosing type. | |||
*/ | |||
private IntroducedDoc introduced; | |||
public MemberDocImpl(com.sun.javadoc.ClassDoc containingClass) { | |||
super(containingClass); | |||
} | |||
/** | |||
* Returns whether the passed in Object is equals | |||
* based on type <b>names</b> and the name | |||
* of the declaration. | |||
* | |||
* @return <code>true</code> if the passed in Object | |||
* is equal to this based on type names | |||
* and field names. | |||
*/ | |||
public abstract boolean weakEquals(Object other); | |||
/** | |||
* Sets this member's introduction. | |||
* | |||
* @param introduced the new introduction. | |||
*/ | |||
protected void setIntroduced(IntroducedDoc introduced) { | |||
this.introduced = introduced; | |||
} | |||
/** | |||
* Returns the introduction that introduced this member onto | |||
* its enclosing type -- this value may be <code>null</code> | |||
* if the member wasn't introduced. | |||
* | |||
* @return an IntroducedDoc representing the introduction | |||
* that introduced this member onto its enclosing | |||
* type. The return value may be <code>null</code>. | |||
*/ | |||
public IntroducedDoc introduced() { | |||
return introduced; | |||
} | |||
/** | |||
* Returns <code>true</code>if this code is <i>synthetic</i>. | |||
* | |||
* @return <code>true</code>if this code is <i>synthetic</i>. | |||
*/ | |||
public boolean isSynthetic() { | |||
return (!dec().isLanguageVisible()); | |||
} | |||
} |
@@ -1,125 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.compiler.base.ast.MethodDec; | |||
import org.aspectj.compiler.base.ast.NameType; | |||
import org.aspectj.compiler.base.ast.TypeDec; | |||
import com.sun.javadoc.ClassDoc; | |||
import java.lang.reflect.Modifier; | |||
public class MethodDocImpl | |||
extends CodeDocImpl | |||
implements org.aspectj.ajdoc.MethodDoc { | |||
/* | |||
* This is a hack because the compiler isn't resolving | |||
* introduced types. | |||
*/ | |||
private org.aspectj.compiler.base.ast.Type type; | |||
public void setType(org.aspectj.compiler.base.ast.Type type) { | |||
this.type = type; | |||
} | |||
public MethodDocImpl(ClassDoc containingClass, MethodDec methodDec) { | |||
super(containingClass, methodDec); | |||
setType(codeDec().getResultTypeD().getType()); | |||
} | |||
protected MethodDec methodDec() { | |||
return (MethodDec)codeDec(); | |||
} | |||
/** | |||
* Returns <code>true</code>. | |||
* | |||
* @return <code>true</code>. | |||
*/ | |||
public boolean isMethod() { | |||
return true; | |||
} | |||
/** | |||
* Returns <code>true</code> if this method is <code>abstract</code>. | |||
* | |||
* @return <code>true</code> if this method is <code>abstract</code>. | |||
*/ | |||
public boolean isAbstract() { | |||
return methodDec().isAbstract(); | |||
} | |||
/** | |||
* Returns the return type of this method. | |||
* | |||
* @return the Type representing the type this | |||
* method returns. | |||
*/ | |||
public com.sun.javadoc.Type returnType() { | |||
return TypeImpl.getInstance(type); | |||
//return null; //TODO getResultTypeD().getType(); | |||
} | |||
/** | |||
* Returns the type that nearest super class that defines | |||
* this method. | |||
* | |||
* @return the type that nearest super class that defines | |||
* this method. | |||
*/ | |||
public ClassDoc overriddenClass() { | |||
//Exprs params = getFormals().makeExprs(); // do this for side-effect?XXX | |||
TypeDec where = methodDec().getDeclaringType().getTypeDec(); | |||
NameType superType = (NameType)where.getSuperClassType(); | |||
while (superType != null) { | |||
MethodDec method = Util.methodDec(superType, | |||
methodDec().getId(), | |||
methodDec().getFormals()); | |||
if (method != null && !method.getId().equals("not$found")) { | |||
if (method.getDeclaringType().equals(superType)) { | |||
return null; | |||
} | |||
} | |||
if (superType.getTypeDec().getFullName(). | |||
equals("java.lang.Object")) { | |||
return null; | |||
} | |||
superType = (NameType)superType.getTypeDec().getSuperClassType(); | |||
} | |||
return null; | |||
} | |||
/** | |||
* Returns the int modifiers for this method. | |||
* | |||
* @return the int modifiers for this method. | |||
* @see java.lang.reflect.Modifier | |||
*/ | |||
public int modifierSpecifier() { | |||
//XXX interface methods have the ABSTRACT bit set | |||
if (containingClass().isInterface()) { | |||
return super.modifierSpecifier() & ~Modifier.ABSTRACT; | |||
} | |||
return super.modifierSpecifier(); | |||
} | |||
} |
@@ -1,95 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.ajdoc.ClassDoc; | |||
import org.aspectj.ajdoc.OfClauseDoc; | |||
import org.aspectj.ajdoc.OfEachObjectDoc; | |||
import org.aspectj.compiler.crosscuts.ast.Pcd; | |||
import org.aspectj.compiler.crosscuts.ast.PerCFlow; | |||
import org.aspectj.compiler.crosscuts.ast.PerClause; | |||
import org.aspectj.compiler.crosscuts.ast.PerObject; | |||
import org.aspectj.compiler.crosscuts.ast.PerSingleton; | |||
import java.util.Collections; | |||
import java.util.List; | |||
public class OfClauseDocImpl { | |||
/** TODO */ | |||
public final static OfClauseDoc getInstance(PerClause clause) { | |||
return factory.getInstance(clause); | |||
} | |||
/** The factory used to create the instance. */ | |||
private final static Factory factory = new Factory(); | |||
/** TODO */ | |||
private final static class OfEachObjectDocImpl implements OfEachObjectDoc { | |||
private final List instances; | |||
private OfEachObjectDocImpl(PerObject eo) { | |||
instances = createInstances(eo); | |||
} | |||
public ClassDoc[] instances() { | |||
return (ClassDoc[])instances.toArray(new ClassDoc[instances.size()]); | |||
} | |||
public OfEachObjectDoc.Kind kind() { | |||
return OfClauseDoc.Kind.EACH_OBJECT; | |||
} | |||
private List createInstances(PerObject eo) { | |||
Pcd pc = eo.getPcd(); | |||
if (pc == null) { | |||
return Collections.EMPTY_LIST; | |||
} | |||
return Collections.EMPTY_LIST; | |||
} | |||
} | |||
/** TODO */ | |||
private static class Factory { | |||
private final static OfClauseDoc EACH_CFLOW = new OfClauseDoc(){ | |||
public OfClauseDoc.Kind kind() { | |||
return OfClauseDoc.Kind.EACH_CFLOW; | |||
} | |||
}; | |||
private final static OfClauseDoc EACH_JVM = new OfClauseDoc() { | |||
public OfClauseDoc.Kind kind() { | |||
return OfClauseDoc.Kind.EACH_JVM; | |||
} | |||
}; | |||
public final OfClauseDoc getInstance(PerClause clause) { | |||
if (clause instanceof PerCFlow) { | |||
return EACH_CFLOW; | |||
} | |||
if (clause instanceof PerSingleton) { | |||
return EACH_JVM; | |||
} | |||
if (clause instanceof PerObject) { | |||
return new OfEachObjectDocImpl((PerObject)clause); | |||
} | |||
return null; //??? error | |||
} | |||
} | |||
} |
@@ -1,336 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import org.aspectj.ajdoc.PackageDoc; | |||
import org.aspectj.compiler.base.ast.Type; | |||
import org.aspectj.compiler.base.ast.TypeDec; | |||
import org.aspectj.compiler.crosscuts.AspectJCompiler; | |||
import com.sun.javadoc.ClassDoc; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.HashMap; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Set; | |||
/** | |||
* Represents a package in the aspectj-world. | |||
* A package is a passive container of classes given to it. | |||
* It does not enforce visibility rules. However, you can | |||
* purge packages without classes from the static list of packages. | |||
* @author Jeff Palm | |||
*/ | |||
public class PackageDocImpl | |||
extends DocImpl | |||
implements org.aspectj.ajdoc.PackageDoc { | |||
public final static String UNNAMED_PACKAGE = ""; //unnamed-package"; | |||
private static AjdocCompiler ajdoc = Ajdoc.instance(); | |||
private static AspectJCompiler ajc = ajdoc; | |||
public AspectJCompiler ajc() { return ajc; } | |||
private Set allClasses = new HashSet(); | |||
private Comment comment; | |||
private String name; | |||
/** | |||
* Only want to create these within the static access. | |||
* | |||
* @param name name of the new package. | |||
*/ | |||
private PackageDocImpl(String name) { | |||
this.name = name; | |||
findDocumentation(); | |||
} | |||
/** | |||
* Adds a class to this package. | |||
* | |||
* @param classDoc The new class. | |||
*/ | |||
public void addClass(ClassDoc classDoc) { | |||
allClasses.add(classDoc); | |||
} | |||
/** | |||
* Attempts to find a class with name <code>className</code> | |||
* in this package. | |||
* | |||
* @param className name of the class to find. | |||
*/ | |||
public ClassDoc findClass(String className) { | |||
Type type = ajc.getTypeManager(). | |||
findType(name(), className); | |||
if (type != null) { | |||
return ClassDocImpl.getInstance(type.getTypeDec()); | |||
} | |||
for (Iterator i = allClasses.iterator(); i.hasNext();) { | |||
ClassDoc cd = (ClassDoc)i.next(); | |||
if (className.equals(cd.name())) { | |||
return cd; //todo wes was null? | |||
} | |||
} | |||
return null; | |||
} | |||
/** | |||
* Returns all the classes in this package. | |||
* | |||
* @return an array of ClassDoc representing all | |||
* the classes in this package. | |||
*/ | |||
public ClassDoc[] allClasses() { | |||
return (ClassDoc[])allClasses.toArray(new ClassDoc[allClasses.size()]); | |||
} | |||
/** | |||
* Returns all the aspects in this package. | |||
* | |||
* @return an array of AspectDoc representing all | |||
* the aspects in this package. | |||
*/ | |||
public AspectDoc[] aspects() { | |||
List list = new ArrayList(); | |||
for (Iterator i = allClasses.iterator(); i.hasNext();) { | |||
org.aspectj.ajdoc.ClassDoc doc = (org.aspectj.ajdoc.ClassDoc)i.next(); | |||
if (doc.isAspect()) list.add(doc); | |||
} | |||
return (AspectDoc[])list.toArray | |||
(new AspectDoc[list.size()]); | |||
} | |||
/** | |||
* Returns all the ordinary classes in this package. | |||
* | |||
* @return an array of ClassDoc representing all | |||
* the ordinary classes in this package. | |||
*/ | |||
public ClassDoc[] ordinaryClasses() { | |||
List list = new ArrayList(); | |||
for (Iterator i = allClasses.iterator(); i.hasNext();) { | |||
ClassDoc doc = (ClassDoc)i.next(); | |||
if (doc.isOrdinaryClass()) list.add(doc); | |||
} | |||
return (ClassDoc[])list.toArray | |||
(new ClassDoc[list.size()]); | |||
} | |||
/** | |||
* Returns all the exceptions in this package. | |||
* | |||
* @return an array of ClassDoc representing all | |||
* the exceptions in this package. | |||
*/ | |||
public ClassDoc[] exceptions() { | |||
List list = new ArrayList(); | |||
for (Iterator i = allClasses.iterator(); i.hasNext();) { | |||
ClassDoc doc = (ClassDoc)i.next(); | |||
if (doc.isException()) list.add(doc); | |||
} | |||
return (ClassDoc[])list.toArray | |||
(new ClassDoc[list.size()]); | |||
} | |||
/** | |||
* Returns all the errors in this package. | |||
* | |||
* @return an array of ClassDoc representing all | |||
* the errors in this package. | |||
*/ | |||
public ClassDoc[] errors() { | |||
List list = new ArrayList(); | |||
for (Iterator i = allClasses.iterator(); i.hasNext();) { | |||
ClassDoc doc = (ClassDoc)i.next(); | |||
if (doc.isError()) list.add(doc); | |||
} | |||
return (ClassDoc[])list.toArray | |||
(new ClassDoc[list.size()]); | |||
} | |||
/** | |||
* Returns all the interfaces in this package. | |||
* | |||
* @return an array of ClassDoc representing all | |||
* the interfaces in this package. | |||
*/ | |||
public ClassDoc[] interfaces() { | |||
List list = new ArrayList(); | |||
for (Iterator i = allClasses.iterator(); i.hasNext();) { | |||
ClassDoc doc = (ClassDoc)i.next(); | |||
if (doc.isInterface()) list.add(doc); | |||
} | |||
return (ClassDoc[])list.toArray | |||
(new ClassDoc[list.size()]); | |||
} | |||
/** | |||
* Returns the name if included -- null otherwise. | |||
* | |||
* @return the name if included -- null otherwise. | |||
*/ | |||
public String name() { | |||
return isIncluded() ? name : null; | |||
} | |||
/** | |||
* Compare based on <code>name()</code>. | |||
* | |||
* @param other other Object. | |||
* @return <code>true</code> if the other Object is a | |||
* PackageDocImpl and has the same name. | |||
*/ | |||
public boolean equals(Object other) { | |||
return other instanceof PackageDocImpl && other != null | |||
? name().equals(((PackageDocImpl)other).name()) | |||
: super.equals(other); | |||
} | |||
/** | |||
* Returns the name. | |||
* | |||
* @return the name. | |||
*/ | |||
public String toString() { | |||
return name(); | |||
} | |||
private void findDocumentation() { | |||
if (ajdoc == null) return; | |||
String filename = (name.equals("") | |||
? name | |||
: name.replace('.',File.separatorChar) | |||
+ File.separatorChar) + "package.html"; | |||
File html = ajdoc.findFile(filename, false); | |||
if (html == null) return; | |||
String rawCommentText = Util.documentation(html, ajdoc.err()); | |||
//TODO: should be done in aspect from Aspects.java | |||
//FormalComment comment = new FormalComment(rawCommentText); | |||
setComment(new Comment(this, rawCommentText)); | |||
} | |||
/* ------------------------------------------------------------ | |||
* Factory stuff | |||
* ------------------------------------------------------------ | |||
*/ | |||
private static Map namesToPackages = new HashMap(); | |||
/** | |||
* Returns the collection of known packages. | |||
* | |||
* @return a Collection representing the known packages. | |||
*/ | |||
public static Collection packages() { | |||
return namesToPackages.values(); | |||
} | |||
/** | |||
* Inits the world and AspectJCompiler with these | |||
* packages. | |||
* | |||
* @param world current World. | |||
* @param ajc current compiler. | |||
*/ | |||
public static void init(AspectJCompiler ajc) { | |||
PackageDocImpl.ajc = ajc; | |||
if (ajc instanceof AjdocCompiler) { | |||
PackageDocImpl.ajdoc = (AjdocCompiler)ajc; | |||
} | |||
} | |||
/** | |||
* Returns a package for a TypeDec. | |||
* | |||
* @param typeDec TypeDec whose package is desired. | |||
* @return a PackageDocImpl for a given TypeDec. | |||
*/ | |||
public static PackageDocImpl getPackageDoc(TypeDec typeDec) { | |||
return getPackageDoc(typeDec.getPackageName()); | |||
} | |||
/** | |||
* Returns a package for a name. | |||
* | |||
* @param packageName package name for which to look. | |||
* @return a PackageDocImpl for a given package name. | |||
*/ | |||
public static PackageDocImpl getPackageDoc(String packageName) { | |||
return addPackageDoc(packageName); | |||
} | |||
/** | |||
* Adds a package with name <code>name</code> if it | |||
* already doesn't exist, and returns the new package | |||
* (if own with the same name didn't exist) or the | |||
* existing package. | |||
* | |||
* @param name name of the new package. | |||
* @return current package mapping to | |||
* <code>name</code>. | |||
*/ | |||
public static PackageDocImpl addPackageDoc(String name) { | |||
if (name == null) name = UNNAMED_PACKAGE; | |||
PackageDocImpl packageDoc = (PackageDocImpl)namesToPackages.get(name); | |||
if (packageDoc == null) { | |||
packageDoc = new PackageDocImpl(name); | |||
addPackageDoc(packageDoc); | |||
} | |||
return packageDoc; | |||
} | |||
/** | |||
* Adds the PackageDoc if one doesn't already exist | |||
* with the same name, and returns the existing or created | |||
* package with the same name as the one passed in . | |||
* | |||
* @param packageDoc PackageDoc we want to add. | |||
* @return package in the world with the same | |||
* name as <code>packageDoc</code>. | |||
*/ | |||
public static PackageDocImpl addPackageDoc(PackageDoc packageDoc) { | |||
if (packageDoc == null) return null; | |||
return (PackageDocImpl)namesToPackages.put(packageDoc.name(), | |||
packageDoc); | |||
} | |||
/** | |||
* Sets the include flag to false for empty packages | |||
* todo: remove instead? | |||
*/ | |||
public static void excludeEmptyPackages() { | |||
for (Iterator i = packages().iterator(); i.hasNext();) { | |||
PackageDocImpl pkg = (PackageDocImpl)i.next(); | |||
if (pkg.allClasses().length < 1) { | |||
pkg.setIncluded(false); | |||
} | |||
} | |||
} | |||
} |
@@ -1,86 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import com.sun.javadoc.Doc; | |||
import com.sun.javadoc.ParamTag; | |||
import java.util.Locale; | |||
/** | |||
* The implementation of a param tag. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public class ParamTagImpl extends TagImpl implements ParamTag { | |||
private String parameterComment; | |||
private String parameterName; | |||
/** | |||
* Constructs the new tag with given parameters. | |||
* | |||
* @param doc the new value for <code>doc</code>. | |||
* @param name the new value for <code>name</code>. | |||
* @param text the new value for <code>text</code>. | |||
* @param locale the new value for <code>locale</code>. | |||
* @param err the new value for <code>err</code>. | |||
*/ | |||
public ParamTagImpl(Doc doc, | |||
String name, | |||
String text, | |||
Locale loc, | |||
ErrPrinter err) { | |||
super(doc, name, null, loc, err); | |||
String[] split = split(text); | |||
parameterName = split[0]; | |||
parameterComment = split[1]; | |||
setText(parameterComment); | |||
} | |||
/** | |||
* Returns the parameter comment. | |||
* | |||
* @return the parameter comment. | |||
*/ | |||
public String parameterComment() { | |||
return parameterComment; | |||
} | |||
/** | |||
* Returns the name of the parameter. | |||
* | |||
* @return the name of the parameter. | |||
*/ | |||
public String parameterName() { | |||
return parameterName; | |||
} | |||
/** | |||
* Returns <code>param</code>. | |||
* | |||
* @return <code>param</code>. | |||
*/ | |||
public String kind() { | |||
return "@param"; | |||
} | |||
} |
@@ -1,70 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.compiler.base.ast.FormalDec; | |||
import com.sun.javadoc.Type; | |||
public class ParameterImpl implements org.aspectj.ajdoc.Parameter { | |||
private final FormalDec formalDec; | |||
public ParameterImpl(FormalDec formalDec) { | |||
this.formalDec = formalDec; | |||
} | |||
/** | |||
* Returns the name of this formal. | |||
* | |||
* @return the name of this formal. | |||
*/ | |||
public String name() { | |||
return formalDec.getId(); | |||
} | |||
/** | |||
* Returns the type of this formal. | |||
* | |||
* @return the type of this formal. | |||
*/ | |||
public Type type() { | |||
return TypeImpl.getInstance(formalDec.getType()); | |||
} | |||
/** | |||
* Returns the type name of this formal including | |||
* any dimension information. | |||
* | |||
* @return the type name of this formal including | |||
* any dimension information. | |||
*/ | |||
public String typeName() { | |||
return type().qualifiedTypeName() + type().dimension(); | |||
} | |||
public boolean equals(Object o) { | |||
if (!(o instanceof ParameterImpl)) return false; | |||
ParameterImpl p = (ParameterImpl)o; | |||
return typeName().equals(p.typeName()); | |||
} | |||
} |
@@ -1,143 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.ajdoc.ClassDoc; | |||
import org.aspectj.ajdoc.PointcutDoc; | |||
import org.aspectj.compiler.base.ast.Dec; | |||
import org.aspectj.compiler.base.ast.Formals; | |||
import org.aspectj.compiler.base.ast.NameType; | |||
import org.aspectj.compiler.base.ast.TypeD; | |||
import org.aspectj.compiler.base.ast.TypeDec; | |||
import org.aspectj.compiler.base.ast.TypeDs; | |||
import org.aspectj.compiler.crosscuts.ast.PointcutDec; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
public class PointcutDocImpl | |||
extends ExecutableMemberDocImpl | |||
implements PointcutDoc { | |||
/** The pointcut to which we delegate. */ | |||
private final PointcutDec pointcutDec; | |||
public PointcutDocImpl(ClassDoc containingClass, PointcutDec pointcutDec) { | |||
super(containingClass); | |||
this.pointcutDec = pointcutDec; | |||
} | |||
/** | |||
* Returns a empty list because advice cannot | |||
* be placed on a pointcut. | |||
* | |||
* @return Collection.EMPTY_LIST; | |||
*/ | |||
protected Collection createAdvice() { | |||
return Collections.EMPTY_LIST; | |||
} | |||
/** | |||
* Returns the underlying Dec -- a PointcutDec. | |||
* | |||
* @return the underlying Dec -- a PointcutDec. | |||
*/ | |||
protected Dec dec() { | |||
return pointcutDec; | |||
} | |||
/** | |||
* Returns the Formals of the underlying PointcutDec. | |||
* | |||
* @return the Formals of the underlying PointcutDec. | |||
*/ | |||
protected Formals getFormals() { | |||
return pointcutDec.getFormals(); | |||
} | |||
/** | |||
* Returns null because pointcut cannot throw execptions. | |||
* | |||
* @return null. | |||
*/ | |||
public TypeDs getThrows() { | |||
return null; | |||
} | |||
/** | |||
* Returns the return type of this method. | |||
* | |||
* @return the Type representing the type this | |||
* method returns. | |||
*/ | |||
public com.sun.javadoc.Type resultType() { | |||
TypeD typed = pointcutDec.getResultTypeD(); | |||
if (typed == null) return null; //TODO: maybe return VOID | |||
return null; //TODOtyped.getType(); | |||
} | |||
/** | |||
* Returns the type that nearest super class that defines | |||
* this method. | |||
* | |||
* @return the type that nearest super class that defines | |||
* this method. | |||
*/ | |||
public com.sun.javadoc.ClassDoc overriddenClass() { | |||
//TODO: This sucks!!! | |||
TypeDec where = pointcutDec.getDeclaringType().getTypeDec(); | |||
NameType superType = (NameType)where.getSuperClassType(); | |||
while (superType != null) { | |||
PointcutDec pc = Util.pointcutDec(superType, | |||
pointcutDec.getId(), | |||
pointcutDec.getFormals()); | |||
if (pc != null && !pc.getId().equals("NOT_FOUND")) { | |||
// XXX TypeDec result = superType.getTypeDec(); | |||
return null; //TODOresult; | |||
} | |||
if (superType.getTypeDec().getFullName(). | |||
equals("java.lang.Object")) { | |||
return null; | |||
} | |||
superType = (NameType)superType.getTypeDec().getSuperClassType(); | |||
} | |||
return null; | |||
} | |||
/** | |||
* Returns <code>true</code>. | |||
* | |||
* @return <code>true</code>. | |||
*/ | |||
public boolean isPointcut() { | |||
return true; | |||
} | |||
/** | |||
* Returns <code>true</code> if this method is <code>abstract</code>. | |||
* | |||
* @return <code>true</code> if this method is <code>abstract</code>. | |||
*/ | |||
public boolean isAbstract() { | |||
return pointcutDec.isAbstract(); | |||
} | |||
} |
@@ -1,203 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.compiler.base.ast.Dec; | |||
import org.aspectj.compiler.base.ast.Modifiers; | |||
import org.aspectj.compiler.base.ast.NameType; | |||
import org.aspectj.compiler.base.ast.TypeDec; | |||
import org.aspectj.compiler.crosscuts.AspectJCompiler; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.PackageDoc; | |||
import java.lang.reflect.Modifier; | |||
public abstract class ProgramElementDocImpl | |||
extends DocImpl | |||
implements org.aspectj.ajdoc.ProgramElementDoc { | |||
/** The containing ClassDoc. */ | |||
private final ClassDoc containingClass; | |||
/* | |||
construction of ProgramElementDocImpl must not recursively | |||
invoke construction of instances of subclass ClassDocImpl | |||
or endless recursion will be possible | |||
*/ | |||
public ProgramElementDocImpl(ClassDoc containingClass) { | |||
this.containingClass = containingClass; | |||
} | |||
/** | |||
* Returns the underlying Dec used for a number of methods. | |||
* | |||
* @return the underlying Dec used for a number of methods. | |||
*/ | |||
protected abstract Dec dec(); | |||
/** | |||
* Returns the AspectJCompiler that this tree. Delegates | |||
* to the underlying {@link #dec()}. | |||
* | |||
* @return the AspectJCompiler that compiled this tree. | |||
*/ | |||
protected final AspectJCompiler ajc() { | |||
return (AspectJCompiler)dec().getCompiler(); | |||
} | |||
/** | |||
* Returns this's Comment. | |||
* | |||
* @return the Comment for this Doc. | |||
*/ | |||
public Comment getComment() { | |||
if (super.getComment() == null) { | |||
setComment(new Comment(this, dec().getFormalComment(), err())); | |||
} | |||
return super.getComment(); | |||
} | |||
/** | |||
* Returns the nearest enclosing class. The returned value | |||
* is <code>null</code> if this is a top-level entity. | |||
* | |||
* @return a ClassDoc representing the nearest | |||
* enclosing class. This can be null for | |||
* top-level entities. | |||
*/ | |||
public ClassDoc containingClass() { | |||
return containingClass; | |||
} | |||
/** | |||
* Returns the package in which this Dec was declared. | |||
* | |||
* @return a PackageDoc representing the package | |||
* in which this Dec was declared. | |||
*/ | |||
public PackageDoc containingPackage() { | |||
return PackageDocImpl.getPackageDoc(nonNullTypeDec()); | |||
} | |||
/** | |||
*/ | |||
public TypeDec nonNullTypeDec() { | |||
if (dec().getDeclaringType() == null) return null; | |||
return ((NameType)dec().getDeclaringType()).getTypeDec(); | |||
} | |||
/** | |||
* An int form of this Dec's modifiers. | |||
* | |||
* @return an int form this Dec's modifiers. | |||
* @see java.lang.reflect.Modifier | |||
*/ | |||
public int modifierSpecifier() { | |||
return dec().getModifiers().getValue(); | |||
} | |||
/** | |||
* Returns the modifiers as a String. | |||
* | |||
* @return a String representing to modifiers. | |||
*/ | |||
public String modifiers() { | |||
return Modifier.toString(modifierSpecifier()); | |||
} | |||
/** | |||
* Returns <code>true</code> if this is <code>public</code>. | |||
* | |||
* @return <code>true</code> if this is <code>public</code>. | |||
*/ | |||
public boolean isPublic() { | |||
return dec().isPublic(); | |||
} | |||
/** | |||
* Returns <code>true</code> if this is <code>protected</code>. | |||
* | |||
* @return <code>true</code> if this is <code>protected</code>. | |||
*/ | |||
public boolean isProtected() { | |||
return dec().isProtected(); | |||
} | |||
/** | |||
* Returns <code>true</code> if this is <i>package private</i>. | |||
* | |||
* @return <code>true</code> if this is <i>package private</i>. | |||
*/ | |||
public boolean isPackagePrivate() { | |||
Modifiers mods = dec().getModifiers(); | |||
// todo: consider creating Dec.isPackagePrivate() | |||
// todo: consider NPE if mods null | |||
return ((null != mods) && mods.isPackagePrivate()); | |||
} | |||
/** | |||
* Returns <code>true</code> if this is <code>private</code>. | |||
* | |||
* @return <code>true</code> if this is <code>private</code>. | |||
*/ | |||
public boolean isPrivate() { | |||
return dec().isPrivate(); | |||
} | |||
/** | |||
* Returns <code>true</code> if this is <code>static</code>. | |||
* | |||
* @return <code>true</code> if this is <code>static</code>. | |||
*/ | |||
public boolean isStatic() { | |||
return dec().isStatic(); | |||
} | |||
/** | |||
* Returns <code>true</code> if this is <code>final</code>. | |||
* | |||
* @return <code>true</code> if this is <code>final</code>. | |||
*/ | |||
public boolean isFinal() { | |||
return dec().isFinal(); | |||
} | |||
/** | |||
* Returns the fully-qualified type name of this Dec (not member name). | |||
* | |||
* @return the fully-qualified name. | |||
*/ | |||
public String qualifiedName() { | |||
return name(); | |||
} | |||
/** | |||
* Returns the name -- e.g. ID. | |||
* | |||
* @return the name of the Dec. | |||
*/ | |||
public String name() { | |||
return dec().getId(); | |||
} | |||
} |
@@ -1,42 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
/** | |||
* Utility interface to allow us to shut up | |||
* the writers from redeclaring the generatio | |||
* of files. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface Quietable { | |||
/** | |||
* Tell someone to be quiet. | |||
*/ | |||
public void quiet(); | |||
/** | |||
* Allow someone to speak again. | |||
*/ | |||
public void speak(); | |||
} |
@@ -1,404 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.compiler.base.ast.TypeDec; | |||
import org.aspectj.compiler.base.ast.World; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.PackageDoc; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Set; | |||
/** | |||
* This is responsible for constituting the world | |||
* of specified[classes|packages] and all classes. | |||
* It ensures that any classes compiled are included (if appropriate) | |||
* but does not ensure that linked classes are. | |||
*/ | |||
public class RootDocImpl | |||
extends DocImpl | |||
implements org.aspectj.ajdoc.RootDoc, | |||
Quietable { | |||
/** The collection of packages specified to be documented. */ | |||
private final Set specifiedPackages; | |||
/** The collection of types specified to be documented. */ | |||
private final Set specifiedClasses; | |||
/** The collection of packages visible in this world. */ | |||
private final Set packages = new HashSet(); | |||
/** The collection of classes visible in this world. */ | |||
private final Set classes = new HashSet(); | |||
/** The documentation options. */ | |||
private final String[][] options; | |||
/** The World delegate. */ | |||
private final World world; | |||
/** Determines whether items are included */ | |||
private final AccessChecker filter; | |||
public RootDocImpl(World world, String[][] options, | |||
Collection pkgnames, Collection classnames, | |||
AccessChecker filter) { | |||
this.world = world; | |||
this.options = options; | |||
this.filter = (null != filter ? filter : AccessChecker.PUBLIC); | |||
Set set = createSpecifiedPackages(pkgnames); | |||
specifiedPackages = set; // modifiable to prune empty packages | |||
set = createSpecifiedClasses(classnames); | |||
specifiedClasses = Collections.unmodifiableSet(set); | |||
// adds all world classes and packages for classes and packages | |||
// addWorldTypes(); // todo re-enable as needed | |||
// make sure specified are added - should duplicate world | |||
// but should come after since packages are removed if empty | |||
addSpecifiedPackages(); | |||
addSpecifiedClasses(); | |||
setupDominatesRelations(); | |||
ensureWorldInclusion(); | |||
} | |||
/* ------------------------------------------------------------ | |||
* Implementation of RootDoc | |||
* ------------------------------------------------------------ | |||
*/ | |||
/** | |||
* Returns the classes visible in this world. | |||
* | |||
* @return an array of ClassDoc representing the visible | |||
* classes in this world. | |||
*/ | |||
public ClassDoc[] classes() { | |||
return (ClassDoc[])classes.toArray | |||
(new org.aspectj.ajdoc.ClassDoc[classes.size()]); | |||
} | |||
/** | |||
* Returns a type visible in this world | |||
* for the name <code>className</code>. If there is | |||
* no visible package, this method will return | |||
* <code>null</code>. | |||
* | |||
* @return an instance of ClassDoc in this world | |||
* that corresponds to <code>className</code>. | |||
* <code>null</code> is returned if there exists | |||
* no such visible type named <code>className</code>. | |||
*/ | |||
public ClassDoc classNamed(String className) { | |||
ClassDoc[] docs = classes(); | |||
for (int i = 0; i < docs.length; i++) { | |||
ClassDoc doc = docs[i]; | |||
if (doc.name().equals(className)) { | |||
return doc; | |||
} | |||
} | |||
return null; | |||
} | |||
/** | |||
* Returns a package visible in this world | |||
* for the name <code>packageName</code>. If there is | |||
* no visible package, this method will return | |||
* <code>null</code>. | |||
* | |||
* @return an instance of PackageDoc in this world | |||
* that corresponds to <code>packageName</code>. | |||
* <code>null</code> is returned if there exists | |||
* no such visible package named <code>packageName</code>. | |||
*/ | |||
public PackageDoc packageNamed(String packageName) { | |||
for (Iterator i = packages.iterator(); i.hasNext();) { | |||
PackageDoc doc = (PackageDoc)i.next(); | |||
if (doc.name().equals(packageName)) { | |||
return doc; | |||
} | |||
} | |||
return null; | |||
} | |||
/** | |||
* Returns the underlying world. | |||
* | |||
* @return an instance of World representing all | |||
* the CompilationUnits. | |||
*/ | |||
public World world() { | |||
return world; | |||
} | |||
/** | |||
* Returns the documentation options. | |||
* | |||
* @return the documentation options. | |||
*/ | |||
public String[][] options() { | |||
return options; | |||
} | |||
/** | |||
* Returns the types specified to be documented. | |||
* | |||
* @return an array of ClassDoc representing the | |||
* specified types. | |||
*/ | |||
public ClassDoc[] specifiedClasses() { | |||
return (ClassDoc[])specifiedClasses.toArray | |||
(new org.aspectj.ajdoc.ClassDoc[specifiedClasses.size()]); | |||
} | |||
/** | |||
* Returns the packages specified to be documented. | |||
* | |||
* @return an array of PackageDoc representing the | |||
* specified packages. | |||
*/ | |||
public PackageDoc[] specifiedPackages() { | |||
return (PackageDoc[])specifiedPackages.toArray | |||
(new org.aspectj.ajdoc.PackageDoc[specifiedPackages.size()]); | |||
} | |||
/* ------------------------------------------------------------ | |||
* Implementation of Quietable | |||
* ------------------------------------------------------------ | |||
*/ | |||
/** <code>true</code> when notices should be printed. */ | |||
private boolean notice = true; | |||
/** Supresses output notices. */ | |||
public void quiet() { notice = false; } | |||
/** Allows output notices. */ | |||
public void speak() { notice = true; } | |||
/* ------------------------------------------------------------ | |||
* Implementation of DocErrReporter | |||
* ------------------------------------------------------------ | |||
*/ | |||
/** | |||
* Prints the error message <code>msg</code> using | |||
* the current error handler. | |||
* | |||
* @param msg the error message. | |||
*/ | |||
public void printError(String msg) { | |||
err().printError(msg); | |||
} | |||
/** | |||
* Prints the notice message <code>msg</code> using | |||
* the current error handler. | |||
* | |||
* @param msg the notice message. | |||
*/ | |||
public void printNotice(String msg) { | |||
if (notice) err().printNotice(msg); | |||
} | |||
/** | |||
* Prints the warning message <code>msg</code> using | |||
* the current error handler. | |||
* | |||
* @param msg the warning message. | |||
*/ | |||
public void printWarning(String msg) { | |||
err().printWarning(msg); | |||
} | |||
/* ------------------------------------------------------------ | |||
* Implementation of Doc | |||
* ------------------------------------------------------------ | |||
*/ | |||
/** | |||
* Returns <code>null</code>. | |||
* | |||
* @return <code>null</code>. | |||
*/ | |||
public String name() { | |||
return "who knows???"; | |||
} | |||
/* ------------------------------------------------------------ | |||
* Helper methods | |||
* ------------------------------------------------------------ | |||
*/ | |||
/** | |||
* Creates only PackageDocs that were included on the command | |||
* line, even if they are empty. Should be used only for | |||
* specifiedPackages. | |||
*/ | |||
private HashSet createSpecifiedPackages(Collection pkgnames) { | |||
HashSet result = new HashSet(); | |||
for (Iterator i = pkgnames.iterator(); i.hasNext();) { | |||
String pkgname = (String)i.next(); | |||
PackageDocImpl pkgdoc = PackageDocImpl.getPackageDoc(pkgname); | |||
pkgdoc.setIncluded(true); | |||
result.add(pkgdoc); | |||
} | |||
return result; | |||
} | |||
private void addWorldTypes() { | |||
for (Iterator i = world.getTypes().iterator(); i.hasNext();) { | |||
TypeDec td = (TypeDec)i.next(); | |||
ClassDocImpl cd = ClassDocImpl.getInstance(td); | |||
addClass(cd); | |||
cd.setIncluded(filter.canAccess(td)); | |||
} | |||
} | |||
/** | |||
* Creates only ClassDocs that were included on the command | |||
* line, and then only if they pass the filter. | |||
* Should be used only for specifiedClasses. | |||
* todo: createClasses uses to use all classes if no names | |||
*/ | |||
private HashSet createSpecifiedClasses(Collection classnames) { | |||
HashSet result = new HashSet(); | |||
if (classnames != null) { | |||
for (Iterator i = classnames.iterator(); i.hasNext();) { | |||
String classname = (String)i.next(); | |||
for (Iterator j = world.getTypes().iterator(); j.hasNext();) { | |||
TypeDec td = (TypeDec)j.next(); | |||
if (filter.canAccess(td)) { | |||
ClassDoc cd = ClassDocImpl.getInstance(td); | |||
if (cd.qualifiedName().equals(classname)) { | |||
result.add(cd); | |||
// add inner classes since not specified explicitly | |||
ClassDoc[] inners = cd.innerClasses(); // no cycles, right? | |||
if (null != inners) { | |||
for (int l = 0; l < inners.length; l++) { | |||
result.add(inners[l]); | |||
} | |||
} | |||
break; | |||
} | |||
} | |||
} | |||
// todo: warn if class specified but not in world? | |||
} | |||
} | |||
return result; | |||
} | |||
private void addSpecifiedClasses() { | |||
for (Iterator i = new ArrayList(specifiedClasses).iterator(); i.hasNext();) { | |||
ClassDoc cd = (ClassDoc)i.next(); | |||
addClass(cd); | |||
} | |||
} | |||
private void addSpecifiedPackages() { | |||
for (Iterator i = new ArrayList(specifiedPackages).iterator(); i.hasNext();) { | |||
PackageDoc pd = (PackageDoc)i.next(); | |||
ClassDoc[] allClasses = pd.allClasses(); | |||
if (allClasses.length == 0) { | |||
specifiedPackages.remove(pd); | |||
} else { | |||
for (int j = 0; j < allClasses.length; j++) { | |||
addClass(allClasses[j]); | |||
} | |||
} | |||
} | |||
} | |||
/** | |||
* If filter accepts this ClassDoc, | |||
* Add it and and inner classes to classes | |||
* and add package to packages. | |||
*/ | |||
private void addClass(ClassDoc cd) { | |||
if (null == cd) return; | |||
ClassDocImpl impl = (ClassDocImpl) cd; | |||
if (filter.canAccess(impl.typeDec()) | |||
&& (!classes.contains(impl))) { | |||
impl.setIncluded(true); | |||
classes.add(impl); | |||
packages.add(impl.containingPackage()); | |||
ClassDoc[] inners = impl.innerClasses(); | |||
for (int i = 0; i < inners.length; i++) { | |||
addClass(inners[i]); | |||
} | |||
} // todo: flag classes not added? | |||
} | |||
/** Read all classes to find any dominates relations */ | |||
private void setupDominatesRelations() { | |||
// Find just the aspects | |||
List aspects = new ArrayList(); | |||
ClassDoc[] classes = classes(); | |||
for (int i = 0; i < classes.length; i++) { | |||
ClassDocImpl cd = (ClassDocImpl)classes[i]; | |||
if (cd.isAspect()) { | |||
aspects.add(cd); | |||
} | |||
} | |||
// Iterate over the aspects, if | |||
for (Iterator i = aspects.iterator(); i.hasNext();) { | |||
AspectDocImpl aspect1 = (AspectDocImpl)i.next(); | |||
for (Iterator j = aspects.iterator(); j.hasNext();) { | |||
AspectDocImpl aspect2 = (AspectDocImpl)j.next(); | |||
if (aspect1.dominates(aspect2)) { | |||
aspect1.addDominatee(aspect2); | |||
aspect2.addDominator(aspect1); | |||
} | |||
} | |||
} | |||
} | |||
/** | |||
* Ensure compiled classes are included if they pass the filter | |||
* and excluded otherwise. | |||
* todo: The set of types available includes the world plus reachable | |||
* types from there; I would like to exclude the reachable ones, | |||
* but do not know how. | |||
*/ | |||
private void ensureWorldInclusion() { | |||
for (Iterator i = world.getTypes().iterator(); i.hasNext();) { | |||
TypeDec td = (TypeDec)i.next(); | |||
ClassDocImpl cd = ClassDocImpl.getInstance(td); | |||
boolean isIncluded = cd.isIncluded(); | |||
// todo: update to consider enclosing class privileges | |||
boolean shouldInclude = filter.canAccess(td); | |||
if (shouldInclude != isIncluded) { | |||
cd.setIncluded(shouldInclude); | |||
} | |||
} | |||
} | |||
} |
@@ -1,72 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import com.sun.javadoc.DocErrorReporter; | |||
import com.sun.javadoc.RootDoc; | |||
import java.util.List; | |||
/** | |||
* Interface specifying types that | |||
* can produce RootDocs. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public interface RootDocMaker { | |||
/** | |||
* Returns a RootDoc using the passed in parameters. | |||
* Throw a CannotMakeRootDocException is something | |||
* goes awry. | |||
* | |||
* @param sourcepath sourcepath to use. | |||
* @param classpath classpath to use. | |||
* @param bootclasspath bootclasspath to use. | |||
* @param extdirs extdirs to use. | |||
* @param flags flags to use. | |||
* @param encoding encoding to use. | |||
* @param locale locale to use. | |||
* @param source source to use. | |||
* @param filenamesAndPackages filenamesAndPackages to use. | |||
* @param options options to use. | |||
* @param err ErrPrinter to use. | |||
* @param programName program name to use. | |||
* @param filter filter to use. | |||
* @return a RootDoc. | |||
*/ | |||
public RootDoc makeRootDoc(String sourcepath, | |||
String classpath, | |||
String bootclasspath, | |||
String extdirs, | |||
long flags, | |||
String encoding, | |||
String locale, | |||
String source, | |||
List filenamesAndPackages, | |||
List options, | |||
DocErrorReporter err, | |||
String programName, | |||
AccessChecker filter) | |||
throws CannotMakeRootDocException; | |||
} |
@@ -1,874 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.ajdoc.AdviceDoc; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import org.aspectj.ajdoc.PointcutDoc; | |||
import org.aspectj.compiler.base.JavaCompiler; | |||
import org.aspectj.compiler.base.ast.ASTObject; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.ConstructorDoc; | |||
import com.sun.javadoc.Doc; | |||
import com.sun.javadoc.FieldDoc; | |||
import com.sun.javadoc.MemberDoc; | |||
import com.sun.javadoc.MethodDoc; | |||
import com.sun.javadoc.PackageDoc; | |||
import com.sun.javadoc.Parameter; | |||
import com.sun.javadoc.SeeTag; | |||
import java.io.PrintStream; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.Locale; | |||
import java.util.StringTokenizer; | |||
/** | |||
* Implementation of see tags in the aspectj-world. | |||
* See source for bug comments | |||
* @author Jeff Palm | |||
*/ | |||
public class SeeTagImpl extends TagImpl implements SeeTag { | |||
/* | |||
* This implementation handles | |||
*<pre>{@link package.class#member label} | |||
* @see package.class#member label | |||
* @see "some reference" | |||
* @see <any tag - should be url></pre>. | |||
* It has errors since the tag-separating code which provides | |||
* input is wrong, and it's very weak in how it handles | |||
* text and URLs. Most of the action is in resolve(). | |||
*/ | |||
/** The package name specified by the user -- may be null. */ | |||
private String packageName; | |||
/** The class name specified by the user -- may be null. */ | |||
private String className; | |||
/** The member name specified by the user -- may be null. */ | |||
private String memberName; | |||
/** The referenced package. */ | |||
private PackageDoc packageDoc; | |||
/** The referenced class. */ | |||
private ClassDoc classDoc; | |||
/** The referenced member. */ | |||
private MemberDoc memberDoc; | |||
/** The label associated with the tag. */ | |||
private String label = ""; | |||
/** A shared instance of the compiler -- a little hacky. */ | |||
private static JavaCompiler ajc = AjdocCompiler.instance(); | |||
/** | |||
* Constructs the new tag with given parameters and | |||
* calls resolve to parse the class, package, and members. | |||
* | |||
* @param doc the new value for <code>doc</code>. | |||
* @param name the new value for <code>name</code>. | |||
* @param text the new value for <code>text</code>. | |||
* @param locale the new value for <code>locale</code>. | |||
* @param err the new value for <code>err</code>. | |||
*/ | |||
public SeeTagImpl(Doc doc, | |||
String name, | |||
String text, | |||
Locale loc, | |||
ErrPrinter err) { | |||
super(doc, name, text, loc, err); | |||
resolve(); | |||
} | |||
/** | |||
* Returns the label. | |||
* | |||
* @return the label. | |||
*/ | |||
public String label() { | |||
return label; | |||
} | |||
/** | |||
* Returns the referenced package's name. | |||
* This <b>can</b> be <code>null</code>. | |||
* | |||
* @return the referenced package's name. | |||
*/ | |||
public String referencedPackageName() { | |||
return packageName; | |||
} | |||
/** | |||
* Returns the referenced package. | |||
* This <b>can</b> be <code>null</code>. | |||
* | |||
* @return a PackageDoc with name packageName. | |||
*/ | |||
public PackageDoc referencedPackage() { | |||
look(); | |||
return packageDoc; | |||
} | |||
/** | |||
* Returns the referenced class's name. | |||
* This <b>can</b> be <code>null</code>. | |||
* | |||
* @return the referenced class's name. | |||
*/ | |||
public String referencedClassName() { | |||
return className; | |||
} | |||
/** | |||
* Returns the referenced class. | |||
* This <b>can</b> be <code>null</code>. | |||
* | |||
* @return a ClassDoc with name className. | |||
*/ | |||
public ClassDoc referencedClass() { | |||
look(); | |||
return classDoc; | |||
} | |||
/** | |||
* Returns the referenced members's name. | |||
* This <b>can</b> be <code>null</code>. | |||
* This can be null. | |||
* | |||
* @return the referenced class's name. | |||
*/ | |||
public String referencedMemberName() { | |||
return memberName; | |||
} | |||
/** | |||
* Returns the referenced member. | |||
* This <b>can</b> be <code>null</code>. | |||
* | |||
* @return a ClassDoc with name memberName. | |||
*/ | |||
public MemberDoc referencedMember() { | |||
look(); | |||
return memberDoc; | |||
} | |||
/** | |||
* Returns <code>see</code>. | |||
* | |||
* @return <code>see</code>. | |||
*/ | |||
public String kind() { | |||
return "@see"; | |||
} | |||
protected JavaCompiler ajc() { | |||
if (ajc != null) { | |||
return ajc; | |||
} else if (doc() instanceof ASTObject) { | |||
return ajc = ((ASTObject)doc()).getCompiler(); | |||
} else if (doc() instanceof PackageDocImpl) { | |||
return ajc = ((PackageDocImpl)doc()).ajc(); | |||
} | |||
return null; | |||
} | |||
void debugState(String m, PrintStream err) { | |||
if (System.getProperty("seetag.debug") != null) { | |||
if (null == err) err = System.err; | |||
err.println("\t______________________ " + m | |||
+ "\n\tpackageName: "+packageName | |||
+ "\n\t packageDoc: " +packageDoc | |||
+ "\n\t className: " +className | |||
+ "\n\t classDoc: " +classDoc | |||
+ "\n\t memberName: " +memberName | |||
+ "\n\t memberDoc: " +memberDoc | |||
+ "\n\t label: " +label | |||
); | |||
} | |||
} | |||
private boolean looked = false; | |||
private void look() { | |||
if (!looked) { | |||
looked = true; | |||
dolook(); | |||
} | |||
debugState("SeeTagImpl.look()", null); | |||
} | |||
private void dolook() { | |||
// For null or empty classnames set the current doc | |||
// to the referenced class | |||
if (className == null || className.length() < 1) { | |||
classDoc = classDoc(doc()); | |||
} else { | |||
// Use the class in which this doc is contained | |||
// as a starting point... | |||
ClassDoc container = classDoc(doc()); | |||
// ..and try to find the class from there | |||
if (container == null) { | |||
//TODO: Find class somewhere else | |||
} else { | |||
String fullName; | |||
if (packageName == null || packageName.length() < 1) { | |||
fullName = className; | |||
} else { | |||
fullName = packageName + '.' + className; | |||
} | |||
// As per the language spec... | |||
// http://java.sun.com/docs/books/jls/second_edition/ (con't) | |||
// html/names.doc.html#32725 | |||
// We must first consider types before identifiers, | |||
// therefore, if there is no right parent in the member name | |||
// we have to consider this first an inner class, and if | |||
// one is found set the member name to nul | |||
if (memberName != null && | |||
memberName.indexOf('(') == -1) { | |||
classDoc = container.findClass(fullName + '.' + memberName); | |||
// If we found an inner class, don't look for a member | |||
if (classDoc != null) { | |||
memberName = null; | |||
} | |||
} | |||
// Now if we didn't find an inner class, just look | |||
// up the full name | |||
if (classDoc == null) { | |||
classDoc = container.findClass(fullName); | |||
} | |||
} | |||
} | |||
// If we found a class, then the package is that | |||
// class's contained package | |||
if (classDoc != null) { | |||
packageDoc = classDoc.containingPackage(); | |||
} else if (packageName == null) { | |||
// If we didn't find a class, but the class name | |||
// contains no periods, maybe the class name's really | |||
// a package name | |||
if (classDoc == null && className != null && | |||
className.indexOf('.') == -1) { | |||
packageDoc = PackageDocImpl.getPackageDoc(className); | |||
} | |||
// Otherwise, if the referenced class isn't null, set the | |||
// referenced package to that class's contained package | |||
else if (classDoc != null) { | |||
packageDoc = classDoc.containingPackage(); | |||
} | |||
// Lastly, if the current doc is a package (i.e. package.html) | |||
// then set the referenced package to the current doc | |||
else if (doc() instanceof PackageDoc) { | |||
packageDoc = (PackageDoc)doc(); | |||
} | |||
} else { | |||
// Look for the fully qualified name of the | |||
// package elsewhere | |||
packageDoc = PackageDocImpl.getPackageDoc(packageName != null | |||
? packageName | |||
: ""); | |||
} | |||
// Look for the member if the member name wasn't null | |||
if (memberName != null) { | |||
lookForMember(memberName, (org.aspectj.ajdoc.ClassDoc)classDoc); | |||
} | |||
} | |||
private void lookForMember(String spec, | |||
org.aspectj.ajdoc.ClassDoc container) { | |||
int ilparen = spec.indexOf('('); | |||
String name; | |||
// No parens mean a field or a method | |||
// The order is for looking is: | |||
// [1] field | |||
// [2] method | |||
// [3] pointcut | |||
if (ilparen == -1) { | |||
name = spec; | |||
if ((memberDoc = fieldDoc(name, container)) != null) { | |||
return; | |||
} | |||
if ((memberDoc = methodDoc(name, container, null)) != null) { | |||
return; | |||
} | |||
if ((memberDoc = pointcutDoc(name, container, null)) != null) { | |||
return; | |||
} | |||
} else { | |||
name = spec.substring(0, ilparen); | |||
} | |||
int irparen = spec.lastIndexOf(')'); | |||
// Crop out the parameters | |||
String paramsString; | |||
if (irparen != -1) { | |||
paramsString = spec.substring(ilparen+1, irparen); | |||
} else { | |||
paramsString = spec.substring(ilparen+1, spec.length()-1); | |||
} | |||
// Convert the raw parameters to an array | |||
String[] paramNames = paramNames(paramsString); | |||
// Try to match the name and parameters if the following order: | |||
// [1] method | |||
// [2] constructor | |||
// [3] pointcut | |||
// [4] advice | |||
if ((memberDoc = methodDoc(name, container, paramNames)) != null) { | |||
return; | |||
} | |||
if ((memberDoc = constructorDoc(container, paramNames)) != null) { | |||
return; | |||
} | |||
if ((memberDoc = pointcutDoc(name, container, paramNames)) != null) { | |||
return; | |||
} | |||
if (container instanceof AspectDoc) { | |||
if ((memberDoc = adviceDoc(name, | |||
(AspectDoc)container, | |||
paramNames)) != null) { | |||
return; | |||
} | |||
} | |||
} | |||
private String[] paramNames(String restNoParens) { | |||
if (restNoParens == null || restNoParens.length() == 0) { | |||
return new String[0]; | |||
} | |||
List params = new ArrayList(); | |||
for (StringTokenizer t = new StringTokenizer(restNoParens, ",", false); | |||
t.hasMoreTokens();) { | |||
String spec = t.nextToken().trim(); | |||
int ispace = spec.indexOf(' '); | |||
if (ispace != -1) { | |||
spec = spec.substring(0, ispace); | |||
} | |||
params.add(spec); | |||
} | |||
return (String[])params.toArray(new String[params.size()]); | |||
} | |||
private FieldDoc fieldDoc(String name, ClassDoc container) { | |||
for (ClassDoc cd = container; cd != null; cd = cd.superclass()) { | |||
FieldDoc[] docs = cd.fields(); | |||
for (int i = 0, N = docs.length; i < N; i++) { | |||
if (docs[i].name().equals(name)) { | |||
return docs[i]; | |||
} | |||
} | |||
} | |||
return null; | |||
} | |||
private PointcutDoc pointcutDoc(String name, | |||
org.aspectj.ajdoc.ClassDoc container, | |||
String[] paramNames) { | |||
if (null == name) return null; // XXX warn or error | |||
for (org.aspectj.ajdoc.ClassDoc cd = container; | |||
cd != null; | |||
cd = (org.aspectj.ajdoc.ClassDoc)cd.superclass()) { | |||
PointcutDoc[] docs = cd.pointcuts(); | |||
if (null == docs) { | |||
continue; | |||
} | |||
for (int i = 0, N = docs.length; i < N; i++) { | |||
PointcutDoc md = docs[i]; | |||
if ((null != md) | |||
&& (name.equals(md.name())) | |||
&& ((null == paramNames) | |||
|| parametersMatch(md.parameters(), paramNames, container))) { | |||
return md; | |||
} | |||
} | |||
} | |||
return null; | |||
} | |||
private MethodDoc methodDoc(String name, ClassDoc container, | |||
String[] paramNames) { | |||
for (ClassDoc cd = container; cd != null; cd = cd.superclass()) { | |||
MethodDoc[] docs = cd.methods(); | |||
for (int i = 0, N = docs.length; i < N; i++) { | |||
MethodDoc md = docs[i]; | |||
if (!md.name().equals(name)) { | |||
continue; | |||
} | |||
if (paramNames == null) { | |||
return md; | |||
} else { | |||
if (parametersMatch(md.parameters(), | |||
paramNames, | |||
container)) { | |||
return md; | |||
} | |||
} | |||
} | |||
} | |||
return null; | |||
} | |||
private ConstructorDoc constructorDoc(ClassDoc container, | |||
String[] paramNames) { | |||
for (ClassDoc cd = container; cd != null; cd = cd.superclass()) { | |||
ConstructorDoc[] docs = cd.constructors(); | |||
for (int i = 0, N = docs.length; i < N; i++) { | |||
ConstructorDoc md = docs[i]; | |||
if (paramNames == null) { | |||
return md; | |||
} else { | |||
if (parametersMatch(md.parameters(), | |||
paramNames, | |||
container)) { | |||
return md; | |||
} | |||
} | |||
} | |||
} | |||
return null; | |||
} | |||
private AdviceDoc adviceDoc(String name, | |||
AspectDoc container, | |||
String[] paramNames) { | |||
AspectDoc cd = container; | |||
while (cd != null) { | |||
AdviceDoc[] docs = cd.advice(); | |||
for (int i = 0, N = docs.length; i < N; i++) { | |||
AdviceDoc md = docs[i]; | |||
if (!(name.equals(md.name()))) { | |||
continue; | |||
} | |||
if (paramNames == null) { | |||
return md; | |||
} else { | |||
if (parametersMatch(md.parameters(), | |||
paramNames, | |||
container)) { | |||
return md; | |||
} | |||
} | |||
} | |||
Object o = cd.superclass(); | |||
if (o instanceof AspectDoc) { | |||
cd = (AspectDoc) o; | |||
} else { | |||
cd = null; | |||
} | |||
} | |||
return null; | |||
} | |||
private boolean parametersMatch(Parameter[] params, | |||
String[] paramNames, | |||
ClassDoc container) { | |||
if ((null == params) || (null == paramNames) || (null == container)) { | |||
return false; | |||
} | |||
if (params.length != paramNames.length) { | |||
return false; | |||
} | |||
for (int i = 0, N = params.length; i < N; i++) { | |||
com.sun.javadoc.Type type1 = params[i].type(); | |||
com.sun.javadoc.Type type2 = TypeImpl.getInstance(paramNames[i], | |||
container); | |||
if ((null == type1) || (!type1.equals(type2))) { | |||
return false; | |||
} | |||
} | |||
return true; | |||
} | |||
private ClassDoc classDoc(Doc d) { | |||
if (d instanceof ClassDoc) { | |||
return (ClassDoc)d; | |||
} | |||
if (d instanceof MemberDoc) { | |||
return ((MemberDoc)d).containingClass(); | |||
} | |||
return null; | |||
} | |||
/** find next (matching) char x, ignoring instances | |||
* preceded by escape character '\'. | |||
*/ | |||
private static int findNextChar(final String s, final int start, final char x) { // XXX to Util | |||
if ((null != s) && (start >= 0)) { | |||
boolean escaped = false; | |||
for (int i = start; i < s.length(); i++) { | |||
char c = s.charAt(i); | |||
if (('\\' == c) && !escaped) { | |||
escaped = true; | |||
continue; | |||
} else if ((x == c) && !escaped) { | |||
return i; | |||
} | |||
if (escaped) { | |||
escaped = false; | |||
} | |||
} | |||
} | |||
return -1; | |||
} | |||
/** | |||
* This looks a bit hideous, and it is, I had a state diagram | |||
* with every thing labled, but I lost it -- sorry ;). | |||
* <pre>{@link package.class#member label} </pre> | |||
* http://java.sun.com/j2se/1.3/docs/tooldocs/solaris/javadoc.html#\{@link} | |||
*/ | |||
private void resolve() { | |||
String str = text(); | |||
if (str == null || str.length() < 1) { | |||
return; | |||
} | |||
str = str.trim(); | |||
int N = str.length(); | |||
char first = str.charAt(0); | |||
if (first == '<') { | |||
if ((N < 4) || (str.charAt(N-1) != '>')) { | |||
err().error("see_tag_unterminated_url",str); | |||
} else { | |||
char second = str.charAt(1); | |||
if ((second == 'a') || (second == 'A')) { | |||
label = str; | |||
} else { | |||
err().error("see_tag_unterminated_url",str); // XXX wrong message | |||
} | |||
} | |||
return; | |||
} | |||
if (first == '"') { | |||
if (N == 1) { | |||
err().error("see_tag_unterminated_string",str); | |||
} else if (str.charAt(N-1) == '"') { | |||
label = str; | |||
} else { | |||
int loc = findNextChar(str, 1, '"'); | |||
if (-1 == loc) { | |||
err().error("see_tag_unterminated_string",str); | |||
} else { | |||
label = str.substring(0, loc+1); | |||
} | |||
} | |||
return; | |||
} | |||
// XXX but does not handle URLs? | |||
char c = 0; | |||
int state = 0, next = 0; | |||
boolean finished = false; | |||
int iclassEnd = -1; | |||
int isharp = -1; | |||
int ilastDot = -1; | |||
int iStartLabel = -1; | |||
int iEndMemberLabel = -1; // membername plus parameters | |||
boolean sharp = false; | |||
int i; | |||
done: | |||
for (i = 0; i < N; i++, state = next) { | |||
c = str.charAt(i); | |||
switch (state) { | |||
case 0: // seeking initial: [type|memberName] | |||
if (ident(c)) { next = 1; } | |||
else if (c == '#') { next = 2; iclassEnd = i-1; } | |||
else { | |||
err().error("see_tag_dot_sharp_or_id","\""+c+"\"@0",str); | |||
return; | |||
} | |||
break; | |||
case 1: // reading initial [type|memberName] | |||
if (ident(c)) { next = 1; } | |||
else if (c == '#') { next = 2; iclassEnd = i-1; } | |||
else if (c == '.') { next = 3; ilastDot = i; } | |||
else if (space(c)) { iclassEnd = i-1; next = 16; } | |||
else { | |||
err().error("see_tag_invalid_package_or_class","\""+c+"\"@1",str); | |||
return; | |||
} | |||
break; | |||
case 2: // start reading membername (field only?) | |||
sharp = true; | |||
if (ident(c)) { next = 4; isharp = i; } | |||
else { | |||
err().error("see_tag_expecting_field_name","\""+c+"\"@2",str); | |||
return; | |||
} | |||
break; | |||
case 3: // reading qualified type name | |||
if (ident(c)) { next = 1; } | |||
else { | |||
err().error("see_tag_invalid_id","\""+c+"\"@3",str); | |||
return; | |||
} | |||
break; | |||
case 4: // reading membername | |||
if (ident(c)) { next = 4; } | |||
else if (space(c)) { next = 13; iEndMemberLabel = i-1;} | |||
else if (c == '(') { next = 15; } | |||
else { | |||
err().error("see_tag_invalid_param_start","\""+c+"\"@4",str); | |||
return; | |||
} | |||
break; | |||
case 5: // start reading parms | |||
if (ident(c)) { next = 6; } | |||
else if (space(c)) { next = 5; } | |||
else if (c == ')') { next = 13; iEndMemberLabel = i;} | |||
else { | |||
err().error("see_tag_premature_param_end","\""+c+"\"@5",str); | |||
return; | |||
} | |||
break; | |||
case 6: // reading parm (or type?) | |||
if (ident(c)) { next = 6; } | |||
else if (c == '.') { next = 7; } | |||
else if (c == '[') { next = 8; } | |||
else if (space(c)) { next = 10; } | |||
else if (c == ',') { next = 12; } | |||
else if (c == ')') { iEndMemberLabel = i; next = 16; } | |||
else { | |||
err().error("see_tag_invalid_parameter_type","\""+c+"\"@6",str); | |||
return; | |||
} | |||
break; | |||
case 7: // reading qualified parameter type . | |||
if (ident(c)) { next = 6; } | |||
else { | |||
err().error("see_tag_invalid_parameter_type_ident","\""+c+"\"@7",str); | |||
return; | |||
} | |||
break; | |||
case 8: // reading end of [] | |||
if (c == ']') { next = 9; } | |||
else if (space(c)) { next = 8; } | |||
else { | |||
err().error("see_tag_unterminated_array_type","\""+c+"\"@8",str); | |||
return; | |||
} | |||
break; | |||
case 9: // maybe completed parameter type | |||
if (c == '[') { next = 8; } | |||
else if (space(c)) { next = 10; } | |||
else if (c == ',') { next = 12; } | |||
else if (c == ')') { iEndMemberLabel = i; next = 16; } | |||
else { | |||
err().error("see_tag_invalid_parameter_type","\""+c+"\"@9",str); | |||
return; | |||
} | |||
break; | |||
case 10: // completed parm type? | |||
if (ident(c)) { next = 11; } | |||
else if (space(c)) { next = 12; } | |||
else if (c == ',') { next = 14; } | |||
else if (c == ')') { iEndMemberLabel = i; next = 16; } | |||
else { | |||
err().error("see_tag_invalid_parameters","\""+c+"\"@10",str); | |||
return; | |||
} | |||
break; | |||
case 11: // reading parm type? | |||
if (ident(c)) { next = 11; } | |||
else if (space(c)) { next = 12; } | |||
else if (c == ',') { next = 14; } | |||
else if (c == ')') { iEndMemberLabel = i; next = 16; } | |||
else { | |||
err().error("see_tag_invalid_parameters","\""+c+"\"@11",str); | |||
return; | |||
} | |||
break; | |||
case 12: // looking for next parm? | |||
if (space(c)) { next = 12; } | |||
else if (c == ',') { next = 14; } | |||
else if (ident(c)) { next = 15; } | |||
else if (c == ')') { iEndMemberLabel = i; next = 16; } | |||
else { | |||
err().error("see_tag_invalid_parameters","\""+c+"\"@12",str); | |||
return; | |||
} | |||
break; | |||
case 13: // seeking parms or label | |||
if (space(c)) { next = 13; } | |||
else if (c == '(') { next = 5; } // start reading parms | |||
else if (ident(c)) { // start reading label | |||
iStartLabel = i; next = 17; | |||
} | |||
else { | |||
err().error("see_tag_invalid_parameters","\""+c+"\"@13",str); | |||
return; | |||
} | |||
break; | |||
case 14: // type name (or identifier) | |||
if (ident(c)) { next = 6; } | |||
else if (space(c)) { next = 14; } | |||
else { | |||
err().error("see_tag_expecting_typename_or_whitespace","\""+c+"\"@14",str); | |||
return; | |||
} | |||
break; | |||
case 15: // reading parms | |||
if (ident(c)) { next = 6; } | |||
else if (space(c)) { next = 15; } | |||
else if (c == ')') { iEndMemberLabel = i; next = 16; } | |||
else { | |||
err().error("see_tag_premature_param_end","\""+c+"\"@15",str); | |||
return; | |||
} | |||
break; | |||
case 16 : // seeking label | |||
if (ident(c)) { iStartLabel = i; next = 17; } | |||
else if (space(c)) { next = 16; } | |||
else { | |||
String s = "\"" + c + "\" in \"" + text() + "\""; | |||
err().error("see_tag_premature_param_end",s + "@16",str); | |||
return; | |||
} | |||
break; | |||
case 17 : // reading label - may have internal spaces | |||
if (ident(c)) { next = 17; } | |||
else if (space(c)) { next = 17; } | |||
// XXX known limitation - labels may only be ident + whitespace (no -) | |||
else { | |||
err().error("see_tag_premature_param_end","\""+c+"\"@17",str); | |||
return; | |||
} | |||
break; | |||
} | |||
if (i == N-1) { | |||
finished = next == -1 | |||
|| next == 1 || next == 13 | |||
|| next == 16 || next == 17 | |||
|| next == 4 || next == 12; | |||
} | |||
} | |||
if (sharp) { | |||
if (ilastDot != -1) { | |||
packageName = str.substring(0, ilastDot); | |||
} | |||
} else { | |||
if (ilastDot == -1) { | |||
//packageName = str; | |||
} else { | |||
packageName = str.substring(0, ilastDot); | |||
} | |||
} | |||
if (sharp) { | |||
if (iclassEnd != -1) { | |||
if (ilastDot == -1) { | |||
className = str.substring(0, iclassEnd+1); | |||
} else { | |||
className = str.substring(ilastDot+1, iclassEnd+1); | |||
} | |||
} | |||
} else { | |||
if (ilastDot == -1) { | |||
if (iclassEnd != -1) { | |||
className = str.substring(0, iclassEnd+1); | |||
} else { | |||
className = str; | |||
} | |||
} else { | |||
if (iclassEnd != -1) { | |||
className = str.substring(ilastDot+1, iclassEnd+1); | |||
} else { | |||
className = str.substring(ilastDot+1); | |||
} | |||
} | |||
} | |||
if (sharp) { | |||
if (-1 != iEndMemberLabel) { | |||
memberName = str.substring(isharp, iEndMemberLabel+1).trim(); | |||
} else { | |||
memberName = str.substring(isharp).trim(); | |||
} | |||
// hack to remove spaces between method name and parms | |||
int parmLoc = memberName.indexOf("("); | |||
if (-1 != parmLoc) { | |||
int spaceLoc = memberName.indexOf(" "); | |||
if ((-1 != spaceLoc) && (spaceLoc < parmLoc)) { | |||
memberName = memberName.substring(0,spaceLoc) | |||
+ memberName.substring(parmLoc).trim(); | |||
} | |||
} | |||
} | |||
if (!finished) { | |||
err().error("see_tag_prematurely_done",str); | |||
} else { | |||
if (iStartLabel != -1) { | |||
label = str.substring(iStartLabel).trim(); | |||
} else if (i < N-1) { // when does this happen? | |||
label = str.substring(i).trim(); | |||
} | |||
} | |||
} | |||
// test-only methods | |||
String getPackageName() {return packageName;} | |||
String getClassName() { return className;} | |||
String getMemberName() { return memberName; } | |||
String getLabel() { return label; } | |||
} |
@@ -1,173 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.Doc; | |||
import com.sun.javadoc.SerialFieldTag; | |||
import java.util.Locale; | |||
/** | |||
* Represents a serial field tag in the aspectj-world. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public class SerialFieldTagImpl | |||
extends TagImpl implements SerialFieldTag, | |||
Comparable { | |||
private String description; | |||
private String fieldName; | |||
private String fieldType; | |||
private ClassDoc fieldTypeDoc; | |||
/** | |||
* Constructs the new tag with given parameters and | |||
* then tries to resolve the names of the text. | |||
* | |||
* @param doc the new value for <code>doc</code>. | |||
* @param name the new value for <code>name</code>. | |||
* @param text the new value for <code>text</code>. | |||
* @param locale the new value for <code>locale</code>. | |||
* @param err the new value for <code>err</code>. | |||
*/ | |||
public SerialFieldTagImpl(Doc doc, | |||
String name, | |||
String text, | |||
Locale loc, | |||
ErrPrinter err) { | |||
super(doc, name, text, loc, err); | |||
resolveNames(text); | |||
} | |||
/** | |||
* Returns the description. | |||
* | |||
* @return the description. | |||
*/ | |||
public String description() { | |||
return description; | |||
} | |||
/** | |||
* Returns the field name. | |||
* | |||
* @return the field name. | |||
*/ | |||
public String fieldName() { | |||
return fieldName; | |||
} | |||
/** | |||
* Returns the field type. | |||
* | |||
* @return the field type. | |||
*/ | |||
public String fieldType() { | |||
return fieldType; | |||
} | |||
/** | |||
* Returns the class of the field type. | |||
* | |||
* @return a ClassDoc with type name fieldType. | |||
*/ | |||
public ClassDoc fieldTypeDoc() { | |||
return fieldTypeDoc; | |||
} | |||
//XXX | |||
//TODO: implement | |||
public int compareTo(Object other) { | |||
return -1; | |||
} | |||
/** | |||
* Returns <code>serialField</code>. | |||
* | |||
* @return <code>serialField</code>. | |||
*/ | |||
public String kind() { | |||
return "@serialField"; | |||
} | |||
private void resolveNames(String str) { | |||
// | |||
// @serialField field-name field-type field-description | |||
// | |||
if (str == null || (str = str.trim()).length() < 1) return; | |||
final int N = str.length(); | |||
int i = 0; | |||
int start; | |||
// Find the first char in the field-name | |||
start = i; | |||
if (i < N && !start(str.charAt(i++))) { | |||
err().error("serialField_tag_invalid_field_name_start", | |||
""+str.charAt(i)); | |||
return; | |||
} | |||
// Find the rest of the field-name | |||
while (i < N && !space(str.charAt(i))) { | |||
if (!ident(str.charAt(i))) { | |||
err().error("serialField_tag_invalid_field_name_part", | |||
""+str.charAt(i)); | |||
return; | |||
} | |||
i++; | |||
} | |||
// Found the field-name | |||
fieldName = str.substring(start, i).trim(); | |||
// Find the first char in the field-type | |||
start = i; | |||
if (i < N && !start(str.charAt(i++))) { | |||
err().error("serialField_tag_invalid_type_name_start", | |||
""+str.charAt(i)); | |||
return; | |||
} | |||
// Find the rest of the field-name | |||
while (i < N && !space(str.charAt(i))) { | |||
if (!(str.charAt(i) == '[' || | |||
str.charAt(i) == ']' || | |||
ident(str.charAt(i)))) { | |||
err().error("serialField_tag_invalid_type_name_part", | |||
""+str.charAt(i)); | |||
return; | |||
} | |||
} | |||
// Found the field-type | |||
fieldType = str.substring(start, i).trim(); | |||
// The rest is the field-description | |||
if (i < N) { | |||
description = str.substring(i).trim(); | |||
} | |||
} | |||
} |
@@ -1,181 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import com.sun.javadoc.Doc; | |||
import com.sun.javadoc.Tag; | |||
import java.util.Locale; | |||
public class TagImpl implements Tag { | |||
private Locale locale; | |||
private ErrPrinter err; | |||
private String name; | |||
private String text; | |||
private Doc doc; | |||
/** | |||
* Constructs the new tag with given parameters. | |||
* | |||
* @param doc the new value for <code>doc</code>. | |||
* @param name the new value for <code>name</code>. | |||
* @param text the new value for <code>text</code>. | |||
* @param locale the new value for <code>locale</code>. | |||
* @param err the new value for <code>err</code>. | |||
*/ | |||
public TagImpl(Doc doc, | |||
String name, | |||
String text, | |||
Locale locale, | |||
ErrPrinter err) { | |||
this.doc = doc; | |||
this.name = name; | |||
this.text = text; | |||
this.locale = locale; | |||
this.err = err; | |||
} | |||
/** | |||
* Returns the Doc associated with this tag. | |||
* | |||
* @return the Doc associated with this tag. | |||
*/ | |||
protected final Doc doc() { | |||
return doc; | |||
} | |||
/** | |||
* Returns the ErrPrinter associated with this tag. | |||
* | |||
* @return the ErrPrinter associated with this tag. | |||
*/ | |||
protected final ErrPrinter err() { | |||
return err == null ? ErrPrinter.instance : err; | |||
} | |||
/** | |||
* Delegates to {@link Util#start(char)}. | |||
* | |||
* @see Util#start(char) | |||
*/ | |||
protected final static boolean start(char c) { return Util.start(c); } | |||
/** | |||
* Delegates to {@link Util#ident(char)}. | |||
* | |||
* @see Util#ident(char) | |||
*/ | |||
protected final static boolean ident(char c) { return Util.ident(c); } | |||
/** | |||
* Delegates to {@link Util#space(char)}. | |||
* | |||
* @see Util#space(char) | |||
*/ | |||
protected final static boolean space(char c) { return Util.space(c); } | |||
/** | |||
* Delegates to {@link Util#split(char)}. | |||
* | |||
* @see Util#split(char) | |||
*/ | |||
protected final static String[] split(String s) { return Util.split(s); } | |||
/** | |||
* Returns the name. | |||
* | |||
* @return the name. | |||
*/ | |||
public String name() { | |||
return name; | |||
} | |||
/** | |||
* Returns the kind followed by the String text. | |||
* | |||
* @return kind followed by the String text. | |||
*/ | |||
public String toString() { | |||
return kind() + " " + text; | |||
} | |||
/** | |||
* Returns the kind of tag. | |||
* | |||
* @return kind of the tag. | |||
*/ | |||
public String kind() { | |||
return name; | |||
} | |||
/** | |||
* Returns the String text of this tag. | |||
* | |||
* @return String text of this tag. | |||
*/ | |||
public String text() { | |||
return text; | |||
} | |||
/** | |||
* Sets the String text. | |||
* | |||
* @param text the new value for <code>text</code>. | |||
*/ | |||
protected void setText(String text) { | |||
this.text = text; | |||
} | |||
/** | |||
* Returns the locale. | |||
* | |||
* @return the locale. | |||
*/ | |||
public Locale locale() { | |||
return locale; | |||
} | |||
/** | |||
* Returns the inline tags in this tag. | |||
* | |||
* @return an array of Tag representing the inline | |||
* tags in this tag. | |||
* @see Util#inlineTags | |||
*/ | |||
public Tag[] inlineTags() { | |||
return Util.inlineTags(doc(), text(), locale(), err()); //doc()); | |||
} | |||
/** | |||
* Returns the first sentence tags in this tag. | |||
* | |||
* @return an array of Tag representing the first sentence | |||
* tags in this tag. | |||
* @see Util#firstSentenceTags | |||
*/ | |||
public Tag[] firstSentenceTags() { | |||
return Util.firstSentenceTags(doc(), text(), locale(), err()); | |||
} | |||
} |
@@ -1,104 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.Doc; | |||
import com.sun.javadoc.ThrowsTag; | |||
import java.util.Locale; | |||
/** | |||
* Represents a throws tag in the aspectj-world. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public class ThrowsTagImpl extends TagImpl implements ThrowsTag { | |||
private ClassDoc exception; | |||
private String exceptionComment; | |||
private String exceptionName; | |||
/** | |||
* Constructs the new tag with given parameters and | |||
* splits the text. | |||
* | |||
* @param doc the new value for <code>doc</code>. | |||
* @param name the new value for <code>name</code>. | |||
* @param text the new value for <code>text</code>. | |||
* @param locale the new value for <code>locale</code>. | |||
* @param err the new value for <code>err</code>. | |||
*/ | |||
public ThrowsTagImpl(Doc doc, | |||
String name, | |||
String text, | |||
Locale loc, | |||
ErrPrinter err) { | |||
super(doc, name, text, loc, err); | |||
String[] split = split(text); | |||
exceptionName = split[0]; | |||
exceptionComment = split[1]; | |||
exception = findException(); | |||
} | |||
/** | |||
* Returns the exception thrown. | |||
* | |||
* @return a ClassDoc that represents the thrown exception. | |||
*/ | |||
public ClassDoc exception() { | |||
return exception; | |||
} | |||
/** | |||
* Returns the comment text. | |||
* | |||
* @return a String of the comment text. | |||
*/ | |||
public String exceptionComment() { | |||
return exceptionComment; | |||
} | |||
/** | |||
* Returns the name of the type of exception thrown. | |||
* | |||
* @return a String name of the type of exception thrown. | |||
*/ | |||
public String exceptionName() { | |||
return exceptionName; | |||
} | |||
/** | |||
* Returns <code>throws</code>. | |||
* | |||
* @return <code>throws</code>. | |||
*/ | |||
public String kind() { | |||
return "@throws"; | |||
} | |||
//XXX | |||
//TODO: implement FUUUUUUCCCCCCCCCKKKKKKKKKKKK | |||
private ClassDoc findException() { | |||
return null; | |||
} | |||
} |
@@ -1,165 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.compiler.base.ast.ArrayType; | |||
import org.aspectj.compiler.base.ast.NameType; | |||
import org.aspectj.compiler.base.ast.PrimitiveType; | |||
import org.aspectj.compiler.base.ast.Type; | |||
import com.sun.javadoc.ClassDoc; | |||
public class TypeImpl { //implements org.aspectj.ajdoc.Type { | |||
public static com.sun.javadoc.Type getInstance(Type type) { | |||
return factory.getInstance(type); | |||
} | |||
public static com.sun.javadoc.Type getInstance(String spec, | |||
ClassDoc where) { | |||
return factory.getInstance(spec, where); | |||
} | |||
private final static class Primitive implements org.aspectj.ajdoc.Type { | |||
public final static Primitive getInstance(PrimitiveType type) { | |||
return getInstance(type.getName()); | |||
} | |||
public final static Primitive getInstance(String name) { | |||
if ("void".equals(name)) return voidType; | |||
if ("boolean".equals(name)) return booleanType; | |||
if ("byte".equals(name)) return byteType; | |||
if ("char".equals(name)) return charType; | |||
if ("short".equals(name)) return shortType; | |||
if ("int".equals(name)) return intType; | |||
if ("long".equals(name)) return longType; | |||
if ("float".equals(name)) return floatType; | |||
if ("double".equals(name)) return doubleType; | |||
return null; | |||
} | |||
public final static boolean isPrimitive(String name) { | |||
return name.equals("boolean") | |||
|| name.equals("byte") | |||
|| name.equals("char") | |||
|| name.equals("short") | |||
|| name.equals("int") | |||
|| name.equals("long") | |||
|| name.equals("float") | |||
|| name.equals("double"); | |||
} | |||
private final String name; | |||
private Primitive(String name) { this.name = name; } | |||
public String toString() { return name; } | |||
public String typeName() { return name; } | |||
public String qualifiedTypeName() { return name; } | |||
public String dimension() { return ""; } | |||
public ClassDoc asClassDoc() { return null; } | |||
private final static Primitive voidType = new Primitive("void"); | |||
private final static Primitive booleanType = new Primitive("boolean"); | |||
private final static Primitive byteType = new Primitive("byte"); | |||
private final static Primitive charType = new Primitive("char"); | |||
private final static Primitive shortType = new Primitive("short"); | |||
private final static Primitive intType = new Primitive("int"); | |||
private final static Primitive longType = new Primitive("long"); | |||
private final static Primitive floatType = new Primitive("float"); | |||
private final static Primitive doubleType = new Primitive("double"); | |||
} | |||
private final static class Array implements org.aspectj.ajdoc.Type { | |||
protected final com.sun.javadoc.Type type; | |||
protected final int dimension; | |||
private Array(com.sun.javadoc.Type type, int dimension) { | |||
this.type = type; | |||
//TODO: tune this later | |||
this.dimension = dimension; | |||
} | |||
public String toString() { return type.toString(); } | |||
public String typeName() { return type.typeName(); } | |||
public String qualifiedTypeName() { return type.qualifiedTypeName(); } | |||
public ClassDoc asClassDoc() { return type.asClassDoc(); } | |||
public String dimension() { | |||
String str = ""; | |||
for (int i = 0; i < dimension; i++) str += "[]"; | |||
return str; | |||
} | |||
public boolean equals(Object other) { | |||
if (!(other instanceof Array)) { | |||
return super.equals(other); | |||
} | |||
Array array = (Array)other; | |||
return array.type.equals(type) | |||
&& array.dimension == dimension; | |||
} | |||
} | |||
private static final Factory factory = new Factory(); | |||
private final static class Factory { | |||
private com.sun.javadoc.Type getInstance(Type type) { | |||
if (type instanceof PrimitiveType) { | |||
return Primitive.getInstance((PrimitiveType)type); | |||
} else if (type instanceof ArrayType) { | |||
ArrayType arrayType = (ArrayType)type; | |||
Type component = arrayType.getComponentType(); | |||
while (component instanceof ArrayType) { | |||
component = ((ArrayType)component).getComponentType(); | |||
} | |||
return new Array(getInstance(component), | |||
arrayType.getArrayDimCount()); | |||
} else { | |||
return ClassDocImpl.getInstance(((NameType)type).getTypeDec()); | |||
} | |||
} | |||
private com.sun.javadoc.Type getInstance(String spec, | |||
ClassDoc where) { | |||
int ibracket = spec.indexOf('['); | |||
String name; | |||
int dimension; | |||
if (ibracket != -1) { | |||
name = spec.substring(0, ibracket); | |||
dimension = spec.substring(ibracket+1).length()/2; | |||
} else { | |||
name = spec; | |||
dimension = 0; | |||
} | |||
com.sun.javadoc.Type type = Primitive.getInstance(name); | |||
if (type == null) { | |||
type = where.findClass(name); //TODO | |||
} | |||
if (dimension > 0) { | |||
type = new Array(type, dimension); | |||
} | |||
return type; | |||
} | |||
} | |||
} |
@@ -1,933 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc; | |||
import org.aspectj.compiler.base.ast.Constructor; | |||
import org.aspectj.compiler.base.ast.ConstructorDec; | |||
import org.aspectj.compiler.base.ast.Exprs; | |||
import org.aspectj.compiler.base.ast.Field; | |||
import org.aspectj.compiler.base.ast.FieldDec; | |||
import org.aspectj.compiler.base.ast.Formals; | |||
import org.aspectj.compiler.base.ast.Method; | |||
import org.aspectj.compiler.base.ast.MethodDec; | |||
import org.aspectj.compiler.base.ast.NameType; | |||
import org.aspectj.compiler.base.ast.Type; | |||
import org.aspectj.compiler.base.ast.TypeDec; | |||
import org.aspectj.compiler.crosscuts.ast.PointcutDec; | |||
import org.aspectj.compiler.crosscuts.ast.PointcutSO; | |||
import com.sun.javadoc.Doc; | |||
import com.sun.javadoc.ExecutableMemberDoc; | |||
import com.sun.javadoc.MemberDoc; | |||
import com.sun.javadoc.Parameter; | |||
import com.sun.javadoc.Tag; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.Comparator; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Locale; | |||
import java.util.StringTokenizer; | |||
/** | |||
* A utility class used by lots of folks. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public class Util { | |||
/** | |||
* Delegate to Character.isJavaIdentifierStart(char). | |||
* | |||
* @return <code>true</code> if <code>c</code> can | |||
* start a java identifier. | |||
*/ | |||
public final static boolean start(char c) { | |||
return Character.isJavaIdentifierStart(c); | |||
} | |||
/** | |||
* Delegate to Character.isJavaIdentifierPart(char). | |||
* | |||
* @return <code>true</code> if <code>c</code> can | |||
* be a part of a java identifier. | |||
*/ | |||
public final static boolean ident(char c) { | |||
return Character.isJavaIdentifierPart(c); | |||
} | |||
/** | |||
* Delegate to Character.isWhitespace(char). | |||
* | |||
* @return <code>true</code> if <code>c</code> is | |||
* valid white space. | |||
*/ | |||
public final static boolean space(char c) { | |||
return Character.isWhitespace(c); | |||
} | |||
/** | |||
* Returns true is <code>c</code> is a newline character. | |||
* | |||
* @return <code>true</code> if | |||
* <code>c == '\n' || c == '\r'</code>. | |||
*/ | |||
public final static boolean newline(char c) { | |||
return c == '\n' || c == '\r'; | |||
} | |||
/** | |||
* Returns two strings split at the first white space. | |||
* | |||
* @return an array of two Strings split at | |||
* the first white space. | |||
*/ | |||
public static String[] split(String str) { | |||
String[] strs = new String[2]; | |||
for (int i = 0; i < str.length(); i++) { | |||
if (space(str.charAt(i))) { | |||
strs[0] = str.substring(0, i); | |||
strs[1] = str.substring(i+1); | |||
break; | |||
} | |||
} | |||
if (strs[0] == null) { | |||
strs[0] = str; | |||
strs[1] = ""; | |||
} | |||
return strs; | |||
} | |||
/** | |||
* Returns the inline tags found in <code>str</code>. | |||
* | |||
* @param doc Doc to give to the new tag. | |||
* @param str String from which to create the tags. | |||
* @param loc Locale to give to the new tag. | |||
* @param err ErrPrinter to give to the new tag. | |||
* @return an array of Tag representing the inline | |||
* tags found in str. | |||
*/ | |||
public final static Tag[] inlineTags(Doc doc, | |||
String str, | |||
Locale loc, | |||
ErrPrinter err) { | |||
if (str == null || str.length() < 1) { | |||
return new Tag[0]; | |||
} | |||
int N = str.length(); | |||
List list = new ArrayList(); | |||
int i = 0; | |||
for (int j = i; i < N; j = i) { | |||
// Try to match a link tag | |||
int ileft = str.indexOf("{@", i); | |||
// If there are no more link tags, return the rest | |||
// of str as a 'Text' Tag | |||
if (ileft == -1) { | |||
list.add(new TagImpl(doc, "Text", | |||
str.substring(i), | |||
loc, err)); | |||
break; | |||
} | |||
if (j < ileft) { | |||
list.add(new TagImpl(doc, "Text", | |||
str.substring(j, ileft), | |||
loc, err)); | |||
} | |||
// If there is a tag and it's name is 'link ' try to | |||
// match it | |||
i = ileft; | |||
if (i+7 < N && | |||
str.substring(i+2, i+7).toLowerCase().equals("link ")) { | |||
i += 7; | |||
for (; str.charAt(i) != '}'; i++) { | |||
if (i == N-1) { | |||
err.error("tag_unterminated_link_tag", | |||
str.substring(i)); | |||
break; | |||
} | |||
} | |||
list.add(new SeeTagImpl(doc, "@link", | |||
str.substring(ileft+7, i), | |||
loc, err)); | |||
} else { | |||
err.error("tag_invalid_link_tag", | |||
str.substring(i)); | |||
} | |||
// Don't want to include the right brace | |||
i += 1; | |||
} | |||
return (Tag[])list.toArray(new Tag[list.size()]); | |||
} | |||
/** | |||
* Returns the first sentence tags found in <code>str</code>. | |||
* | |||
* @param doc Doc to give to the new tag. | |||
* @param str String from which to create the tags. | |||
* @param loc Locale to give to the new tag. | |||
* @param err ErrPrinter to give to the new tag. | |||
* @return an array of Tag representing the first | |||
* sentence tags found in str. | |||
*/ | |||
public final static Tag[] firstSentenceTags(Doc doc, | |||
String str, | |||
Locale loc, | |||
ErrPrinter err) { | |||
return inlineTags(doc, firstSentenceText(str, loc, err), loc, err); | |||
} | |||
/** | |||
* Returns the first sentence tags found in <code>str</code>, | |||
* using <code>Locale.US</code> as the default locale. | |||
* | |||
* @param doc Doc to give to the new tag. | |||
* @param str String from which to create the tags. | |||
* @param err ErrPrinter to give to the new tag. | |||
* @return an array of Tag representing the first | |||
* sentence tags found in str. | |||
*/ | |||
private static String firstSentenceText(String str, | |||
Locale loc, | |||
ErrPrinter err) { | |||
if (str == null || loc == null || !loc.equals(Locale.US)) { | |||
return ""; | |||
} | |||
final int N = str.length(); | |||
int i; | |||
for (i = 0; i < N; i++) { | |||
// A period at the end of the text or a | |||
// period followed by white space is the | |||
// end of a sentence | |||
if (str.charAt(i) == '.') { | |||
if (i == N-1) { | |||
return str.substring(0, i+1); | |||
} | |||
if (space(str.charAt(i+1))) { | |||
return str.substring(0, i+2); | |||
} | |||
} | |||
// An HTML tag the signals the end -- one of: | |||
// <p> </p> <h1> <h2> <h3> <h4> | |||
// <h5> <h6> <hr> <pre> or </pre> | |||
if (str.charAt(i) == '<') { | |||
int j = i+1; | |||
// Find the closing '>' | |||
while (j < N && str.charAt(j) != '>') j++; | |||
// If there's no closing '>' signal an error | |||
if (j == N) { | |||
err.error("unterminated_html_tag", str); | |||
return str; | |||
} | |||
// Inspect the inside of the tag | |||
String innards = str.substring(i+1, j).trim().toLowerCase(); | |||
if (innards.equals("p") || innards.equals("pre") || | |||
innards.equals("h1") || innards.equals("h2") || | |||
innards.equals("h3") || innards.equals("h4") || | |||
innards.equals("h5") || innards.equals("h6") || | |||
innards.equals("hr")) { | |||
return str.substring(0, i+1); | |||
} | |||
} | |||
} | |||
return str; | |||
} | |||
/** | |||
* Returns the tags found in <code>str</code>. | |||
* | |||
* @param doc Doc to give to the new tag. | |||
* @param str String from which to create the tags. | |||
* @param loc Locale to give to the new tag. | |||
* @param err ErrPrinter to give to the new tag. | |||
* @return an array of Tag representing the | |||
* tags found in str. | |||
*/ | |||
public final static List findTags(Doc doc, | |||
String str, | |||
Locale loc, | |||
ErrPrinter err) { | |||
//XXX This sucks!!! Will redo later. | |||
boolean newline = true; | |||
List result = new ArrayList(); | |||
if (str == null) return result; | |||
final int N = str.length(); | |||
int lastTag = -1; | |||
for (int i = 0; i < N; i++) { | |||
if (newline(str.charAt(i))) { | |||
newline = true; | |||
// XXX need to evaluate - some tags can span newlines? | |||
// if (lastTag != -1) { // now requiring tags not to span newlines | |||
// result.add(parse(doc, str.substring(lastTag, i), | |||
// loc, err)); | |||
// } | |||
// lastTag = -1 | |||
} else if (space(str.charAt(i)) && newline) { | |||
} else if (str.charAt(i) == '@' && newline) { | |||
if (lastTag != -1) { | |||
result.add(parse(doc, str.substring(lastTag, i), | |||
loc, err)); | |||
} | |||
lastTag = i; | |||
} else { | |||
newline = false; | |||
} | |||
} | |||
if (lastTag != -1) { | |||
result.add(parse(doc, str.substring(lastTag), | |||
loc, err)); | |||
} | |||
return result; | |||
} | |||
private final static Tag parse(Doc doc, | |||
String str, | |||
Locale loc, | |||
ErrPrinter err) { | |||
Tag result = null; | |||
String[] split = split(str); | |||
String name = split[0]; | |||
String rest = split[1]; | |||
if (name.equals("@see")) { | |||
result = new SeeTagImpl(doc, name, rest, loc, err); | |||
} else if (name.equals("@exception") || name.equals("@throws")) { | |||
result = new ThrowsTagImpl(doc, name, rest, loc, err); | |||
} else if (name.equals("@serialField")) { | |||
result = new SerialFieldTagImpl(doc, name, rest, loc, err); | |||
} else if (name.equals("@param")) { | |||
result = new ParamTagImpl(doc, name, rest, loc, err); | |||
} else { | |||
result = new TagImpl(doc, name, rest, loc, err); | |||
} | |||
return result; | |||
} | |||
/** | |||
* Returns the raw comment text found in <code>str</code>. | |||
* | |||
* @param str String containing comment from which | |||
* the raw comment is found. | |||
* @return String with the raw comment taken | |||
* from <code>str</code>. | |||
*/ | |||
public final static String rawCommentText(String str) { | |||
if (str == null) return ""; | |||
if (str.length() < 3) return ""; | |||
String withstars = ""; | |||
int islash = str.indexOf('/'); | |||
if (islash == -1 || islash+2 >= str.length()) { | |||
return ""; | |||
} | |||
if (str.charAt(islash+1) != '*' || | |||
str.charAt(islash+2) != '*') { | |||
return ""; | |||
} | |||
int start = islash+2+1; | |||
while (str.charAt(start) == '*' || space(str.charAt(start))) start++; | |||
int end = str.length()-2; | |||
while (str.charAt(end) == '*') end--; | |||
if (start != -1 && end > start) { | |||
withstars = str.substring(start, end+1); | |||
} | |||
//String result = ""; | |||
StringBuffer result = new StringBuffer(withstars.length()); | |||
for (StringTokenizer t = new StringTokenizer(withstars, "\n", true); | |||
t.hasMoreTokens();) { | |||
String line = t.nextToken(); | |||
if (line == null || line.length() == 0) continue; | |||
int i; | |||
for (i = 0; i < line.length(); i++) { | |||
if (!(line.charAt(i) == '*' || | |||
line.charAt(i) == ' ')) { | |||
break; | |||
} | |||
} | |||
//result += line.substring(i); | |||
result.append(line.substring(i)); | |||
} | |||
//return result; | |||
return result.toString(); | |||
} | |||
/** | |||
* Returns the comment text from the passed in | |||
* raw comment text -- e.g. no tags at the end. | |||
* | |||
* @param rawCommentText raw comment text to search. | |||
* @return the comment text from | |||
* <code>rawCommentText</code>. | |||
*/ | |||
public final static String commentText(String rawCommentText) { | |||
//String result = ""; | |||
if (rawCommentText == null) { | |||
return ""; | |||
} | |||
StringBuffer result = new StringBuffer(rawCommentText.length()); | |||
outer: | |||
for (StringTokenizer t = new StringTokenizer(rawCommentText, "\n", true); | |||
t.hasMoreTokens();) { | |||
String line = t.nextToken(); | |||
if (line == null || line.length() == 0) continue; | |||
int i; | |||
for (i = 0; i < line.length(); i++) { | |||
char c = line.charAt(i); | |||
if (c == ' ' || c == '\t') { | |||
} else if (c == '@') { | |||
break outer; | |||
} else { | |||
//result += line; | |||
result.append(line); | |||
continue outer; | |||
} | |||
} | |||
} | |||
//return result; | |||
return result.toString(); | |||
} | |||
/** | |||
* Compares using names. | |||
* | |||
* @param $ First Doc. | |||
* @param _ Second Doc. | |||
* @return -1 if either are null, else | |||
* <code>$.name.compareTo(_.name</code>. | |||
*/ | |||
public final static int compareTo(Doc $, Doc _) { | |||
return ($ == null || _ == null) ? -1 : $.name().compareTo(_.name()); | |||
} | |||
/** | |||
* Returns the signature, given <code>parameters</code>, | |||
* without flattening. | |||
* | |||
* @param parameters an array of Parameter. | |||
* @return String representation of the parameters. | |||
* @see #signature(Parameter[],boolean) | |||
*/ | |||
public final static String signature(Parameter[] parameters) { | |||
return signature(parameters, false); | |||
} | |||
/** | |||
* Returns the signature, given <code>parameters</code>, | |||
* with flattening. | |||
* | |||
* @param parameters an array of Parameter. | |||
* @return String representation of the parameters. | |||
* @see #signature(Parameter[],boolean) | |||
*/ | |||
public final static String flatSignature(Parameter[] parameters) { | |||
return signature(parameters, true); | |||
} | |||
/** | |||
* Returns the signature, given <code>parameters</code> | |||
* and flattens if <code>flatten</code>. | |||
* | |||
* @param parameters an array of Parameter. | |||
* @param flatten <code>true</code> if the parameter names | |||
* should be flattened. | |||
* @return String representation of the parameters. | |||
*/ | |||
public final static String signature(Parameter[] parameters, | |||
boolean flatten) { | |||
if (parameters == null || parameters.length == 0) { | |||
return "()"; | |||
} | |||
//String str = "("; | |||
StringBuffer str = new StringBuffer((flatten ? 8 : 20) * | |||
parameters.length); | |||
str.append("("); | |||
final int N = parameters.length; | |||
for (int i = 0; i < N; i++) { | |||
String typeName = parameters[i].typeName(); | |||
if (flatten) { | |||
int idot = typeName.lastIndexOf('.'); | |||
if (idot != -1) { | |||
typeName = typeName.substring(idot+1); | |||
} | |||
} | |||
//str += typeName + (i < N-1 ? "," : ""); | |||
str.append(typeName + (i < N-1 ? "," : "")); | |||
} | |||
//str += ")"; | |||
str.append(")"); | |||
//return str; | |||
return str.toString(); | |||
} | |||
/** | |||
* Returns <code>true</code> -- include all members for now. | |||
* | |||
* @param doc member to consider. | |||
* @param flags access flags. | |||
*/ | |||
public final static boolean isIncluded(MemberDoc doc, long flags) { | |||
return true; | |||
} | |||
/** | |||
* Returns <code>true</code> if <code>dec</code> | |||
* isn't local or annonymous or <code>null</code>. | |||
* | |||
* @param dec TypeDec to consider. | |||
* @return <code>true</code> isn't dec is local or | |||
* annonymous or <code>null</code>. | |||
*/ | |||
public final static boolean isIncluded(TypeDec dec) { | |||
if (dec == null) { | |||
return false; | |||
} | |||
if (dec.isLocal() && dec.isAnonymous()) { | |||
return false; | |||
} | |||
return true; //XXX to do | |||
} | |||
//XXX Debugging | |||
public final static void dump(Object o, String prefix) { | |||
System.err.println(">> Dumping:"+o); | |||
java.lang.reflect.Method[] ms = o.getClass().getMethods(); | |||
List list = new ArrayList(); | |||
for (int i = 0; i < ms.length; i++) { | |||
list.add(ms[i]); | |||
} | |||
Collections.sort(list, new Comparator() { | |||
public int compare(Object o1, Object o2) { | |||
return str(o1).compareTo(str(o2)); | |||
} | |||
public boolean equals(Object o1, Object o2) { | |||
return str(o1).equals(str(o2)); | |||
} | |||
private String str(Object _) { | |||
return (_ != null && _ instanceof java.lang.reflect.Method) | |||
? ((java.lang.reflect.Method)_).getName() : _+""; | |||
} | |||
}); | |||
for (Iterator i = list.iterator(); i.hasNext();) { | |||
java.lang.reflect.Method m = (java.lang.reflect.Method)i.next(); | |||
if (m.getParameterTypes().length == 0 && | |||
m.getName().startsWith(prefix)) { | |||
try { | |||
System.err.println(" "+m.getName()+":"+ | |||
m.invoke(o, new Object[0])); | |||
} catch (Throwable _) {} | |||
} | |||
} | |||
} | |||
public final static void gets(Object o) { | |||
dump(o, "get"); | |||
} | |||
public final static void array(Object[] os) { | |||
array(os, false); | |||
} | |||
public final static void array(Object[] os, boolean gets) { | |||
if (os == null) { | |||
System.err.println("NULL"); | |||
return; | |||
} | |||
System.err.println(os.getClass().getName()+":" + os.length); | |||
for (int i = 0; i < os.length; i++) { | |||
System.err.println(" [" + i +"]:" + os[i]); | |||
if (gets) gets(os[i]); | |||
} | |||
} | |||
/** | |||
* Returns the HTML documentation found in <code>html</code> | |||
* using <code>err</code> to report errors. | |||
* | |||
* @param html File in which to look. | |||
* @param err ErrPrinter to use to report errors. | |||
* @return HTML documentaiton found in <code>html</code>. | |||
*/ | |||
public static String documentation(File html, ErrPrinter err) { | |||
String str = ""; | |||
InputStream in = null; | |||
try { | |||
in = new FileInputStream(html); | |||
} catch (IOException ioe) { | |||
err.ex(ioe, "ioexception_open", html.getAbsolutePath()); | |||
return ""; | |||
} | |||
try { | |||
byte[] bytes = new byte[in.available()]; | |||
in.read(bytes, 0, bytes.length); | |||
in.close(); | |||
str = new String(bytes); | |||
} catch (IOException ioe) { | |||
err.ex(ioe, "ioexception_reading", html.getAbsolutePath()); | |||
} | |||
int[] is = new int[]{-10,-1}; | |||
int i = 0; | |||
final char[] chars = new char[]{'/','B','O','D','Y','>'}; | |||
for (int j = 1; j >= 0; j--) { | |||
nextTag: | |||
for (; i != -1; i = str.indexOf('<', i+1)) { | |||
nextLt: | |||
for (int s = i+1, k = j; s < str.length(); s++, k++) { | |||
char c = str.charAt(s); | |||
if (k == chars.length) { | |||
is[j] += s+2; | |||
break nextTag; | |||
} | |||
if (!(c == chars[k] || c == (chars[k] | 0x01000000))) { | |||
break nextLt; | |||
} | |||
} | |||
} | |||
} | |||
if (is[0] > -1 && is[1] > -1) { | |||
str = str.substring(is[1], is[0]); | |||
} | |||
return str; | |||
} | |||
/** | |||
* Returns the result of invoking the method <code>name</code> | |||
* on <code>target</code> with parameters <code>params</code> | |||
* declared in the <code>target</code>'s class using arguments | |||
* <code>args</code>. | |||
* | |||
* @param target target Object. | |||
* @param name name of the method. | |||
* @param params array of Class of parameters of the method. | |||
* @param args array of Object of arguments to the method. | |||
* @return the result of invoking the method. | |||
* @see #invoke(Class,Object,String,Class[],Object[]) | |||
*/ | |||
public static Object invoke(Object target, String name, | |||
Class[] params, Object[] args) { | |||
return invoke(target.getClass(), target, name, params, args); | |||
} | |||
/** | |||
* Returns the result of invoking the method <code>name</code> | |||
* on <code>target</code> with parameters <code>params</code> | |||
* declared in the <code>type</code> using arguments | |||
* <code>args</code>. | |||
* This method handles any errors that arise in doing so. | |||
* | |||
* @param type type in which the method is declared. | |||
* @param target target Object -- null for static methods. | |||
* @param name name of the method. | |||
* @param params array of Class of parameters of the method. | |||
* @param args array of Object of arguments to the method. | |||
* @return the result of invoking the method. | |||
*/ | |||
public static Object invoke(Class type, Object target, String name, | |||
Class[] params, Object[] args) { | |||
try { | |||
java.lang.reflect.Method method = type.getDeclaredMethod(name, params); | |||
method.setAccessible(true); | |||
return method.invoke(target, args); | |||
} catch (Exception e) { | |||
e.printStackTrace(); //TODO | |||
} | |||
return null; | |||
} | |||
/** | |||
* Returns the value of access the field <code>name</code> | |||
* declared in <code>type</code> on <code>target</code>. | |||
* This method handles any errors that arise in doing so. | |||
* | |||
* @param type type in which the field is declared. | |||
* @param target target that is currently holding the field -- | |||
* null for static fields. | |||
* @param name name of the field. | |||
* @return the result of accessing this field. | |||
*/ | |||
public static Object access(Class type, Object target, String name) { | |||
try { | |||
java.lang.reflect.Field field = type.getDeclaredField(name); | |||
field.setAccessible(true); | |||
return field.get(target); | |||
} catch (Exception e) { //TODO | |||
e.printStackTrace(); | |||
} | |||
return null; | |||
} | |||
/** | |||
* Returns the ExecutableMemberDoc from the array passed | |||
* in whose parameters <i>weakly</i> match those of | |||
* <code>params</code> and whose name matches exactly | |||
* with <code>name</code>. | |||
* This method <b>can</b> return <code>null</code>. | |||
* | |||
* @param emds an array of ExecutableMemberDoc from which | |||
* the returned value comes. | |||
* @param name the name of the member to return. | |||
* @param params an array of Parameter that represent | |||
* the parameters we're trying to match. | |||
* @return an ExecutableMemberDoc whose parameters | |||
* match the names and order found in | |||
* <code>params</code> and whose name | |||
* exactly equals <code>name</code>. | |||
*/ | |||
public final static ExecutableMemberDoc executableMemberDoc | |||
(ExecutableMemberDoc[] emds, | |||
String name, | |||
Parameter[] params) { | |||
ExecutableMemberDoc result = null; | |||
next: | |||
for (int i = 0; i < emds.length; i++) { | |||
ExecutableMemberDoc emd = emds[i]; | |||
if (emd.name().equals(name) && | |||
params.length == emd.parameters().length) { | |||
for (int j = 0; j < params.length; j++) { | |||
if (!params[j].typeName().equals | |||
(emd.parameters()[j].typeName())) { | |||
continue next; | |||
} | |||
result = emd; | |||
break next; | |||
} | |||
} | |||
} | |||
return result; | |||
} | |||
/** | |||
* Returns the PointcutDoc from the array passed | |||
* in whose parameters <i>weakly</i> match those of | |||
* <code>formals</code> and whose name matches exactly | |||
* with <code>id</code>. | |||
* This method <b>can</b> return <code>null</code>. | |||
* | |||
* @param nameType the type in which we're searching. | |||
* @param id the name of the pointcut to return. | |||
* @param formals the Formals whose name and order | |||
* must match to return a pointcut. | |||
* @return a PointcutDoc whose parameters | |||
* match the names and order found in | |||
* <code>formals</code> and whose name | |||
* exactly equals <code>id</code>. | |||
*/ | |||
public final static PointcutDec pointcutDec(NameType nameType, | |||
String id, | |||
Formals formals) { | |||
PointcutDec result = null; | |||
next: | |||
for (Iterator i = nameType.getPointcuts().iterator(); i.hasNext();) { | |||
PointcutDec md = ((PointcutSO)i.next()).getPointcutDec(); | |||
if (md.getFormals().size() == formals.size() && | |||
id.equals(md.getId())) { | |||
for (int j = 0; j < formals.size(); j++) { | |||
if (!md.getFormals().get(j).getType().getString(). | |||
equals(formals.get(j).getType().getString())) { | |||
continue next; | |||
} | |||
} | |||
result = md; | |||
break next; | |||
} | |||
} | |||
return result; | |||
} | |||
/** | |||
* Returns the MethodDoc from the array passed | |||
* in whose parameters <i>weakly</i> match those of | |||
* <code>formals</code> and whose name matches exactly | |||
* with <code>id</code>. | |||
* This method <b>can</b> return <code>null</code>. | |||
* | |||
* @param nameType the type in which we're searching. | |||
* @param id the name of the method to return. | |||
* @param formals the Formals whose name and order | |||
* must match to return a method. | |||
* @return a MethodDoc whose parameters | |||
* match the names and order found in | |||
* <code>formals</code> and whose name | |||
* exactly equals <code>id</code>. | |||
*/ | |||
public final static MethodDec methodDec(NameType nameType, | |||
String id, | |||
Formals formals) { | |||
MethodDec result = null; | |||
next: | |||
for (Iterator i = nameType.getMethods().iterator(); i.hasNext();) { | |||
//MethodDec md = (MethodDec)i.next(); | |||
MethodDec md = ((Method)i.next()).getMethodDec(); | |||
if (md.getFormals().size() == formals.size() && | |||
id.equals(md.getId())) { | |||
for (int j = 0; j < formals.size(); j++) { | |||
if (!md.getFormals().get(j).getType().getString(). | |||
equals(formals.get(j).getType().getString())) { | |||
continue next; | |||
} | |||
} | |||
result = md; | |||
break next; | |||
} | |||
} | |||
return result; | |||
} | |||
/** | |||
* Returns the PointcutDec named <code>name</code>, | |||
* contained in <code>typeDec</code> with type <code>type</code>. | |||
* <code>showError</code> is passed to subsequent methods | |||
* to supress or warrant error printing. | |||
* This may return null. | |||
* | |||
* @param type Type in which this pointcut was declared. | |||
* @param name name of the pointcut. | |||
* @param typeDec TypeDec in which we're searching. | |||
* @param showError <code>true</code> is an error should | |||
* be printed upon not finding a pointcut. | |||
* @return the pointcut declared in <code>type</code> | |||
* named <code>name</code>, found by searching | |||
* from <code>typeDec</code>. This may be | |||
* null. | |||
*/ | |||
public static PointcutDec getPointcutDec(Type type, | |||
String name, | |||
TypeDec typeDec, | |||
boolean showError) { | |||
PointcutSO so = ((NameType)type).getPointcut(name, typeDec, showError); | |||
PointcutDec dec = null; | |||
if (so != null) { | |||
dec = (PointcutDec)so.getCorrespondingDec(); | |||
} | |||
return dec; | |||
} | |||
/** | |||
* Returns the FieldDec named <code>name</code>, | |||
* contained in <code>typeDec</code> with type <code>type</code>. | |||
* <code>showError</code> is passed to subsequent methods | |||
* to supress or warrant error printing. | |||
* This may return null. | |||
* | |||
* @param type Type in which this field was declared. | |||
* @param name name of the field. | |||
* @param typeDec TypeDec in which we're searching. | |||
* @param showError <code>true</code> is an error should | |||
* be printed upon not finding a field. | |||
* @return the field declared in <code>type</code> | |||
* named <code>name</code>, found by searching | |||
* from <code>typeDec</code>. This may be | |||
* null. | |||
*/ | |||
public static FieldDec getFieldDec(Type type, | |||
String name, | |||
TypeDec typeDec, | |||
boolean showError) { | |||
Field so = ((NameType)type).getField(name, typeDec, showError); | |||
FieldDec dec = null; | |||
if (so != null) { | |||
dec = (FieldDec)so.getCorrespondingDec(); | |||
} | |||
return dec; | |||
} | |||
/** | |||
* Returns the MethodDec named <code>name</code>, with | |||
* formals <code>params</code>, | |||
* contained in <code>typeDec</code> with type <code>type</code>. | |||
* <code>showError</code> is passed to subsequent methods | |||
* to supress or warrant error printing. | |||
* This may return null. | |||
* | |||
* @param type Type in which this method was declared. | |||
* @param name name of the method. | |||
* @param typeDec TypeDec in which we're searching. | |||
* @param params the method's formal parameters. | |||
* @param showError <code>true</code> is an error should | |||
* be printed upon not finding a method. | |||
* @return the method declared in <code>type</code> | |||
* named <code>name</code>, found by searching | |||
* from <code>typeDec</code>. This may be | |||
* null. | |||
*/ | |||
public static MethodDec getMethodDec(Type type, | |||
String name, | |||
TypeDec typeDec, | |||
Exprs params, | |||
boolean showError) { | |||
Method so = ((NameType)type).getMethod(name, typeDec, params, showError); | |||
MethodDec dec = null; | |||
if (so != null) { | |||
dec = so.getMethodDec(); | |||
} | |||
return dec; | |||
} | |||
/** | |||
* Returns the ConstructorDec named <code>name</code>, with | |||
* formals <code>params</code>, | |||
* contained in <code>typeDec</code> with type <code>type</code>. | |||
* <code>showError</code> is passed to subsequent constructors | |||
* to supress or warrant error printing. | |||
* This may return null. | |||
* | |||
* @param type Type in which this constructor was declared. | |||
* @param name name of the constructor. | |||
* @param typeDec TypeDec in which we're searching. | |||
* @param params the constructor's formal parameters. | |||
* @param showError <code>true</code> is an error should | |||
* be printed upon not finding a constructor. | |||
* @return the constructor declared in <code>type</code> | |||
* named <code>name</code>, found by searching | |||
* from <code>typeDec</code>. This may be | |||
* null. | |||
*/ | |||
public static ConstructorDec getConstructorDec(Type type, | |||
TypeDec typeDec, | |||
Exprs params, | |||
boolean showError) { | |||
Constructor so = ((NameType)type).getConstructor(typeDec, | |||
params, showError); | |||
ConstructorDec dec = null; | |||
if (so != null) { | |||
dec = (ConstructorDec)so.getCorrespondingDec(); | |||
} | |||
return dec; | |||
} | |||
} |
@@ -1,77 +0,0 @@ | |||
usage_help=usage\: {0} [options] [packagenames] [sourcefiles] [classnames] [@files]\n-overview <file> Read overview documentation from HTML file\n-public Show only public classes and members\n-protected Show protected/public classes and members (default)\n-package Show package/protected/public classes and members\n-private Show all classes and members\n-help Display command line options\n-doclet <class> Generate output via alternate doclet (unsupported)\n-docletpath <path> Specify where to find doclet class files (unsupported)\n-sourcepath <pathlist> Specify where to find source files\n-classpath <pathlist> Specify where to find user class files\n-bootclasspath <pathlist> Override location of class files loaded\n by the bootstrap class loader \n-source 1.4 Provide source compatibility with Java 1.4 \n-extdirs <dirlist> Override location of installed extensions\n-verbose Output messages about what AJDoc is doing\n-locale <name> Locale to be used, e.g. en_US or en_US_WIN\n-encoding <name> Source file encoding name\n-standard Use com.sun.tools.doclets.standard.Standard doclet\n-log Log each pass of document generation\n-argfile <file> The file contains a line-delimited list of files\n inserted into the argument list\n-compiler <class> Generate RootDoc to doclet via alternate compiler (unsupported) | |||
\n-J<flag> Pass <flag> directly to the runtime system\n | |||
internal_error=Internal error\: {0} | |||
file_not_found_exception:Cannot read file\: {0}. | |||
io_exception:IOException\: {0}. | |||
argument_already_seen=The {0} option may be specified no more than once. | |||
invalid_flag=invalid flag\: {0}. | |||
requires_argument=option {0} requires {1} argument(s). | |||
cant_create_root_doc=Cannot create RootDoc from class {0}. | |||
cant_create_root_doc_ex=Cannot create RootDoc from class {0}\: {1}. | |||
incorrect_root_doc_class=The class {0} must implement the interface org.aspectj.tools.javadoc.RootDocMaker, not {1}. | |||
root_doc_maker_is_null=Could not create RootDocMaker from class {0}. | |||
done_in=[done in {0} ms] | |||
internal_error_exception_thrown=Internal error\: In class {0}, method {1} has thrown an exception: {2}. | |||
method_not_accessible=In class {0}, method {1} not accessible. | |||
class_not_found=Cannot find {0} class {1}. | |||
invoke_exception_thrown=Could not invoke method {0} in class {1}. | |||
must_return=In class {0}, method {1} must return {2}, not {3}. | |||
doclet_method_not_found=Doclet class {0} does not contain a {1} method. | |||
doclet_method_not_accessible=In doclet class {0}, method {1} not accessible. | |||
doclet_method_must_be_static=In doclet class {0}, method {1} must be static. | |||
out_of_memory=java.lang.OutOfMemoryError\: Please increase memory.\nFor example, on the Sun Classic or HotSpot VMs, add the option -J-Xmx\nsuch as -J-Xmx32m. | |||
exception_thrown=In {0} class {1}, method {2} has thrown an exception\: {3} | |||
No_packages_or_classes_specified=No packages or classes specified. | |||
cant_create_doclet:Cannot create Doclet from class {0} | |||
method_not_found={0} class {1} does not contain a {2} method. | |||
method_not_accessible=In {0} class {1}, method {2} not accessible. | |||
must_have_default_ctor=Class {0} must contain a default, no-arguments constructor. | |||
class_cast_exception:Return type of method {0} in class {1} must be {2}, not {3} | |||
cant_construct_object=Cannot construct object of type {0} | |||
unsupported_version=The version {0} is currently not supported by {1}. | |||
see_tag_prematurely_done=Prematurely done reading - not finished\: {0} | |||
see_tag_unterminated_url=Unterminated see tag URL\: {0} | |||
see_tag_unterminated_string=Unterminated see tag string\: {0} | |||
see_tag_invalid_package_or_class=Invalid package or class in see tag\:{0}\: {1} | |||
see_tag_invalid_field_name=Invalid field name in see tag\:{0}\: {1} | |||
see_tag_invalid_param_start=Invalid parameter start in see tag\:{0}\: {1} | |||
see_tag_premature_param_end=Premature end of parameters in see tag\:{0}\: {1} | |||
see_tag_invalid_id=Invalid identifier in see tag\:{0}\: {1} | |||
see_tag_invalid_parameter_type=Invalid parameter type in see tag {0}\: {1} | |||
see_tag_invalid_parameter_type=Invalid parameter type in see tag {0}\: {1} | |||
see_tag_invalid_parameter_type_lbrace=Invalid parameter type in see tag, looking for left brace {0}\: {1} | |||
see_tag_invalid_parameter_type_ident=Invalid parameter type in see tag, looking for identifier {0}\: {1} | |||
see_tag_unterminated_array_type=Unterminated array type in see tag\: {0} | |||
see_tag_invalid_parameter_name=Invalid parameter name in see tag\: {0} | |||
see_tag_invalid_parameters=Invalid paramters in see tag\: {0} | |||
see_tag_expecting_typename_or_whitespace:Expecting type name or white space in see tag\: {0} | |||
see_tag_expecting_field_name:Expecting field name after # in see tag\: {0} | |||
see_tag_dot_sharp_or_id:Expecting '\#', ., or identifier in see set\: {0} | |||
tag_invalid_link_tag=Invalid link tag\: {0} | |||
tag_unterminated_link_tag=Unterminated link tag\: {0} | |||
serialField_tag_invalid_field_name_start=Invalid start of a field name in serialField tag\: '{0}' | |||
serialField_tag_invalid_field_name_part=Invalid part of a field name in serialField tag\: '{0}' | |||
serialField_tag_invalid_type_name_start=Invalid start of a type name in serialField tag\: '{0}' | |||
serialField_tag_invalid_type_name_part=Invalid part of a type name in serialField tag\: '{0}' | |||
unterminated_html_tag=Unterminated HTML tag\: {0} | |||
Loading_source_file=Loading source file {0}... | |||
Loading_source_file_for_class=Loading source file for class {0}... | |||
Loading_source_files_for_package=Loading source files for package {0}... | |||
ioexception_open=Trouble openning file {0} | |||
ioexception_close=Trouble closing file {0} | |||
ioexception_reading=Trouble reading from file {0} | |||
cant_resolve_file=Cannot resolve file {0} | |||
file_doesnt_exist=The file {0} does not exist | |||
invalid_package_name:Invalid package name: {0} | |||
internal_msg=Please copy the following text into an email message and send it,\n\ | |||
along with any additional information you can add to: \n\ | |||
\n\ | |||
support@aspectj.org \n\ | |||
starting_internal_compile=Starting compile... | |||
initializing_world=Initializing world... | |||
creating_root=Creating root... | |||
generating_docs=Generating documentation... |
@@ -1,151 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc.rootmakers; | |||
import java.lang.reflect.InvocationTargetException; | |||
import java.lang.reflect.Method; | |||
import org.aspectj.tools.ajdoc.ErrPrinter; | |||
/** | |||
* An abstract class for a javadoc rootmaker. | |||
* Provides some error handling and misc. functionality. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public abstract class Javadoc { | |||
/** Subclasses may want this ;). */ | |||
protected ErrPrinter err; | |||
/** Default ctor. */ | |||
public Javadoc() {} | |||
/** | |||
* Returns the result of invoking <code>method</code>, | |||
* on target <code>owner</code>, with arguments <code>args</code>. | |||
* This method handles errors that arise. | |||
* | |||
* @param method method to invoke. | |||
* @param owner target of the invocation. | |||
* @param args arguments to pass the method. | |||
* @return result of invoking the method on | |||
* the passed in owner with the passed in | |||
* parameters. | |||
*/ | |||
protected final Object invoke(Method method, Object owner, Object[] args) { | |||
if (method == null || owner == null) return null; | |||
String classname = owner.getClass().getName(); | |||
String methodName = method.getName(); | |||
try { | |||
Thread.currentThread().setContextClassLoader | |||
(owner.getClass().getClassLoader()); | |||
return method.invoke(owner, args); | |||
} catch (InvocationTargetException e) { | |||
err.invocationTargetException(e, classname, methodName); | |||
} catch (IllegalAccessException e) { | |||
err.ex(e, "method_not_accessible", classname, methodName); | |||
} catch (Exception e) { | |||
err.ex(e, "exception_thrown", "List", | |||
classname, methodName, e != null ? e.getMessage() : e+""); | |||
} | |||
return null; | |||
} | |||
/** | |||
* Returns the <code>Class</code> with name <code>classname</code>. | |||
* This may return null if <code>Class.forName</code> returns null, | |||
* but otherwise, this method handles resulting errors. | |||
* | |||
* @param classname name of the class to get. | |||
* @return Class named <code>clasname</code>. | |||
*/ | |||
protected final Class type(String classname) { | |||
try { | |||
return Class.forName(classname); | |||
} catch (ClassNotFoundException e) { | |||
err.ex(e, "class_not_found", "Hashtable", classname); | |||
} | |||
return null; | |||
} | |||
/** | |||
* Returns the method named <code>name</code>, whose parameters | |||
* are declared <code>params</code>, and which is declared | |||
* in <code>type</code>. | |||
* | |||
* @param name name of the method. | |||
* @param params type of the parameters. | |||
* @param type type in which the resulting method is declared. | |||
* @return the method named <code>name</code>, whose parameters | |||
* are declared <code>params</code>, and which is declared | |||
* in <code>type</code>. This may be null. | |||
*/ | |||
protected final Method method(String name, Class[] params, Class type) { | |||
if (type == null) return null; | |||
try { | |||
return type.getMethod(name, params); | |||
} catch (NoSuchMethodException e) { | |||
err.ex(e, "method_not_found", type.getClass().getName(), name); | |||
} | |||
return null; | |||
} | |||
/** | |||
* Returns the Object resulting from default construction | |||
* of a class named <code>classname</code>. This method | |||
* handles all errors that arise. | |||
* | |||
* @param classname class name of the resulting Object. | |||
* @return new instance made from the default | |||
* construction of a class named | |||
* <code>classname</code>. This may be null. | |||
* @see #newInstance(Class) | |||
*/ | |||
protected final Object newInstance(String classname) { | |||
return newInstance(type(classname)); | |||
} | |||
/** | |||
* Returns the Object resulting from default construction | |||
* of a class <code>type</code>. This method | |||
* handles all errors that arise. | |||
* | |||
* @param type Class of the resulting Object. | |||
* @return new instance made from the default | |||
* construction of a class named | |||
* <code>classname</code>. This may be null. | |||
*/ | |||
protected final Object newInstance(Class type) { | |||
if (type == null) return null; | |||
try { | |||
return type.newInstance(); | |||
} catch (InstantiationException e) { | |||
err.ex(e, "must_have_default_ctor", type.getClass().getName()); | |||
return null; | |||
} catch (IllegalAccessException e) { | |||
err.ex(e, "method_not_accessible", type.getClass().getName(), "new()"); | |||
return null; | |||
} | |||
} | |||
} |
@@ -1,77 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc.rootmakers; | |||
import com.sun.javadoc.RootDoc; | |||
import com.sun.javadoc.DocErrorReporter; | |||
import java.lang.reflect.Method; | |||
import java.util.List; | |||
import org.aspectj.tools.ajdoc.AccessChecker; | |||
import org.aspectj.tools.ajdoc.RootDocMaker; | |||
import org.aspectj.tools.ajdoc.CannotMakeRootDocException; | |||
/** | |||
* Makes a RootDoc using javadoc from SDK 1.3 as an example. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public class Javadoc13 extends Javadoc implements RootDocMaker { | |||
public Javadoc13() {} | |||
public RootDoc makeRootDoc(String sourcepath, | |||
String classpath, | |||
String bootclasspath, | |||
String extdirs, | |||
long flags, | |||
String encoding, | |||
String locale, | |||
String source, | |||
List classesAndPackages, | |||
List options, | |||
DocErrorReporter messager, | |||
String programName, | |||
AccessChecker filter) | |||
throws CannotMakeRootDocException { | |||
// todo: options ignored in 13? | |||
Class envClass = type("com.sun.tools.javadoc.Env"); | |||
if (envClass == null) return null; | |||
Method create = method("create", new Class[]{String.class, | |||
String.class, | |||
String.class, | |||
String.class, | |||
int.class, | |||
String.class}, | |||
envClass); | |||
if (create == null) return null; | |||
Object env = invoke(create, null, new Object[]{sourcepath, | |||
classpath, | |||
bootclasspath, | |||
extdirs, | |||
new Integer((int)flags), | |||
encoding}); | |||
if (env == null) return null; | |||
return null; | |||
} | |||
} |
@@ -1,273 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.ajdoc.rootmakers; | |||
//import com.sun.javadoc.RootDoc; | |||
//import com.sun.javadoc.DocErrorReporter; | |||
// | |||
//import java.lang.reflect.InvocationTargetException; | |||
//import java.lang.reflect.Constructor; | |||
//import java.lang.reflect.Method; | |||
//import java.util.Iterator; | |||
//import java.util.List; | |||
// | |||
//import org.aspectj.tools.ajdoc.CannotMakeRootDocException; | |||
//import org.aspectj.tools.ajdoc.ErrPrinter; | |||
//import org.aspectj.tools.ajdoc.RootDocMaker; | |||
//import org.aspectj.tools.ajdoc.AccessChecker; | |||
//XXX | |||
//import com.sun.tools.javac.v8.util.Hashtable; | |||
/** | |||
* Makes a RootDoc using javadoc from SDK 1.4 as an example. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
//public class Javadoc14 extends Javadoc implements RootDocMaker { | |||
// | |||
// public Javadoc14() {} | |||
// | |||
// public RootDoc makeRootDoc(String sourcepath, | |||
// String classpath, | |||
// String bootclasspath, | |||
// String extdirs, | |||
// long flags, | |||
// String encoding, | |||
// String locale, | |||
// String source, | |||
// List classesAndPackages, | |||
// List options, | |||
// DocErrorReporter docErrorReporter, | |||
// String programName, | |||
// AccessChecker filter) | |||
// throws CannotMakeRootDocException { | |||
// this.err = (ErrPrinter)docErrorReporter; | |||
// Class hashtableClass = null; | |||
// String classname = "com.sun.tools.javac.v8.util.Hashtable"; | |||
// try { | |||
// hashtableClass = Class.forName(classname); | |||
// } catch (ClassNotFoundException e) { | |||
// err.ex(e, "class_not_found", "Hashtable", classname); | |||
// return null; | |||
// } | |||
// Object hashtable = null; | |||
// try { | |||
// hashtable = hashtableClass.newInstance(); | |||
// Method put = hashtableClass.getMethod("put", | |||
// new Class[]{Object.class, | |||
// Object.class}); | |||
// if (sourcepath != null) { | |||
// put.invoke(hashtable, new Object[]{"-sourcepath", | |||
// sourcepath}); | |||
// } | |||
// if (classpath != null) { | |||
// put.invoke(hashtable, new Object[]{"-classpath", | |||
// classpath}); | |||
// } | |||
// if (bootclasspath != null) { | |||
// put.invoke(hashtable, new Object[]{"-bootclasspath", | |||
// bootclasspath}); | |||
// } | |||
// if (extdirs != null) { | |||
// put.invoke(hashtable, new Object[]{"-extdirs", | |||
// extdirs}); | |||
// } | |||
// if (encoding != null) { | |||
// put.invoke(hashtable, new Object[]{"-encoding", | |||
// encoding}); | |||
// } | |||
// if (true || (flags & 0x1) != 0) { | |||
// put.invoke(hashtable, new Object[]{"-verbose", | |||
// ""}); | |||
// } | |||
// if (source != null) { | |||
// put.invoke(hashtable, new Object[]{"-source", | |||
// source}); | |||
// } | |||
// if (filter != null) { | |||
// put.invoke(hashtable, new Object[]{"-" + filter.getOption(), | |||
// ""}); | |||
// } | |||
// Hashtable h = (Hashtable)hashtable; | |||
// | |||
// } catch (NoSuchMethodException e) { | |||
// err.ex(e, "method_not_found", classname, "put"); | |||
// return null; | |||
// } catch (InvocationTargetException e) { | |||
// err.invocationTargetException(e, classname, "put"); | |||
// return null; | |||
// } catch (InstantiationException e) { | |||
// err.ex(e, "must_have_default_ctor", classname); | |||
// return null; | |||
// } catch (IllegalAccessException e) { | |||
// err.ex(e, "method_not_accessible", classname, "new()"); | |||
// return null; | |||
// } | |||
// Class messagerClass = null; | |||
// classname = "com.sun.tools.javadoc.Messager"; | |||
// try { | |||
// messagerClass = Class.forName(classname); | |||
// } catch (ClassNotFoundException e) { | |||
// err.ex(e, "class_not_found", "Messager", classname); | |||
// return null; | |||
// } | |||
// Object messager = null; | |||
// try { | |||
// Constructor ctor = | |||
// messagerClass.getConstructor(new Class[]{String.class}); | |||
// messager = ctor.newInstance(new Object[]{programName}); | |||
// } catch (InstantiationException e) { | |||
// err.ex(e, "cant_construct_object", classname); | |||
// return null; | |||
// } catch (NoSuchMethodException e) { | |||
// err.ex(e, "method_not_found", classname, "new(String)"); | |||
// return null; | |||
// } catch (IllegalAccessException e) { | |||
// err.ex(e, "method_not_accessible", classname, "new(String)"); | |||
// return null; | |||
// } catch (InvocationTargetException e) { | |||
// err.invocationTargetException(e, classname, "new(String)"); | |||
// return null; | |||
// } | |||
// Class javadocToolClass = null; | |||
// classname = "com.sun.tools.javadoc.JavadocTool"; | |||
// try { | |||
// javadocToolClass = Class.forName(classname); | |||
// } catch (ClassNotFoundException e) { | |||
// err.ex(e, "class_not_found", "JavadocTool", classname); | |||
// return null; | |||
// } | |||
// Object javadocTool = null; | |||
// try { | |||
// Method make = javadocToolClass.getMethod("make", | |||
// new Class[]{messagerClass, | |||
// hashtableClass}); | |||
// javadocTool = make.invoke(null, new Object[]{messager, | |||
// hashtable}); | |||
// } catch (NoSuchMethodException e) { | |||
// err.ex(e, "method_not_found", classname, "make"); | |||
// return null; | |||
// } catch (InvocationTargetException e) { | |||
// err.invocationTargetException(e, classname, "make"); | |||
// return null; | |||
// } catch (IllegalAccessException e) { | |||
// err.ex(e, "method_not_accessible", classname, "make"); | |||
// return null; | |||
// } catch (Exception e) { | |||
// err.ex(e, "exception_thrown", "JavadocTool", | |||
// classname, "make", e != null ? e.getMessage() : e+""); | |||
// return null; | |||
// } | |||
// Class modifierFilterClass = null; | |||
// classname = "com.sun.tools.javadoc.ModifierFilter"; | |||
// try { | |||
// modifierFilterClass = Class.forName(classname); | |||
// } catch (ClassNotFoundException e) { | |||
// err.ex(e, "class_not_found", "ModifierFilter", classname); | |||
// return null; | |||
// } | |||
// Object modifierFilter = null; | |||
// classname = "com.sun.tools.javadoc.ModifierFilter"; | |||
// try { | |||
// Constructor ctor = | |||
// modifierFilterClass.getConstructor(new Class[]{long.class}); | |||
// modifierFilter = ctor.newInstance(new Object[]{new Long(flags)}); | |||
// } catch (InstantiationException e) { | |||
// err.ex(e, "cant_construct_object", classname); | |||
// return null; | |||
// } catch (NoSuchMethodException e) { | |||
// err.ex(e, "method_not_found", classname, "new()"); | |||
// return null; | |||
// } catch (IllegalAccessException e) { | |||
// err.ex(e, "method_not_accessible", classname, "new()"); | |||
// return null; | |||
// } catch (InvocationTargetException e) { | |||
// err.invocationTargetException(e, classname, "new()"); | |||
// return null; | |||
// } | |||
// Class listClass = null; | |||
// classname = "com.sun.tools.javac.v8.util.List"; | |||
// try { | |||
// listClass = Class.forName(classname); | |||
// } catch (ClassNotFoundException e) { | |||
// err.ex(e, "class_not_found", "List", classname); | |||
// return null; | |||
// } | |||
// RootDoc rootDoc = null; | |||
// classname = "com.sun.tools.javadoc.JavadocTool"; | |||
// try { | |||
// Method getRootDocImpl = | |||
// javadocToolClass.getMethod("getRootDocImpl", | |||
// new Class[]{String.class, | |||
// modifierFilterClass, | |||
// listClass, | |||
// listClass}); | |||
// Object classesOrPackageList = list(classesAndPackages, listClass); | |||
// Object optionsList = list(options, listClass); | |||
// | |||
// rootDoc = | |||
// (RootDoc)getRootDocImpl.invoke(javadocTool, | |||
// new Object[]{locale, | |||
// modifierFilter, | |||
// classesOrPackageList, | |||
// optionsList}); | |||
// } catch (NoSuchMethodException e) { | |||
// err.ex(e, "method_not_found", classname, "getRootDocImpl"); | |||
// return null; | |||
// } catch (InvocationTargetException e) { | |||
// err.invocationTargetException(e, classname, "getRootDocImpl"); | |||
// return null; | |||
// } catch (IllegalAccessException e) { | |||
// err.ex(e, "method_not_accessible", classname, "getRootDocImpl"); | |||
// return null; | |||
// } catch (ClassCastException e) { | |||
// err.ex(e, "class_cast_exception", "getRootDocImpl", classname, | |||
// "com.sun.javadoc.RootDoc", | |||
// rootDoc == null ? "" : rootDoc.getClass().getName()); | |||
// return null; | |||
// } | |||
// return rootDoc; | |||
// } | |||
// | |||
// | |||
// private final Object list(List list, Class listClass) { | |||
// if (listClass == null) return null; | |||
// Object newlist = newInstance(listClass); | |||
// if (newlist == null) return null; | |||
// if (list == null) return newlist; | |||
// Class listBufferClass = type("com.sun.tools.javac.v8.util.ListBuffer"); | |||
// if (listBufferClass == null) return newlist; | |||
// Object listBuffer = newInstance(listBufferClass); | |||
// if (listBuffer == null) return newlist; | |||
// Method append = method("append", new Class[]{Object.class},listBufferClass); | |||
// if (append == null) return newlist; | |||
// for (Iterator i = list.iterator(); i.hasNext();) { | |||
// invoke(append, listBuffer, new Object[]{i.next()}); | |||
// } | |||
// | |||
// Method toList = method("toList", new Class[]{}, listBufferClass); | |||
// if (toList == null) return newlist; | |||
// newlist = invoke(toList, listBuffer, new Object[]{}); | |||
// return newlist; | |||
// } | |||
//} |
@@ -1,85 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import org.aspectj.ajdoc.IntroducedDoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.MemberDoc; | |||
import com.sun.tools.doclets.IndexBuilder; | |||
import java.io.IOException; | |||
public class AbstractIndexWriter | |||
extends com.sun.tools.doclets.standard.AbstractIndexWriter | |||
{ | |||
protected AbstractIndexWriter(String path, | |||
String filename, | |||
String relativePath, | |||
IndexBuilder indexbuilder) | |||
throws IOException { | |||
super(path, filename, relativePath, indexbuilder); | |||
} | |||
protected AbstractIndexWriter(String filename, | |||
IndexBuilder indexbuilder) | |||
throws IOException { | |||
super(filename, indexbuilder); | |||
} | |||
protected void printClassInfo(ClassDoc cd) { | |||
if (cd instanceof AspectDoc) { | |||
print("aspect "); | |||
printPreQualifiedClassLink(cd); | |||
print('.'); | |||
} else { | |||
super.printClassInfo(cd); | |||
} | |||
} | |||
protected void printMemberDesc(MemberDoc member) { | |||
String classdesc = Statics.type(member.containingClass()) + " " + | |||
getPreQualifiedClassLink(member.containingClass()); | |||
if (member instanceof org.aspectj.ajdoc.MemberDoc) { | |||
org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member; | |||
if (md.isAdvice()) { | |||
printText("doclet.Advice_in", classdesc); | |||
} else if (md.isPointcut()) { | |||
printText("doclet.Pointcut_in", classdesc); | |||
} | |||
} else { | |||
super.printMemberDesc(member); | |||
} | |||
if (member instanceof org.aspectj.ajdoc.MemberDoc) { | |||
IntroducedDoc intro = | |||
((org.aspectj.ajdoc.MemberDoc)member).introduced(); | |||
if (intro != null) { | |||
print(' '); | |||
printText("doclet.introduced_by", | |||
Statics.type(intro.containingClass()) + " " + | |||
getPreQualifiedClassLink(intro.containingClass())); | |||
} | |||
} | |||
} | |||
} |
@@ -1,477 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.DocErrorReporter; | |||
import com.sun.javadoc.PackageDoc; | |||
import com.sun.javadoc.RootDoc; | |||
import com.sun.tools.doclets.ClassTree; | |||
import com.sun.tools.doclets.DocletAbortException; | |||
import com.sun.tools.doclets.HtmlDocWriter; | |||
import com.sun.tools.doclets.IndexBuilder; | |||
import java.io.IOException; | |||
import java.lang.reflect.Constructor; | |||
import java.util.Arrays; | |||
/** | |||
* An abstract allowing one to customize the writers | |||
* used in ajdoc. Subclasses should define the three | |||
* generate methods to specify the documentation made. | |||
* | |||
* @see #preGenerationClasses() | |||
* @see #postGenerationClasses() | |||
* @see #checkClasses() | |||
* @author Jeff Palm | |||
*/ | |||
public abstract class AbstractStandard | |||
extends com.sun.tools.doclets.standard.Standard { | |||
// todo wes removed restriction, but implemented Standard as singleton via proxy | |||
private static int refCount = 0; | |||
{ | |||
if (refCount > 0) { | |||
System.err.println("Warning: " + refCount + " AbstractStandard already "); | |||
} | |||
refCount++; | |||
} | |||
/** | |||
* The ClassTree that is available to subclasses and it gaurateed | |||
* to be created before pre-generating classes. | |||
*/ | |||
protected ClassTree classtree; | |||
protected static boolean start(AbstractStandard as, | |||
RootDoc root) throws IOException { | |||
try { | |||
as.getConfiguration().setOptions(root); | |||
as.startGeneration(root); | |||
} catch (DocletAbortException exc) { | |||
return false; | |||
} | |||
return true; | |||
} | |||
/** | |||
* Returns the types of {@link Pass}es that will | |||
* run before generating classes. | |||
* | |||
* @return an array of Class, where each entry | |||
* is a subclass of {@link Pass}, ordered | |||
* to run directly before generating the | |||
* classes. | |||
*/ | |||
protected abstract Class[] preGenerationClasses(); | |||
/** | |||
* Returns the types of {@link Pass}es that will | |||
* run after generating classes. | |||
* | |||
* @return an array of Class, where each entry | |||
* is a subclass of {@link Pass}, ordered | |||
* to run directly after generating the | |||
* classes. | |||
*/ | |||
protected abstract Class[] postGenerationClasses(); | |||
/** | |||
* Returns the types of {@link CheckPass}es that will | |||
* run to check the classes. | |||
* | |||
* @return an array of Class, where each entry | |||
* is a subclass of {@link CheckPass}, ordered | |||
* to run in order to check the classes passed | |||
* into the class generation phase. | |||
*/ | |||
protected abstract Class[] checkClasses(); | |||
/** | |||
* Return the configuration used by a subclass. This | |||
* allows the subclass to specify it's own kind. | |||
* | |||
* @return a customized configuration. | |||
*/ | |||
public abstract ConfigurationStandard getConfiguration(); | |||
protected ConfigurationStandard makeConfiguration() { | |||
return new ConfigurationStandard(); | |||
} | |||
/** | |||
* Returns the configuration, and ensures that | |||
* HtmlDocWriter.configuration is of the type used by | |||
* this class. | |||
* | |||
* @return the current instanceof ConfigurationStandard being | |||
* used and creates one if needed. This will <b>not</b> | |||
* be null. | |||
*/ | |||
// todo these are the heinous globals that impose one process per classloader | |||
public static com.sun.tools.doclets.standard.ConfigurationStandard | |||
configuration() { | |||
if (HtmlDocWriter.configuration == null || | |||
!(HtmlDocWriter.configuration instanceof ConfigurationStandard)) { | |||
HtmlDocWriter.configuration = new ConfigurationStandard(); | |||
//TODO: change to makeConfiguration() | |||
} | |||
return (ConfigurationStandard)HtmlDocWriter.configuration; | |||
} | |||
/** | |||
* Creates and returns an IndexBuilder that includes aspects. | |||
* | |||
* @param root RootDoc to pass the new IndexBuilder. | |||
* @param classesOnly <code>true</code> if only classes | |||
* should be included. | |||
* @return an IndexBuilder that includes aspects. | |||
*/ | |||
protected IndexBuilder indexBuilder(RootDoc root, boolean classesOnly) { | |||
class MyIndexBuilder extends IndexBuilder { | |||
public MyIndexBuilder(RootDoc r, boolean n) { | |||
super(r, n); | |||
} | |||
public MyIndexBuilder(RootDoc r, boolean n, boolean b) { | |||
super(r, n, b); | |||
} | |||
protected void putMembersInIndexMap(ClassDoc classdoc) { | |||
super.putMembersInIndexMap(classdoc); | |||
if (classdoc instanceof org.aspectj.ajdoc.ClassDoc) { | |||
org.aspectj.ajdoc.ClassDoc cd = | |||
(org.aspectj.ajdoc.ClassDoc)classdoc; | |||
adjustIndexMap(cd.pointcuts()); | |||
if (cd instanceof AspectDoc) { | |||
adjustIndexMap(((AspectDoc)cd).advice()); | |||
} | |||
} | |||
} | |||
} | |||
return new MyIndexBuilder(root, configuration().nodeprecated, classesOnly); | |||
} | |||
/** | |||
* Does the work in generating the documentation. | |||
* First, call all the passes return from {@link #generateCheckPasses} | |||
* them perform some copying. Second build the classtree, run the | |||
* pre-classgeneration passes, generate the packages, generate the | |||
* classes, then call all the postGenerationClasses. | |||
* | |||
* @param root the root of the documentation. | |||
*/ | |||
protected void startGeneration(RootDoc root) throws DocletAbortException { | |||
if (!generateCheckPasses(getConfiguration(), root)) return; | |||
performCopy(getConfiguration().destdirname, | |||
getConfiguration().helpfile); | |||
performCopy(getConfiguration().destdirname, | |||
getConfiguration().stylesheetfile); | |||
classtree = new ClassTree(root, getConfiguration().nodeprecated); | |||
generatePrePasses(getConfiguration(), root); | |||
generatePackageCycle(getConfiguration().packages, | |||
getConfiguration().createtree, | |||
getConfiguration().nodeprecated); | |||
generateClassFiles(root, classtree); | |||
generatePostPasses(getConfiguration(), root); | |||
} | |||
/** | |||
* A class representing a single pass in the generation cycles. It | |||
* does some of the dirty work for you. | |||
*/ | |||
public static abstract class Pass { | |||
/** The root available to this pass. */ | |||
protected RootDoc root; | |||
/** The configuration available to this pass. */ | |||
protected ConfigurationStandard cs; | |||
/** The doclet available to this pass. */ | |||
protected AbstractStandard std; | |||
public Pass() {} | |||
/** | |||
* Returns the title of the pass for logging. | |||
* | |||
* @return the unique title of this pass. This can | |||
* be <code>null</code> to disable display. | |||
*/ | |||
public abstract String title(); | |||
/** | |||
* Do the generation work. All instance variables | |||
* are guaranteed to be set. | |||
*/ | |||
protected abstract void gen() throws DocletAbortException; | |||
/** | |||
* Do the actual generation if {@link #cond} returns | |||
* <code>true</code>. Do some other logging, too. | |||
* | |||
* @param std the AbstractStandard to use. | |||
* @param cs the ConfigurationStandard to use. | |||
* @param root the RootDoc to use. | |||
*/ | |||
public final void generate(AbstractStandard std, | |||
ConfigurationStandard cs, | |||
RootDoc root) | |||
throws DocletAbortException { | |||
this.std = std; | |||
this.cs = cs; | |||
this.root = root; | |||
if (cond()) { | |||
String title = title(); | |||
long start = System.currentTimeMillis(); | |||
if (cs.log && title != null) { | |||
cs.standardmessage.notice("doclet.pass_msg", title); | |||
} | |||
gen(); | |||
if (cs.log && title != null) { | |||
long stop = System.currentTimeMillis(); | |||
cs.standardmessage.notice("doclet.done_msg", | |||
title, (stop-start)+""); | |||
} | |||
} | |||
} | |||
/** | |||
* Returns whether the generation should proceed. Override | |||
* this method for conditional passes. | |||
* | |||
* @return <code>true</code> is this pass shoulud proceed. | |||
*/ | |||
protected boolean cond() { | |||
return true; | |||
} | |||
} | |||
/** | |||
* A convenience class for doing checks. | |||
*/ | |||
public abstract static class Check extends Pass { | |||
/** | |||
* Returns the error message if check fails. | |||
* | |||
* @return error message if check fails. | |||
*/ | |||
protected abstract String message(); | |||
/** | |||
* Returns whether check has failed or not. | |||
* | |||
* @return <code>true</code> is check fails. | |||
*/ | |||
protected abstract boolean cond(); | |||
/** | |||
* Prints message, because we've failed and throws | |||
* a DocletAbortException to notify the doclet | |||
* that we've failed. | |||
*/ | |||
protected void gen() throws DocletAbortException { | |||
cs.standardmessage.error(message()); | |||
throw new DocletAbortException(); | |||
} | |||
/** | |||
* Returns null, because we don't want to be displayed. | |||
* | |||
* @return <code>null</code>. | |||
*/ | |||
public String title() { return null; } | |||
} | |||
/** | |||
* Generates the passes to run before generating the classes. | |||
*/ | |||
private final void generatePrePasses(ConfigurationStandard cs, | |||
RootDoc root) | |||
throws DocletAbortException { | |||
generatePasses(cs, root, preGenerationClasses()); | |||
} | |||
/** | |||
* Generates the passes to run after generating the classes. | |||
*/ | |||
private final void generatePostPasses(ConfigurationStandard cs, | |||
RootDoc root) | |||
throws DocletAbortException { | |||
generatePasses(cs, root, postGenerationClasses()); | |||
} | |||
/** | |||
* Generates the passes that run before doing anything. These | |||
* passes check that it's OK to do anything. | |||
*/ | |||
private final boolean generateCheckPasses(ConfigurationStandard cs, | |||
RootDoc root) | |||
throws DocletAbortException { | |||
try { | |||
generatePasses(cs, root, checkClasses()); | |||
} catch (DocletAbortException e) { | |||
return false; | |||
} | |||
return true; | |||
} | |||
/** | |||
* Generates passes from <code>classes</code>. For each | |||
* class found in <code>classes</code> a constructor taking zero | |||
* or one-argument is called. Then the generate method is | |||
* called on that Pass passing it <code>this</code>, the | |||
* configuration, and root. | |||
* | |||
* @param cs configuration to use. | |||
* @param root root we're documenting. | |||
* @param classes list of subtypes of {@link Pass} that | |||
* will be run. | |||
*/ | |||
private final void generatePasses(ConfigurationStandard cs, | |||
RootDoc root, | |||
Class[] classes) | |||
throws DocletAbortException { | |||
if (classes == null) return; | |||
nextClass: | |||
for (int i = 0; i < classes.length; i++) { | |||
try { | |||
Constructor[] ctrs = classes[i].getConstructors(); | |||
nextCtr: | |||
for (int j = 0; j < ctrs.length; j++) { | |||
Pass pass = null; | |||
if (ctrs[j].getParameterTypes().length == 0) { | |||
pass = (Pass)ctrs[j].newInstance(new Object[]{}); | |||
} else if (ctrs[j].getParameterTypes().length == 1) { | |||
pass = (Pass)ctrs[j].newInstance(new Object[]{this}); | |||
} | |||
if (pass != null) { | |||
pass.generate(this,cs,root); | |||
continue nextClass; | |||
} | |||
} | |||
throw new Exception("Can't create pass for class " + classes[i]); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
Standard.configuration().standardmessage. | |||
error("doclet.exception", e+""); | |||
throw new DocletAbortException(); | |||
} | |||
} | |||
} | |||
/** | |||
* Generates the packages. | |||
*/ | |||
protected void generatePackageCycle(PackageDoc[] pkgs, | |||
boolean createtree, | |||
boolean nodeprecated) | |||
throws DocletAbortException { | |||
Arrays.sort(pkgs); | |||
for (int i = 0; i < pkgs.length; i++) { | |||
PackageDoc prev = i == 0 ? null : pkgs[i-1]; | |||
PackageDoc curr = pkgs[i]; | |||
PackageDoc next = i == pkgs.length-1 ? null : pkgs[i+1]; | |||
generatePackages(prev, curr, next, | |||
createtree, nodeprecated); | |||
} | |||
} | |||
/** | |||
* Generates a package doc for the three PackageDocs passed. | |||
*/ | |||
protected void generatePackages(PackageDoc prev, | |||
PackageDoc curr, | |||
PackageDoc next, | |||
boolean createtree, | |||
boolean nodeprecated) | |||
throws DocletAbortException { | |||
PackageWriter.generate(curr, prev, next); | |||
if (createtree) { | |||
PackageTreeWriter.generate(curr, prev, | |||
next, nodeprecated); | |||
} | |||
PackageFrameWriter.generate(curr); | |||
} | |||
/** | |||
* Generates all the classes. | |||
*/ | |||
protected void generateClassCycle(ClassDoc[] cs, | |||
ClassTree classtree, | |||
boolean nopackage) | |||
throws DocletAbortException { | |||
Arrays.sort(cs); | |||
for(int i = 0; i < cs.length; i++) { | |||
if (configuration().nodeprecated && | |||
cs[i].tags("deprecated").length > 0) { | |||
continue; | |||
} | |||
ClassDoc prev = i == 0 ? null : cs[i-1]; | |||
ClassDoc curr = cs[i]; | |||
ClassDoc next = i == cs.length-1 ? null : cs[i+1]; | |||
generateClasses(prev, curr, next, | |||
classtree, nopackage); | |||
} | |||
} | |||
/** | |||
* Generates class docs for the three ClassDocs passed. | |||
*/ | |||
protected void generateClasses(ClassDoc prev, | |||
ClassDoc curr, | |||
ClassDoc next, | |||
ClassTree classtree, | |||
boolean nopackage) | |||
throws DocletAbortException { | |||
ClassWriter.generate(curr, prev, next, | |||
classtree, nopackage); | |||
} | |||
/** | |||
* Returns the delegation to {@link #configuration()}. | |||
*/ | |||
public static int optionLength(String option) { | |||
return configuration().optionLength(option); | |||
} | |||
/** | |||
* Returns the delegation to {@link #configuration()}. | |||
*/ | |||
public static boolean validOptions(String options[][], | |||
DocErrorReporter reporter) | |||
throws IOException { | |||
return configuration().validOptions(options, reporter); | |||
} | |||
} | |||
@@ -1,393 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.IntroducedDoc; | |||
import org.aspectj.tools.ajdoc.Access; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.ProgramElementDoc; | |||
import java.lang.reflect.Constructor; | |||
import java.lang.reflect.Method; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.HashMap; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Map; | |||
public class AbstractSubWriter | |||
extends com.sun.tools.doclets.standard.AbstractSubWriter | |||
implements AbstractSubWriterAJ | |||
{ | |||
public AbstractSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, | |||
ClassDoc classdoc) | |||
{ | |||
super(writer, classdoc); | |||
} | |||
public AbstractSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) | |||
{ | |||
super(writer); | |||
} | |||
public final void printSummaryMember(ClassDoc cd, ProgramElementDoc member) { | |||
writer.printSummaryLinkType(this, member); | |||
printSummaryLink(cd, member); | |||
printSummaryLinkComment(member); | |||
} | |||
protected final void printCrosscuts(ProgramElementDoc member) { | |||
if (hasCrosscuts(classdoc, member)) { | |||
writer.dl(); | |||
writer.dd(); | |||
printCrosscuts(classdoc, member); | |||
writer.ddEnd(); | |||
writer.dlEnd(); | |||
} | |||
} | |||
protected /*abstract*/ Class delegateClass() { throw new RuntimeException(""); } | |||
/*final*/ private com.sun.tools.doclets.standard.AbstractSubWriter del; | |||
{ setDelegator(); } | |||
protected final void setDelegator() { | |||
com.sun.tools.doclets.standard.AbstractSubWriter mw = null; | |||
try { | |||
List list = new ArrayList(); | |||
if (writer != null) list.add(writer); | |||
if (classdoc != null) list.add(classdoc); | |||
setDelegator(mw = findDelegate | |||
(list.toArray | |||
(new Object[list.size()]))); | |||
} finally { | |||
del = mw; | |||
} | |||
} | |||
public final com.sun.tools.doclets.standard.AbstractSubWriter del() { | |||
return del; | |||
} | |||
private final void setDelegator(Object o) { | |||
if (o == null) return; | |||
try { | |||
Method[] ms = o.getClass().getMethods(); | |||
for (int i = 0; i < ms.length; i++) { | |||
if (ms[i].getName().equals("setDelegator")) { | |||
ms[i].invoke(o, new Object[]{this}); | |||
} | |||
} | |||
} catch (Exception e) { | |||
Standard.configuration().standardmessage. | |||
error("doclet.exception_encountered", e+""); | |||
} | |||
} | |||
private final com.sun.tools.doclets.standard.AbstractSubWriter | |||
findDelegate(Object[] params) { | |||
if (delegateClass() == null) { | |||
return this; | |||
} | |||
try { | |||
Constructor[] cs = delegateClass().getConstructors(); | |||
for (int i = 0; i < cs.length; i++) { | |||
if (cs[i].getParameterTypes().length == params.length) { | |||
return (com.sun.tools.doclets.standard.AbstractSubWriter) | |||
cs[i].newInstance(params); | |||
} | |||
} | |||
} catch (Exception e) { | |||
Standard.configuration().standardmessage. | |||
error("doclet.exception_encountered", e+""); | |||
} | |||
return null; | |||
} | |||
public int getMemberKind() { | |||
return -1; | |||
} | |||
public void printSummaryLabel(ClassDoc cd) { | |||
if (keyName() != null) { | |||
summaryLabel(keyName()); | |||
} else { | |||
del.printSummaryLabel(cd); | |||
} | |||
} | |||
public void printSummaryAnchor(ClassDoc cd) { | |||
if (keyName() != null) { | |||
summaryAnchor(keyName()); | |||
} else { | |||
del.printSummaryAnchor(cd); | |||
} | |||
} | |||
public void printInheritedSummaryAnchor(ClassDoc cd) { | |||
del.printInheritedSummaryAnchor(cd); | |||
} | |||
protected void printSummaryType(ProgramElementDoc member) { | |||
Access.printSummaryType(this, member); | |||
} | |||
protected void printSummaryLink(ClassDoc cd, | |||
ProgramElementDoc member) { | |||
Access.printSummaryLink(this, cd, member); | |||
} | |||
protected void printInheritedSummaryLink(ClassDoc cd, | |||
ProgramElementDoc member) { | |||
Access.printInheritedSummaryLink(this, cd, member); | |||
} | |||
protected void printHeader(ClassDoc cd) { | |||
if (keyName() != null) { | |||
header(keyName()); | |||
} else { | |||
Access.printHeader(this, cd); | |||
} | |||
} | |||
protected void printBodyHtmlEnd(ClassDoc cd) { | |||
Access.printBodyHtmlEnd(this, cd); | |||
} | |||
protected final void printMember(ProgramElementDoc elem) { | |||
nonfinalPrintMember(elem); | |||
printCrosscuts(elem); | |||
} | |||
protected void nonfinalPrintMember(ProgramElementDoc elem) { | |||
Access.printMember(this, elem); | |||
} | |||
protected void printDeprecatedLink(ProgramElementDoc member) { | |||
Access.printDeprecatedLink(this, member); | |||
} | |||
protected void printNavSummaryLink(ClassDoc cd, boolean link) { | |||
if (keyName() != null) { | |||
navSummaryLink(cd, keyName(), link); | |||
} else { | |||
Access.printNavSummaryLink(this, cd, link); | |||
} | |||
} | |||
protected void printNavDetailLink(boolean link) { | |||
if (keyName() != null) { | |||
navDetailLink(keyName(), link); | |||
} else { | |||
Access.printNavDetailLink(this, link); | |||
} | |||
} | |||
protected /*abstract*/ String propertyName() { return keyName(); } | |||
protected /*abstract*/ String keyName() { return null; } | |||
protected final String lowercase() { | |||
String str = propertyName(); | |||
return str == null || str.length() == 0 ? "" : | |||
Character.toLowerCase(str.charAt(0)) + | |||
str.substring(1); | |||
} | |||
public void printInheritedSummaryLabel(ClassDoc cd) { | |||
summaryLabel("Inherited_From", cd); | |||
} | |||
public void printIntroducedSummaryLabel(ClassDoc cd) { | |||
summaryLabel("Introduced_From", cd); | |||
} | |||
public void printIntroducedSummaryAnchor(ClassDoc cd) { | |||
summaryAnchor("introduced_from_class", cd); | |||
} | |||
protected final void summaryLabel(String keyName) { | |||
writer.boldText("doclet." + keyName + "_Summary"); | |||
} | |||
protected final void summaryAnchor(String keyName) { | |||
writer.anchor(keyName.toLowerCase() + "_summary"); | |||
} | |||
protected final void summaryLabel(String type, ClassDoc cd) { | |||
writer.bold(); | |||
writer.printText("doclet." + propertyName() + "s_" + type, | |||
Statics.type(cd), | |||
writer.getPreQualifiedClassLink(cd)); | |||
writer.boldEnd(); | |||
} | |||
protected final void summaryAnchor(String type, ClassDoc cd) { | |||
writer.anchor(lowercase() + "s_" + type + "_" + cd.qualifiedName()); | |||
} | |||
protected final String navKey(String keyName) { | |||
return "doclet.nav" + keyName; | |||
} | |||
protected final String navKey() { | |||
return navKey(keyName()); | |||
} | |||
protected final void navLink(ClassDoc cd, String keyName, | |||
boolean link, String kind) { | |||
if (link) { | |||
writer.printHyperLink | |||
("", | |||
cd == null ? | |||
keyName.toLowerCase() + "_" + kind : | |||
keyName.toLowerCase() + "s_inherited_from_class_" + | |||
cd.qualifiedName(), | |||
writer.getText(navKey(keyName))); | |||
} else { | |||
writer.printText(navKey(keyName)); | |||
} | |||
} | |||
protected final void navSummaryLink(ClassDoc cd, String keyName, boolean link) { | |||
navLink(cd, keyName, link, "summary"); | |||
} | |||
protected final void navDetailLink(String keyName, boolean link) { | |||
navLink(null, keyName, link, "detail"); | |||
} | |||
protected final void header(String keyName) { | |||
writer.anchor(keyName.toLowerCase() + "_detail"); | |||
writer.printTableHeadingBackground | |||
(writer.getText("doclet." + keyName + "_Detail")); | |||
} | |||
public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) {} | |||
public void printSummaryCrosscuts(ClassDoc cd, ProgramElementDoc member) {} | |||
public boolean hasCrosscuts(ClassDoc cd,ProgramElementDoc member) { | |||
return false; | |||
} | |||
protected void printHead(String name) { | |||
writer.h3(); | |||
writer.print(name); | |||
writer.h3End(); | |||
} | |||
protected List nointros(List members) { | |||
List list = new ArrayList(); | |||
for (Iterator i = members.iterator(); i.hasNext();) { | |||
Object o = i.next(); | |||
if (o instanceof org.aspectj.ajdoc.MemberDoc) { | |||
IntroducedDoc intro = | |||
((org.aspectj.ajdoc.MemberDoc)o).introduced(); | |||
if (intro == null || intro.containingClass().equals(classdoc)) { | |||
list.add(o); | |||
} | |||
} else { | |||
list.add(o); | |||
} | |||
} | |||
return list; | |||
} | |||
public void printMembersSummary() { | |||
nointros = true; | |||
super.printMembersSummary(); | |||
nointros = false; | |||
} | |||
protected final void printSummaryLinkComment(ProgramElementDoc member) { | |||
writer.codeEnd(); | |||
writer.println(); | |||
writer.br(); | |||
Access.printCommentDef(this, member); | |||
boolean newline = member.tags("deprecated").length + | |||
member.firstSentenceTags().length > 0; | |||
if (classdoc != null || true) { // ?? always | |||
if (hasCrosscuts(classdoc, member)) { | |||
if (newline) { | |||
writer.br(); | |||
writer.printNbsps(); | |||
} | |||
printSummaryCrosscuts(classdoc, member); | |||
} | |||
} | |||
writer.summaryRowEnd(); | |||
writer.trEnd(); | |||
} | |||
public void printIntroducedSummaryHeader(ClassDoc cd) { | |||
printIntroducedSummaryAnchor(cd); | |||
writer.tableIndexSummary(); | |||
writer.tableInheritedHeaderStart("#EEEEFF"); | |||
printIntroducedSummaryLabel(cd); | |||
writer.tableInheritedHeaderEnd(); | |||
writer.trBgcolorStyle("white", "TableRowColor"); | |||
writer.summaryRow(0); | |||
writer.code(); | |||
} | |||
public void printIntroducedSummaryFooter(ClassDoc cd) { | |||
writer.codeEnd(); | |||
writer.summaryRowEnd(); | |||
writer.trEnd(); | |||
writer.tableEnd(); | |||
writer.space(); | |||
} | |||
public void printIntroducedSummaryMember(ClassDoc cd, | |||
ProgramElementDoc member) { | |||
printIntroducedSummaryLink(cd, member); | |||
} | |||
public void printIntroducedSummaryLink(ClassDoc cd, | |||
ProgramElementDoc member) {} | |||
public void printIntroducedMembersSummary() { | |||
Map typesToMembers = new HashMap(); | |||
for (Iterator i = members(classdoc).iterator(); i.hasNext();) { | |||
Object o = i.next(); | |||
if (!(o instanceof org.aspectj.ajdoc.MemberDoc)) continue; | |||
org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)o; | |||
if (md.introduced() != null) { | |||
ClassDoc cd = md.introduced().containingClass(); | |||
List members = (List)typesToMembers.get(cd); | |||
if (members == null) members = new ArrayList(); | |||
members.add(md); | |||
typesToMembers.put(cd, members); | |||
} | |||
} | |||
for (Iterator i = typesToMembers.keySet().iterator(); i.hasNext();) { | |||
ClassDoc cd = (ClassDoc)i.next(); | |||
printIntroducedSummaryHeader(cd); | |||
List members = (List)typesToMembers.get(cd); | |||
Collections.sort(members); | |||
for (Iterator j = members.iterator(); j.hasNext();) { | |||
printIntroducedSummaryMember(cd, (ProgramElementDoc)j.next()); | |||
if (j.hasNext()) print(", "); | |||
} | |||
printIntroducedSummaryFooter(cd); | |||
} | |||
} | |||
private boolean nointros = false; | |||
public void printMembers() { | |||
nointros = true; | |||
super.printMembers(); | |||
nointros = false; | |||
} | |||
public void navSummaryLink() { | |||
nointros = true; | |||
super.navSummaryLink(); | |||
nointros = false; | |||
} | |||
protected void navDetailLink() { | |||
printNavDetailLink(members(classdoc).size() > 0 ? true : false); | |||
} | |||
public final List members(ClassDoc cd) { | |||
return nointros ? nointros(getMembers(cd)) : getMembers(cd); | |||
} | |||
protected List getMembers(ClassDoc cd) { | |||
return super.members(cd); | |||
} | |||
} | |||
@@ -1,33 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.ProgramElementDoc; | |||
public interface AbstractSubWriterAJ { | |||
public void printCrosscuts(ClassDoc cd, ProgramElementDoc member); | |||
public void printSummaryCrosscuts(ClassDoc cd, ProgramElementDoc member); | |||
public boolean hasCrosscuts(ClassDoc cd, ProgramElementDoc member); | |||
public void printIntroducedSummaryAnchor(ClassDoc cd); | |||
public void printIntroducedSummaryLabel(ClassDoc cd); | |||
} |
@@ -1,104 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.PackageDoc; | |||
import com.sun.tools.doclets.ClassTree; | |||
import com.sun.tools.doclets.DocletAbortException; | |||
import java.io.IOException; | |||
import java.util.List; | |||
public class AbstractTreeWriter | |||
extends com.sun.tools.doclets.standard.AbstractTreeWriter | |||
{ | |||
protected boolean seenAspect = false; | |||
protected boolean aspectMode = false; | |||
protected AbstractTreeWriter(String filename, ClassTree classtree) | |||
throws IOException, DocletAbortException { | |||
super(filename, classtree); | |||
} | |||
protected AbstractTreeWriter(String path, String filename, | |||
ClassTree classtree, PackageDoc pkg) | |||
throws IOException, DocletAbortException { | |||
super(path, filename, classtree, pkg); | |||
} | |||
protected void generateLevelInfo(ClassDoc parent, List list) { | |||
if (list.size() > 0) { | |||
ul(); | |||
for (int i = 0; i < list.size(); i++) { | |||
ClassDoc local = (ClassDoc)list.get(i); | |||
boolean isAspect = local instanceof org.aspectj.ajdoc.AspectDoc; | |||
if (aspectMode) { | |||
if (!local.qualifiedTypeName().equals("java.lang.Object") | |||
&& !isAspect) { | |||
continue; | |||
} | |||
} else if (isAspect) { | |||
continue; | |||
} | |||
printPartialInfo(local); | |||
printExtendsImplements(parent, local); | |||
generateLevelInfo(local, classtree.subs(local)); | |||
} | |||
ulEnd(); | |||
} | |||
} | |||
protected void printExtendsImplements(ClassDoc parent, ClassDoc cd) { | |||
super.printExtendsImplements(parent, cd); | |||
if (cd instanceof AspectDoc) { | |||
printDominationInfo(((AspectDoc)cd).dominatees(), "dominates"); | |||
printDominationInfo(((AspectDoc)cd).dominators(), "dominated by"); | |||
} | |||
} | |||
protected void printDominationInfo(AspectDoc[] aspects, | |||
String whosOnTop) { | |||
if (aspects != null && aspects.length > 0) { | |||
print(" (" + whosOnTop + " "); | |||
for (int i = 0; i < aspects.length; i++) { | |||
if (i > 0) print(", "); | |||
printPreQualifiedClassLink(aspects[i]); | |||
} | |||
print(")"); | |||
} | |||
} | |||
protected void generateTree(List list, String heading) { | |||
super.generateTree(list, heading); | |||
if (heading.equals("doclet.Class_Hierarchy")) { | |||
aspectMode = true; | |||
generateTree(list, "doclet.Aspect_Hierarchy"); | |||
aspectMode = false; | |||
} | |||
} | |||
} |
@@ -1,273 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.AdviceDoc; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import org.aspectj.tools.ajdoc.Access; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.ExecutableMemberDoc; | |||
import com.sun.javadoc.MemberDoc; | |||
import com.sun.javadoc.ProgramElementDoc; | |||
import com.sun.javadoc.Tag; | |||
import com.sun.javadoc.Type; | |||
import com.sun.tools.doclets.Util; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Set; | |||
import java.util.TreeMap; | |||
public class AdviceSubWriter extends ExecutableMemberSubWriter { | |||
protected Class delegateClass() { | |||
return MethodSubWriter.class; | |||
} | |||
public AdviceSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, | |||
AspectDoc aspectdoc) | |||
{ | |||
super(writer, aspectdoc); | |||
} | |||
public AdviceSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) | |||
{ | |||
super(writer); | |||
} | |||
protected final String keyName() { return "Advice"; } | |||
protected String where(ProgramElementDoc member) { | |||
return getWhere(classdoc, member); | |||
} | |||
public static String getWhere(ClassDoc cd, ProgramElementDoc member) { | |||
return getName(cd, (AdviceDoc)member).replace(' ','_').replace('#','-'); | |||
} | |||
protected void printSummaryType(ProgramElementDoc member) { | |||
AdviceDoc advice = (AdviceDoc)member; | |||
printModifiers(advice); | |||
} | |||
protected void printReturnTag(Tag[] returnsTag) { | |||
if (returnsTag.length > 0) { | |||
writer.dt(); | |||
writer.boldText("doclet.Returns"); | |||
writer.dd(); | |||
writer.printInlineComment(returnsTag[0]); | |||
} | |||
} | |||
protected void printTagsInfoHeader() { | |||
writer.dd(); | |||
writer.dl(); | |||
} | |||
protected void printTagsInfoFooter() { | |||
writer.dlEnd(); | |||
writer.ddEnd(); | |||
} | |||
protected void printSignature(ExecutableMemberDoc member) { | |||
AdviceDoc advice = (AdviceDoc)member; | |||
writer.displayLength = 0; | |||
writer.pre(); | |||
printReturnType(advice); | |||
bold(advice.name()); | |||
printParameters(advice); | |||
if (advice.isThrowing()) { | |||
writer.print(" throwing "); | |||
printExtraType(advice.extraType()); | |||
} | |||
if (advice.isReturning()) { | |||
writer.print(" returning "); | |||
printExtraType(advice.extraType()); | |||
} | |||
writer.preEnd(); | |||
} | |||
protected void printExtraType(Type type) { | |||
print(' '); | |||
print('('); | |||
if (type != null) { | |||
printTypeLink(type); | |||
} | |||
print(')'); | |||
} | |||
public static String getName(ClassDoc cd, AdviceDoc advice) { | |||
String name = advice.name(); | |||
int num = 1; | |||
for (Iterator i = staticMembers(cd).iterator(); i.hasNext();) { | |||
AdviceDoc ad = (AdviceDoc)i.next(); | |||
if (ad.equals(advice)) { | |||
break; | |||
} | |||
if (ad.name().equals(name)) { | |||
num++; | |||
} | |||
} | |||
return name + " #" + num; | |||
} | |||
protected String name(ProgramElementDoc member) { | |||
return getName(classdoc, (AdviceDoc)member); | |||
} | |||
protected void printParameters(ExecutableMemberDoc member) { | |||
//AdviceDoc advice = (AdviceDoc)member; | |||
Access.printParameters | |||
((com.sun.tools.doclets.standard.ExecutableMemberSubWriter) | |||
((AbstractSubWriter)del()).del(), | |||
member); | |||
} | |||
protected void printReturnType(AdviceDoc advice) { | |||
Type type = advice.returnType(); | |||
if (type != null) { | |||
printTypeLink(type); | |||
print(' '); | |||
} | |||
} | |||
public void nonfinalPrintMember(ProgramElementDoc elem) { | |||
AdviceDoc advice = (AdviceDoc)elem; | |||
writer.anchor(where(advice)); | |||
printHead(advice); | |||
printSignature(advice); | |||
printFullComment(advice); | |||
} | |||
protected void printSummaryLink(ClassDoc cd, ProgramElementDoc member) { | |||
ExecutableMemberDoc emd = (ExecutableMemberDoc)member; | |||
String name = emd.name(); | |||
writer.bold(); | |||
writer.printClassLink(cd, where(emd), name, false); | |||
writer.boldEnd(); | |||
writer.displayLength = name.length(); | |||
printParameters(emd); | |||
} | |||
protected void printHead(MemberDoc member) { | |||
printHead(name(member)); | |||
} | |||
protected static List staticMembers(ClassDoc classdoc) { | |||
if (!(classdoc instanceof AspectDoc)) return Collections.EMPTY_LIST; | |||
AdviceDoc[] advice = ((AspectDoc)classdoc).advice(); | |||
return advice == null ? Collections.EMPTY_LIST : Util.asList(advice); | |||
} | |||
protected List getMembers(ClassDoc classdoc) { | |||
return staticMembers(classdoc); | |||
} | |||
public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) { | |||
if (!(cd instanceof AspectDoc)) return; | |||
//AspectDoc ad = (AspectDoc)cd; | |||
AdviceDoc advice = (AdviceDoc)member; | |||
ExecutableMemberDoc[] crosscuts = advice.crosscuts(); | |||
if (null != crosscuts && crosscuts.length > 0) { | |||
writer.dt(); | |||
writer.boldText("doclet.Crosscuts"); | |||
Set set = new HashSet(); | |||
for (int i = 0; i < crosscuts.length; i++) { | |||
set.add(crosscuts[i]); | |||
} | |||
List list = new ArrayList(set); | |||
Collections.sort(list); | |||
for (Iterator i = list.iterator(); i.hasNext();) { | |||
ExecutableMemberDoc emd = (ExecutableMemberDoc)i.next(); | |||
if (null != emd) { | |||
writer.dd(); | |||
writer.code(); | |||
String where = emd instanceof AdviceDoc | |||
? where(emd) | |||
: super.where(emd); | |||
writer.printClassLink(emd.containingClass(), | |||
where, label(emd)); | |||
print(" in "); | |||
writer.printClassLink(emd.containingClass()); | |||
writer.codeEnd(); | |||
print('.'); | |||
} | |||
} | |||
} | |||
} | |||
public void printSummaryCrosscuts(ClassDoc cd, | |||
ProgramElementDoc member) { | |||
class CCs extends TreeMap { | |||
void add(ExecutableMemberDoc cc) { | |||
if (null != cc) { | |||
Object o = get(cc.containingClass()); | |||
if (o == null) { | |||
o = cc; | |||
} else if (o instanceof ExecutableMemberDoc) { | |||
o = new Integer(2); | |||
} else { | |||
o = new Integer(((Integer)o).intValue()+1); | |||
} | |||
put(cc.containingClass(), o); | |||
} | |||
} | |||
} | |||
ExecutableMemberDoc[] crosscuts = ((AdviceDoc)member).crosscuts(); | |||
if (crosscuts.length > 0) { | |||
writer.boldText("doclet.Advises"); | |||
CCs ccs = new CCs(); | |||
for (int i = 0; i < crosscuts.length; i++) { | |||
ccs.add(crosscuts[i]); | |||
} | |||
for (Iterator i = ccs.keySet().iterator(); i.hasNext();) { | |||
print(' '); | |||
ClassDoc target = (ClassDoc)i.next(); | |||
Object o = ccs.get(target); | |||
String link; | |||
String name = target.name(); | |||
if (o instanceof AdviceDoc) { | |||
link = where((AdviceDoc)o); | |||
} else if (o instanceof ExecutableMemberDoc) { | |||
link = super.where((ExecutableMemberDoc)o); | |||
} else { | |||
link = "method_detail"; | |||
name += "(" + o + ")"; | |||
} | |||
writer.printClassLink(target, link, name); | |||
if (i.hasNext()) print(","); | |||
} | |||
} | |||
} | |||
public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) { | |||
return true; | |||
} | |||
} |
@@ -1,109 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.ProgramElementDoc; | |||
import com.sun.javadoc.Type; | |||
import com.sun.tools.doclets.VisibleMemberMap; | |||
public class ClassSubWriter extends AbstractSubWriter { | |||
public static class Del extends com.sun.tools.doclets.standard.ClassSubWriter { | |||
protected ClassSubWriter mw; | |||
public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, | |||
ClassDoc classdoc) | |||
{ | |||
super(writer, classdoc); | |||
} | |||
public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) | |||
{ | |||
super(writer); | |||
} | |||
public void printMembersSummary() { | |||
mw.printMembersSummary(); | |||
mw.printIntroducedMembersSummary(); | |||
if (writer instanceof ClassWriter) { | |||
((ClassWriter)writer).printAspectJSummary(); | |||
} | |||
} | |||
public void printMembers() { | |||
mw.printMembers(); | |||
} | |||
protected void navSummaryLink() { | |||
mw.navSummaryLink(); | |||
if (writer instanceof ClassWriter) { | |||
((ClassWriter)writer).navstate++; | |||
} | |||
} | |||
protected void navDetailLink() { | |||
mw.navDetailLink(); | |||
} | |||
public void setDelegator(ClassSubWriter mw) { this.mw = mw; } | |||
} | |||
protected Class delegateClass() { | |||
return Del.class; | |||
} | |||
public ClassSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, | |||
ClassDoc classdoc) | |||
{ | |||
super(writer, classdoc); | |||
} | |||
public ClassSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) | |||
{ | |||
super(writer); | |||
} | |||
public int getMemberKind() { | |||
//XXX hack!!! | |||
return VisibleMemberMap.INNERCLASSES; | |||
} | |||
protected void printSummaryType(ProgramElementDoc member) { | |||
ClassDoc cd = (ClassDoc)member; | |||
printModifierAndType(cd, null); | |||
} | |||
protected void printModifierAndType(ProgramElementDoc member, | |||
Type type) { | |||
writer.printTypeSummaryHeader(); | |||
printModifier(member); | |||
if (type == null) { | |||
print(member instanceof AspectDoc ? | |||
"aspect" : member.isClass() ? | |||
"class" : | |||
"interface"); | |||
} else { | |||
printTypeLink(type); | |||
} | |||
writer.printTypeSummaryFooter(); | |||
} | |||
} | |||
@@ -1,294 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.AdviceDoc; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import org.aspectj.ajdoc.IntroducedDoc; | |||
import org.aspectj.ajdoc.IntroducedSuperDoc; | |||
import org.aspectj.ajdoc.IntroductionDoc; | |||
import org.aspectj.ajdoc.PointcutDoc; | |||
import org.aspectj.tools.ajdoc.Util; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.ExecutableMemberDoc; | |||
import com.sun.javadoc.FieldDoc; | |||
import com.sun.javadoc.MemberDoc; | |||
import com.sun.javadoc.PackageDoc; | |||
import com.sun.javadoc.Parameter; | |||
import com.sun.javadoc.ProgramElementDoc; | |||
import com.sun.javadoc.RootDoc; | |||
import com.sun.javadoc.Type; | |||
import com.sun.tools.doclets.ClassTree; | |||
import com.sun.tools.doclets.DocletAbortException; | |||
import java.lang.reflect.Constructor; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.HashMap; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* Provides support for aspects. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public class ClassUseMapper { | |||
/** | |||
* Maps a ClassDoc to advice that return its type. | |||
*/ | |||
public final Map classToAdviceReturn = new HashMap(); | |||
/** | |||
* Maps a ClassDoc to advice that have its type | |||
* are arguments. | |||
*/ | |||
public final Map classToAdviceArgs = new HashMap(); | |||
/** | |||
* Maps a ClassDoc to pointcuts that return its type. | |||
*/ | |||
public final Map classToPointcutReturn = new HashMap(); | |||
/** | |||
* Maps a ClassDoc to pointcuts that have its type | |||
* as arguments. | |||
*/ | |||
public final Map classToPointcutArgs = new HashMap(); | |||
/** | |||
* Maps a ClassDoc to field introductions that | |||
* are its type. | |||
*/ | |||
public final Map classToFieldIntroductions = new HashMap(); | |||
/** | |||
* Maps a ClassDoc to class introductions that | |||
* are its type. | |||
*/ | |||
public final Map classToClassIntroductions = new HashMap(); | |||
/** | |||
* Maps a ClassDoc to interface introductions that | |||
* are its type. | |||
*/ | |||
public final Map classToInterfaceIntroductions = new HashMap(); | |||
/** | |||
* Maps a ClassDoc to aspects that advise it. | |||
*/ | |||
public final Map classToAdvisors = new HashMap(); | |||
/** | |||
* Maps a ClassDoc to aspects that it dominates. | |||
*/ | |||
public final Map classToDominatees = new HashMap(); | |||
/** | |||
* Maps a ClassDoc to aspects that dominate it.. | |||
*/ | |||
public final Map classToDominators = new HashMap(); | |||
public static void generate(RootDoc root, ClassTree classtree) | |||
throws DocletAbortException { | |||
try { | |||
ClassUseMapper mapper = new ClassUseMapper(root, classtree); | |||
ClassDoc[] classes = root.classes(); | |||
for (int i = 0; i < classes.length; i++) { | |||
ClassUseWriter.generate(mapper, classes[i]); | |||
} | |||
PackageDoc[] pkgs = Standard.configuration().packages; | |||
for (int i = 0; i < pkgs.length; i++) { | |||
com.sun.tools.doclets.standard.PackageUseWriter. | |||
generate(mapper.mapper, pkgs[i]); | |||
} | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
Standard.configuration().standardmessage. | |||
error("doclet.exception", e+"", | |||
"creating class use tree"); | |||
throw new DocletAbortException(); | |||
} | |||
} | |||
protected final com.sun.tools.doclets.standard.ClassUseMapper mapper; | |||
public ClassUseMapper(RootDoc root, ClassTree classtree) | |||
throws Exception { | |||
Constructor constr = | |||
com.sun.tools.doclets.standard.ClassUseMapper.class. | |||
getDeclaredConstructor(new Class[] { | |||
com.sun.javadoc.RootDoc.class, | |||
com.sun.tools.doclets.ClassTree.class, | |||
}); | |||
constr.setAccessible(true); | |||
mapper = (com.sun.tools.doclets.standard.ClassUseMapper)constr. | |||
newInstance(new Object[]{root, classtree}); | |||
classToPackageSave = new HashMap(); | |||
for (Iterator i = mapper.classToPackage.keySet().iterator(); i.hasNext();) { | |||
Object key = i.next(); | |||
classToPackageSave.put(key, new HashSet((Collection) | |||
mapper.classToPackage. | |||
get(key))); | |||
} | |||
finish(root, classtree); | |||
} | |||
protected Object saved; | |||
protected final Map classToPackageSave; | |||
protected final com.sun.tools.doclets.standard.ClassUseMapper mapper | |||
(ClassDoc classdoc) | |||
{ | |||
Object noaspects = classToPackageSave.get(classdoc); | |||
saved = mapper.classToPackage.get(classdoc); | |||
mapper.classToPackage.put(classdoc, noaspects); | |||
return mapper; | |||
} | |||
protected void restore(ClassDoc classdoc) { | |||
mapper.classToPackage.put(classdoc, saved); | |||
} | |||
protected void finish(RootDoc root, ClassTree classtree) { | |||
ClassDoc[] classes = root.classes(); | |||
for (int i = 0; i < classes.length; i++) { | |||
ClassDoc cd = classes[i]; | |||
if (cd instanceof org.aspectj.ajdoc.ClassDoc) { | |||
org.aspectj.ajdoc.ClassDoc acd = (org.aspectj.ajdoc.ClassDoc)cd; | |||
PointcutDoc[] pcs = acd.pointcuts(); | |||
for (int j = 0; j < pcs.length; j++) { | |||
PointcutDoc pd = pcs[j]; | |||
mapExecutable(pd); | |||
Type result = pd.resultType(); | |||
if (result != null) { | |||
ClassDoc tcd = result.asClassDoc(); | |||
if (tcd != null) { | |||
add(classToPointcutReturn, tcd, pd); | |||
} | |||
} | |||
} | |||
} | |||
if (cd instanceof AspectDoc) { | |||
AspectDoc ad = (AspectDoc)cd; | |||
AdviceDoc[] adocs = ad.advice(); | |||
for (int j = 0; j < adocs.length; j++) { | |||
AdviceDoc adoc = adocs[j]; | |||
mapExecutable(adoc); | |||
Type result = adoc.returnType(); | |||
if (result != null) { | |||
ClassDoc tcd = result.asClassDoc(); | |||
if (tcd != null) { | |||
add(classToAdviceReturn, tcd, adoc); | |||
} | |||
} | |||
ExecutableMemberDoc[] emds = adoc.crosscuts(); | |||
if (null != emds) { | |||
for (int k = 0; k < emds.length; k++) { | |||
ExecutableMemberDoc emd = emds[k]; | |||
if (null != emd) { | |||
ClassDoc tcd = emd.containingClass(); | |||
ClassDoc fcd = adoc.containingClass(); | |||
//TODO: This probably sucks!!! | |||
if (!refList(classToAdvisors, tcd).contains(fcd)) { | |||
add(classToAdvisors, tcd, fcd); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
IntroductionDoc[] ids = ad.introductions(); | |||
for (int j = 0; j < ids.length; j++) { | |||
IntroductionDoc id = ids[j]; | |||
if (id instanceof IntroducedDoc) { | |||
IntroducedDoc idd = (IntroducedDoc)id; | |||
MemberDoc mem = idd.member(); | |||
if (mem.isField()) { | |||
FieldDoc fd = (FieldDoc)mem; | |||
ClassDoc tcd = fd.type().asClassDoc(); | |||
add(classToFieldIntroductions, tcd, fd); | |||
} | |||
} else if (id instanceof IntroducedSuperDoc) { | |||
IntroducedSuperDoc idd = (IntroducedSuperDoc)id; | |||
boolean isImplements = idd.isImplements(); | |||
Type[] types = idd.types(); | |||
for (int k = 0; k < types.length; k++) { | |||
ClassDoc tcd = types[k].asClassDoc(); | |||
add(isImplements ? | |||
classToInterfaceIntroductions : | |||
classToClassIntroductions, tcd, idd); | |||
} | |||
} | |||
} | |||
AspectDoc[] dominatees = ad.dominatees(); | |||
for (int j = 0; j < dominatees.length; j++) { | |||
add(classToDominatees, ad, dominatees[j]); | |||
} | |||
AspectDoc[] dominators = ad.dominators(); | |||
for (int j = 0; j < dominators.length; j++) { | |||
add(classToDominators, ad, dominators[j]); | |||
} | |||
} | |||
} | |||
} | |||
protected void mapExecutable(ExecutableMemberDoc em) { | |||
Parameter[] params = em.parameters(); | |||
List classargs = new ArrayList(); | |||
Map argsmap = ((org.aspectj.ajdoc.MemberDoc)em).isAdvice() ? | |||
classToAdviceArgs : classToPointcutArgs ; | |||
for (int i = 0; i < params.length; i++) { | |||
ClassDoc pcd = params[i].type().asClassDoc(); | |||
if (pcd != null && !classargs.contains(pcd)) { | |||
add(argsmap, pcd, em); | |||
classargs.add(pcd); | |||
} | |||
} | |||
} | |||
protected List refList(Map map, ClassDoc cd) { | |||
return (List)Util.invoke(mapper, "refList", | |||
new Class[]{java.util.Map.class, | |||
com.sun.javadoc.ClassDoc.class}, | |||
new Object[]{map, cd}); | |||
} | |||
protected void add(Map map, ClassDoc cd, ProgramElementDoc ref) { | |||
Util.invoke(mapper, "add", | |||
new Class[]{java.util.Map.class, | |||
com.sun.javadoc.ClassDoc.class, | |||
com.sun.javadoc.ProgramElementDoc.class}, | |||
new Object[]{map, cd, ref}); | |||
} | |||
} |
@@ -1,272 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.tools.ajdoc.Access; | |||
import org.aspectj.tools.ajdoc.Util; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.PackageDoc; | |||
import com.sun.tools.doclets.DirectoryManager; | |||
import com.sun.tools.doclets.DocletAbortException; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Map; | |||
/** | |||
* Provides support for aspects. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public class ClassUseWriter | |||
extends com.sun.tools.doclets.standard.ClassUseWriter | |||
{ | |||
/** | |||
* The target ClassDoc. | |||
*/ | |||
protected final ClassDoc classdoc; | |||
/** | |||
* Maps PackageDocs to advice arguments. | |||
*/ | |||
protected final Map pkgToAdviceArgs; | |||
/** | |||
* Maps PackageDocs to advice return types. | |||
*/ | |||
protected final Map pkgToAdviceReturn; | |||
/** | |||
* Maps PackageDocs to pointcut arguments. | |||
*/ | |||
protected final Map pkgToPointcutArgs; | |||
/** | |||
* Maps PackageDocs to pointcut return types. | |||
*/ | |||
protected final Map pkgToPointcutReturn; | |||
/** | |||
* Maps PackageDocs to field introductions. | |||
*/ | |||
protected final Map pkgToFieldIntroductions; | |||
/** | |||
* Maps PackageDocs to class introductions. | |||
*/ | |||
protected final Map pkgToClassIntroductions; | |||
/** | |||
* Maps PackageDocs to interface introductions. | |||
*/ | |||
protected final Map pkgToInterfaceIntroductions; | |||
/** | |||
* Maps PackageDocs to class advisors. | |||
*/ | |||
protected final Map pkgToClassAdvisors; | |||
/** | |||
* Maps PackageDocs to aspects that dominate | |||
* aspects in that package. | |||
*/ | |||
protected final Map pkgToAspectDominatees; | |||
/** | |||
* Maps PackageDocs to aspects that are dominated | |||
* by aspects in that package. | |||
*/ | |||
protected final Map pkgToAspectDominators; | |||
/** | |||
* The MethodSubWriter to use. | |||
*/ | |||
protected final MethodSubWriter methodSubWriter | |||
= new MethodSubWriter(this); | |||
/** | |||
* The ConstructorSubWriter to use. | |||
*/ | |||
protected final ConstructorSubWriter constrSubWriter | |||
= new ConstructorSubWriter(this); | |||
/** | |||
* The FieldSubWriter to use. | |||
*/ | |||
protected final FieldSubWriter fieldSubWriter | |||
= new FieldSubWriter(this); | |||
/** | |||
* The ClassSubWriter to use. | |||
*/ | |||
protected final ClassSubWriter classSubWriter | |||
= new ClassSubWriter(this); | |||
/** | |||
* The PointcutSubWriter to use. | |||
*/ | |||
protected final PointcutSubWriter pointcutSubWriter | |||
= new PointcutSubWriter(this); | |||
/** | |||
* The SuperIntroductionSubWriter to use. | |||
*/ | |||
protected final SuperIntroductionSubWriter superIntroductionSubWriter | |||
= new SuperIntroductionSubWriter(this); | |||
/** | |||
* The FieldIntroductionSubWriter to use. | |||
*/ | |||
protected final FieldIntroductionSubWriter fieldIntroductionSubWriter | |||
= new FieldIntroductionSubWriter(this); | |||
/** | |||
* The ConstructorIntroductionSubWriter to use. | |||
*/ | |||
protected final ConstructorIntroductionSubWriter constrIntroductionSubWriter | |||
= new ConstructorIntroductionSubWriter(this); | |||
/** | |||
* The MethodIntroductionSubWriter to use. | |||
*/ | |||
protected final MethodIntroductionSubWriter methodIntroductionSubWriter | |||
= new MethodIntroductionSubWriter(this); | |||
/** | |||
* The AdviceSubWriter to use. | |||
*/ | |||
protected final AdviceSubWriter adviceSubWriter | |||
= new AdviceSubWriter(this); | |||
public ClassUseWriter(ClassUseMapper mapper, | |||
String path, | |||
String filename, | |||
String relpath, | |||
ClassDoc classdoc) | |||
throws IOException, DocletAbortException { | |||
super(mapper.mapper(classdoc), path, | |||
filename, relpath, classdoc); | |||
mapper.restore(classdoc); | |||
this.classdoc = Access.classdoc(this); | |||
this.pkgToAdviceReturn = | |||
_pkgDivide(mapper.classToAdviceReturn); | |||
this.pkgToAdviceArgs = | |||
_pkgDivide(mapper.classToAdviceArgs); | |||
this.pkgToPointcutReturn = | |||
_pkgDivide(mapper.classToPointcutReturn); | |||
this.pkgToPointcutArgs = | |||
_pkgDivide(mapper.classToPointcutArgs); | |||
this.pkgToFieldIntroductions = | |||
_pkgDivide(mapper.classToFieldIntroductions); | |||
this.pkgToClassIntroductions = | |||
_pkgDivide(mapper.classToClassIntroductions); | |||
this.pkgToInterfaceIntroductions = | |||
_pkgDivide(mapper.classToInterfaceIntroductions); | |||
this.pkgToClassAdvisors = | |||
_pkgDivide(mapper.classToAdvisors); | |||
this.pkgToAspectDominatees = | |||
_pkgDivide(mapper.classToDominatees); | |||
this.pkgToAspectDominators = | |||
_pkgDivide(mapper.classToDominators); | |||
} | |||
protected com.sun.tools.doclets.standard.ClassUseWriter | |||
writer; | |||
private Map _pkgDivide(Map classMap) { | |||
return (Map)Util.invoke | |||
(com.sun.tools.doclets.standard.ClassUseWriter.class, | |||
this, "pkgDivide", | |||
new Class[]{java.util.Map.class}, | |||
new Object[]{classMap}); | |||
} | |||
public static void generate(ClassUseMapper mapper, | |||
ClassDoc classdoc) | |||
throws DocletAbortException { | |||
ClassUseWriter cw = null; | |||
String path = DirectoryManager.getDirectoryPath(classdoc. | |||
containingPackage()); | |||
if (path.length() > 0) { | |||
path += File.separator; | |||
} | |||
path += "class-use"; | |||
String filename = classdoc.name() + ".html"; | |||
String pkgname = classdoc.containingPackage().name(); | |||
pkgname += (pkgname.length() > 0 ? "." : "") + "class-use"; | |||
String relpath = DirectoryManager.getRelativePath(pkgname); | |||
try { | |||
(cw = new ClassUseWriter(mapper, path, filename, | |||
relpath, classdoc)). | |||
generateClassUseFile(); | |||
} catch (IOException e) { | |||
Standard.configuration().standardmessage. | |||
error("doclet.exception_encountered", e+"", filename); | |||
throw new DocletAbortException(); | |||
} finally { | |||
if (cw != null) cw.close(); | |||
} | |||
} | |||
protected void generateClassUse(PackageDoc pkg) throws IOException { | |||
super.generateClassUse(pkg); | |||
String classlink = getClassLink(classdoc); | |||
String pkglink = getPackageLink(pkg); | |||
printUseInfo(adviceSubWriter, pkgToAdviceReturn, | |||
pkg, "AdviceReturn", classlink, pkglink); | |||
printUseInfo(adviceSubWriter, pkgToAdviceArgs, | |||
pkg, "AdviceArgs", classlink, pkglink); | |||
printUseInfo(pointcutSubWriter, pkgToPointcutReturn, | |||
pkg, "PointcutReturn", classlink, pkglink); | |||
printUseInfo(pointcutSubWriter, pkgToPointcutArgs, | |||
pkg, "PointcutArgs", classlink, pkglink); | |||
printUseInfo(fieldIntroductionSubWriter, pkgToFieldIntroductions, | |||
pkg, "FieldIntroductions", classlink, pkglink); | |||
printUseInfo(superIntroductionSubWriter, pkgToClassIntroductions, | |||
pkg, "ClassIntroductions", classlink, pkglink); | |||
printUseInfo(superIntroductionSubWriter, pkgToInterfaceIntroductions, | |||
pkg, "InterfaceIntroductions", classlink, pkglink); | |||
printUseInfo(classSubWriter, pkgToClassAdvisors, | |||
pkg, "ClassAdvisors", classlink, pkglink); | |||
printUseInfo(classSubWriter, pkgToAspectDominatees, | |||
pkg, "AspectDominatees", classlink, pkglink); | |||
printUseInfo(classSubWriter, pkgToAspectDominators, | |||
pkg, "AspectDominators", classlink, pkglink); | |||
} | |||
protected final void printUseInfo(AbstractSubWriter mw, Map map, | |||
PackageDoc pkg, String kind, | |||
String classlink, String pkglink) { | |||
Access.printUseInfo(mw, map.get(pkg), | |||
getText("doclet.ClassUse_" + kind, | |||
classlink,pkglink)); | |||
} | |||
} |
@@ -1,554 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.AdviceDoc; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import org.aspectj.ajdoc.IntroducedDoc; | |||
import org.aspectj.ajdoc.IntroducedSuperDoc; | |||
import org.aspectj.ajdoc.IntroductionDoc; | |||
import org.aspectj.ajdoc.OfClauseDoc; | |||
import org.aspectj.ajdoc.OfEachObjectDoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.ExecutableMemberDoc; | |||
import com.sun.javadoc.MemberDoc; | |||
import com.sun.tools.doclets.ClassTree; | |||
import com.sun.tools.doclets.DirectoryManager; | |||
import com.sun.tools.doclets.DocletAbortException; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Set; | |||
import java.util.TreeSet; | |||
public class ClassWriter extends com.sun.tools.doclets.standard.ClassWriter { | |||
/** | |||
* The MethodSubWriter that prints out the methods | |||
* of <code>classdoc</code>. | |||
*/ | |||
protected MethodSubWriter ourMethodSubWriter; | |||
/** | |||
* The ConstructorSubWriter that prints out the constructors | |||
* of <code>classdoc</code>. | |||
*/ | |||
protected ConstructorSubWriter ourConstrSubWriter; | |||
/** | |||
* The FieldSubWriter that prints out the fields | |||
* of <code>classdoc</code>. | |||
*/ | |||
protected FieldSubWriter ourFieldSubWriter; | |||
/** | |||
* The ClassSubWriter that prints out the classs | |||
* of <code>classdoc</code>. | |||
*/ | |||
protected ClassSubWriter ourInnerSubWriter; | |||
/** | |||
* The PointcutSubWriter that prints out the pointcuts | |||
* of <code>classdoc</code>. | |||
*/ | |||
protected PointcutSubWriter pointcutSubWriter = null; | |||
/** | |||
* The SuperIntroductionSubWriter that prints out the superintroductions | |||
* of <code>classdoc</code>. | |||
*/ | |||
protected SuperIntroductionSubWriter superIntroductionSubWriter = null; | |||
/** | |||
* The FieldIntroductionSubWriter that prints out the fieldintroductions | |||
* of <code>classdoc</code>. | |||
*/ | |||
protected FieldIntroductionSubWriter fieldIntroductionSubWriter = null; | |||
/** | |||
* The ConstructorIntroductionSubWriter that prints out the constructorintroductions | |||
* of <code>classdoc</code>. | |||
*/ | |||
protected ConstructorIntroductionSubWriter constrIntroductionSubWriter = null; | |||
/** | |||
* The MethodIntroductionSubWriter that prints out the methodintroductions | |||
* of <code>classdoc</code>. | |||
*/ | |||
protected MethodIntroductionSubWriter methodIntroductionSubWriter = null; | |||
/** | |||
* The AdviceSubWriter that prints out the advices | |||
* of <code>classdoc</code>. | |||
*/ | |||
protected AdviceSubWriter adviceSubWriter = null; | |||
/** | |||
* Construct a ClassWriter from the passed in arguments. This | |||
* will instantiate the subwriters to be used. | |||
* | |||
* @param path the path directory of the html file to generate. | |||
* @param filename the html file to generate. | |||
* @param classdoc the ClassDoc for which this file will | |||
* be generated. | |||
* @param prev the ClassDoc preceding <code>classdoc</code> | |||
* in order of generation. | |||
* @param next the ClassDoc following <code>classdoc</code> | |||
* in order of generation. | |||
* @param classtree the ClassTree to use. | |||
* @param nopackage whether this <code>classdoc</code>'s package | |||
* is specified to be documented. | |||
*/ | |||
public ClassWriter(String path, | |||
String filename, | |||
ClassDoc classdoc, | |||
ClassDoc prev, | |||
ClassDoc next, | |||
ClassTree classtree, | |||
boolean nopackage) | |||
throws IOException, DocletAbortException { | |||
super(path, filename, classdoc, prev, | |||
next, classtree, nopackage); | |||
// Construct the subwriters just for ClassDocs | |||
// We want our superclass to delegate to our subwriters delegate, | |||
// but we want to call our subwriters. So we set our superclasses | |||
// subwriters to our subwriters delegates. | |||
ourMethodSubWriter = new MethodSubWriter(this, classdoc); | |||
methodSubWriter = (com.sun.tools.doclets.standard.MethodSubWriter) | |||
ourMethodSubWriter.del(); | |||
constrSubWriter = (com.sun.tools.doclets.standard.ConstructorSubWriter) | |||
(ourConstrSubWriter = new ConstructorSubWriter(this, classdoc)).del(); | |||
fieldSubWriter = (com.sun.tools.doclets.standard.FieldSubWriter) | |||
(ourFieldSubWriter = new FieldSubWriter(this, classdoc)).del(); | |||
innerSubWriter = (com.sun.tools.doclets.standard.ClassSubWriter) | |||
(ourInnerSubWriter = new ClassSubWriter(this, classdoc)).del(); | |||
if (classdoc instanceof org.aspectj.ajdoc.ClassDoc) { | |||
pointcutSubWriter = | |||
new PointcutSubWriter(this, (org.aspectj.ajdoc.ClassDoc)classdoc); | |||
} | |||
// If we've been passed an AspectDoc, create the AspectJ-specfic | |||
// subwriters | |||
if (classdoc instanceof AspectDoc) { | |||
AspectDoc ad = (AspectDoc)classdoc; | |||
superIntroductionSubWriter = new SuperIntroductionSubWriter(this, ad); | |||
fieldIntroductionSubWriter = new FieldIntroductionSubWriter(this, ad); | |||
constrIntroductionSubWriter = new ConstructorIntroductionSubWriter(this, ad); | |||
methodIntroductionSubWriter = new MethodIntroductionSubWriter(this, ad); | |||
adviceSubWriter = new AdviceSubWriter(this, ad); | |||
} | |||
} | |||
public static void generate(ClassDoc classdoc, | |||
ClassDoc prev, | |||
ClassDoc next, | |||
ClassTree classtree, | |||
boolean nopackage) | |||
throws DocletAbortException { | |||
ClassWriter cw = null; | |||
String path = DirectoryManager.getDirectoryPath | |||
(classdoc.containingPackage()); | |||
String filename = classdoc.name() + ".html"; | |||
try { | |||
(cw = new ClassWriter(path, filename, classdoc, | |||
prev, next, classtree, nopackage)). | |||
generateClassFile(); | |||
} catch (IOException e) { | |||
Standard.configuration().standardmessage. | |||
error("doclet.exception_encountered", e+"", filename); | |||
throw new DocletAbortException(); | |||
} finally { | |||
if (cw != null) cw.close(); | |||
} | |||
} | |||
/** | |||
* Prints the header of the class -- which is one | |||
* of <code>class</code>, <code>interface</code> or | |||
* <code>aspect</code> with the name <code>title</code>. | |||
* | |||
* @param title the name of the class. | |||
*/ | |||
public void printHeader(String title) { | |||
int ispace = title.indexOf(' '); | |||
if (ispace != -1) { | |||
title = Statics.type(classdoc) + title.substring(ispace); | |||
} | |||
super.printHeader(title); | |||
} | |||
/* | |||
* This is set up to intercept calls to print out | |||
* the correct type of classdoc before we automatically | |||
* print 'class' or 'interface'. | |||
*/ | |||
private boolean h2warn = false; | |||
/** | |||
* If we've started to print a h2 heading, we're | |||
* printing the name of the class so get ready to | |||
* to intercept the call. | |||
*/ | |||
public void h2() { | |||
h2warn = true; | |||
super.h2(); | |||
} | |||
/** | |||
* After printing the class declaration with the h2 heading | |||
* turn off the h2 warning. | |||
*/ | |||
public void h2End() { | |||
h2warn = false; | |||
super.h2End(); | |||
} | |||
/** | |||
* This is where we intercept the call to print so | |||
* we can print the correct type. | |||
*/ | |||
public void print(String str) { | |||
if (h2warn) { | |||
int ispace = str.indexOf(' '); | |||
if (ispace != -1 && str.charAt(0) == 'C') { | |||
str = Statics.type(classdoc) + str.substring(ispace); | |||
} | |||
} | |||
super.print(str); | |||
} | |||
/** | |||
* Print the members summary for our AspectJ subwriters. | |||
*/ | |||
protected void printAspectJSummary() { | |||
printMembersSummary(superIntroductionSubWriter); | |||
printMembersSummary(fieldIntroductionSubWriter); | |||
printMembersSummary(constrIntroductionSubWriter); | |||
printMembersSummary(methodIntroductionSubWriter); | |||
printMembersSummary(pointcutSubWriter); | |||
printMembersSummary(adviceSubWriter); | |||
} | |||
/** | |||
* Formats the output correctly for a member summary. | |||
* | |||
* @param mw the AbstractSubWriter to use. | |||
*/ | |||
protected final void printMembersSummary(AbstractSubWriter mw) { | |||
if (mw != null) { | |||
println(); | |||
println("<!-- === " + getText(mw.navKey()) + " SUMMARY === -->"); | |||
println(); | |||
mw.printMembersSummary(); | |||
} | |||
} | |||
/** | |||
* Print the members detail for our AspectJ subwriters. | |||
*/ | |||
protected void printAspectJDetail() { | |||
printMembersDetail(superIntroductionSubWriter); | |||
printMembersDetail(fieldIntroductionSubWriter); | |||
printMembersDetail(constrIntroductionSubWriter); | |||
printMembersDetail(methodIntroductionSubWriter); | |||
printMembersDetail(pointcutSubWriter); | |||
printMembersDetail(adviceSubWriter); | |||
} | |||
/** | |||
* Formats the output correctly for a member detail. | |||
* | |||
* @param mw the AbstractSubWriter to use. | |||
*/ | |||
protected final void printMembersDetail(AbstractSubWriter mw) { | |||
if (mw != null) { | |||
println("<!-- ===" + getText(mw.navKey()) + " DETAIL === -->"); | |||
println(); | |||
mw.printMembers(); | |||
println(); | |||
} | |||
} | |||
//TODO: Just need to make sure 'aspect; shows up and | |||
//TODO not 'class' | |||
protected void printClassDescription() { | |||
boolean isInterface = classdoc.isInterface(); | |||
boolean isAspect = classdoc instanceof AspectDoc; | |||
dl(); | |||
dt(); | |||
print(classdoc.modifiers() + " "); | |||
if (!isInterface) { | |||
print(isAspect ? "aspect " : "class "); | |||
} | |||
bold(classdoc.name()); | |||
if (!isInterface) { | |||
ClassDoc superclass = classdoc.superclass(); | |||
if (superclass != null) { | |||
dt(); | |||
print("extends "); | |||
printClassLink(superclass); | |||
printIntroducedSuper(superclass); | |||
} | |||
} | |||
ClassDoc[] implIntfacs = classdoc.interfaces(); | |||
if (implIntfacs != null && implIntfacs.length > 0) { | |||
dt(); | |||
print(isInterface? "extends " : "implements "); | |||
for (int i = 0; i < implIntfacs.length; i++) { | |||
if (i > 0) print(", "); | |||
printClassLink(implIntfacs[i]); | |||
printIntroducedSuper(implIntfacs[i]); | |||
} | |||
} | |||
if (isAspect) { | |||
AspectDoc ad = (AspectDoc)classdoc; | |||
OfClauseDoc ofClause = ad.ofClause(); | |||
if (ofClause != null) { | |||
dt(); | |||
if (ofClause.kind() == OfClauseDoc.Kind.EACH_CFLOW) { | |||
print("percflow(..)"); | |||
} else if (ofClause.kind() == OfClauseDoc.Kind.EACH_JVM) { | |||
print("issingleton()"); | |||
} else if (ofClause.kind() == OfClauseDoc.Kind.EACH_OBJECT) { | |||
print("pertarget("); | |||
printClassLinks(((OfEachObjectDoc)ofClause).instances()); | |||
print(")"); | |||
} | |||
} | |||
AspectDoc[] dominatees = ad.dominatees(); | |||
if (dominatees != null && dominatees.length > 0) { | |||
dt(); | |||
print("dominates "); | |||
printClassLinks(dominatees); | |||
} | |||
AspectDoc[] dominators = ad.dominators(); | |||
if (dominators != null && dominators.length > 0) { | |||
dt(); | |||
print("dominated by "); | |||
printClassLinks(dominators); | |||
} | |||
} | |||
dlEnd(); | |||
} | |||
/** | |||
* Prints a list of class links separated by commas. | |||
* | |||
* @param cds array of ClassDoc to be printed. | |||
*/ | |||
protected void printClassLinks(ClassDoc[] cds) { | |||
if (cds == null || cds.length < 1) return; | |||
for (int i = 0; i < cds.length; i++) { | |||
if (i > 0) print(", "); | |||
if (cds[i] != null) { | |||
printClassLink(cds[i]); | |||
} | |||
} | |||
} | |||
/** | |||
* Prints information about <code>classdoc</code>'s type introduction | |||
* if <code>cd</code>'s type was introduced onto <code>classdoc</code>. | |||
* | |||
* @param cd the ClassDoc being printed. | |||
*/ | |||
protected void printIntroducedSuper(ClassDoc cd) { | |||
IntroducedSuperDoc[] intros = | |||
((org.aspectj.ajdoc.ClassDoc)classdoc).introducers(); | |||
if (null != intros) { | |||
for (int i = 0; i < intros.length; i++) { | |||
IntroducedSuperDoc intro = intros[i]; | |||
org.aspectj.ajdoc.Type[] types = intro.types(); | |||
for (int j = 0; j < types.length; j++) { | |||
if (types[j].equals(cd)) { | |||
print(' '); | |||
printText("doclet.by_parens", | |||
getClassLink | |||
(intro.containingClass(), | |||
superIntroductionSubWriter.link(intro), | |||
"introduced"), | |||
getClassLink(intro.containingClass())); | |||
break; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
/** | |||
* Print the navSummaryLink for all the AspectJ subwriters. | |||
*/ | |||
protected void navAspectJSummaryLinks() { | |||
navSummaryLink(superIntroductionSubWriter); | |||
navSummaryLink(fieldIntroductionSubWriter); | |||
navSummaryLink(constrIntroductionSubWriter); | |||
navSummaryLink(methodIntroductionSubWriter); | |||
navSummaryLink(pointcutSubWriter); | |||
navSummaryLink(adviceSubWriter); | |||
} | |||
/** | |||
* Prints the navSummaryLink correctly. | |||
* | |||
* @param mw AbstractSubWriter to invoke. | |||
*/ | |||
protected final void navSummaryLink(AbstractSubWriter mw) { | |||
if (mw != null) { | |||
mw.navSummaryLink(); | |||
_navGap(); | |||
} | |||
} | |||
/** | |||
* Print the navDetailLink for all the AspectJ subwriters. | |||
*/ | |||
protected void navAspectJDetailLinks() { | |||
navDetailLink(superIntroductionSubWriter); | |||
navDetailLink(fieldIntroductionSubWriter); | |||
navDetailLink(constrIntroductionSubWriter); | |||
navDetailLink(methodIntroductionSubWriter); | |||
navDetailLink(pointcutSubWriter); | |||
navDetailLink(adviceSubWriter); | |||
} | |||
/** | |||
* Prints the navDetailLink correctly. | |||
* | |||
* @param mw AbstractSubWriter to invoke. | |||
*/ | |||
protected final void navDetailLink(AbstractSubWriter mw) { | |||
if (mw != null) { | |||
mw.navDetailLink(); | |||
_navGap(); | |||
} | |||
} | |||
/* | |||
* A hack... I'll explain later, if you need to change | |||
* this mail jeffrey_palm@hotmail.com. | |||
*/ | |||
protected final void _navGap() { super.navGap(); } | |||
protected int navstate = 0; | |||
protected void navGap() { | |||
_navGap(); | |||
if (navstate == 1) { | |||
navAspectJSummaryLinks(); | |||
navstate++; | |||
} else if (navstate == 3) { | |||
navAspectJDetailLinks(); | |||
navstate++; | |||
} | |||
} | |||
protected void printEnclosingClassInfo() { | |||
super.printEnclosingClassInfo(); | |||
printAdvisorInfo(); | |||
printAdviseeInfo(); | |||
} | |||
protected void printAdviseeInfo() { | |||
if (!(classdoc instanceof AspectDoc)) return; | |||
AspectDoc ad = (AspectDoc)classdoc; | |||
Set set = new TreeSet(); | |||
AdviceDoc[] as = ad.advice(); | |||
if (as != null) { | |||
for (int i = 0; i < as.length; i++) { | |||
ExecutableMemberDoc[] crosscuts = as[i].crosscuts(); | |||
if (null != crosscuts) { | |||
for (int j = 0; j < crosscuts.length; j++) { | |||
if (null != crosscuts[j]) { | |||
set.add(crosscuts[j].containingClass()); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
IntroductionDoc[] is = ad.introductions(); | |||
if (null != is) { | |||
for (int i = 0 ; i < is.length; i++) { | |||
ClassDoc[] targets = is[i].targets(); | |||
for (int j = 0; j < targets.length; j++) { | |||
set.add(targets[j]); | |||
} | |||
} | |||
printInfo(set, "doclet.All_Advisees"); | |||
} | |||
} | |||
protected void printAdvisorInfo() { | |||
Set set = new TreeSet(); | |||
set.addAll(advisors(classdoc.fields())); | |||
set.addAll(advisors(classdoc.methods())); | |||
set.addAll(advisors(classdoc.constructors())); | |||
printInfo(set, "doclet.All_Advisors"); | |||
} | |||
protected void printInfo(Collection classdocs, String str) { | |||
if ((null != classdocs) && (classdocs.size() > 0)) { | |||
printInfoHeader(); | |||
boldText(str); | |||
dd(); | |||
for (Iterator i = classdocs.iterator(); i.hasNext();) { | |||
printClassLink((ClassDoc)i.next()); | |||
if (i.hasNext()) print(", "); | |||
} | |||
ddEnd(); | |||
dlEnd(); | |||
} | |||
} | |||
protected final Collection advisors(final MemberDoc[] ms) { | |||
List list = new ArrayList(); | |||
if (null != ms) { | |||
for (int i = 0 ; i < ms.length; i++) { | |||
IntroducedDoc id = | |||
((org.aspectj.ajdoc.MemberDoc)ms[i]).introduced(); | |||
if (id != null) list.add(id.containingClass()); | |||
if (ms[i] instanceof org.aspectj.ajdoc.ExecutableMemberDoc) { | |||
AdviceDoc[] as = | |||
((org.aspectj.ajdoc.ExecutableMemberDoc)ms[i]).advice(); | |||
for (int j = 0; j < as.length; j++) { | |||
list.add(as[j].containingClass()); | |||
} | |||
} | |||
} | |||
} | |||
return list; | |||
} | |||
} | |||
@@ -1,120 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import com.sun.javadoc.RootDoc; | |||
import com.sun.tools.doclets.MessageRetriever; | |||
import java.io.IOException; | |||
import java.net.URL; | |||
import java.util.Locale; | |||
import java.util.MissingResourceException; | |||
import java.util.PropertyResourceBundle; | |||
import java.util.ResourceBundle; | |||
/** | |||
* A customized configuration. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public class ConfigurationStandard | |||
extends com.sun.tools.doclets.standard.ConfigurationStandard | |||
{ | |||
/** It true we don't print crosscut information. */ | |||
public boolean nocrosscuts = false; | |||
/** If true we don't print crosscut summary information. */ | |||
public boolean nosummarycrosscuts = false; | |||
/** If true we log each pass in the doclet. */ | |||
public boolean log = false; | |||
public ConfigurationStandard() { | |||
// standardmessage = new MessageRetriever | |||
// ("org.aspectj.tools.doclets.standard.resources.standard"); | |||
String loc = "org.aspectj.tools.doclets.standard.resources.standard"; | |||
final ClassLoader loader = getClass().getClassLoader(); | |||
// XXX move persistant resource loader to util | |||
ResourceBundle bundle = null; | |||
for (int i = 0; ((null == bundle) && (i < 4)); i++) { | |||
try { | |||
switch (i) { | |||
case 0: | |||
bundle = ResourceBundle.getBundle(loc); | |||
standardmessage = new MessageRetriever(bundle); | |||
break; | |||
case 1: | |||
Locale locale = Locale.getDefault(); | |||
bundle = ResourceBundle.getBundle(loc, locale, loader); | |||
standardmessage = new MessageRetriever(bundle); | |||
break; | |||
case 2: | |||
standardmessage = new MessageRetriever(loc); | |||
break; | |||
case 3: | |||
URL pURL = loader.getResource(loc + ".properties"); | |||
bundle = new PropertyResourceBundle(pURL.openStream()); | |||
standardmessage = new MessageRetriever(loc); | |||
break; | |||
} | |||
break; // from for loop | |||
} catch (MissingResourceException e) { } // error below | |||
catch (IOException ie) { } // error below | |||
} | |||
if (null == bundle) { | |||
throw new Error("unable to load resource: " + loc); | |||
} | |||
} | |||
//TODO: Document the new options in help | |||
public void setSpecificDocletOptions(RootDoc root) { | |||
String[][] options = root.options(); | |||
for (int i = 0; i < options.length; ++i) { | |||
String opt = options[i][0].toLowerCase(); | |||
if (opt.equals("-nocrosscuts")) { | |||
nocrosscuts = true; | |||
nosummarycrosscuts = true; | |||
} else if (opt.equals("-nosummarycrosscuts")) { | |||
nosummarycrosscuts = true; | |||
} else if (opt.equals("-log")) { | |||
log = true; | |||
} | |||
} | |||
super.setSpecificDocletOptions(root); | |||
} | |||
public int specificDocletOptionLength(String opt) { | |||
if (opt.equals("-nocrosscuts") || | |||
opt.equals("-nosummarycrosscuts") || | |||
opt.equals("-log")) { | |||
return 1; | |||
} | |||
return super.specificDocletOptionLength(opt); | |||
} | |||
} | |||
@@ -1,126 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import org.aspectj.ajdoc.IntroducedDoc; | |||
import org.aspectj.ajdoc.IntroductionDoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.MemberDoc; | |||
import com.sun.javadoc.ProgramElementDoc; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Set; | |||
public class ConstructorIntroductionSubWriter extends ConstructorSubWriter { | |||
public ConstructorIntroductionSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, | |||
AspectDoc ad) | |||
{ | |||
super(writer, ad); | |||
} | |||
public ConstructorIntroductionSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) | |||
{ | |||
super(writer); | |||
} | |||
protected final String keyName() { return "Constructor_Introduction"; } | |||
protected List getMembers(ClassDoc cd) { | |||
if (!(cd instanceof AspectDoc)) return super.getMembers(cd); | |||
IntroductionDoc[] introductions = ((AspectDoc)cd).introductions(); | |||
List list = new ArrayList(); | |||
if (introductions == null) return list; | |||
for (int i = 0; i < introductions.length; i++) { | |||
IntroductionDoc id = introductions[i]; | |||
if (!(id instanceof IntroducedDoc)) continue; | |||
MemberDoc member = ((IntroducedDoc)id).member(); | |||
if (member.isConstructor()) { | |||
//ConstructorDec constructor = (ConstructorDec)member; | |||
//TODO: constructor.bindSignatures(((ClassDec)cd).getTypeScope()); | |||
list.add(member); //constructor); | |||
} | |||
} | |||
return list; | |||
} | |||
public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) { | |||
org.aspectj.ajdoc.ConstructorDoc constr = | |||
(org.aspectj.ajdoc.ConstructorDoc)member; | |||
IntroducedDoc intro = constr.introduced(); | |||
//String name = where(constr); | |||
ClassDoc[] targets = intro.targets(); | |||
if (targets.length > 0) { | |||
writer.dt(); | |||
writer.boldText("doclet.Introduced_on"); | |||
writer.dd(); | |||
writer.code(); | |||
for (int i = 0; i < targets.length; i++) { | |||
if (i > 0) writer.print(", "); | |||
ClassDoc target = targets[i]; | |||
writer.printClassLink(target, | |||
"constructors_introduced_from_class_" + | |||
cd.qualifiedName(), | |||
target.name()); | |||
} | |||
writer.codeEnd(); | |||
writer.ddEnd(); // XXX added for balance | |||
} | |||
} | |||
public void printSummaryCrosscuts(ClassDoc cd, | |||
ProgramElementDoc member) { | |||
Set set = new HashSet(); | |||
org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member; | |||
IntroducedDoc intro = md.introduced(); | |||
ClassDoc[] targets = intro.targets(); | |||
for (int i = 0; i < targets.length; i++) { | |||
set.add(targets[i]); | |||
} | |||
if (targets.length > 0) { | |||
writer.boldText("doclet.Advises"); | |||
List list = new ArrayList(set); | |||
Collections.sort(list); | |||
for (Iterator i = list.iterator(); i.hasNext();) { | |||
print(' '); | |||
ClassDoc target = (ClassDoc)i.next(); | |||
writer.printClassLink(target, | |||
"constructors_introduced_from_class_" | |||
+ cd.qualifiedName(), | |||
target.name()); | |||
if (i.hasNext()) print(","); | |||
} | |||
} | |||
} | |||
public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) { | |||
return true; | |||
} | |||
} |
@@ -1,85 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.ProgramElementDoc; | |||
import com.sun.tools.doclets.VisibleMemberMap; | |||
public class ConstructorSubWriter extends ExecutableMemberSubWriter { | |||
public static class Del | |||
extends com.sun.tools.doclets.standard.ConstructorSubWriter { | |||
protected ConstructorSubWriter mw; | |||
public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, | |||
ClassDoc classdoc) { | |||
super(writer, classdoc); | |||
} | |||
public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) | |||
{ | |||
super(writer); | |||
} | |||
public void printMembersSummary() { | |||
mw.printMembersSummary(); | |||
mw.printIntroducedMembersSummary(); | |||
} | |||
public void printMembers() { | |||
mw.printMembers(); | |||
} | |||
protected void navSummaryLink() { | |||
mw.navSummaryLink(); | |||
} | |||
protected void navDetailLink() { | |||
mw.navDetailLink(); | |||
} | |||
public void setDelegator(ConstructorSubWriter mw) { this.mw = mw; } | |||
public void printSummaryMember(ClassDoc cd, ProgramElementDoc member) { | |||
mw.printSummaryMember(cd, member); | |||
} | |||
} | |||
protected Class delegateClass() { | |||
return Del.class; | |||
} | |||
public ConstructorSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, | |||
ClassDoc classdoc) | |||
{ | |||
super(writer, classdoc); | |||
} | |||
public ConstructorSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) | |||
{ | |||
super(writer); | |||
} | |||
public int getMemberKind() { | |||
//XXX hack!!! | |||
return VisibleMemberMap.CONSTRUCTORS; | |||
} | |||
protected String propertyName() { return "Constructor"; } | |||
} | |||
@@ -1,120 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import org.aspectj.ajdoc.IntroducedDoc; | |||
import org.aspectj.ajdoc.IntroductionDoc; | |||
import org.aspectj.tools.ajdoc.Util; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.MemberDoc; | |||
import com.sun.javadoc.RootDoc; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
public class DeprecatedAPIListBuilder | |||
extends com.sun.tools.doclets.standard.DeprecatedAPIListBuilder | |||
{ | |||
private List deprecatedadvice = new ArrayList(); | |||
private List deprecatedpointcuts = new ArrayList(); | |||
private List deprecatedfieldintroductions = new ArrayList(); | |||
private List deprecatedmethodintroductions = new ArrayList(); | |||
private List deprecatedconstructorintroductions = new ArrayList(); | |||
private List deprecatedsuperintroductions = new ArrayList(); | |||
public DeprecatedAPIListBuilder(RootDoc root) { | |||
super(root); | |||
buildDeprecatedAPIInfo(root); | |||
} | |||
protected void buildDeprecatedAPIInfo(RootDoc root) { | |||
ClassDoc[] cs = root.classes(); | |||
for (int i = 0; i < cs.length; i++) { | |||
org.aspectj.ajdoc.ClassDoc c = (org.aspectj.ajdoc.ClassDoc)cs[i]; | |||
_composeDeprecatedList(deprecatedpointcuts, c.pointcuts()); | |||
if (c instanceof AspectDoc) { | |||
AspectDoc ad = (AspectDoc)c; | |||
_composeDeprecatedList(deprecatedadvice, ad.advice()); | |||
IntroductionDoc[] intros = ad.introductions(); | |||
for (int j = 0; j < intros.length; j++) { | |||
if (intros[j] instanceof IntroducedDoc) { | |||
MemberDoc md = ((IntroducedDoc)intros[j]).member(); | |||
if (md == null) continue; | |||
if (md.isField()) { | |||
_composeDeprecatedList(deprecatedfieldintroductions, | |||
intros[j]); | |||
} else if (md.isMethod()) { | |||
_composeDeprecatedList(deprecatedmethodintroductions, | |||
intros[j]); | |||
} else { | |||
_composeDeprecatedList(deprecatedconstructorintroductions, | |||
intros[j]); | |||
} | |||
} else { | |||
_composeDeprecatedList(deprecatedsuperintroductions, | |||
intros[j]); | |||
} | |||
} | |||
} | |||
} | |||
Collections.sort(deprecatedadvice); | |||
Collections.sort(deprecatedpointcuts); | |||
Collections.sort(deprecatedfieldintroductions); | |||
Collections.sort(deprecatedmethodintroductions); | |||
Collections.sort(deprecatedconstructorintroductions); | |||
Collections.sort(deprecatedsuperintroductions); | |||
} | |||
protected void _composeDeprecatedList(List list, MemberDoc member) { | |||
_composeDeprecatedList(list, new MemberDoc[]{member}); | |||
} | |||
protected void _composeDeprecatedList(List list, MemberDoc[] members) { | |||
Util.invoke(com.sun.tools.doclets.standard.DeprecatedAPIListBuilder.class, | |||
this, "composeDeprecatedList", | |||
new Class[]{java.util.List.class, | |||
com.sun.javadoc.MemberDoc[].class}, | |||
new Object[]{list, members}); | |||
} | |||
public List getDeprecatedAdivce() { | |||
return deprecatedadvice; | |||
} | |||
public List getDeprecatedPointcuts() { | |||
return deprecatedpointcuts; | |||
} | |||
public List getDeprecatedFieldIntroductions() { | |||
return deprecatedfieldintroductions; | |||
} | |||
public List getDeprecatedMethodIntroductions() { | |||
return deprecatedmethodintroductions; | |||
} | |||
public List getDeprecatedConstructorIntroductions() { | |||
return deprecatedconstructorintroductions; | |||
} | |||
public List getDeprecatedSuperIntroductions() { | |||
return deprecatedsuperintroductions; | |||
} | |||
} |
@@ -1,94 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.tools.ajdoc.Access; | |||
import com.sun.javadoc.RootDoc; | |||
import com.sun.tools.doclets.DocletAbortException; | |||
import java.io.IOException; | |||
import java.util.List; | |||
public class DeprecatedListWriter | |||
extends com.sun.tools.doclets.standard.DeprecatedListWriter | |||
{ | |||
protected DeprecatedAPIListBuilder builder; | |||
public DeprecatedListWriter(String filename, | |||
DeprecatedAPIListBuilder builder) | |||
throws IOException { | |||
super(filename); | |||
this.builder = builder; | |||
} | |||
public static void generate(RootDoc root) throws DocletAbortException { | |||
String filename = "deprecated-list.html"; | |||
DeprecatedListWriter dw = null; | |||
try { | |||
(dw = new DeprecatedListWriter(filename, | |||
new DeprecatedAPIListBuilder(root))). | |||
generateDeprecatedListFile(); | |||
} catch (IOException e) { | |||
Standard.configuration(). | |||
standardmessage.error("doclet.exception_encountered", | |||
e+"", filename); | |||
throw new DocletAbortException(); | |||
} finally { | |||
if (dw != null) dw.close(); | |||
} | |||
} | |||
protected void generateDeprecatedListFile() throws IOException { | |||
generateDeprecatedListFile(builder); | |||
} | |||
protected void printDeprecatedFooter() { | |||
printRestOfDeprecatedListFile(); | |||
super.printDeprecatedFooter(); | |||
} | |||
protected void printRestOfDeprecatedListFile() { | |||
deprecatedListFile(new AdviceSubWriter(this), | |||
builder.getDeprecatedAdivce()); | |||
deprecatedListFile(new PointcutSubWriter(this), | |||
builder.getDeprecatedPointcuts()); | |||
deprecatedListFile(new FieldIntroductionSubWriter(this), | |||
builder.getDeprecatedFieldIntroductions()); | |||
deprecatedListFile(new MethodIntroductionSubWriter(this), | |||
builder.getDeprecatedMethodIntroductions()); | |||
deprecatedListFile(new ConstructorIntroductionSubWriter(this), | |||
builder.getDeprecatedConstructorIntroductions()); | |||
deprecatedListFile(new SuperIntroductionSubWriter(this), | |||
builder.getDeprecatedSuperIntroductions()); | |||
} | |||
protected final void deprecatedListFile(AbstractSubWriter mw, | |||
List list) { | |||
Access.printDeprecatedAPI(mw, list, | |||
"doclet.Deprecated_" + | |||
mw.keyName() + "s"); | |||
} | |||
} |
@@ -1,139 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.AdviceDoc; | |||
import org.aspectj.ajdoc.IntroducedDoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.ExecutableMemberDoc; | |||
import com.sun.javadoc.ProgramElementDoc; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Set; | |||
public abstract class ExecutableMemberSubWriter extends AbstractSubWriter { | |||
public ExecutableMemberSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, | |||
ClassDoc classdoc) | |||
{ | |||
super(writer, classdoc); | |||
} | |||
public ExecutableMemberSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) | |||
{ | |||
super(writer); | |||
} | |||
protected String where(ProgramElementDoc member) { | |||
ExecutableMemberDoc emd = (ExecutableMemberDoc)member; | |||
return emd.name() + emd.signature(); | |||
} | |||
protected String label(ExecutableMemberDoc emd) { | |||
return emd.qualifiedName() + emd.flatSignature(); | |||
} | |||
public void printIntroducedSummaryLink(ClassDoc cd, | |||
ProgramElementDoc member) { | |||
ExecutableMemberDoc emd = (ExecutableMemberDoc)member; | |||
writer.printClassLink(cd, where(emd), emd.name(), false); | |||
} | |||
public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) { | |||
org.aspectj.ajdoc.ExecutableMemberDoc emd = | |||
(org.aspectj.ajdoc.ExecutableMemberDoc)member; | |||
IntroducedDoc intro = emd.introduced(); | |||
if (intro != null) { | |||
writer.dt(); | |||
writer.boldText("doclet.Introduced_from"); | |||
writer.dd(); | |||
org.aspectj.ajdoc.MemberDoc otherMember = | |||
(org.aspectj.ajdoc.MemberDoc)intro.member(); | |||
String name = where(otherMember); | |||
ClassDoc containing = intro.containingClass(); | |||
writer.printClassLink(containing, name, | |||
containing.typeName(), false); | |||
} | |||
AdviceDoc[] advice = emd.advice(); | |||
if (advice.length > 0) { | |||
writer.boldText("doclet.Crosscut_by"); | |||
Set set = new HashSet(); | |||
for (int i = 0; i < advice.length; i++) { | |||
set.add(advice[i]); | |||
} | |||
List list = new ArrayList(set); | |||
Collections.sort(list); | |||
for (Iterator i = list.iterator(); i.hasNext();) { | |||
writer.dd(); | |||
writer.code(); | |||
AdviceDoc ad = (AdviceDoc)i.next(); | |||
writer.printClassLink(ad.containingClass(), | |||
AdviceSubWriter.getWhere | |||
(ad.containingClass(), ad), | |||
label(ad)); | |||
print(" in "); | |||
writer.printClassLink(ad.containingClass()); | |||
writer.codeEnd(); | |||
print('.'); | |||
} | |||
} | |||
} | |||
public void printSummaryCrosscuts(ClassDoc cd, | |||
ProgramElementDoc member) { | |||
Set cds = new HashSet(); | |||
org.aspectj.ajdoc.ExecutableMemberDoc emd = | |||
(org.aspectj.ajdoc.ExecutableMemberDoc)member; | |||
AdviceDoc[] advice = emd.advice(); | |||
for (int i = 0; i < advice.length; i++) { | |||
cds.add(advice[i].containingClass()); | |||
} | |||
if (cds.size() > 0) { | |||
writer.boldText("doclet.Advised_by"); | |||
List list = new ArrayList(cds); | |||
Collections.sort(list); | |||
for (Iterator i = list.iterator(); i.hasNext();) { | |||
print(' '); | |||
ClassDoc cdoc = (ClassDoc)i.next(); | |||
writer.printClassLink(cdoc, "advice_detail", cdoc.name()); | |||
if (i.hasNext()) print(","); | |||
} | |||
} | |||
} | |||
public boolean hasCrosscuts(ClassDoc classDoc, | |||
ProgramElementDoc member) { | |||
org.aspectj.ajdoc.ExecutableMemberDoc emd = | |||
(org.aspectj.ajdoc.ExecutableMemberDoc)member; | |||
return emd.introduced() != null || emd.advice().length > 0; | |||
} | |||
} | |||
@@ -1,131 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import org.aspectj.ajdoc.IntroducedDoc; | |||
import org.aspectj.ajdoc.IntroductionDoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.MemberDoc; | |||
import com.sun.javadoc.ProgramElementDoc; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Set; | |||
public class FieldIntroductionSubWriter extends FieldSubWriter { | |||
public FieldIntroductionSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, | |||
AspectDoc ad) | |||
{ | |||
super(writer, ad); | |||
} | |||
public FieldIntroductionSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) | |||
{ | |||
super(writer); | |||
} | |||
protected final String keyName() { return "Field_Introduction"; } | |||
public void printInheritedSummaryAnchor(ClassDoc cd) {} | |||
public void printInheritedSummaryLabel(ClassDoc cd) {} | |||
protected void printInheritedSummaryLink(ClassDoc cd, ProgramElementDoc ped) {} | |||
protected List getMembers(ClassDoc cd) { | |||
if (!(cd instanceof AspectDoc)) return super.getMembers(cd); | |||
IntroductionDoc[] introductions = ((AspectDoc)cd).introductions(); | |||
List list = new ArrayList(); | |||
if (introductions == null) return list; | |||
for (int i = 0; i < introductions.length; i++) { | |||
IntroductionDoc id = introductions[i]; | |||
if (!(id instanceof IntroducedDoc)) continue; | |||
MemberDoc member = ((IntroducedDoc)id).member(); | |||
if (member.isField()) { | |||
//FieldDec field = (FieldDec)member; | |||
//TODO: field.bindSignatures(((ClassDec)cd).getTypeScope()); | |||
list.add(member); //field); | |||
} | |||
} | |||
return list; | |||
} | |||
/** print links back to aspect in target class docs? | |||
* or forward from aspects to target class members? */ | |||
public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) { | |||
org.aspectj.ajdoc.FieldDoc field = (org.aspectj.ajdoc.FieldDoc)member; | |||
IntroducedDoc intro = field.introduced(); | |||
//String name = field.name(); | |||
ClassDoc[] targets = intro.targets(); | |||
if (targets.length > 0) { | |||
writer.dt(); // define term | |||
writer.boldText("doclet.Introduced_on"); | |||
writer.dd(); | |||
writer.code(); | |||
for (int i = 0; i < targets.length; i++) { | |||
if (i > 0) writer.print(", "); | |||
ClassDoc target = targets[i]; | |||
writer.printClassLink(target, | |||
"fields_introduced_from_class_" + | |||
cd.qualifiedName(), | |||
target.name()); | |||
} | |||
writer.codeEnd(); | |||
writer.ddEnd(); // XXX added for balance | |||
} | |||
} | |||
public void printSummaryCrosscuts(ClassDoc cd, | |||
ProgramElementDoc member) { | |||
Set set = new HashSet(); | |||
org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member; | |||
IntroducedDoc intro = md.introduced(); | |||
ClassDoc[] targets = intro.targets(); | |||
for (int i = 0; i < targets.length; i++) { | |||
set.add(targets[i]); | |||
} | |||
if (targets.length > 0) { | |||
writer.boldText("doclet.Advises"); | |||
List list = new ArrayList(set); | |||
Collections.sort(list); | |||
for (Iterator i = list.iterator(); i.hasNext();) { | |||
print(' '); | |||
ClassDoc target = (ClassDoc)i.next(); | |||
writer.printClassLink(target, | |||
"fields_introduced_from_class_" | |||
+ cd.qualifiedName(), | |||
target.name()); | |||
if (i.hasNext()) print(","); | |||
} | |||
} | |||
} | |||
public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) { | |||
return true; | |||
} | |||
} |
@@ -1,116 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.IntroducedDoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.ProgramElementDoc; | |||
import com.sun.tools.doclets.VisibleMemberMap; | |||
public class FieldSubWriter extends AbstractSubWriter { | |||
public static class Del extends com.sun.tools.doclets.standard.FieldSubWriter { | |||
protected FieldSubWriter mw; | |||
public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, | |||
ClassDoc classdoc) | |||
{ | |||
super(writer, classdoc); | |||
} | |||
public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) | |||
{ | |||
super(writer); | |||
} | |||
public void printMembersSummary() { | |||
mw.printMembersSummary(); | |||
mw.printIntroducedMembersSummary(); | |||
} | |||
public void printMembers() { | |||
if (writer instanceof ClassWriter) { | |||
((ClassWriter)writer).printAspectJDetail(); | |||
} | |||
mw.printMembers(); | |||
} | |||
protected void navSummaryLink() { | |||
mw.navSummaryLink(); | |||
} | |||
protected void navDetailLink() { | |||
if (writer instanceof ClassWriter) { | |||
((ClassWriter)writer).navstate++; | |||
} | |||
mw.navDetailLink(); | |||
} | |||
public void setDelegator(FieldSubWriter mw) { this.mw = mw; } | |||
public void printSummaryMember(ClassDoc cd, ProgramElementDoc member) { | |||
mw.printSummaryMember(cd, member); | |||
} | |||
} | |||
protected Class delegateClass() { | |||
return Del.class; | |||
} | |||
public FieldSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, | |||
ClassDoc classdoc) | |||
{ | |||
super(writer, classdoc); | |||
} | |||
public FieldSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) | |||
{ | |||
super(writer); | |||
} | |||
public int getMemberKind() { | |||
//XXX hack!!! | |||
return VisibleMemberMap.FIELDS; | |||
} | |||
protected String propertyName() { return "Field"; } | |||
public void printIntroducedSummaryLink(ClassDoc cd, | |||
ProgramElementDoc member) { | |||
writer.printClassLink(cd, member.name(), member.name(), false); | |||
} | |||
public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) { | |||
org.aspectj.ajdoc.FieldDoc field = (org.aspectj.ajdoc.FieldDoc)member; | |||
IntroducedDoc intro = field.introduced(); | |||
if (intro != null) { | |||
writer.dt(); | |||
writer.boldText("doclet.Introduced_from"); | |||
writer.dd(); | |||
writer.printClassLink(intro.containingClass(), | |||
Statics.where(intro.member())); | |||
} | |||
} | |||
public void printSummaryCrosscuts(ClassDoc cd, ProgramElementDoc member) {} | |||
public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) { | |||
return true || ((org.aspectj.ajdoc.MemberDoc)member).introduced() != null; | |||
} | |||
} | |||
@@ -1,136 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.AspectDoc; | |||
import org.aspectj.ajdoc.IntroducedDoc; | |||
import org.aspectj.ajdoc.IntroductionDoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.MemberDoc; | |||
import com.sun.javadoc.ProgramElementDoc; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Set; | |||
public class MethodIntroductionSubWriter extends MethodSubWriter { | |||
public MethodIntroductionSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, | |||
AspectDoc ad) | |||
{ | |||
super(writer, ad); | |||
} | |||
public MethodIntroductionSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) | |||
{ | |||
super(writer); | |||
} | |||
protected final String keyName() { return "Method_Introduction"; } | |||
public void printInheritedSummaryAnchor(ClassDoc cd) {} | |||
public void printInheritedSummaryLabel(ClassDoc cd) {} | |||
protected void printInheritedSummaryLink(ClassDoc cd, ProgramElementDoc ped) {} | |||
protected List getMembers(ClassDoc cd) { | |||
if (!(cd instanceof AspectDoc)) return super.getMembers(cd); | |||
IntroductionDoc[] introductions = ((AspectDoc)cd).introductions(); | |||
List list = new ArrayList(); | |||
if (introductions == null) return list; | |||
for (int i = 0; i < introductions.length; i++) { | |||
IntroductionDoc id = introductions[i]; | |||
if (!(id instanceof IntroducedDoc)) continue; | |||
MemberDoc member = ((IntroducedDoc)id).member(); | |||
if (member.isMethod()) { | |||
//MethodDec method = (MethodDec)member; | |||
//TODO: method.bindSignatures(((ClassDec)cd).getTypeScope()); | |||
list.add(member); //method); | |||
} | |||
} | |||
return list; | |||
} | |||
/** print in the detail context at the bottom of the page | |||
* the links out to affected classes/members for this method introduction | |||
* (in this aspect) | |||
*/ | |||
public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) { | |||
org.aspectj.ajdoc.MethodDoc method = (org.aspectj.ajdoc.MethodDoc)member; | |||
IntroducedDoc intro = method.introduced(); | |||
ClassDoc[] targets = intro.targets(); | |||
if (targets.length > 0) { | |||
writer.dt(); | |||
writer.boldText("doclet.Introduced_on"); | |||
writer.dd(); | |||
writer.code(); | |||
for (int i = 0; i < targets.length; i++) { | |||
if (i > 0) writer.print(", "); | |||
ClassDoc target = targets[i]; | |||
writer.printClassLink(target, | |||
"methods_introduced_from_class_" + | |||
cd.qualifiedName(), | |||
target.name()); | |||
} | |||
writer.codeEnd(); | |||
writer.ddEnd(); // XXX added for balance | |||
} | |||
} | |||
/** print in the summary context at the top of the page | |||
* the links out to affected classes/members for this method introduction | |||
* (in this aspect) | |||
*/ | |||
public void printSummaryCrosscuts(ClassDoc cd, | |||
ProgramElementDoc member) { | |||
Set set = new HashSet(); | |||
org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member; | |||
IntroducedDoc intro = md.introduced(); | |||
ClassDoc[] targets = intro.targets(); | |||
for (int i = 0; i < targets.length; i++) { | |||
set.add(targets[i]); | |||
} | |||
if (targets.length > 0) { | |||
writer.boldText("doclet.Advises"); | |||
List list = new ArrayList(set); | |||
Collections.sort(list); | |||
for (Iterator i = list.iterator(); i.hasNext();) { | |||
print(' '); | |||
ClassDoc target = (ClassDoc)i.next(); | |||
writer.printClassLink(target, | |||
"methods_introduced_from_class_" | |||
+ cd.qualifiedName(), | |||
target.name()); | |||
if (i.hasNext()) print(","); | |||
} | |||
} | |||
} | |||
public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) { | |||
return true; | |||
} | |||
} |
@@ -1,112 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.AdviceDoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.ExecutableMemberDoc; | |||
import com.sun.javadoc.MethodDoc; | |||
import com.sun.javadoc.ProgramElementDoc; | |||
import com.sun.tools.doclets.VisibleMemberMap; | |||
public class MethodSubWriter extends ExecutableMemberSubWriter { | |||
public static class Del | |||
extends com.sun.tools.doclets.standard.MethodSubWriter { | |||
protected MethodSubWriter mw; | |||
public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, | |||
ClassDoc classdoc) | |||
{ | |||
super(writer, classdoc); | |||
} | |||
public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) | |||
{ | |||
super(writer); | |||
} | |||
public void printMembersSummary() { | |||
mw.printMembersSummary(); | |||
mw.printIntroducedMembersSummary(); | |||
} | |||
public void printMembers() { | |||
mw.printMembers(); | |||
} | |||
protected void navSummaryLink() { | |||
mw.navSummaryLink(); | |||
} | |||
protected void navDetailLink() { | |||
mw.navDetailLink(); | |||
} | |||
public void setDelegator(MethodSubWriter mw) { this.mw = mw; } | |||
public void printSummaryMember(ClassDoc cd, ProgramElementDoc member) { | |||
mw.printSummaryMember(cd, member); | |||
} | |||
} | |||
protected Class delegateClass() { return Del.class; } | |||
public MethodSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, | |||
ClassDoc classdoc) | |||
{ | |||
super(writer, classdoc); | |||
} | |||
public MethodSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) | |||
{ | |||
super(writer); | |||
} | |||
public int getMemberKind() { | |||
//XXX hack!!! | |||
return VisibleMemberMap.METHODS; | |||
} | |||
//XXX | |||
//hacks | |||
protected void printSummaryType(ProgramElementDoc member) { | |||
if (member instanceof MethodDoc) { | |||
//TODO: Put in Access... | |||
MethodDoc meth = (MethodDoc)member; | |||
printModifierAndType(meth, meth.returnType()); | |||
} else if (member instanceof AdviceDoc) { | |||
AdviceDoc advice = (AdviceDoc)member; | |||
printModifierAndType(advice, advice.returnType()); | |||
} | |||
} | |||
protected void printSignature(ExecutableMemberDoc member) { | |||
writer.displayLength = 0; | |||
writer.pre(); | |||
printModifiers(member); | |||
//printReturnType((MethodDoc)member); | |||
bold(member.name()); | |||
// printParameters(member); | |||
// printExceptions(member); | |||
writer.preEnd(); | |||
} | |||
//end-hacks | |||
protected String propertyName() { return "Method"; } | |||
} | |||
@@ -1,75 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import com.sun.javadoc.PackageDoc; | |||
import com.sun.tools.doclets.DirectoryManager; | |||
import com.sun.tools.doclets.DocletAbortException; | |||
import java.io.IOException; | |||
public class PackageFrameWriter | |||
extends com.sun.tools.doclets.standard.PackageFrameWriter | |||
{ | |||
protected final PackageDoc packagedoc; | |||
public PackageFrameWriter(String path, | |||
String filename, | |||
PackageDoc packagedoc) | |||
throws IOException, DocletAbortException { | |||
super(path, filename, packagedoc); | |||
this.packagedoc = packagedoc; | |||
} | |||
public static void generate(PackageDoc pkg) throws DocletAbortException { | |||
PackageFrameWriter pw = null; | |||
String path = DirectoryManager.getDirectoryPath(pkg); | |||
String filename = "package-frame" + ".html"; | |||
try { | |||
(pw = new PackageFrameWriter(path, filename, pkg)). | |||
generatePackageFile(); | |||
} catch (IOException e) { | |||
Standard.configuration().standardmessage. | |||
error("doclet.exception_encountered", | |||
e+"", filename); | |||
throw new DocletAbortException(); | |||
} finally { | |||
if (pw != null) pw.close(); | |||
} | |||
} | |||
protected void generateClassListing() { | |||
generateClassKindListing(packagedoc.interfaces(), | |||
getText("doclet.Interfaces")); | |||
generateClassKindListing(Statics.classes(packagedoc. | |||
ordinaryClasses()), | |||
getText("doclet.Classes")); | |||
generateClassKindListing(((org.aspectj.ajdoc.PackageDoc)packagedoc). | |||
aspects(), | |||
getText("doclet.Aspects")); | |||
generateClassKindListing(packagedoc.exceptions(), | |||
getText("doclet.Exceptions")); | |||
generateClassKindListing(packagedoc.errors(), | |||
getText("doclet.Errors")); | |||
} | |||
} |
@@ -1,97 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.PackageDoc; | |||
import com.sun.tools.doclets.ClassTree; | |||
import com.sun.tools.doclets.DirectoryManager; | |||
import com.sun.tools.doclets.DocletAbortException; | |||
import java.io.IOException; | |||
import java.util.List; | |||
public class PackageTreeWriter | |||
extends com.sun.tools.doclets.standard.PackageTreeWriter | |||
{ | |||
protected class Del extends AbstractTreeWriter { | |||
public Del(String s, ClassTree c) | |||
throws IOException, DocletAbortException { | |||
super(s, c); | |||
} | |||
public void print(String s) { | |||
PackageTreeWriter.this.print(s); | |||
} | |||
} | |||
final protected Del del; | |||
{ | |||
Standard.quiet(); | |||
Del d = null; | |||
try { | |||
d = new Del(filename, classtree); | |||
} catch (Exception e) { | |||
Standard.configuration().standardmessage. | |||
error("doclet.exception_encountered", | |||
e+"", filename); | |||
} finally { | |||
del = d; | |||
Standard.speak(); | |||
} | |||
} | |||
protected void generateLevelInfo(ClassDoc parent, List list) { | |||
del.generateLevelInfo(parent, list); | |||
} | |||
protected void generateTree(List list, String heading) { | |||
del.generateTree(list, heading); | |||
} | |||
public PackageTreeWriter(String path, | |||
String filename, | |||
PackageDoc packagedoc, | |||
PackageDoc prev, | |||
PackageDoc next, | |||
boolean noDeprecated) | |||
throws IOException, DocletAbortException { | |||
super(path, filename, packagedoc, prev, next, noDeprecated); | |||
} | |||
public static void generate(PackageDoc pkg, PackageDoc prev, | |||
PackageDoc next, boolean noDeprecated) | |||
throws DocletAbortException { | |||
PackageTreeWriter pw = null; | |||
String path = DirectoryManager.getDirectoryPath(pkg); | |||
String filename = "package-tree.html"; | |||
try { | |||
(pw = new PackageTreeWriter(path, filename, pkg, | |||
prev, next, noDeprecated)). | |||
generatePackageTreeFile(); | |||
} catch (IOException e) { | |||
Standard.configuration().standardmessage. | |||
error("doclet.exception_encountered", | |||
e+"", filename); | |||
throw new DocletAbortException(); | |||
} finally { | |||
if (pw != null) pw.close(); | |||
} | |||
} | |||
} |
@@ -1,79 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import com.sun.javadoc.PackageDoc; | |||
import com.sun.tools.doclets.DirectoryManager; | |||
import com.sun.tools.doclets.DocletAbortException; | |||
import java.io.IOException; | |||
public class PackageWriter | |||
extends com.sun.tools.doclets.standard.PackageWriter | |||
{ | |||
protected final PackageDoc packagedoc; | |||
public PackageWriter(String path, | |||
String filename, | |||
PackageDoc packagedoc, | |||
PackageDoc prev, | |||
PackageDoc next) | |||
throws IOException, DocletAbortException { | |||
super(path, filename, packagedoc, prev, next); | |||
this.packagedoc = packagedoc; | |||
} | |||
public static void generate(PackageDoc pkg, | |||
PackageDoc prev, | |||
PackageDoc next) throws DocletAbortException { | |||
PackageWriter pw; | |||
String path = DirectoryManager.getDirectoryPath(pkg); | |||
String filename = "package-summary.html"; | |||
try { | |||
(pw = new PackageWriter(path, filename, pkg, prev, next)). | |||
generatePackageFile(); | |||
pw.close(); | |||
pw.copyDocFiles(path); | |||
} catch (IOException e) { | |||
Standard.configuration().standardmessage. | |||
error("doclet.exception_encountered", e+"", filename); | |||
throw new DocletAbortException(); | |||
} | |||
} | |||
protected void generateClassListing() { | |||
generateClassKindListing(packagedoc.interfaces(), | |||
getText("doclet.Interface_Summary")); | |||
generateClassKindListing(Statics.classes(packagedoc.ordinaryClasses()), | |||
getText("doclet.Class_Summary")); | |||
generateClassKindListing(((org.aspectj.ajdoc.PackageDoc)packagedoc).aspects(), | |||
getText("doclet.Aspect_Summary")); | |||
generateClassKindListing(packagedoc.exceptions(), | |||
getText("doclet.Exception_Summary")); | |||
generateClassKindListing(packagedoc.errors(), | |||
getText("doclet.Error_Summary")); | |||
} | |||
} | |||
@@ -1,227 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.ajdoc.PointcutDoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.MemberDoc; | |||
import com.sun.javadoc.ParamTag; | |||
import com.sun.javadoc.Parameter; | |||
import com.sun.javadoc.ProgramElementDoc; | |||
import com.sun.javadoc.SeeTag; | |||
import com.sun.javadoc.Tag; | |||
import com.sun.javadoc.Type; | |||
import com.sun.tools.doclets.Util; | |||
import java.util.List; | |||
public class PointcutSubWriter extends AbstractSubWriter { | |||
protected Class delegateClass() { | |||
return null; | |||
} | |||
public PointcutSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, | |||
ClassDoc classdoc) | |||
{ | |||
super(writer, classdoc); | |||
} | |||
public PointcutSubWriter | |||
(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) | |||
{ | |||
super(writer); | |||
} | |||
protected final String keyName() { return "Pointcut"; } | |||
// public void printInheritedSummaryAnchor(ClassDoc cd) { | |||
// writer.anchor("pointcuts_inherited_from_class_" + cd.qualifiedName()); | |||
// } | |||
// public void printInheritedSummaryLabel(ClassDoc cd) { | |||
// String classlink = writer.getPreQualifiedClassLink(cd); | |||
// writer.bold(); | |||
// writer.printText("doclet.Pointcuts_Inherited_From", | |||
// Statics.type(cd), | |||
// classlink); | |||
// writer.boldEnd(); | |||
// } | |||
void printSignature(MemberDoc member) { | |||
PointcutDoc pcd = (PointcutDoc)member; | |||
writer.displayLength = 0; | |||
writer.pre(); | |||
printModifiers(pcd); | |||
bold(pcd.name()); | |||
printParameters(pcd); | |||
printResultType(pcd); | |||
writer.preEnd(); | |||
} | |||
void printResultType(PointcutDoc pcd) { | |||
Type result = pcd.resultType(); | |||
if (result != null) { | |||
writer.code(); | |||
print(" returns "); | |||
printTypeLink(result); | |||
writer.codeEnd(); | |||
} | |||
} | |||
protected void printSummaryLink(ClassDoc cd, ProgramElementDoc member) { | |||
PointcutDoc pcd = (PointcutDoc)member; | |||
String name = member.name(); | |||
writer.bold(); | |||
writer.printClassLink(cd, name + pcd.signature(), name, false); | |||
writer.boldEnd(); | |||
writer.displayLength = name.length(); | |||
printParameters(pcd); | |||
printResultType(pcd); | |||
} | |||
protected void printInheritedSummaryLink(ClassDoc cd, | |||
ProgramElementDoc member) { | |||
PointcutDoc pcd = (PointcutDoc)member; | |||
String name = member.name(); | |||
writer.printClassLink(cd, name + pcd.signature(), name, false); | |||
} | |||
protected void printSummaryType(ProgramElementDoc member) { | |||
PointcutDoc pcd = (PointcutDoc)member; | |||
writer.printTypeSummaryHeader(); | |||
printModifier(pcd); | |||
writer.printTypeSummaryFooter(); | |||
} | |||
protected void printBodyHtmlEnd(ClassDoc cd) { | |||
} | |||
protected void nonfinalPrintMember(ProgramElementDoc member) { | |||
PointcutDoc pcd = (PointcutDoc)member; | |||
writer.anchor(pcd.name() + pcd.signature()); | |||
printHead(pcd); | |||
printSignature(pcd); | |||
printFullComment(pcd); | |||
} | |||
protected void printDeprecatedLink(ProgramElementDoc member) { | |||
writer.printClassLink(member.containingClass(), | |||
member.name(), | |||
((PointcutDoc)member).qualifiedName()); | |||
} | |||
protected List getMembers(ClassDoc cd) { | |||
return Util.asList(((org.aspectj.ajdoc.ClassDoc)cd).pointcuts()); | |||
} | |||
protected void printParameters(PointcutDoc member) { | |||
print('('); | |||
Parameter[] params = member.parameters(); | |||
for (int i = 0; i < params.length; i++) { | |||
printParam(params[i]); | |||
if (i < params.length-1) { | |||
writer.print(','); | |||
writer.print(' '); | |||
} | |||
} | |||
writer.print(')'); | |||
} | |||
protected void printParam(Parameter param) { | |||
printTypedName(param.type(), param.name()); | |||
} | |||
protected void printParamTags(ParamTag[] params) { | |||
if (params.length > 0) { | |||
writer.dt(); | |||
writer.boldText("doclet.Parameters"); | |||
for (int i = 0; i < params.length; ++i) { | |||
ParamTag pt = params[i]; | |||
writer.dd(); | |||
writer.code(); | |||
print(pt.parameterName()); | |||
writer.codeEnd(); | |||
print(" - "); | |||
writer.printInlineComment(pt); | |||
} | |||
} | |||
} | |||
protected void printReturnTag(Tag[] returnsTag) { | |||
if (returnsTag.length > 0) { | |||
writer.dt(); | |||
writer.boldText("doclet.Returns"); | |||
writer.dd(); | |||
writer.printInlineComment(returnsTag[0]); | |||
} | |||
} | |||
protected void printOverridden(ClassDoc overridden, PointcutDoc pcd) { | |||
if (overridden != null) { | |||
String name = pcd.name(); | |||
writer.dt(); | |||
writer.boldText("doclet.Overrides"); | |||
writer.dd(); | |||
writer.printText("doclet.in_class", | |||
writer.codeText | |||
(writer.getClassLink(overridden, | |||
name + pcd.signature(), | |||
name, false)), | |||
writer.codeText | |||
(writer.getClassLink(overridden))); | |||
} | |||
} | |||
protected void printTags(ProgramElementDoc member) { | |||
PointcutDoc pcd = (PointcutDoc)member; | |||
ParamTag[] params = pcd.paramTags(); | |||
Tag[] returnsTag = pcd.tags("return"); | |||
Tag[] sinces = pcd.tags("since"); | |||
SeeTag[] sees = pcd.seeTags(); | |||
ClassDoc[] intfacs = member.containingClass().interfaces(); | |||
ClassDoc overridden = pcd.overriddenClass(); | |||
if (intfacs.length > 0 || overridden != null) { | |||
writer.dd(); | |||
writer.dl(); | |||
printOverridden(overridden, pcd); | |||
writer.dlEnd(); | |||
writer.ddEnd(); | |||
} | |||
if (params.length + | |||
returnsTag.length + | |||
sinces.length + | |||
sees.length > 0) { | |||
writer.dd(); | |||
writer.dl(); | |||
printParamTags(params); | |||
printReturnTag(returnsTag); | |||
writer.printSinceTag(pcd); | |||
writer.printSeeTags(pcd); | |||
writer.dlEnd(); | |||
writer.ddEnd(); | |||
} | |||
} | |||
} |
@@ -1,87 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import com.sun.javadoc.MemberDoc; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.tools.doclets.DocletAbortException; | |||
import com.sun.tools.doclets.IndexBuilder; | |||
import java.io.IOException; | |||
public class SingleIndexWriter | |||
extends com.sun.tools.doclets.standard.SingleIndexWriter | |||
{ | |||
protected class Del extends AbstractIndexWriter { | |||
public Del(String s, IndexBuilder i) throws IOException { | |||
super(s, i); | |||
} | |||
public void print(String s) { | |||
SingleIndexWriter.this.print(s); | |||
} | |||
} | |||
final protected Del del; | |||
{ | |||
Standard.quiet(); | |||
Del d = null; | |||
try { | |||
d = new Del(filename, indexbuilder); | |||
} catch (Exception e) { | |||
Standard.configuration().standardmessage. | |||
error("doclet.exception_encountered", | |||
e+"", filename); | |||
} finally { | |||
del = d; | |||
Standard.speak(); | |||
} | |||
} | |||
protected void printMemberDesc(MemberDoc member) { | |||
del.printMemberDesc(member); | |||
} | |||
protected void printClassInfo(ClassDoc cd) { | |||
del.printClassInfo(cd); | |||
} | |||
public SingleIndexWriter(String filename, | |||
IndexBuilder indexbuilder) throws IOException { | |||
super(filename, indexbuilder); | |||
} | |||
public static void generate(IndexBuilder indexbuilder) | |||
throws DocletAbortException { | |||
SingleIndexWriter sw = null; | |||
String filename = "index-all.html"; | |||
try { | |||
(sw = new SingleIndexWriter(filename, indexbuilder)). | |||
generateIndexFile(); | |||
} catch (IOException e) { | |||
Standard.configuration().standardmessage.error | |||
("doclet.exception_encountered", | |||
e+"", filename); | |||
throw new DocletAbortException(); | |||
} finally { | |||
if (sw != null) sw.close(); | |||
} | |||
} | |||
} |
@@ -1,99 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import com.sun.javadoc.ClassDoc; | |||
import com.sun.javadoc.MemberDoc; | |||
import com.sun.tools.doclets.DirectoryManager; | |||
import com.sun.tools.doclets.DocletAbortException; | |||
import com.sun.tools.doclets.IndexBuilder; | |||
import java.io.IOException; | |||
public class SplitIndexWriter | |||
extends com.sun.tools.doclets.standard.SplitIndexWriter | |||
{ | |||
protected class Del extends AbstractIndexWriter { | |||
public Del(String s, IndexBuilder i) throws IOException { | |||
super(s, i); | |||
} | |||
public void print(String s) { | |||
SplitIndexWriter.this.print(s); | |||
} | |||
} | |||
final protected Del del; | |||
{ | |||
Standard.quiet(); | |||
Del d = null; | |||
try { | |||
d = new Del(filename, indexbuilder); | |||
} catch (Exception e) { | |||
Standard.configuration().standardmessage. | |||
error("doclet.exception_encountered", | |||
e+"", filename); | |||
} finally { | |||
del = d; | |||
Standard.speak(); | |||
} | |||
} | |||
protected void printMemberDesc(MemberDoc member) { | |||
del.printMemberDesc(member); | |||
} | |||
protected void printClassInfo(ClassDoc cd) { | |||
del.printClassInfo(cd); | |||
} | |||
public SplitIndexWriter(String path, String filename, | |||
String relpath, IndexBuilder indexbuilder, | |||
int prev, int next) throws IOException { | |||
super(path, filename, relpath, | |||
indexbuilder, prev, next); | |||
} | |||
public static void generate(IndexBuilder indexbuilder) | |||
throws DocletAbortException { | |||
SplitIndexWriter sw = null; | |||
String filename = ""; | |||
String path = DirectoryManager.getPath("index-files"); | |||
String relpath = DirectoryManager.getRelativePath("index-files"); | |||
try { | |||
for (int i = 0; i < indexbuilder.elements().length; i++) { | |||
int j = i + 1; | |||
int prev = (j == 1)? -1: i; | |||
int next = (j == indexbuilder.elements().length)? -1: j + 1; | |||
filename = "index-" + j +".html"; | |||
(sw = new SplitIndexWriter(path, filename, relpath, | |||
indexbuilder, prev, next)). | |||
generateIndexFile((Character) | |||
indexbuilder.elements()[i]); | |||
} | |||
} catch (IOException e) { | |||
Standard.configuration(). | |||
standardmessage.error("doclet.exception_encountered", | |||
e+"", filename); | |||
throw new DocletAbortException(); | |||
} finally { | |||
if (sw != null) sw.close(); | |||
} | |||
} | |||
} |
@@ -1,251 +0,0 @@ | |||
/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* This file is part of the debugger and core tools for the AspectJ(tm) | |||
* programming language; see http://aspectj.org | |||
* | |||
* The contents of this file are subject to the Mozilla Public License | |||
* Version 1.1 (the "License"); you may not use this file except in | |||
* compliance with the License. You may obtain a copy of the License at | |||
* either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is AspectJ. | |||
* | |||
* The Initial Developer of the Original Code is Xerox Corporation. Portions | |||
* created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. | |||
* All Rights Reserved. | |||
*/ | |||
package org.aspectj.tools.doclets.standard; | |||
import org.aspectj.tools.ajdoc.Quietable; | |||
import com.sun.javadoc.RootDoc; | |||
import com.sun.tools.doclets.DocletAbortException; | |||
import com.sun.tools.doclets.standard.AllClassesFrameWriter; | |||
import com.sun.tools.doclets.standard.FrameOutputWriter; | |||
import com.sun.tools.doclets.standard.HelpWriter; | |||
import com.sun.tools.doclets.standard.PackageIndexFrameWriter; | |||
import com.sun.tools.doclets.standard.PackageIndexWriter; | |||
import com.sun.tools.doclets.standard.PackageListWriter; | |||
import com.sun.tools.doclets.standard.PackagesFileWriter; | |||
import com.sun.tools.doclets.standard.SerializedFormWriter; | |||
import com.sun.tools.doclets.standard.StylesheetWriter; | |||
import java.io.IOException; | |||
/** | |||
* Main doclet for ajdoc. It defines a number of | |||
* passes to use in generating the documentation. | |||
* | |||
* @author Jeff Palm | |||
*/ | |||
public class Standard extends AbstractStandard { | |||
private static Standard SINGLETON; // todo: prefer early/final? | |||
public static final Standard getSingleton() { | |||
if (null == SINGLETON) { | |||
SINGLETON = new Standard(); | |||
} | |||
return SINGLETON; | |||
} | |||
private Standard() {} | |||
public static boolean start(RootDoc root) throws IOException { | |||
return start(getSingleton(), root); | |||
} | |||
public ConfigurationStandard getConfiguration() { | |||
return (ConfigurationStandard)configuration(); | |||
} | |||
public static void quiet() { | |||
if (configuration().root instanceof Quietable) { | |||
((Quietable)configuration().root).quiet(); | |||
} | |||
} | |||
public static void speak() { | |||
if (configuration().root instanceof Quietable) { | |||
((Quietable)configuration().root).speak(); | |||
} | |||
} | |||
public static class ClassUseMapperPass extends Pass { | |||
protected boolean cond() { | |||
return cs.classuse; | |||
} | |||
protected void gen() throws DocletAbortException { | |||
ClassUseMapper.generate(root, std.classtree); | |||
} | |||
public String title() { return "class use mapper"; } | |||
} | |||
public static class TreeWriterPass extends Pass { | |||
protected boolean cond() { | |||
return cs.createtree; | |||
} | |||
protected void gen() throws DocletAbortException { | |||
TreeWriter.generate(std.classtree); | |||
} | |||
public String title() { return "tree writer"; } | |||
} | |||
public static class SplitIndexWriterPass extends Pass { | |||
protected boolean cond() { | |||
return cs.createindex && cs.splitindex; | |||
} | |||
protected void gen() throws DocletAbortException { | |||
SplitIndexWriter.generate(std.indexBuilder(root, false)); | |||
} | |||
public String title() { return "split index"; } | |||
} | |||
public static class SingleIndexWriterPass extends Pass { | |||
protected boolean cond() { | |||
return cs.createindex && !cs.splitindex; | |||
} | |||
protected void gen() throws DocletAbortException { | |||
SingleIndexWriter.generate(std.indexBuilder(root, false)); | |||
} | |||
public String title() { return "single index"; } | |||
} | |||
public static class DeprecatedListWriterPass extends Pass { | |||
protected boolean cond() { | |||
return !cs.nodeprecatedlist && !cs.nodeprecated; | |||
} | |||
protected void gen() throws DocletAbortException { | |||
DeprecatedListWriter.generate(root); | |||
} | |||
public String title() { return "deprecated list"; } | |||
} | |||
public static class AllClassesFrameWriterPass extends Pass { | |||
protected void gen() throws DocletAbortException { | |||
AllClassesFrameWriter.generate(std.indexBuilder(root, true)); | |||
} | |||
public String title() { return "all classes frame"; } | |||
} | |||
public static class FrameOutputWriterPass extends Pass { | |||
protected void gen() throws DocletAbortException { | |||
FrameOutputWriter.generate(); | |||
} | |||
public String title() { return "output frame"; } | |||
} | |||
public static class PackagesFileWriterPass extends Pass { | |||
protected void gen() throws DocletAbortException { | |||
PackagesFileWriter.generate(); | |||
} | |||
public String title() { return "packages files"; } | |||
} | |||
public static class PackageIndexWriterPass extends Pass { | |||
protected boolean cond(ConfigurationStandard cs) { | |||
return cs.createoverview; | |||
} | |||
protected void gen() throws DocletAbortException { | |||
PackageIndexWriter.generate(root); | |||
} | |||
public String title() { return "package index"; } | |||
} | |||
public static class PackageIndexFrameWriterPass extends Pass { | |||
protected boolean cond() { | |||
return cs.packages.length > 1; | |||
} | |||
protected void gen() throws DocletAbortException { | |||
PackageIndexFrameWriter.generate(); | |||
} | |||
public String title() { return "package index frame"; } | |||
} | |||
protected Class[] preGenerationClasses() { | |||
return new Class[] { | |||
ClassUseMapperPass.class, | |||
TreeWriterPass.class, | |||
SplitIndexWriterPass.class, | |||
SingleIndexWriterPass.class, | |||
DeprecatedListWriterPass.class, | |||
AllClassesFrameWriterPass.class, | |||
FrameOutputWriterPass.class, | |||
PackagesFileWriterPass.class, | |||
PackageIndexWriterPass.class, | |||
PackageIndexFrameWriterPass.class, | |||
}; | |||
} | |||
public static class SerializedFormWriterPass extends Pass { | |||
protected void gen() throws DocletAbortException { | |||
SerializedFormWriter.generate(root); | |||
} | |||
public String title() { return "serialized form"; } | |||
} | |||
public static class PackageListWriterPass extends Pass { | |||
protected void gen() throws DocletAbortException { | |||
PackageListWriter.generate(root); | |||
} | |||
public String title() { return "package list"; } | |||
} | |||
public static class HelpWriterPass extends Pass { | |||
protected boolean cond() { | |||
return cs.helpfile.length() == 0 && | |||
!cs.nohelp; | |||
} | |||
protected void gen() throws DocletAbortException { | |||
HelpWriter.generate(); | |||
} | |||
public String title() { return "help"; } | |||
} | |||
public static class StylesheetWriterPass extends Pass { | |||
protected boolean cond() { | |||
return cs.stylesheetfile.length() == 0; | |||
} | |||
protected void gen() throws DocletAbortException { | |||
StylesheetWriter.generate(); | |||
} | |||
public String title() { return "style sheet"; } | |||
} | |||
protected Class[] postGenerationClasses() { | |||
return new Class[] { | |||
SerializedFormWriterPass.class, | |||
PackageListWriterPass.class, | |||
HelpWriterPass.class, | |||
StylesheetWriterPass.class, | |||
}; | |||
} | |||
public static class NoPublicClassesToDocumentCheck extends Check { | |||
protected boolean cond() { | |||
return root.classes().length == 0; | |||
} | |||
protected String message() { | |||
return "doclet.No_Public_Classes_To_Document"; | |||
} | |||
} | |||
public static class NoNonDeprecatedClassToDocumentCheck extends Check { | |||
protected boolean cond() { | |||
return cs.topFile.length() == 0; | |||
} | |||
protected String message() { | |||
return "doclet.No_Non_Deprecated_Classes_To_Document"; | |||
} | |||
} | |||
protected Class[] checkClasses() { | |||
return new Class[] { | |||
NoPublicClassesToDocumentCheck.class, | |||
NoNonDeprecatedClassToDocumentCheck.class, | |||
}; | |||
} | |||
} | |||