Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
616067a2
D
dragonwell8_langtools
项目概览
openanolis
/
dragonwell8_langtools
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_langtools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
616067a2
编写于
1月 10, 2013
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8004834: Add doclint support into javadoc
Reviewed-by: darcy
上级
553579f6
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
401 addition
and
54 deletion
+401
-54
src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java
...com/sun/tools/doclets/formats/html/ConfigurationImpl.java
+41
-6
src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
...com/sun/tools/doclets/internal/toolkit/Configuration.java
+3
-1
src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties
...ols/doclets/internal/toolkit/resources/doclets.properties
+2
-0
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java
...tools/doclets/internal/toolkit/util/MessageRetriever.java
+6
-5
src/share/classes/com/sun/tools/javac/comp/Enter.java
src/share/classes/com/sun/tools/javac/comp/Enter.java
+6
-2
src/share/classes/com/sun/tools/javadoc/DocEnv.java
src/share/classes/com/sun/tools/javadoc/DocEnv.java
+38
-5
src/share/classes/com/sun/tools/javadoc/DocImpl.java
src/share/classes/com/sun/tools/javadoc/DocImpl.java
+8
-2
src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java
...are/classes/com/sun/tools/javadoc/JavadocMemberEnter.java
+3
-3
src/share/classes/com/sun/tools/javadoc/RootDocImpl.java
src/share/classes/com/sun/tools/javadoc/RootDocImpl.java
+11
-2
test/com/sun/javadoc/5093723/T5093723.java
test/com/sun/javadoc/5093723/T5093723.java
+1
-1
test/com/sun/javadoc/testBadSourceFile/TestBadSourceFile.java
.../com/sun/javadoc/testBadSourceFile/TestBadSourceFile.java
+2
-2
test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
.../testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
+5
-5
test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
...adoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
+2
-2
test/com/sun/javadoc/testReturnTag/TestReturnTag.java
test/com/sun/javadoc/testReturnTag/TestReturnTag.java
+2
-2
test/com/sun/javadoc/testTagInheritence/TestTagInheritence.java
...om/sun/javadoc/testTagInheritence/TestTagInheritence.java
+2
-2
test/com/sun/javadoc/testTagMisuse/TestTagMisuse.java
test/com/sun/javadoc/testTagMisuse/TestTagMisuse.java
+2
-2
test/com/sun/javadoc/testValueTag/TestValueTag.java
test/com/sun/javadoc/testValueTag/TestValueTag.java
+2
-1
test/com/sun/javadoc/testWarnBadParamNames/TestWarnBadParamNames.java
.../javadoc/testWarnBadParamNames/TestWarnBadParamNames.java
+2
-2
test/com/sun/javadoc/testWarnings/TestWarnings.java
test/com/sun/javadoc/testWarnings/TestWarnings.java
+3
-3
test/tools/javadoc/6958836/Test.java
test/tools/javadoc/6958836/Test.java
+2
-1
test/tools/javadoc/6964914/Test.java
test/tools/javadoc/6964914/Test.java
+2
-1
test/tools/javadoc/6964914/TestStdDoclet.java
test/tools/javadoc/6964914/TestStdDoclet.java
+2
-1
test/tools/javadoc/MaxWarns.java
test/tools/javadoc/MaxWarns.java
+1
-1
test/tools/javadoc/T6551367.java
test/tools/javadoc/T6551367.java
+2
-2
test/tools/javadoc/doclint/DocLintTest.java
test/tools/javadoc/doclint/DocLintTest.java
+251
-0
未找到文件。
src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java
浏览文件 @
616067a2
/*
* Copyright (c) 1998, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -33,8 +33,10 @@ import javax.tools.JavaFileManager;
import
com.sun.javadoc.*
;
import
com.sun.tools.doclets.internal.toolkit.*
;
import
com.sun.tools.doclets.internal.toolkit.util.*
;
import
com.sun.tools.doclint.DocLint
;
import
com.sun.tools.javac.file.JavacFileManager
;
import
com.sun.tools.javac.util.Context
;
import
com.sun.tools.javadoc.RootDocImpl
;
/**
* Configure the output based on the command line options.
...
...
@@ -171,6 +173,11 @@ public class ConfigurationImpl extends Configuration {
*/
public
boolean
createoverview
=
false
;
/**
* Collected set of doclint options
*/
public
Set
<
String
>
doclintOpts
=
new
LinkedHashSet
<
String
>();
/**
* Unique Resource Handler for this package.
*/
...
...
@@ -255,6 +262,10 @@ public class ConfigurationImpl extends Configuration {
nooverview
=
true
;
}
else
if
(
opt
.
equals
(
"-overview"
))
{
overview
=
true
;
}
else
if
(
opt
.
equals
(
"-xdoclint"
))
{
doclintOpts
.
add
(
null
);
}
else
if
(
opt
.
startsWith
(
"-xdoclint:"
))
{
doclintOpts
.
add
(
opt
.
substring
(
opt
.
indexOf
(
":"
)
+
1
));
}
}
if
(
root
.
specifiedClasses
().
length
>
0
)
{
...
...
@@ -270,6 +281,10 @@ public class ConfigurationImpl extends Configuration {
}
setCreateOverview
();
setTopFile
(
root
);
if
(
root
instanceof
RootDocImpl
)
{
((
RootDocImpl
)
root
).
initDocLint
(
doclintOpts
);
}
}
/**
...
...
@@ -303,7 +318,9 @@ public class ConfigurationImpl extends Configuration {
option
.
equals
(
"-serialwarn"
)
||
option
.
equals
(
"-use"
)
||
option
.
equals
(
"-nonavbar"
)
||
option
.
equals
(
"-nooverview"
))
{
option
.
equals
(
"-nooverview"
)
||
option
.
equals
(
"-xdoclint"
)
||
option
.
startsWith
(
"-xdoclint:"
))
{
return
1
;
}
else
if
(
option
.
equals
(
"-help"
))
{
System
.
out
.
println
(
getText
(
"doclet.usage"
));
...
...
@@ -410,6 +427,16 @@ public class ConfigurationImpl extends Configuration {
return
false
;
}
noindex
=
true
;
}
else
if
(
opt
.
startsWith
(
"-xdoclint:"
))
{
if
(
opt
.
contains
(
"/"
))
{
reporter
.
printError
(
getText
(
"doclet.Option_doclint_no_qualifiers"
));
return
false
;
}
if
(!
DocLint
.
isValidOption
(
opt
.
replace
(
"-xdoclint:"
,
DocLint
.
XMSGS_CUSTOM_PREFIX
)))
{
reporter
.
printError
(
getText
(
"doclet.Option_doclint_invalid_arg"
));
return
false
;
}
}
}
return
true
;
...
...
@@ -506,8 +533,8 @@ public class ConfigurationImpl extends Configuration {
*/
@Override
public
Locale
getLocale
()
{
if
(
root
instanceof
com
.
sun
.
tools
.
javadoc
.
RootDocImpl
)
return
((
com
.
sun
.
tools
.
javadoc
.
RootDocImpl
)
root
).
getLocale
();
if
(
root
instanceof
RootDocImpl
)
return
((
RootDocImpl
)
root
).
getLocale
();
else
return
Locale
.
getDefault
();
}
...
...
@@ -518,8 +545,8 @@ public class ConfigurationImpl extends Configuration {
@Override
public
JavaFileManager
getFileManager
()
{
if
(
fileManager
==
null
)
{
if
(
root
instanceof
com
.
sun
.
tools
.
javadoc
.
RootDocImpl
)
fileManager
=
((
com
.
sun
.
tools
.
javadoc
.
RootDocImpl
)
root
).
getFileManager
();
if
(
root
instanceof
RootDocImpl
)
fileManager
=
((
RootDocImpl
)
root
).
getFileManager
();
else
fileManager
=
new
JavacFileManager
(
new
Context
(),
false
,
null
);
}
...
...
@@ -527,4 +554,12 @@ public class ConfigurationImpl extends Configuration {
}
private
JavaFileManager
fileManager
;
@Override
public
boolean
showMessage
(
SourcePosition
pos
,
String
key
)
{
if
(
root
instanceof
RootDocImpl
)
{
return
pos
==
null
||
((
RootDocImpl
)
root
).
showTagMessages
();
}
return
true
;
}
}
src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
浏览文件 @
616067a2
/*
* Copyright (c) 1997, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -781,4 +781,6 @@ public abstract class Configuration {
sourcetab
=
n
;
tabSpaces
=
String
.
format
(
"%"
+
n
+
"s"
,
""
);
}
public
abstract
boolean
showMessage
(
SourcePosition
pos
,
String
key
);
}
src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties
浏览文件 @
616067a2
...
...
@@ -11,6 +11,8 @@ doclet.Class_0_implements_serializable=Class {0} implements Serializable
doclet.Class_0_extends_implements_serializable
=
Class {0} extends {1} implements Serializable
doclet.Option_conflict
=
Option {0} conflicts with {1}
doclet.Option_reuse
=
Option reused: {0}
doclet.Option_doclint_no_qualifiers
=
Access qualifiers not permitted for -Xdoclint arguments
doclet.Option_doclint_invalid_arg
=
Invalid argument for -Xdoclint option
doclet.exception_encountered
=
{0} encountered
\n\
\t
while attempting to create file: {1}
doclet.perform_copy_exception_encountered
=
{0} encountered while
\n\
...
...
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java
浏览文件 @
616067a2
/*
* Copyright (c) 1998, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -60,9 +60,9 @@ public class MessageRetriever {
private
ResourceBundle
messageRB
;
/**
* Initilize the ResourceBundle with the given resource.
* Initi
a
lize the ResourceBundle with the given resource.
*
* @param rb the esource bundle to read.
* @param rb the
r
esource bundle to read.
*/
public
MessageRetriever
(
ResourceBundle
rb
)
{
this
.
configuration
=
null
;
...
...
@@ -71,7 +71,7 @@ public class MessageRetriever {
}
/**
* Initilize the ResourceBundle with the given resource.
* Initi
a
lize the ResourceBundle with the given resource.
*
* @param configuration the configuration
* @param resourcelocation Resource.
...
...
@@ -189,7 +189,8 @@ public class MessageRetriever {
* @param args arguments to be replaced in the message.
*/
public
void
warning
(
SourcePosition
pos
,
String
key
,
Object
...
args
)
{
printWarning
(
pos
,
getText
(
key
,
args
));
if
(
configuration
.
showMessage
(
pos
,
key
))
printWarning
(
pos
,
getText
(
key
,
args
));
}
/**
...
...
src/share/classes/com/sun/tools/javac/comp/Enter.java
浏览文件 @
616067a2
/*
* Copyright (c) 1999, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -131,7 +131,11 @@ public class Enter extends JCTree.Visitor {
predefClassDef
=
make
.
ClassDef
(
make
.
Modifiers
(
PUBLIC
),
syms
.
predefClass
.
name
,
null
,
null
,
null
,
null
);
syms
.
predefClass
.
name
,
List
.<
JCTypeParameter
>
nil
(),
null
,
List
.<
JCExpression
>
nil
(),
List
.<
JCTree
>
nil
());
predefClassDef
.
sym
=
syms
.
predefClass
;
todo
=
Todo
.
instance
(
context
);
fileManager
=
context
.
get
(
JavaFileManager
.
class
);
...
...
src/share/classes/com/sun/tools/javadoc/DocEnv.java
浏览文件 @
616067a2
/*
* Copyright (c) 2000, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -31,8 +31,10 @@ import java.util.*;
import
javax.tools.JavaFileManager
;
import
com.sun.javadoc.*
;
import
com.sun.source.util.JavacTask
;
import
com.sun.source.util.TreePath
;
import
com.sun.tools.javac.api.JavacTrees
;
import
com.sun.tools.doclint.DocLint
;
import
com.sun.tools.javac.api.BasicJavacTask
;
import
com.sun.tools.javac.code.*
;
import
com.sun.tools.javac.code.Symbol.*
;
import
com.sun.tools.javac.code.Type.ClassType
;
...
...
@@ -105,6 +107,7 @@ public class DocEnv {
Types
types
;
JavaFileManager
fileManager
;
Context
context
;
DocLint
doclint
;
WeakHashMap
<
JCTree
,
TreePath
>
treePaths
=
new
WeakHashMap
<
JCTree
,
TreePath
>();
...
...
@@ -400,6 +403,9 @@ public class DocEnv {
public
void
warning
(
DocImpl
doc
,
String
key
,
String
a1
)
{
if
(
silent
)
return
;
// suppress messages that have (probably) been covered by doclint
if
(
doclint
!=
null
&&
doc
!=
null
&&
key
.
startsWith
(
"tag"
))
return
;
messager
.
warning
(
doc
==
null
?
null
:
doc
.
position
(),
key
,
a1
);
}
...
...
@@ -732,9 +738,15 @@ public class DocEnv {
return
p
;
}
TreePath
getTreePath
(
JCCompilationUnit
toplevel
,
JCTree
tree
)
{
// don't bother to cache paths for classes and members
return
new
TreePath
(
getTreePath
(
toplevel
),
tree
);
TreePath
getTreePath
(
JCCompilationUnit
toplevel
,
JCClassDecl
tree
)
{
TreePath
p
=
treePaths
.
get
(
tree
);
if
(
p
==
null
)
treePaths
.
put
(
tree
,
p
=
new
TreePath
(
getTreePath
(
toplevel
),
tree
));
return
p
;
}
TreePath
getTreePath
(
JCCompilationUnit
toplevel
,
JCClassDecl
cdecl
,
JCTree
tree
)
{
return
new
TreePath
(
getTreePath
(
toplevel
,
cdecl
),
tree
);
}
/**
...
...
@@ -781,4 +793,25 @@ public class DocEnv {
result
|=
Modifier
.
VOLATILE
;
return
result
;
}
void
initDoclint
(
Collection
<
String
>
opts
)
{
ArrayList
<
String
>
doclintOpts
=
new
ArrayList
<
String
>();
for
(
String
opt:
opts
)
{
doclintOpts
.
add
(
opt
==
null
?
DocLint
.
XMSGS_OPTION
:
DocLint
.
XMSGS_CUSTOM_PREFIX
+
opt
);
}
if
(
doclintOpts
.
size
()
==
1
&&
doclintOpts
.
get
(
0
).
equals
(
DocLint
.
XMSGS_CUSTOM_PREFIX
+
"none"
))
{
return
;
}
JavacTask
t
=
BasicJavacTask
.
instance
(
context
);
doclint
=
new
DocLint
();
doclint
.
init
(
t
,
doclintOpts
.
toArray
(
new
String
[
doclintOpts
.
size
()]),
false
);
}
boolean
showTagMessages
()
{
return
(
doclint
==
null
);
}
}
src/share/classes/com/sun/tools/javadoc/DocImpl.java
浏览文件 @
616067a2
/*
* Copyright (c) 1997, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -126,7 +126,13 @@ public abstract class DocImpl implements Doc, Comparable<Object> {
*/
Comment
comment
()
{
if
(
comment
==
null
)
{
comment
=
new
Comment
(
this
,
documentation
());
String
d
=
documentation
();
if
(
env
.
doclint
!=
null
&&
treePath
!=
null
&&
d
.
equals
(
getCommentText
(
treePath
)))
{
env
.
doclint
.
scan
(
treePath
);
}
comment
=
new
Comment
(
this
,
d
);
}
return
comment
;
}
...
...
src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java
浏览文件 @
616067a2
/*
* Copyright (c) 2003, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -72,7 +72,7 @@ public class JavadocMemberEnter extends MemberEnter {
super
.
visitMethodDef
(
tree
);
MethodSymbol
meth
=
tree
.
sym
;
if
(
meth
==
null
||
meth
.
kind
!=
Kinds
.
MTH
)
return
;
TreePath
treePath
=
docenv
.
getTreePath
(
env
.
toplevel
,
tree
);
TreePath
treePath
=
docenv
.
getTreePath
(
env
.
toplevel
,
env
.
enclClass
,
tree
);
if
(
meth
.
isConstructor
())
docenv
.
makeConstructorDoc
(
meth
,
treePath
);
else
if
(
isAnnotationTypeElement
(
meth
))
...
...
@@ -90,7 +90,7 @@ public class JavadocMemberEnter extends MemberEnter {
if
(
tree
.
sym
!=
null
&&
tree
.
sym
.
kind
==
Kinds
.
VAR
&&
!
isParameter
(
tree
.
sym
))
{
docenv
.
makeFieldDoc
(
tree
.
sym
,
docenv
.
getTreePath
(
env
.
toplevel
,
tree
));
docenv
.
makeFieldDoc
(
tree
.
sym
,
docenv
.
getTreePath
(
env
.
toplevel
,
env
.
enclClass
,
tree
));
}
}
...
...
src/share/classes/com/sun/tools/javadoc/RootDocImpl.java
浏览文件 @
616067a2
/*
* Copyright (c) 1997, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -26,13 +26,14 @@
package
com.sun.tools.javadoc
;
import
java.io.IOException
;
import
java.util.Collection
;
import
java.util.Locale
;
import
javax.tools.JavaFileManager
;
import
javax.tools.JavaFileObject
;
import
javax.tools.StandardJavaFileManager
;
import
com.sun.javadoc.*
;
import
com.sun.tools.javac.tree.JCTree.JCClassDecl
;
import
com.sun.tools.javac.util.List
;
import
com.sun.tools.javac.util.ListBuffer
;
...
...
@@ -375,4 +376,12 @@ public class RootDocImpl extends DocImpl implements RootDoc {
public
JavaFileManager
getFileManager
()
{
return
env
.
fileManager
;
}
public
void
initDocLint
(
Collection
<
String
>
opts
)
{
env
.
initDoclint
(
opts
);
}
public
boolean
showTagMessages
()
{
return
env
.
showTagMessages
();
}
}
test/com/sun/javadoc/5093723/T5093723.java
浏览文件 @
616067a2
...
...
@@ -36,7 +36,7 @@ public class T5093723 extends JavadocTester {
private
static
final
String
BUG_ID
=
"5093723"
;
private
static
final
String
[]
ARGS
=
new
String
[]
{
"-d"
,
BUG_ID
+
".out"
,
"-source"
,
"5"
,
"-d"
,
BUG_ID
+
".out"
,
"-source"
,
"5"
,
"-Xdoclint:none"
,
SRC_DIR
+
"/DocumentedClass.java"
,
SRC_DIR
+
"/UndocumentedClass.java"
};
...
...
test/com/sun/javadoc/testBadSourceFile/TestBadSourceFile.java
浏览文件 @
616067a2
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -40,7 +40,7 @@ public class TestBadSourceFile extends JavadocTester {
//Javadoc arguments.
private
static
final
String
[]
ARGS
=
new
String
[]
{
"-d"
,
BUG_ID
,
SRC_DIR
+
FS
+
"C2.java"
"-
Xdoclint:none"
,
"-
d"
,
BUG_ID
,
SRC_DIR
+
FS
+
"C2.java"
};
//Input for string search tests.
...
...
test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
浏览文件 @
616067a2
/*
* Copyright (c) 2009, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -222,19 +222,19 @@ public class TestHtmlDefinitionListTag extends JavadocTester {
private
static
final
String
[]
ARGS1
=
new
String
[]
{
"-d"
,
BUG_ID
,
"-sourcepath"
,
SRC_DIR
,
"pkg1"
};
"-
Xdoclint:none"
,
"-
d"
,
BUG_ID
,
"-sourcepath"
,
SRC_DIR
,
"pkg1"
};
private
static
final
String
[]
ARGS2
=
new
String
[]
{
"-d"
,
BUG_ID
,
"-nocomment"
,
"-sourcepath"
,
SRC_DIR
,
"pkg1"
};
"-
Xdoclint:none"
,
"-
d"
,
BUG_ID
,
"-nocomment"
,
"-sourcepath"
,
SRC_DIR
,
"pkg1"
};
private
static
final
String
[]
ARGS3
=
new
String
[]
{
"-d"
,
BUG_ID
,
"-nodeprecated"
,
"-sourcepath"
,
SRC_DIR
,
"pkg1"
};
"-
Xdoclint:none"
,
"-
d"
,
BUG_ID
,
"-nodeprecated"
,
"-sourcepath"
,
SRC_DIR
,
"pkg1"
};
private
static
final
String
[]
ARGS4
=
new
String
[]
{
"-d"
,
BUG_ID
,
"-nocomment"
,
"-nodeprecated"
,
"-sourcepath"
,
SRC_DIR
,
"pkg1"
};
"-
Xdoclint:none"
,
"-
d"
,
BUG_ID
,
"-nocomment"
,
"-nodeprecated"
,
"-sourcepath"
,
SRC_DIR
,
"pkg1"
};
/**
* The entry point of the test.
...
...
test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
浏览文件 @
616067a2
/*
* Copyright (c) 2003, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -40,7 +40,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
//Javadoc arguments.
private
static
final
String
[]
ARGS
=
new
String
[]
{
"-d"
,
BUG_ID
,
"-use"
,
"-source"
,
"1.5"
,
"-sourcepath"
,
SRC_DIR
,
"pkg"
,
"pkg1"
,
"pkg2"
"-
Xdoclint:none"
,
"-
d"
,
BUG_ID
,
"-use"
,
"-source"
,
"1.5"
,
"-sourcepath"
,
SRC_DIR
,
"pkg"
,
"pkg1"
,
"pkg2"
};
//Input for string search tests.
...
...
test/com/sun/javadoc/testReturnTag/TestReturnTag.java
浏览文件 @
616067a2
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -39,7 +39,7 @@ public class TestReturnTag extends JavadocTester {
//Javadoc arguments.
private
static
final
String
[]
ARGS
=
new
String
[]
{
"-d"
,
BUG_ID
,
"-sourcepath"
,
SRC_DIR
,
SRC_DIR
+
FS
+
"TestReturnTag.java"
"-
Xdoclint:none"
,
"-
d"
,
BUG_ID
,
"-sourcepath"
,
SRC_DIR
,
SRC_DIR
+
FS
+
"TestReturnTag.java"
};
//Input for string search tests.
...
...
test/com/sun/javadoc/testTagInheritence/TestTagInheritence.java
浏览文件 @
616067a2
/*
* Copyright (c) 2002, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -36,7 +36,7 @@ public class TestTagInheritence extends JavadocTester {
private
static
final
String
BUG_ID
=
"4496223-4496270-4618686-4720974-4812240-6253614-6253604"
;
private
static
final
String
[]
ARGS
=
new
String
[]
{
"-d"
,
BUG_ID
,
"-sourcepath"
,
SRC_DIR
,
"pkg"
,
"firstSentence"
,
"firstSentence2"
"-
Xdoclint:none"
,
"-
d"
,
BUG_ID
,
"-sourcepath"
,
SRC_DIR
,
"pkg"
,
"firstSentence"
,
"firstSentence2"
};
/**
...
...
test/com/sun/javadoc/testTagMisuse/TestTagMisuse.java
浏览文件 @
616067a2
/*
* Copyright (c) 2001, 20
02
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 20
13
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -42,7 +42,7 @@ public class TestTagMisuse extends JavadocTester {
};
private
static
final
String
[][]
NEGATED_TEST
=
NO_TEST
;
private
static
final
String
[]
ARGS
=
new
String
[]
{
"-d"
,
BUG_ID
,
SRC_DIR
+
FS
+
"TestTagMisuse.java"
"-
Xdoclint:none"
,
"-
d"
,
BUG_ID
,
SRC_DIR
+
FS
+
"TestTagMisuse.java"
};
/**
...
...
test/com/sun/javadoc/testValueTag/TestValueTag.java
浏览文件 @
616067a2
/*
* Copyright (c) 2003, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -41,6 +41,7 @@ public class TestValueTag extends JavadocTester {
//Javadoc arguments.
private
static
final
String
[]
ARGS
=
new
String
[]
{
"-Xdoclint:none"
,
"-d"
,
BUG_ID
,
"-sourcepath"
,
SRC_DIR
,
"-tag"
,
"todo"
,
"pkg1"
,
"pkg2"
};
...
...
test/com/sun/javadoc/testWarnBadParamNames/TestWarnBadParamNames.java
浏览文件 @
616067a2
/*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -43,7 +43,7 @@ public class TestWarnBadParamNames extends JavadocTester {
};
private
static
final
String
[][]
NEGATED_TEST
=
NO_TEST
;
private
static
final
String
[]
ARGS
=
new
String
[]
{
"-d"
,
BUG_ID
,
SRC_DIR
+
FS
+
"C.java"
"-
Xdoclint:none"
,
"-
d"
,
BUG_ID
,
SRC_DIR
+
FS
+
"C.java"
};
/**
...
...
test/com/sun/javadoc/testWarnings/TestWarnings.java
浏览文件 @
616067a2
/*
* Copyright (c) 2004, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -43,11 +43,11 @@ public class TestWarnings extends JavadocTester {
//Javadoc arguments.
private
static
final
String
[]
ARGS
=
new
String
[]
{
"-d"
,
BUG_ID
,
"-sourcepath"
,
SRC_DIR
,
"pkg"
"-
Xdoclint:none"
,
"-
d"
,
BUG_ID
,
"-sourcepath"
,
SRC_DIR
,
"pkg"
};
private
static
final
String
[]
ARGS2
=
new
String
[]
{
"-d"
,
BUG_ID
,
"-private"
,
"-sourcepath"
,
SRC_DIR
,
"pkg"
"-
Xdoclint:none"
,
"-
d"
,
BUG_ID
,
"-private"
,
"-sourcepath"
,
SRC_DIR
,
"pkg"
};
//Input for string search tests.
...
...
test/tools/javadoc/6958836/Test.java
浏览文件 @
616067a2
/*
* Copyright (c) 2010, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -61,6 +61,7 @@ public class Test {
// Force en_US locale in lieu of something like -XDrawDiagnostics.
// For some reason, this must be the first option when used.
opts
.
addAll
(
list
(
"-locale"
,
"en_US"
));
opts
.
add
(
"-Xdoclint:none"
);
opts
.
addAll
(
list
(
"-classpath"
,
System
.
getProperty
(
"test.src"
)));
opts
.
addAll
(
list
(
"-d"
,
testOutDir
.
getPath
()));
opts
.
addAll
(
testOpts
);
...
...
test/tools/javadoc/6964914/Test.java
浏览文件 @
616067a2
/*
* Copyright (c) 2010, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 201
3
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -45,6 +45,7 @@ public class Test {
void
javadoc
(
String
path
,
String
expect
)
{
File
testSrc
=
new
File
(
System
.
getProperty
(
"test.src"
));
String
[]
args
=
{
"-Xdoclint:none"
,
"-source"
,
"1.4"
,
// enables certain Parser warnings
"-bootclasspath"
,
System
.
getProperty
(
"sun.boot.class.path"
),
"-classpath"
,
"."
,
...
...
test/tools/javadoc/6964914/TestStdDoclet.java
浏览文件 @
616067a2
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -57,6 +57,7 @@ public class TestStdDoclet {
Process
p
=
new
ProcessBuilder
()
.
command
(
javadoc
.
getPath
(),
"-J-Xbootclasspath:"
+
System
.
getProperty
(
"sun.boot.class.path"
),
"-Xdoclint:none"
,
"-package"
,
new
File
(
testSrc
,
thisClassName
+
".java"
).
getPath
())
.
redirectErrorStream
(
true
)
...
...
test/tools/javadoc/MaxWarns.java
浏览文件 @
616067a2
...
...
@@ -74,7 +74,7 @@ public class MaxWarns {
String
javadoc
(
File
f
)
{
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
String
[]
args
=
{
"-d"
,
"api"
,
f
.
getPath
()
};
String
[]
args
=
{
"-
Xdoclint:none"
,
"-
d"
,
"api"
,
f
.
getPath
()
};
int
rc
=
com
.
sun
.
tools
.
javadoc
.
Main
.
execute
(
"javadoc"
,
pw
,
pw
,
pw
,
com
.
sun
.
tools
.
doclets
.
standard
.
Standard
.
class
.
getName
(),
args
);
pw
.
flush
();
...
...
test/tools/javadoc/T6551367.java
浏览文件 @
616067a2
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2013,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -46,7 +46,7 @@ public class T6551367 extends com.sun.tools.doclets.standard.Standard {
File
source
=
new
File
(
testSrc
,
file
);
int
rc
=
execute
(
"javadoc"
,
"T6551367"
,
T6551367
.
class
.
getClassLoader
(),
new
String
[]{
source
.
getPath
(),
"-d"
,
destDir
.
getAbsolutePath
()});
new
String
[]{
"-Xdoclint:none"
,
source
.
getPath
(),
"-d"
,
destDir
.
getAbsolutePath
()});
if
(
rc
!=
0
)
throw
new
Error
(
"unexpected exit from javadoc: "
+
rc
);
}
...
...
test/tools/javadoc/doclint/DocLintTest.java
0 → 100644
浏览文件 @
616067a2
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8004834
* @summary Add doclint support into javadoc
*/
import
java.io.File
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.net.URI
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.EnumSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
javax.tools.Diagnostic
;
import
javax.tools.DocumentationTool
;
import
javax.tools.DocumentationTool.DocumentationTask
;
import
javax.tools.JavaFileObject
;
import
javax.tools.SimpleJavaFileObject
;
import
javax.tools.StandardJavaFileManager
;
import
javax.tools.StandardLocation
;
import
javax.tools.ToolProvider
;
import
static
javax
.
tools
.
Diagnostic
.
Kind
.*;
import
com.sun.tools.javac.main.Main
;
public
class
DocLintTest
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
new
DocLintTest
().
run
();
}
DocumentationTool
javadoc
;
StandardJavaFileManager
fm
;
JavaFileObject
file
;
final
String
code
=
/* 01 */
"/** Class comment. */\n"
+
/* 02 */
"public class Test {\n"
+
/* 03 */
" /** Method comment. */\n"
+
/* 04 */
" public void method() { }\n"
+
/* 05 */
"\n"
+
/* 06 */
" /** Syntax < error. */\n"
+
/* 07 */
" private void syntaxError() { }\n"
+
/* 08 */
"\n"
+
/* 09 */
" /** @see DoesNotExist */\n"
+
/* 10 */
" protected void referenceError() { }\n"
+
/* 11 */
"\n"
+
/* 12 */
" /** @return */\n"
+
/* 13 */
" public int emptyReturn() { return 0; }\n"
+
/* 14 */
"}\n"
;
private
final
String
rawDiags
=
"-XDrawDiagnostics"
;
private
enum
Message
{
// doclint messages
DL_ERR6
(
ERROR
,
"Test.java:6:16: compiler.err.proc.messager: malformed HTML"
),
DL_ERR9
(
ERROR
,
"Test.java:9:14: compiler.err.proc.messager: reference not found"
),
DL_WRN12
(
WARNING
,
"Test.java:12:9: compiler.warn.proc.messager: no description for @return"
),
// doclint messages when -XDrawDiagnostics is not in effect
DL_ERR9A
(
ERROR
,
"Test.java:9: error: reference not found"
),
DL_WRN12A
(
WARNING
,
"Test.java:12: warning: no description for @return"
),
// javadoc messages about bad content: these should only appear when doclint is disabled
JD_WRN10
(
WARNING
,
"Test.java:10: warning - Tag @see: reference not found: DoesNotExist"
),
JD_WRN13
(
WARNING
,
"Test.java:13: warning - @return tag has no arguments."
),
// javadoc messages for bad options
OPT_BADARG
(
ERROR
,
"javadoc: error - Invalid argument for -Xdoclint option"
),
OPT_BADQUAL
(
ERROR
,
"javadoc: error - Access qualifiers not permitted for -Xdoclint arguments"
);
final
Diagnostic
.
Kind
kind
;
final
String
text
;
static
Message
get
(
String
text
)
{
for
(
Message
m:
values
())
{
if
(
m
.
text
.
equals
(
text
))
return
m
;
}
return
null
;
}
Message
(
Diagnostic
.
Kind
kind
,
String
text
)
{
this
.
kind
=
kind
;
this
.
text
=
text
;
}
@Override
public
String
toString
()
{
return
"["
+
kind
+
",\""
+
text
+
"\"]"
;
}
}
void
run
()
throws
Exception
{
javadoc
=
ToolProvider
.
getSystemDocumentationTool
();
fm
=
javadoc
.
getStandardFileManager
(
null
,
null
,
null
);
fm
.
setLocation
(
StandardLocation
.
CLASS_OUTPUT
,
Arrays
.
asList
(
new
File
(
"."
)));
file
=
new
SimpleJavaFileObject
(
URI
.
create
(
"Test.java"
),
JavaFileObject
.
Kind
.
SOURCE
)
{
@Override
public
CharSequence
getCharContent
(
boolean
ignoreEncoding
)
{
return
code
;
}
};
test
(
Collections
.<
String
>
emptyList
(),
Main
.
Result
.
ERROR
,
EnumSet
.
of
(
Message
.
DL_ERR9A
,
Message
.
DL_WRN12A
));
test
(
Arrays
.
asList
(
rawDiags
),
Main
.
Result
.
ERROR
,
EnumSet
.
of
(
Message
.
DL_ERR9
,
Message
.
DL_WRN12
));
test
(
Arrays
.
asList
(
"-Xdoclint:none"
),
Main
.
Result
.
OK
,
EnumSet
.
of
(
Message
.
JD_WRN10
,
Message
.
JD_WRN13
));
test
(
Arrays
.
asList
(
rawDiags
,
"-Xdoclint"
),
Main
.
Result
.
ERROR
,
EnumSet
.
of
(
Message
.
DL_ERR9
,
Message
.
DL_WRN12
));
test
(
Arrays
.
asList
(
rawDiags
,
"-Xdoclint:all/public"
),
Main
.
Result
.
ERROR
,
EnumSet
.
of
(
Message
.
OPT_BADQUAL
));
test
(
Arrays
.
asList
(
rawDiags
,
"-Xdoclint:all"
,
"-public"
),
Main
.
Result
.
OK
,
EnumSet
.
of
(
Message
.
DL_WRN12
));
test
(
Arrays
.
asList
(
rawDiags
,
"-Xdoclint:syntax"
),
Main
.
Result
.
OK
,
EnumSet
.
of
(
Message
.
DL_WRN12
));
test
(
Arrays
.
asList
(
rawDiags
,
"-Xdoclint:syntax"
,
"-private"
),
Main
.
Result
.
ERROR
,
EnumSet
.
of
(
Message
.
DL_ERR6
,
Message
.
DL_WRN12
));
test
(
Arrays
.
asList
(
rawDiags
,
"-Xdoclint:reference"
),
Main
.
Result
.
ERROR
,
EnumSet
.
of
(
Message
.
DL_ERR9
));
test
(
Arrays
.
asList
(
rawDiags
,
"-Xdoclint:badarg"
),
Main
.
Result
.
ERROR
,
EnumSet
.
of
(
Message
.
OPT_BADARG
));
if
(
errors
>
0
)
throw
new
Exception
(
errors
+
" errors occurred"
);
}
void
test
(
List
<
String
>
opts
,
Main
.
Result
expectResult
,
Set
<
Message
>
expectMessages
)
{
System
.
err
.
println
(
"test: "
+
opts
);
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
List
<
JavaFileObject
>
files
=
Arrays
.
asList
(
file
);
try
{
DocumentationTask
t
=
javadoc
.
getTask
(
pw
,
fm
,
null
,
null
,
opts
,
files
);
boolean
ok
=
t
.
call
();
pw
.
close
();
String
out
=
sw
.
toString
().
replaceAll
(
"[\r\n]+"
,
"\n"
);
if
(!
out
.
isEmpty
())
System
.
err
.
println
(
out
);
if
(
ok
&&
expectResult
!=
Main
.
Result
.
OK
)
{
error
(
"Compilation succeeded unexpectedly"
);
}
else
if
(!
ok
&&
expectResult
!=
Main
.
Result
.
ERROR
)
{
error
(
"Compilation failed unexpectedly"
);
}
else
check
(
out
,
expectMessages
);
}
catch
(
IllegalArgumentException
e
)
{
System
.
err
.
println
(
e
);
String
expectOut
=
expectMessages
.
iterator
().
next
().
text
;
if
(
expectResult
!=
Main
.
Result
.
CMDERR
)
error
(
"unexpected exception caught"
);
else
if
(!
e
.
getMessage
().
equals
(
expectOut
))
{
error
(
"unexpected exception message: "
+
e
.
getMessage
()
+
" expected: "
+
expectOut
);
}
}
// if (errors > 0)
// throw new Error("stop");
}
private
void
check
(
String
out
,
Set
<
Message
>
expect
)
{
Pattern
ignore
=
Pattern
.
compile
(
"^(Building|Constructing|Generating|Loading|Standard|Starting| ) .*"
);
Pattern
stats
=
Pattern
.
compile
(
"^([1-9]+) (error|warning)(s?)"
);
Set
<
Message
>
found
=
EnumSet
.
noneOf
(
Message
.
class
);
int
e
=
0
,
w
=
0
;
for
(
String
line:
out
.
split
(
"[\r\n]+"
))
{
if
(
ignore
.
matcher
(
line
).
matches
())
continue
;
Matcher
s
=
stats
.
matcher
(
line
);
if
(
s
.
matches
())
{
int
i
=
Integer
.
valueOf
(
s
.
group
(
1
));
if
(
s
.
group
(
2
).
equals
(
"error"
))
e
++;
else
w
++;
continue
;
}
Message
m
=
Message
.
get
(
line
);
if
(
m
==
null
)
error
(
"Unexpected line: "
+
line
);
else
found
.
add
(
m
);
}
for
(
Message
m:
expect
)
{
if
(!
found
.
contains
(
m
))
error
(
"expected message not found: "
+
m
.
text
);
}
for
(
Message
m:
found
)
{
if
(!
expect
.
contains
(
m
))
error
(
"unexpected message found: "
+
m
.
text
);
}
}
void
error
(
String
msg
)
{
System
.
err
.
println
(
"Error: "
+
msg
);
errors
++;
}
int
errors
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录