FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
RxJava/src/test/java/io/reactivex/BaseTypeParser.java at 2.x · hemanthgit/RxJava · GitHub
hemanthgit
/
RxJava
Public
forked from
ReactiveX/RxJava
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
RxJava
/
src
/
test
/
java
/
io
/
reactivex
/
BaseTypeParser.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
145 lines (108 loc) · 5.16 KB
Breadcrumbs
RxJava
/
src
/
test
/
java
/
io
/
reactivex
/
BaseTypeParser.java
Copy path
File metadata and controls
145 lines (108 loc) · 5.16 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/**
* Copyright (c) 2016-present, RxJava Contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
* the License for the specific language governing permissions and limitations under the License.
*/
package
io
.
reactivex
;
import
java
.
io
.
File
;
import
java
.
util
.*;
/**
* Parses the java file of a reactive base type to allow discovering Javadoc mistakes algorithmically.
*/
public
final
class
BaseTypeParser
{
private
BaseTypeParser
() {
throw
new
IllegalStateException
(
"No instances!"
);
}
public
static
class
RxMethod
{
public
String
signature
;
public
String
backpressureKind
;
public
String
schedulerKind
;
public
String
javadoc
;
public
String
backpressureDocumentation
;
public
String
schedulerDocumentation
;
public
int
javadocLine
;
public
int
methodLine
;
public
int
backpressureDocLine
;
public
int
schedulerDocLine
;
}
public
static
List
<
RxMethod
>
parse
(
File
f
,
String
baseClassName
)
throws
Exception
{
List
<
RxMethod
>
list
=
new
ArrayList
<
RxMethod
>();
StringBuilder
b
=
JavadocForAnnotations
.
readFile
(
f
);
int
baseIndex
=
b
.
indexOf
(
"public abstract class "
+
baseClassName
);
if
(
baseIndex
<
0
) {
throw
new
AssertionError
(
"Wrong base class file: "
+
baseClassName
);
}
for
(;;) {
RxMethod
m
=
new
RxMethod
();
int
javadocStart
=
b
.
indexOf
(
"/**"
,
baseIndex
);
if
(
javadocStart
<
0
) {
break
;
}
int
javadocEnd
=
b
.
indexOf
(
"*/"
,
javadocStart
+
2
);
m
.
javadoc
=
b
.
substring
(
javadocStart
,
javadocEnd
+
2
);
m
.
javadocLine
=
JavadocForAnnotations
.
lineNumber
(
b
,
javadocStart
);
int
backpressureDoc
=
b
.
indexOf
(
"<dt><b>Backpressure:</b></dt>"
,
javadocStart
);
if
(
backpressureDoc
>
0
&&
backpressureDoc
<
javadocEnd
) {
m
.
backpressureDocLine
=
JavadocForAnnotations
.
lineNumber
(
b
,
backpressureDoc
);
int
nextDD
=
b
.
indexOf
(
"</dd>"
,
backpressureDoc
);
if
(
nextDD
>
0
&&
nextDD
<
javadocEnd
) {
m
.
backpressureDocumentation
=
b
.
substring
(
backpressureDoc
,
nextDD
+
5
);
}
}
int
schedulerDoc
=
b
.
indexOf
(
"<dt><b>Scheduler:</b></dt>"
,
javadocStart
);
if
(
schedulerDoc
>
0
&&
schedulerDoc
<
javadocEnd
) {
m
.
schedulerDocLine
=
JavadocForAnnotations
.
lineNumber
(
b
,
schedulerDoc
);
int
nextDD
=
b
.
indexOf
(
"</dd>"
,
schedulerDoc
);
if
(
nextDD
>
0
&&
nextDD
<
javadocEnd
) {
m
.
schedulerDocumentation
=
b
.
substring
(
schedulerDoc
,
nextDD
+
5
);
}
}
int
staticMethodDef
=
b
.
indexOf
(
"public static "
,
javadocEnd
+
2
);
if
(
staticMethodDef
<
0
) {
staticMethodDef
=
Integer
.
MAX_VALUE
;
}
int
instanceMethodDef
=
b
.
indexOf
(
"public final "
,
javadocEnd
+
2
);
if
(
instanceMethodDef
<
0
) {
instanceMethodDef
=
Integer
.
MAX_VALUE
;
}
int
javadocStartNext
=
b
.
indexOf
(
"/**"
,
javadocEnd
+
2
);
if
(
javadocStartNext
<
0
) {
javadocStartNext
=
Integer
.
MAX_VALUE
;
}
int
definitionStart
= -
1
;
if
(
staticMethodDef
>
0
&&
staticMethodDef
<
javadocStartNext
&&
staticMethodDef
<
instanceMethodDef
) {
definitionStart
=
staticMethodDef
;
}
if
(
instanceMethodDef
>
0
&&
instanceMethodDef
<
javadocStartNext
&&
instanceMethodDef
<
staticMethodDef
) {
definitionStart
=
instanceMethodDef
;
}
if
(
definitionStart
>
0
) {
int
methodDefEnd
=
b
.
indexOf
(
"{"
,
definitionStart
);
m
.
signature
=
b
.
substring
(
definitionStart
,
methodDefEnd
+
1
);
m
.
methodLine
=
JavadocForAnnotations
.
lineNumber
(
b
,
definitionStart
);
int
backpressureSpec
=
b
.
indexOf
(
"@BackpressureSupport("
,
javadocEnd
);
if
(
backpressureSpec
>
0
&&
backpressureSpec
<
definitionStart
) {
int
backpressureSpecEnd
=
b
.
indexOf
(
")"
,
backpressureSpec
+
21
);
m
.
backpressureKind
=
b
.
substring
(
backpressureSpec
+
21
,
backpressureSpecEnd
);
}
int
schhedulerSpec
=
b
.
indexOf
(
"@SchedulerSupport("
,
javadocEnd
);
if
(
schhedulerSpec
>
0
&&
schhedulerSpec
<
definitionStart
) {
int
schedulerSpecEnd
=
b
.
indexOf
(
")"
,
schhedulerSpec
+
18
);
m
.
schedulerKind
=
b
.
substring
(
schhedulerSpec
+
18
,
schedulerSpecEnd
);
}
list
.
add
(
m
);
baseIndex
=
methodDefEnd
;
}
else
{
baseIndex
=
javadocEnd
+
2
;
}
}
return
list
;
}
}
Back
|
FazBrowse Home
|
New Git URL