Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apidoc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
apidoc
Commits
80acc032
Commit
80acc032
authored
Mar 26, 2020
by
duanledexianxianxian
😁
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
46cafbb5
e019915f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
14 deletions
+36
-14
apidoc-core/src/main/java/kim/apidoc/core/parser/VisitorParser.java
...e/src/main/java/kim/apidoc/core/parser/VisitorParser.java
+36
-14
No files found.
apidoc-core/src/main/java/kim/apidoc/core/parser/VisitorParser.java
View file @
80acc032
...
...
@@ -9,46 +9,68 @@ import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import
com.github.javaparser.ast.body.MethodDeclaration
;
import
com.github.javaparser.ast.visitor.VoidVisitorAdapter
;
/**
* The type Visitor parser.
*/
public
class
VisitorParser
extends
VoidVisitorAdapter
<
Node
>
{
/**
* The Parser strategy.
*/
private
ParserStrategy
parserStrategy
;
/**
* Sets parser strategy.
*
* @param parserStrategy the parser strategy
*/
public
void
setParserStrategy
(
ParserStrategy
parserStrategy
)
{
this
.
parserStrategy
=
parserStrategy
;
}
/**
* 类或者接口声明
* @param classOrInterfaceDeclaration
* @param arg
*/
@Override
public
void
visit
(
final
ClassOrInterfaceDeclaration
n
,
final
Node
arg
)
{
public
void
visit
(
final
ClassOrInterfaceDeclaration
classOrInterfaceDeclaratio
n
,
final
Node
arg
)
{
if
(
arg
instanceof
Project
&&
parserStrategy
.
accept
(
n
))
{
if
(
arg
instanceof
Project
&&
parserStrategy
.
accept
(
classOrInterfaceDeclaratio
n
))
{
Project
project
=
(
Project
)
arg
;
// 章节
Chapter
chapter
=
new
Chapter
();
n
.
getFullyQualifiedName
().
ifPresent
(
chapter:
:
setId
);
chapter
.
setName
(
n
.
getNameAsString
());
n
.
getComment
().
ifPresent
(
chapter:
:
accept
);
classOrInterfaceDeclaratio
n
.
getFullyQualifiedName
().
ifPresent
(
chapter:
:
setId
);
chapter
.
setName
(
classOrInterfaceDeclaratio
n
.
getNameAsString
());
classOrInterfaceDeclaratio
n
.
getComment
().
ifPresent
(
chapter:
:
accept
);
OptionalHelper
.
any
(
chapter
.
getTag
(
"book"
),
chapter
.
getTag
(
"group"
))
.
ifPresent
(
tag
->
chapter
.
setBookName
(
tag
.
getContent
()));
parserStrategy
.
visit
(
n
,
chapter
);
parserStrategy
.
visit
(
classOrInterfaceDeclaratio
n
,
chapter
);
project
.
addChapter
(
chapter
);
super
.
visit
(
n
,
chapter
);
super
.
visit
(
classOrInterfaceDeclaratio
n
,
chapter
);
}
}
/**
* 方法声明
* @param methodDeclaration
* @param arg
*/
@Override
public
void
visit
(
final
MethodDeclaration
n
,
final
Node
arg
)
{
if
(
arg
instanceof
Chapter
&&
parserStrategy
.
accept
(
n
))
{
public
void
visit
(
final
MethodDeclaration
methodDeclaratio
n
,
final
Node
arg
)
{
if
(
arg
instanceof
Chapter
&&
parserStrategy
.
accept
(
methodDeclaratio
n
))
{
Chapter
chapter
=
(
Chapter
)
arg
;
Section
section
=
new
Section
();
section
.
setId
(
n
.
getNameAsString
());
section
.
setName
(
n
.
getNameAsString
());
section
.
setId
(
methodDeclaratio
n
.
getNameAsString
());
section
.
setName
(
methodDeclaratio
n
.
getNameAsString
());
section
.
setIndex
(
chapter
.
getSections
().
size
());
n
.
getComment
().
ifPresent
(
section:
:
accept
);
methodDeclaratio
n
.
getComment
().
ifPresent
(
section:
:
accept
);
parserStrategy
.
visit
(
n
,
chapter
,
section
);
parserStrategy
.
visit
(
methodDeclaratio
n
,
chapter
,
section
);
chapter
.
getSections
().
add
(
section
);
super
.
visit
(
n
,
section
);
super
.
visit
(
methodDeclaratio
n
,
section
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment