QDox

JavaSource.getURL should be available at parse-time.

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.5, 1.6, 1.7
  • Fix Version/s: None
  • Component/s: Java API
  • Labels:
    None
  • Environment:
    Windows 2000, jdk 1.4.2, ANT 1.5.4, Eclipse 3.0 / 3.1M4, QDOX: 1.5 as well as cvs-checkout.
  • Number of attachments :
    0

Description

Description:

At parse-time, when the JavaSource Object is created by the JavadocBuilder > (ModelBuilder <> parser), the URL member of the JavaSource (source) is not set. This is due to the chaining:

addSource(File file){
-> addSource(URL url){
-> addSource(Reader reader, String sourceInfo){
}
<aJavaSource>.setURL(url);
}
}

Problem:

A custom DocletTagFactory (constructor) may be used to parse for Annotations. It might be very useful to report syntax-errors from this custom parser. But these reporting is useless, when no information about the current url being processed is at hand. The DocletTagFactory or the triggered custom parser cannot access that information. The sourceInfo String is provided for the qdox parser's exception reporting, but that information is not available for the DocletTagFactory as well. Throwing an Exception would be a way of bringing the file name to the console, but warnings or debugging should not terminate the application.

Suggestion:

Medium change of the API:

Strip the creation of the JavaSource Object out of the ModelBuilder. Feed the ModelBuilder with a JavaSource instance (replace no-arg Constructor and extend the 2nd) that is already initialized with the URL.

Within JavadocBuilder:

change
addSource(Reader reader, String sourceInfo)

to
addSource(Reader reader, JavaSource source)

and declare it private (delegation only).
The code will then look like:

ModelBuilder builder = new ModelBuilder(
classLibrary,
docletTagFactory,
source
);
...

remove
addSource(Reader reader)

change code of method:

addSource(URL url){
JavaSource source = new JavaSource();
source.setURL(url);
addSource(new InputStreamReader(url.openStream(),encoding),source);
return source;
}

Ok, ok, I completely have no clue about the side effects of this suggested refactoring. But would be pleased, if you do.

BTW: Great work, really. I used xjavadoc and switched to QDox. Similar API, same author, improved from scratch.

Achim

Activity

Hide
Paul Hammant added a comment -

can you supply a patch with unit test(s) ?

Show
Paul Hammant added a comment - can you supply a patch with unit test(s) ?
Hide
Robert Scholte added a comment -

About a year since the last comment
For some other issues we have probably have to touch the javasource and javadocbuilder, so maybe a good moment to have a look at this issue again. Still wondering if there's a test available

Show
Robert Scholte added a comment - About a year since the last comment For some other issues we have probably have to touch the javasource and javadocbuilder, so maybe a good moment to have a look at this issue again. Still wondering if there's a test available
Hide
Robert Scholte added a comment -

Let's close it as cannot reproduce. Main reason is that I've refactored the classlibrary/parser architecture, so it's pretty unlikely that this is still a problem.

Show
Robert Scholte added a comment - Let's close it as cannot reproduce. Main reason is that I've refactored the classlibrary/parser architecture, so it's pretty unlikely that this is still a problem.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
1h
Original Estimate - 1 hour
Remaining:
1h
Remaining Estimate - 1 hour
Logged:
Not Specified
Time Spent - Not Specified