6794582: javadoc should read files using a FileManager

Tue, 20 Jan 2009 15:17:45 -0800

author
jjg
date
Tue, 20 Jan 2009 15:17:45 -0800
changeset 197
1bf037016426
parent 196
1ca2dc8584e1
child 198
b4b1f7732289

6794582: javadoc should read files using a FileManager
Reviewed-by: darcy, bpatel

src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/DocEnv.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/DocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/JavadocTool.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/RootDocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/SourcePositionImpl.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Tue Jan 20 17:49:49 2009 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Tue Jan 20 15:17:45 2009 -0800
     1.3 @@ -25,12 +25,11 @@
     1.4  
     1.5  package com.sun.tools.doclets.formats.html.markup;
     1.6  
     1.7 -import com.sun.tools.doclets.internal.toolkit.*;
     1.8 +import java.io.*;
     1.9 +import java.util.*;
    1.10  
    1.11  import com.sun.javadoc.*;
    1.12 -import java.io.*;
    1.13 -import java.util.*;
    1.14 -import com.sun.tools.doclets.internal.toolkit.util.*;
    1.15 +import com.sun.tools.doclets.internal.toolkit.*;
    1.16  
    1.17  
    1.18  /**
    1.19 @@ -56,8 +55,9 @@
    1.20          super(configuration,
    1.21                null, configuration.destDirName + filename,
    1.22                configuration.docencoding);
    1.23 +        // use File to normalize file separators
    1.24          configuration.message.notice("doclet.Generating_0",
    1.25 -                                     configuration.destDirName + filename);
    1.26 +            new File(configuration.destDirName, filename));
    1.27      }
    1.28  
    1.29      public HtmlDocWriter(Configuration configuration,
    1.30 @@ -65,10 +65,10 @@
    1.31          super(configuration,
    1.32                configuration.destDirName + path, filename,
    1.33                configuration.docencoding);
    1.34 +        // use File to normalize file separators
    1.35          configuration.message.notice("doclet.Generating_0",
    1.36 -                                     configuration.destDirName +
    1.37 -                                         ((path.length() > 0)?
    1.38 -                                              path + File.separator: "") + filename);
    1.39 +            new File(configuration.destDirName,
    1.40 +                    ((path.length() > 0)? path + File.separator: "") + filename));
    1.41      }
    1.42  
    1.43      /**
     2.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java	Tue Jan 20 17:49:49 2009 +0000
     2.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java	Tue Jan 20 15:17:45 2009 -0800
     2.3 @@ -25,10 +25,12 @@
     2.4  
     2.5  package com.sun.tools.doclets.internal.toolkit.util;
     2.6  
     2.7 -import com.sun.tools.doclets.internal.toolkit.*;
     2.8 -import com.sun.javadoc.*;
     2.9  import java.io.*;
    2.10  import java.util.*;
    2.11 +import javax.tools.FileObject;
    2.12 +
    2.13 +import com.sun.javadoc.*;
    2.14 +import com.sun.tools.doclets.internal.toolkit.*;
    2.15  
    2.16  /**
    2.17   * Converts Java Source Code to HTML.
    2.18 @@ -123,16 +125,27 @@
    2.19          if (cd == null || outputdir == null) {
    2.20              return;
    2.21          }
    2.22 -        File file;
    2.23 -        SourcePosition sp = cd.position();
    2.24 -        if (sp == null || (file = sp.file()) == null) {
    2.25 -            return;
    2.26 -        }
    2.27          try {
    2.28 +            SourcePosition sp = cd.position();
    2.29 +            if (sp == null)
    2.30 +                return;
    2.31 +            Reader r;
    2.32 +            // temp hack until we can update SourcePosition API.
    2.33 +            if (sp instanceof com.sun.tools.javadoc.SourcePositionImpl) {
    2.34 +                FileObject fo = ((com.sun.tools.javadoc.SourcePositionImpl) sp).fileObject();
    2.35 +                if (fo == null)
    2.36 +                    return;
    2.37 +                r = fo.openReader(true);
    2.38 +            } else {
    2.39 +                File file = sp.file();
    2.40 +                if (file == null)
    2.41 +                    return;
    2.42 +                r = new FileReader(file);
    2.43 +            }
    2.44 +            LineNumberReader reader = new LineNumberReader(r);
    2.45              int lineno = 1;
    2.46              String line;
    2.47              StringBuffer output = new StringBuffer();
    2.48 -            LineNumberReader reader = new LineNumberReader(new FileReader(file));
    2.49              try {
    2.50                  while ((line = reader.readLine()) != null) {
    2.51                      output.append(formatLine(line, configuration.sourcetab, lineno));
     3.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Tue Jan 20 17:49:49 2009 +0000
     3.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Tue Jan 20 15:17:45 2009 -0800
     3.3 @@ -25,10 +25,11 @@
     3.4  
     3.5  package com.sun.tools.doclets.internal.toolkit.util;
     3.6  
     3.7 +import java.io.*;
     3.8 +import java.util.*;
     3.9 +
    3.10  import com.sun.javadoc.*;
    3.11  import com.sun.tools.doclets.internal.toolkit.*;
    3.12 -import java.util.*;
    3.13 -import java.io.*;
    3.14  
    3.15  /**
    3.16   * Utilities Class for Doclets.
    3.17 @@ -579,7 +580,7 @@
    3.18       * @param docencoding Encoding to be used for this file.
    3.19       * @exception IOException Exception raised by the FileWriter is passed on
    3.20       * to next level.
    3.21 -     * @exception UnSupportedEncodingException Exception raised by the
    3.22 +     * @exception UnsupportedEncodingException Exception raised by the
    3.23       * OutputStreamWriter is passed on to next level.
    3.24       * @return Writer Writer for the file getting generated.
    3.25       * @see java.io.FileOutputStream
    3.26 @@ -598,8 +599,7 @@
    3.27              fos = new FileOutputStream(filename);
    3.28          }
    3.29          if (docencoding == null) {
    3.30 -            OutputStreamWriter oswriter = new OutputStreamWriter(fos);
    3.31 -            return oswriter;
    3.32 +            return new OutputStreamWriter(fos);
    3.33          } else {
    3.34              return new OutputStreamWriter(fos, docencoding);
    3.35          }
     4.1 --- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Tue Jan 20 17:49:49 2009 +0000
     4.2 +++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Tue Jan 20 15:17:45 2009 -0800
     4.3 @@ -25,42 +25,48 @@
     4.4  
     4.5  package com.sun.tools.javadoc;
     4.6  
     4.7 +import java.io.File;
     4.8 +import java.io.IOException;
     4.9 +import java.lang.reflect.Modifier;
    4.10 +import java.net.URI;
    4.11 +import java.util.HashSet;
    4.12 +import java.util.Set;
    4.13 +import javax.tools.FileObject;
    4.14 +import javax.tools.JavaFileManager.Location;
    4.15 +import javax.tools.StandardJavaFileManager;
    4.16 +import javax.tools.StandardLocation;
    4.17 +
    4.18  import com.sun.javadoc.*;
    4.19  
    4.20  import static com.sun.javadoc.LanguageVersion.*;
    4.21  
    4.22 -import com.sun.tools.javac.util.List;
    4.23 -import com.sun.tools.javac.util.ListBuffer;
    4.24 -import com.sun.tools.javac.util.Name;
    4.25 -import com.sun.tools.javac.util.Position;
    4.26 -
    4.27  import com.sun.tools.javac.code.Flags;
    4.28  import com.sun.tools.javac.code.Kinds;
    4.29 -import com.sun.tools.javac.code.TypeTags;
    4.30 -import com.sun.tools.javac.code.Type;
    4.31 -import com.sun.tools.javac.code.Type.ClassType;
    4.32  import com.sun.tools.javac.code.Scope;
    4.33  import com.sun.tools.javac.code.Symbol;
    4.34  import com.sun.tools.javac.code.Symbol.*;
    4.35 +import com.sun.tools.javac.code.Type;
    4.36 +import com.sun.tools.javac.code.Type.ClassType;
    4.37 +import com.sun.tools.javac.code.TypeTags;
    4.38  
    4.39  import com.sun.tools.javac.comp.AttrContext;
    4.40  import com.sun.tools.javac.comp.Env;
    4.41  
    4.42  import com.sun.tools.javac.tree.JCTree;
    4.43 +import com.sun.tools.javac.tree.JCTree.JCClassDecl;
    4.44  import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
    4.45  import com.sun.tools.javac.tree.JCTree.JCImport;
    4.46 -import com.sun.tools.javac.tree.JCTree.JCClassDecl;
    4.47  import com.sun.tools.javac.tree.TreeInfo;
    4.48  
    4.49 +import com.sun.tools.javac.util.List;
    4.50 +import com.sun.tools.javac.util.ListBuffer;
    4.51 +import com.sun.tools.javac.util.Name;
    4.52  import com.sun.tools.javac.util.Names;
    4.53 +import com.sun.tools.javac.util.Position;
    4.54 +
    4.55  import static com.sun.tools.javac.code.Flags.*;
    4.56  import static com.sun.tools.javac.code.Kinds.*;
    4.57  
    4.58 -import java.io.File;
    4.59 -import java.util.Set;
    4.60 -import java.util.HashSet;
    4.61 -import java.lang.reflect.Modifier;
    4.62 -
    4.63  /**
    4.64   * Represents a java class and provides access to information
    4.65   * about the class, the class' comment and tags, and the
    4.66 @@ -271,16 +277,41 @@
    4.67       */
    4.68      public PackageDoc containingPackage() {
    4.69          PackageDocImpl p = env.getPackageDoc(tsym.packge());
    4.70 -        SourcePosition po = position();
    4.71 -        if (po != null && p.setDocPath == false && p.zipDocPath == null) {
    4.72 -            //Set the package path if possible
    4.73 -            File packageDir = po.file().getParentFile();
    4.74 -            if (packageDir != null
    4.75 -                && (new File(packageDir, "package.html")).exists()) {
    4.76 -                p.setDocPath(packageDir.getPath());
    4.77 -            } else {
    4.78 -                p.setDocPath(null);
    4.79 +        if (p.setDocPath == false) {
    4.80 +            FileObject docPath;
    4.81 +            try {
    4.82 +                Location location = env.fileManager.hasLocation(StandardLocation.SOURCE_PATH)
    4.83 +                    ? StandardLocation.SOURCE_PATH : StandardLocation.CLASS_PATH;
    4.84 +
    4.85 +                docPath = env.fileManager.getFileForInput(
    4.86 +                        location, p.qualifiedName(), "package.html");
    4.87 +            } catch (IOException e) {
    4.88 +                docPath = null;
    4.89              }
    4.90 +
    4.91 +            if (docPath == null) {
    4.92 +                // fall back on older semantics of looking in same directory as
    4.93 +                // source file for this class
    4.94 +                SourcePosition po = position();
    4.95 +                if (env.fileManager instanceof StandardJavaFileManager &&
    4.96 +                        po instanceof SourcePositionImpl) {
    4.97 +                    URI uri = ((SourcePositionImpl) po).filename.toUri();
    4.98 +                    if ("file".equals(uri.getScheme())) {
    4.99 +                        File f = new File(uri.getPath());
   4.100 +                        File dir = f.getParentFile();
   4.101 +                        if (dir != null) {
   4.102 +                            File pf = new File(dir, "package.html");
   4.103 +                            if (pf.exists()) {
   4.104 +                                StandardJavaFileManager sfm = (StandardJavaFileManager) env.fileManager;
   4.105 +                                docPath = sfm.getJavaFileObjects(pf).iterator().next();
   4.106 +                            }
   4.107 +                        }
   4.108 +
   4.109 +                    }
   4.110 +                }
   4.111 +            }
   4.112 +
   4.113 +            p.setDocPath(docPath);
   4.114          }
   4.115          return p;
   4.116      }
   4.117 @@ -1251,7 +1282,7 @@
   4.118       */
   4.119      public SourcePosition position() {
   4.120          if (tsym.sourcefile == null) return null;
   4.121 -        return SourcePositionImpl.make(tsym.sourcefile.toString(),
   4.122 +        return SourcePositionImpl.make(tsym.sourcefile,
   4.123                                         (tree==null) ? Position.NOPOS : tree.pos,
   4.124                                         lineMap);
   4.125      }
     5.1 --- a/src/share/classes/com/sun/tools/javadoc/DocEnv.java	Tue Jan 20 17:49:49 2009 +0000
     5.2 +++ b/src/share/classes/com/sun/tools/javadoc/DocEnv.java	Tue Jan 20 15:17:45 2009 -0800
     5.3 @@ -25,8 +25,9 @@
     5.4  
     5.5  package com.sun.tools.javadoc;
     5.6  
     5.7 +import java.lang.reflect.Modifier;
     5.8  import java.util.*;
     5.9 -import java.lang.reflect.Modifier;
    5.10 +import javax.tools.JavaFileManager;
    5.11  
    5.12  import com.sun.javadoc.*;
    5.13  
    5.14 @@ -40,7 +41,6 @@
    5.15  import com.sun.tools.javac.util.Names;
    5.16  import com.sun.tools.javac.util.Position;
    5.17  
    5.18 -
    5.19  /**
    5.20   * Holds the environment for a run of javadoc.
    5.21   * Holds only the information needed throughout the
    5.22 @@ -103,6 +103,7 @@
    5.23  
    5.24      Check chk;
    5.25      Types types;
    5.26 +    JavaFileManager fileManager;
    5.27  
    5.28      /** Allow documenting from class files? */
    5.29      boolean docClasses = false;
    5.30 @@ -133,6 +134,7 @@
    5.31          externalizableSym = reader.enterClass(names.fromString("java.io.Externalizable"));
    5.32          chk = Check.instance(context);
    5.33          types = Types.instance(context);
    5.34 +        fileManager = context.get(JavaFileManager.class);
    5.35  
    5.36          // Default.  Should normally be reset with setLocale.
    5.37          this.doclocale = new DocLocale(this, "", breakiterator);
     6.1 --- a/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Tue Jan 20 17:49:49 2009 +0000
     6.2 +++ b/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Tue Jan 20 15:17:45 2009 -0800
     6.3 @@ -25,11 +25,13 @@
     6.4  
     6.5  package com.sun.tools.javadoc;
     6.6  
     6.7 -import com.sun.javadoc.*;
     6.8 -
     6.9  import java.io.InputStream;
    6.10  import java.io.IOException;
    6.11  import java.text.CollationKey;
    6.12 +import javax.tools.FileObject;
    6.13 +
    6.14 +import com.sun.javadoc.*;
    6.15 +
    6.16  import com.sun.tools.javac.util.Position;
    6.17  
    6.18  /**
    6.19 @@ -43,7 +45,7 @@
    6.20   * @author Atul M Dambalkar
    6.21   * @author Neal Gafter (rewrite)
    6.22   */
    6.23 -abstract class DocImpl implements Doc, Comparable<Object> {
    6.24 +public abstract class DocImpl implements Doc, Comparable<Object> {
    6.25  
    6.26      /**
    6.27       * Doc environment
    6.28 @@ -163,7 +165,7 @@
    6.29      /**
    6.30       * Utility for subclasses which read HTML documentation files.
    6.31       */
    6.32 -    String readHTMLDocumentation(InputStream input, String filename) throws IOException {
    6.33 +    String readHTMLDocumentation(InputStream input, FileObject filename) throws IOException {
    6.34          int filesize = input.available();
    6.35          byte[] filecontents = new byte[filesize];
    6.36          input.read(filecontents, 0, filesize);
     7.1 --- a/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Tue Jan 20 17:49:49 2009 +0000
     7.2 +++ b/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Tue Jan 20 15:17:45 2009 -0800
     7.3 @@ -25,20 +25,18 @@
     7.4  
     7.5  package com.sun.tools.javadoc;
     7.6  
     7.7 +import java.lang.reflect.Modifier;
     7.8 +import java.text.CollationKey;
     7.9 +
    7.10  import com.sun.javadoc.*;
    7.11  
    7.12 +import com.sun.tools.javac.code.Flags;
    7.13 +import com.sun.tools.javac.code.Symbol.*;
    7.14 +import com.sun.tools.javac.code.Type;
    7.15 +import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
    7.16  import com.sun.tools.javac.util.List;
    7.17  import com.sun.tools.javac.util.ListBuffer;
    7.18  import com.sun.tools.javac.util.Position;
    7.19 -import com.sun.tools.javac.code.Flags;
    7.20 -import com.sun.tools.javac.code.Type;
    7.21 -import com.sun.tools.javac.code.Symbol;
    7.22 -import com.sun.tools.javac.code.Symbol.*;
    7.23 -import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
    7.24 -
    7.25 -import java.text.CollationKey;
    7.26 -
    7.27 -import java.lang.reflect.Modifier;
    7.28  
    7.29  /**
    7.30   * Represents a method or constructor of a java class.
    7.31 @@ -267,7 +265,7 @@
    7.32       */
    7.33      public SourcePosition position() {
    7.34          if (sym.enclClass().sourcefile == null) return null;
    7.35 -        return SourcePositionImpl.make(sym.enclClass().sourcefile.toString(),
    7.36 +        return SourcePositionImpl.make(sym.enclClass().sourcefile,
    7.37                                         (tree==null) ? 0 : tree.pos,
    7.38                                         lineMap);
    7.39      }
     8.1 --- a/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Tue Jan 20 17:49:49 2009 +0000
     8.2 +++ b/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Tue Jan 20 15:17:45 2009 -0800
     8.3 @@ -25,6 +25,8 @@
     8.4  
     8.5  package com.sun.tools.javadoc;
     8.6  
     8.7 +import java.lang.reflect.Modifier;
     8.8 +
     8.9  import com.sun.javadoc.*;
    8.10  
    8.11  import static com.sun.javadoc.LanguageVersion.*;
    8.12 @@ -38,9 +40,6 @@
    8.13  
    8.14  import com.sun.tools.javac.util.Position;
    8.15  
    8.16 -import java.lang.reflect.Modifier;
    8.17 -
    8.18 -
    8.19  /**
    8.20   * Represents a field in a java class.
    8.21   *
    8.22 @@ -260,7 +259,7 @@
    8.23       */
    8.24      public SourcePosition position() {
    8.25          if (sym.enclClass().sourcefile == null) return null;
    8.26 -        return SourcePositionImpl.make(sym.enclClass().sourcefile.toString(),
    8.27 +        return SourcePositionImpl.make(sym.enclClass().sourcefile,
    8.28                                         (tree==null) ? 0 : tree.pos,
    8.29                                         lineMap);
    8.30      }
     9.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java	Tue Jan 20 17:49:49 2009 +0000
     9.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java	Tue Jan 20 15:17:45 2009 -0800
     9.3 @@ -25,18 +25,13 @@
     9.4  
     9.5  package com.sun.tools.javadoc;
     9.6  
     9.7 +import java.util.EnumSet;
     9.8 +import javax.tools.JavaFileObject;
     9.9 +
    9.10  import com.sun.tools.javac.code.Symbol.PackageSymbol;
    9.11 -import com.sun.tools.javac.file.JavacFileManager;
    9.12 -import com.sun.tools.javac.file.ZipArchive.ZipFileObject;
    9.13 -import com.sun.tools.javac.file.Old199;
    9.14 -import com.sun.tools.javac.file.ZipFileIndexArchive;
    9.15  import com.sun.tools.javac.jvm.ClassReader;
    9.16  import com.sun.tools.javac.util.Context;
    9.17  
    9.18 -import java.io.File;
    9.19 -import java.util.EnumSet;
    9.20 -import javax.tools.JavaFileObject;
    9.21 -
    9.22  /** Javadoc uses an extended class reader that records package.html entries
    9.23   *  @author Neal Gafter
    9.24   */
    9.25 @@ -82,32 +77,7 @@
    9.26       */
    9.27      @Override
    9.28      protected void extraFileActions(PackageSymbol pack, JavaFileObject fo) {
    9.29 -        CharSequence fileName = Old199.getName(fo);
    9.30 -        if (docenv != null && fileName.equals("package.html")) {
    9.31 -            if (fo instanceof ZipFileObject) {
    9.32 -                ZipFileObject zfo = (ZipFileObject) fo;
    9.33 -                String zipName = zfo.getZipName();
    9.34 -                String entryName = zfo.getZipEntryName();
    9.35 -                int lastSep = entryName.lastIndexOf("/");
    9.36 -                String classPathName = entryName.substring(0, lastSep + 1);
    9.37 -                docenv.getPackageDoc(pack).setDocPath(zipName, classPathName);
    9.38 -            }
    9.39 -            else if (fo instanceof ZipFileIndexArchive.ZipFileIndexFileObject) {
    9.40 -                ZipFileIndexArchive.ZipFileIndexFileObject zfo = (ZipFileIndexArchive.ZipFileIndexFileObject) fo;
    9.41 -                String zipName = zfo.getZipName();
    9.42 -                String entryName = zfo.getZipEntryName();
    9.43 -                if (File.separatorChar != '/') {
    9.44 -                    entryName = entryName.replace(File.separatorChar, '/');
    9.45 -                }
    9.46 -
    9.47 -                int lastSep = entryName.lastIndexOf("/");
    9.48 -                String classPathName = entryName.substring(0, lastSep + 1);
    9.49 -                docenv.getPackageDoc(pack).setDocPath(zipName, classPathName);
    9.50 -            }
    9.51 -            else {
    9.52 -                File fileDir = new File(Old199.getPath(fo)).getParentFile();
    9.53 -                docenv.getPackageDoc(pack).setDocPath(fileDir.getAbsolutePath());
    9.54 -            }
    9.55 -        }
    9.56 +        if (fo.isNameCompatible("package", JavaFileObject.Kind.HTML))
    9.57 +            docenv.getPackageDoc(pack).setDocPath(fo);
    9.58      }
    9.59  }
    10.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocTool.java	Tue Jan 20 17:49:49 2009 +0000
    10.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocTool.java	Tue Jan 20 15:17:45 2009 -0800
    10.3 @@ -25,17 +25,29 @@
    10.4  
    10.5  package com.sun.tools.javadoc;
    10.6  
    10.7 -import java.io.*;
    10.8 +import java.io.File;
    10.9 +import java.io.IOException;
   10.10 +import java.util.Collection;
   10.11 +import java.util.EnumSet;
   10.12 +import java.util.HashMap;
   10.13 +import java.util.Map;
   10.14 +import java.util.Set;
   10.15 +import javax.tools.JavaFileManager.Location;
   10.16 +import javax.tools.JavaFileObject;
   10.17 +import javax.tools.StandardJavaFileManager;
   10.18 +import javax.tools.StandardLocation;
   10.19  
   10.20 -import java.util.Collection;
   10.21 -
   10.22 -import com.sun.tools.javac.code.Symbol.*;
   10.23 -import com.sun.tools.javac.comp.*;
   10.24 -import com.sun.tools.javac.file.Paths;
   10.25 +import com.sun.tools.javac.code.Symbol.CompletionFailure;
   10.26 +import com.sun.tools.javac.comp.Annotate;
   10.27  import com.sun.tools.javac.parser.DocCommentScanner;
   10.28 -import com.sun.tools.javac.tree.*;
   10.29 -import com.sun.tools.javac.tree.JCTree.*;
   10.30 -import com.sun.tools.javac.util.*;
   10.31 +import com.sun.tools.javac.tree.JCTree;
   10.32 +import com.sun.tools.javac.tree.JCTree.JCClassDecl;
   10.33 +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
   10.34 +import com.sun.tools.javac.util.Abort;
   10.35 +import com.sun.tools.javac.util.Context;
   10.36 +import com.sun.tools.javac.util.List;
   10.37 +import com.sun.tools.javac.util.ListBuffer;
   10.38 +import com.sun.tools.javac.util.Position;
   10.39  
   10.40  
   10.41  /**
   10.42 @@ -53,7 +65,6 @@
   10.43      final JavadocClassReader reader;
   10.44      final JavadocEnter enter;
   10.45      final Annotate annotate;
   10.46 -    private final Paths paths;
   10.47  
   10.48      /**
   10.49       * Construct a new JavaCompiler processor, using appropriately
   10.50 @@ -66,7 +77,6 @@
   10.51          reader = JavadocClassReader.instance0(context);
   10.52          enter = JavadocEnter.instance0(context);
   10.53          annotate = Annotate.instance(context);
   10.54 -        paths = Paths.instance(context);
   10.55      }
   10.56  
   10.57      /**
   10.58 @@ -120,7 +130,7 @@
   10.59                        boolean quiet) throws IOException {
   10.60          docenv = DocEnv.instance(context);
   10.61          docenv.showAccess = filter;
   10.62 -    docenv.quiet = quiet;
   10.63 +        docenv.quiet = quiet;
   10.64          docenv.breakiterator = breakiterator;
   10.65          docenv.setLocale(doclocale);
   10.66          docenv.setEncoding(encoding);
   10.67 @@ -133,12 +143,14 @@
   10.68          ListBuffer<JCCompilationUnit> packTrees = new ListBuffer<JCCompilationUnit>();
   10.69  
   10.70          try {
   10.71 +            StandardJavaFileManager fm = (StandardJavaFileManager) docenv.fileManager;
   10.72              for (List<String> it = javaNames; it.nonEmpty(); it = it.tail) {
   10.73                  String name = it.head;
   10.74                  if (!docClasses && name.endsWith(".java") && new File(name).exists()) {
   10.75 +                    JavaFileObject fo = fm.getJavaFileObjects(name).iterator().next();
   10.76                      docenv.notice("main.Loading_source_file", name);
   10.77 -                        JCCompilationUnit tree = parse(name);
   10.78 -                        classTrees.append(tree);
   10.79 +                    JCCompilationUnit tree = parse(fo);
   10.80 +                    classTrees.append(tree);
   10.81                  } else if (isValidPackageName(name)) {
   10.82                      names = names.append(name);
   10.83                  } else if (name.endsWith(".java")) {
   10.84 @@ -151,12 +163,14 @@
   10.85              if (!docClasses) {
   10.86                  // Recursively search given subpackages.  If any packages
   10.87                  //are found, add them to the list.
   10.88 -                searchSubPackages(subPackages, names, excludedPackages);
   10.89 +                Map<String,List<JavaFileObject>> packageFiles =
   10.90 +                        searchSubPackages(subPackages, names, excludedPackages);
   10.91  
   10.92                  // Parse the packages
   10.93                  for (List<String> packs = names.toList(); packs.nonEmpty(); packs = packs.tail) {
   10.94                      // Parse sources ostensibly belonging to package.
   10.95 -                    parsePackageClasses(packs.head, packTrees, excludedPackages);
   10.96 +                    String packageName = packs.head;
   10.97 +                    parsePackageClasses(packageName, packageFiles.get(packageName), packTrees, excludedPackages);
   10.98                  }
   10.99  
  10.100                  if (messager.nerrors() != 0) return null;
  10.101 @@ -167,7 +181,8 @@
  10.102              }
  10.103          } catch (Abort ex) {}
  10.104  
  10.105 -        if (messager.nerrors() != 0) return null;
  10.106 +        if (messager.nerrors() != 0)
  10.107 +            return null;
  10.108  
  10.109          if (docClasses)
  10.110              return new RootDocImpl(docenv, javaNames, options);
  10.111 @@ -185,66 +200,129 @@
  10.112          return isValidClassName(s);
  10.113      }
  10.114  
  10.115 -
  10.116 -    private final static char pathSep = File.pathSeparatorChar;
  10.117 -
  10.118      /**
  10.119       * search all directories in path for subdirectory name. Add all
  10.120       * .java files found in such a directory to args.
  10.121       */
  10.122      private void parsePackageClasses(String name,
  10.123 -                                     ListBuffer<JCCompilationUnit> trees,
  10.124 -                                     List<String> excludedPackages)
  10.125 -        throws IOException {
  10.126 +            Iterable<JavaFileObject> files,
  10.127 +            ListBuffer<JCCompilationUnit> trees,
  10.128 +            List<String> excludedPackages)
  10.129 +            throws IOException {
  10.130          if (excludedPackages.contains(name)) {
  10.131              return;
  10.132          }
  10.133 +
  10.134          boolean hasFiles = false;
  10.135          docenv.notice("main.Loading_source_files_for_package", name);
  10.136 -        name = name.replace('.', File.separatorChar);
  10.137 -        for (File pathname : paths.sourceSearchPath()) {
  10.138 -            File f = new File(pathname, name);
  10.139 -            String names[] = f.list();
  10.140 -            // if names not null, then found directory with source files
  10.141 -            if (names != null) {
  10.142 -                String dir = f.getAbsolutePath();
  10.143 -                if (!dir.endsWith(File.separator))
  10.144 -                    dir = dir + File.separator;
  10.145 -                for (int j = 0; j < names.length; j++) {
  10.146 -                    if (isValidJavaSourceFile(names[j])) {
  10.147 -                        String fn = dir + names[j];
  10.148 -                        // messager.notice("main.Loading_source_file", fn);
  10.149 -                            trees.append(parse(fn));
  10.150 -                        hasFiles = true;
  10.151 -                    }
  10.152 +
  10.153 +        if (files == null) {
  10.154 +            Location location = docenv.fileManager.hasLocation(StandardLocation.SOURCE_PATH)
  10.155 +                    ? StandardLocation.SOURCE_PATH : StandardLocation.CLASS_PATH;
  10.156 +            ListBuffer<JavaFileObject> lb = new ListBuffer<JavaFileObject>();
  10.157 +            for (JavaFileObject fo: docenv.fileManager.list(
  10.158 +                    location, name, EnumSet.of(JavaFileObject.Kind.SOURCE), false)) {
  10.159 +                String binaryName = docenv.fileManager.inferBinaryName(location, fo);
  10.160 +                String simpleName = getSimpleName(binaryName);
  10.161 +                if (isValidClassName(simpleName)) {
  10.162 +                    lb.append(fo);
  10.163                  }
  10.164              }
  10.165 +            files = lb.toList();
  10.166          }
  10.167 -        if (!hasFiles)
  10.168 +
  10.169 +        for (JavaFileObject fo : files) {
  10.170 +            // messager.notice("main.Loading_source_file", fn);
  10.171 +            trees.append(parse(fo));
  10.172 +            hasFiles = true;
  10.173 +        }
  10.174 +
  10.175 +        if (!hasFiles) {
  10.176              messager.warning(null, "main.no_source_files_for_package",
  10.177 -                             name.replace(File.separatorChar, '.'));
  10.178 +                    name.replace(File.separatorChar, '.'));
  10.179 +        }
  10.180      }
  10.181  
  10.182      /**
  10.183       * Recursively search all directories in path for subdirectory name.
  10.184       * Add all packages found in such a directory to packages list.
  10.185       */
  10.186 +    private Map<String,List<JavaFileObject>> searchSubPackages(
  10.187 +            List<String> subPackages,
  10.188 +            ListBuffer<String> packages,
  10.189 +            List<String> excludedPackages)
  10.190 +            throws IOException {
  10.191 +        Map<String,List<JavaFileObject>> packageFiles =
  10.192 +                new HashMap<String,List<JavaFileObject>>();
  10.193 +
  10.194 +        Map<String,Boolean> includedPackages = new HashMap<String,Boolean>();
  10.195 +        includedPackages.put("", true);
  10.196 +        for (String p: excludedPackages)
  10.197 +            includedPackages.put(p, false);
  10.198 +
  10.199 +        if (docenv.fileManager.hasLocation(StandardLocation.SOURCE_PATH)) {
  10.200 +            searchSubPackages(subPackages,
  10.201 +                    includedPackages,
  10.202 +                    packages, packageFiles,
  10.203 +                    StandardLocation.SOURCE_PATH,
  10.204 +                    EnumSet.of(JavaFileObject.Kind.SOURCE));
  10.205 +            searchSubPackages(subPackages,
  10.206 +                    includedPackages,
  10.207 +                    packages, packageFiles,
  10.208 +                    StandardLocation.CLASS_PATH,
  10.209 +                    EnumSet.of(JavaFileObject.Kind.CLASS));
  10.210 +        } else {
  10.211 +            searchSubPackages(subPackages,
  10.212 +                    includedPackages,
  10.213 +                    packages, packageFiles,
  10.214 +                    StandardLocation.CLASS_PATH,
  10.215 +                    EnumSet.of(JavaFileObject.Kind.SOURCE, JavaFileObject.Kind.CLASS));
  10.216 +        }
  10.217 +        return packageFiles;
  10.218 +    }
  10.219 +
  10.220      private void searchSubPackages(List<String> subPackages,
  10.221 -                                   ListBuffer<String> packages,
  10.222 -                                   List<String> excludedPackages) {
  10.223 -        // FIXME: This search path is bogus.
  10.224 -        // Only the effective source path should be searched for sources.
  10.225 -        // Only the effective class path should be searched for classes.
  10.226 -        // Should the bootclasspath/extdirs also be searched for classes?
  10.227 -        java.util.List<File> pathnames = new java.util.ArrayList<File>();
  10.228 -        if (paths.sourcePath() != null)
  10.229 -            for (File elt : paths.sourcePath())
  10.230 -                pathnames.add(elt);
  10.231 -        for (File elt : paths.userClassPath())
  10.232 -            pathnames.add(elt);
  10.233 +            Map<String,Boolean> includedPackages,
  10.234 +            ListBuffer<String> packages,
  10.235 +            Map<String, List<JavaFileObject>> packageFiles,
  10.236 +            StandardLocation location, Set<JavaFileObject.Kind> kinds)
  10.237 +            throws IOException {
  10.238 +        for (String subPackage: subPackages) {
  10.239 +            if (!isIncluded(subPackage, includedPackages))
  10.240 +                continue;
  10.241  
  10.242 -        for (String subPackage : subPackages)
  10.243 -            searchSubPackage(subPackage, packages, excludedPackages, pathnames);
  10.244 +            for (JavaFileObject fo: docenv.fileManager.list(location, subPackage, kinds, true)) {
  10.245 +                String binaryName = docenv.fileManager.inferBinaryName(location, fo);
  10.246 +                String packageName = getPackageName(binaryName);
  10.247 +                String simpleName = getSimpleName(binaryName);
  10.248 +                if (isIncluded(packageName, includedPackages) && isValidClassName(simpleName)) {
  10.249 +                    List<JavaFileObject> list = packageFiles.get(packageName);
  10.250 +                    list = (list == null ? List.of(fo) : list.prepend(fo));
  10.251 +                    packageFiles.put(packageName, list);
  10.252 +                    if (!packages.contains(packageName))
  10.253 +                        packages.add(packageName);
  10.254 +                }
  10.255 +            }
  10.256 +        }
  10.257 +    }
  10.258 +
  10.259 +    private String getPackageName(String name) {
  10.260 +        int lastDot = name.lastIndexOf(".");
  10.261 +        return (lastDot == -1 ? "" : name.substring(0, lastDot));
  10.262 +    }
  10.263 +
  10.264 +    private String getSimpleName(String name) {
  10.265 +        int lastDot = name.lastIndexOf(".");
  10.266 +        return (lastDot == -1 ? name : name.substring(lastDot + 1));
  10.267 +    }
  10.268 +
  10.269 +    private boolean isIncluded(String packageName, Map<String,Boolean> includedPackages) {
  10.270 +        Boolean b = includedPackages.get(packageName);
  10.271 +        if (b == null) {
  10.272 +            b = isIncluded(getPackageName(packageName), includedPackages);
  10.273 +            includedPackages.put(packageName, b);
  10.274 +        }
  10.275 +        return b;
  10.276      }
  10.277  
  10.278      /**
    11.1 --- a/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java	Tue Jan 20 17:49:49 2009 +0000
    11.2 +++ b/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java	Tue Jan 20 15:17:45 2009 -0800
    11.3 @@ -25,30 +25,23 @@
    11.4  
    11.5  package com.sun.tools.javadoc;
    11.6  
    11.7 +import java.io.InputStream;
    11.8 +import java.io.IOException;
    11.9 +import javax.tools.FileObject;
   11.10 +
   11.11  import com.sun.javadoc.*;
   11.12  
   11.13 -import java.io.File;
   11.14 -import java.io.InputStream;
   11.15 -import java.io.FileInputStream;
   11.16 -import java.io.IOException;
   11.17 -import java.util.zip.ZipFile;
   11.18 -import java.util.zip.ZipEntry;
   11.19 -
   11.20  import com.sun.tools.javac.code.Attribute;
   11.21  import com.sun.tools.javac.code.Scope;
   11.22  import com.sun.tools.javac.code.Symbol.ClassSymbol;
   11.23  import com.sun.tools.javac.code.Symbol.PackageSymbol;
   11.24 -import com.sun.tools.javac.comp.AttrContext;
   11.25 -import com.sun.tools.javac.comp.Env;
   11.26  import com.sun.tools.javac.tree.JCTree;
   11.27 +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
   11.28  import com.sun.tools.javac.util.List;
   11.29  import com.sun.tools.javac.util.ListBuffer;
   11.30  import com.sun.tools.javac.util.Name;
   11.31  import com.sun.tools.javac.util.Position;
   11.32  
   11.33 -import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
   11.34 -
   11.35 -
   11.36  /**
   11.37   * Represents a java package.  Provides access to information
   11.38   * about the package, the package's comment and tags, and the
   11.39 @@ -63,14 +56,10 @@
   11.40  
   11.41  public class PackageDocImpl extends DocImpl implements PackageDoc {
   11.42  
   11.43 -    private static final String PACKAGE_HTML_FILE_NAME = "package.html";
   11.44 -
   11.45      protected PackageSymbol sym;
   11.46      private JCCompilationUnit tree = null;    // for source position
   11.47  
   11.48 -    public String docPath = null;
   11.49 -    public String zipDocPath = null;
   11.50 -    public String zipDocEntry = null;
   11.51 +    public FileObject docPath = null;
   11.52      private boolean foundDoc;   // found a doc comment in either
   11.53                                  // package.html or package-info.java
   11.54  
   11.55 @@ -108,30 +97,16 @@
   11.56       * Do lazy initialization of "documentation" string.
   11.57       */
   11.58      String documentation() {
   11.59 -        if (documentation != null) return documentation;
   11.60 -        if (zipDocPath != null) {
   11.61 -            try {
   11.62 -                ZipFile f = new ZipFile(zipDocPath);
   11.63 -                ZipEntry entry = f.getEntry(zipDocEntry);
   11.64 -                if (entry != null) {
   11.65 -                    InputStream s = f.getInputStream(entry);
   11.66 -                    return (documentation = readHTMLDocumentation(s,
   11.67 -                        zipDocPath + File.separatorChar + zipDocEntry));
   11.68 -                }
   11.69 -            } catch (IOException exc) {
   11.70 -                documentation = "";
   11.71 -                env.error(null, "javadoc.File_Read_Error",
   11.72 -                          zipDocPath + File.separatorChar + zipDocEntry);
   11.73 -            }
   11.74 -        }
   11.75 +        if (documentation != null)
   11.76 +            return documentation;
   11.77          if (docPath != null) {
   11.78              // read from file
   11.79              try {
   11.80 -                InputStream s = new FileInputStream(docPath);
   11.81 +                InputStream s = docPath.openInputStream();
   11.82                  documentation = readHTMLDocumentation(s, docPath);
   11.83              } catch (IOException exc) {
   11.84                  documentation = "";
   11.85 -                env.error(null, "javadoc.File_Read_Error", docPath);
   11.86 +                env.error(null, "javadoc.File_Read_Error", docPath.getName());
   11.87              }
   11.88          } else {
   11.89              // no doc file to be had
   11.90 @@ -363,24 +338,12 @@
   11.91      /**
   11.92       * set doc path for an unzipped directory
   11.93       */
   11.94 -    public void setDocPath(String path) {
   11.95 +    public void setDocPath(FileObject path) {
   11.96          setDocPath = true;
   11.97          if (path == null)
   11.98              return;
   11.99 -        String newDocPath = path + File.separatorChar + PACKAGE_HTML_FILE_NAME;
  11.100 -        if (!newDocPath.equals(docPath)) {
  11.101 -            docPath = newDocPath;
  11.102 -            checkDoc();
  11.103 -        }
  11.104 -    }
  11.105 -
  11.106 -    /**
  11.107 -     * set the doc path for zipped directory
  11.108 -     */
  11.109 -    public void setDocPath(String path, String entry) {
  11.110 -        if (!path.equals(zipDocPath)) {
  11.111 -            zipDocPath = path;
  11.112 -            zipDocEntry = entry + PACKAGE_HTML_FILE_NAME;
  11.113 +        if (!path.equals(docPath)) {
  11.114 +            docPath = path;
  11.115              checkDoc();
  11.116          }
  11.117      }
  11.118 @@ -409,7 +372,7 @@
  11.119       */
  11.120      public SourcePosition position() {
  11.121          return (tree != null)
  11.122 -                ? SourcePositionImpl.make(tree.sourcefile + "", tree.pos, tree.lineMap)
  11.123 +                ? SourcePositionImpl.make(tree.sourcefile, tree.pos, tree.lineMap)
  11.124                  : SourcePositionImpl.make(docPath, Position.NOPOS, null);
  11.125      }
  11.126  }
    12.1 --- a/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Tue Jan 20 17:49:49 2009 +0000
    12.2 +++ b/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Tue Jan 20 15:17:45 2009 -0800
    12.3 @@ -26,17 +26,16 @@
    12.4  package com.sun.tools.javadoc;
    12.5  
    12.6  import java.io.IOException;
    12.7 -import java.io.FileInputStream;
    12.8 -import java.io.File;
    12.9 +import java.util.Locale;
   12.10 +import javax.tools.JavaFileObject;
   12.11 +import javax.tools.StandardJavaFileManager;
   12.12  
   12.13  import com.sun.javadoc.*;
   12.14  
   12.15  import com.sun.tools.javac.tree.JCTree.JCClassDecl;
   12.16 -import com.sun.tools.javac.code.Symbol;
   12.17  import com.sun.tools.javac.util.List;
   12.18  import com.sun.tools.javac.util.ListBuffer;
   12.19  import com.sun.tools.javac.util.Position;
   12.20 -import java.util.Locale;
   12.21  
   12.22  /**
   12.23   * This class holds the information from one run of javadoc.
   12.24 @@ -308,10 +307,13 @@
   12.25       * Return the path of the overview file and null if it does not exist.
   12.26       * @return the path of the overview file and null if it does not exist.
   12.27       */
   12.28 -    private String getOverviewPath() {
   12.29 +    private JavaFileObject getOverviewPath() {
   12.30          for (String[] opt : options) {
   12.31              if (opt[0].equals("-overview")) {
   12.32 -                return opt[1];
   12.33 +                if (env.fileManager instanceof StandardJavaFileManager) {
   12.34 +                    StandardJavaFileManager fm = (StandardJavaFileManager) env.fileManager;
   12.35 +                    return fm.getJavaFileObjects(opt[1]).iterator().next();
   12.36 +                }
   12.37              }
   12.38          }
   12.39          return null;
   12.40 @@ -323,7 +325,7 @@
   12.41      protected String documentation() {
   12.42          if (documentation == null) {
   12.43              int cnt = options.length();
   12.44 -            String overviewPath = getOverviewPath();
   12.45 +            JavaFileObject overviewPath = getOverviewPath();
   12.46              if (overviewPath == null) {
   12.47                  // no doc file to be had
   12.48                  documentation = "";
   12.49 @@ -331,11 +333,11 @@
   12.50                  // read from file
   12.51                  try {
   12.52                      documentation = readHTMLDocumentation(
   12.53 -                        new FileInputStream(overviewPath),
   12.54 +                        overviewPath.openInputStream(),
   12.55                          overviewPath);
   12.56                  } catch (IOException exc) {
   12.57                      documentation = "";
   12.58 -                    env.error(null, "javadoc.File_Read_Error", overviewPath);
   12.59 +                    env.error(null, "javadoc.File_Read_Error", overviewPath.getName());
   12.60                  }
   12.61              }
   12.62          }
   12.63 @@ -347,7 +349,7 @@
   12.64       * no position is available.
   12.65       */
   12.66      public SourcePosition position() {
   12.67 -        String path;
   12.68 +        JavaFileObject path;
   12.69          return ((path = getOverviewPath()) == null) ?
   12.70              null :
   12.71              SourcePositionImpl.make(path, Position.NOPOS, null);
    13.1 --- a/src/share/classes/com/sun/tools/javadoc/SourcePositionImpl.java	Tue Jan 20 17:49:49 2009 +0000
    13.2 +++ b/src/share/classes/com/sun/tools/javadoc/SourcePositionImpl.java	Tue Jan 20 15:17:45 2009 -0800
    13.3 @@ -25,11 +25,12 @@
    13.4  
    13.5  package com.sun.tools.javadoc;
    13.6  
    13.7 +import java.io.File;
    13.8 +import javax.tools.FileObject;
    13.9 +
   13.10  import com.sun.javadoc.SourcePosition;
   13.11  import com.sun.tools.javac.util.Position;
   13.12  
   13.13 -import java.io.File;
   13.14 -
   13.15  /**
   13.16   * A source position: filename, line number, and column number.
   13.17   *
   13.18 @@ -37,15 +38,21 @@
   13.19   * @author Neal M Gafter
   13.20   * @author Michael Van De Vanter (position representation changed to char offsets)
   13.21   */
   13.22 -class SourcePositionImpl implements SourcePosition {
   13.23 -    String filename;
   13.24 +public class SourcePositionImpl implements SourcePosition {
   13.25 +    FileObject filename;
   13.26      int position;
   13.27      Position.LineMap lineMap;
   13.28  
   13.29      /** The source file. Returns null if no file information is
   13.30       *  available. */
   13.31      public File file() {
   13.32 -        return (filename == null) ? null : new File(filename);
   13.33 +        return (filename == null) ? null : new File(filename.getName());
   13.34 +    }
   13.35 +
   13.36 +    /** The source file. Returns null if no file information is
   13.37 +     *  available. */
   13.38 +    public FileObject fileObject() {
   13.39 +        return filename;
   13.40      }
   13.41  
   13.42      /** The line in the source file. The first line is numbered 1;
   13.43 @@ -71,7 +78,7 @@
   13.44          }
   13.45      }
   13.46  
   13.47 -    private SourcePositionImpl(String file, int position,
   13.48 +    private SourcePositionImpl(FileObject file, int position,
   13.49                                 Position.LineMap lineMap) {
   13.50          super();
   13.51          this.filename = file;
   13.52 @@ -79,16 +86,27 @@
   13.53          this.lineMap = lineMap;
   13.54      }
   13.55  
   13.56 -    public static SourcePosition make(String file, int pos,
   13.57 +    public static SourcePosition make(FileObject file, int pos,
   13.58                                        Position.LineMap lineMap) {
   13.59          if (file == null) return null;
   13.60          return new SourcePositionImpl(file, pos, lineMap);
   13.61      }
   13.62  
   13.63      public String toString() {
   13.64 +        // Backwards compatibility hack. ZipFileObjects use the format
   13.65 +        // zipfile(zipentry) but javadoc has been using zipfile/zipentry
   13.66 +        String fn = filename.toString();
   13.67 +        if (fn.endsWith(")")) {
   13.68 +            int paren = fn.lastIndexOf("(");
   13.69 +            if (paren != -1)
   13.70 +                fn = fn.substring(0, paren)
   13.71 +                        + File.separatorChar
   13.72 +                        + fn.substring(paren + 1, fn.length() - 1);
   13.73 +        }
   13.74 +
   13.75          if (position == Position.NOPOS)
   13.76 -            return filename;
   13.77 +            return fn;
   13.78          else
   13.79 -            return filename + ":" + line();
   13.80 +            return fn + ":" + line();
   13.81      }
   13.82  }

mercurial