41
41
import java .nio .file .Path ;
42
42
import java .util .Objects ;
43
43
44
- public class JavaParserAdapter {
44
+ public class JavaParserAdapter {
45
45
46
46
/**
47
47
* Wraps the {@link JavaParser}.
@@ -56,11 +56,11 @@ public static JavaParserAdapter of(JavaParser parser) {
56
56
57
57
private final JavaParser parser ;
58
58
59
- public JavaParserAdapter (JavaParser parser ) {
59
+ public JavaParserAdapter (JavaParser parser ) {
60
60
this .parser = Objects .requireNonNull (parser , "A non-null parser should be provided." );
61
61
}
62
62
63
- public JavaParser getParser () {
63
+ public JavaParser getParser () {
64
64
return parser ;
65
65
}
66
66
@@ -80,119 +80,119 @@ private <T extends Node> T handleResult(ParseResult<T> result) {
80
80
throw new ParseProblemException (result .getProblems ());
81
81
}
82
82
83
- public ParserConfiguration getParserConfiguration () {
83
+ public ParserConfiguration getParserConfiguration () {
84
84
return parser .getParserConfiguration ();
85
85
}
86
86
87
- public CompilationUnit parse (InputStream in ) {
87
+ public CompilationUnit parse (InputStream in ) {
88
88
return handleResult (getParser ().parse (in ));
89
89
}
90
90
91
- public CompilationUnit parse (File file ) throws FileNotFoundException {
91
+ public CompilationUnit parse (File file ) throws FileNotFoundException {
92
92
return handleResult (getParser ().parse (file ));
93
93
}
94
94
95
- public CompilationUnit parse (Path path ) throws IOException {
95
+ public CompilationUnit parse (Path path ) throws IOException {
96
96
return handleResult (getParser ().parse (path ));
97
97
}
98
98
99
- public CompilationUnit parse (Reader reader ) {
99
+ public CompilationUnit parse (Reader reader ) {
100
100
return handleResult (getParser ().parse (reader ));
101
101
}
102
102
103
- public CompilationUnit parse (String code ) {
103
+ public CompilationUnit parse (String code ) {
104
104
return handleResult (getParser ().parse (code ));
105
105
}
106
106
107
- public CompilationUnit parseResource (String path ) throws IOException {
107
+ public CompilationUnit parseResource (String path ) throws IOException {
108
108
return handleResult (getParser ().parseResource (path ));
109
109
}
110
110
111
- public BlockStmt parseBlock (String blockStatement ) {
111
+ public BlockStmt parseBlock (String blockStatement ) {
112
112
return handleResult (getParser ().parseBlock (blockStatement ));
113
113
}
114
114
115
- public Statement parseStatement (String statement ) {
115
+ public Statement parseStatement (String statement ) {
116
116
return handleResult (getParser ().parseStatement (statement ));
117
117
}
118
118
119
- public ImportDeclaration parseImport (String importDeclaration ) {
119
+ public ImportDeclaration parseImport (String importDeclaration ) {
120
120
return handleResult (getParser ().parseImport (importDeclaration ));
121
121
}
122
122
123
- public <T extends Expression > T parseExpression (String expression ) {
123
+ public <T extends Expression > T parseExpression (String expression ) {
124
124
return handleResult (getParser ().parseExpression (expression ));
125
125
}
126
126
127
- public AnnotationExpr parseAnnotation (String annotation ) {
127
+ public AnnotationExpr parseAnnotation (String annotation ) {
128
128
return handleResult (getParser ().parseAnnotation (annotation ));
129
129
}
130
130
131
- public BodyDeclaration <?> parseAnnotationBodyDeclaration (String body ) {
131
+ public BodyDeclaration <?> parseAnnotationBodyDeclaration (String body ) {
132
132
return handleResult (getParser ().parseAnnotationBodyDeclaration (body ));
133
133
}
134
134
135
- public BodyDeclaration <?> parseBodyDeclaration (String body ) {
135
+ public BodyDeclaration <?> parseBodyDeclaration (String body ) {
136
136
return handleResult (getParser ().parseBodyDeclaration (body ));
137
137
}
138
138
139
- public ClassOrInterfaceType parseClassOrInterfaceType (String type ) {
139
+ public ClassOrInterfaceType parseClassOrInterfaceType (String type ) {
140
140
return handleResult (getParser ().parseClassOrInterfaceType (type ));
141
141
}
142
142
143
- public Type parseType (String type ) {
143
+ public Type parseType (String type ) {
144
144
return handleResult (getParser ().parseType (type ));
145
145
}
146
146
147
- public VariableDeclarationExpr parseVariableDeclarationExpr (String declaration ) {
147
+ public VariableDeclarationExpr parseVariableDeclarationExpr (String declaration ) {
148
148
return handleResult (getParser ().parseVariableDeclarationExpr (declaration ));
149
149
}
150
150
151
- public Javadoc parseJavadoc (String content ) {
151
+ public Javadoc parseJavadoc (String content ) {
152
152
return JavadocParser .parse (content );
153
153
}
154
154
155
- public ExplicitConstructorInvocationStmt parseExplicitConstructorInvocationStmt (String statement ) {
155
+ public ExplicitConstructorInvocationStmt parseExplicitConstructorInvocationStmt (String statement ) {
156
156
return handleResult (getParser ().parseExplicitConstructorInvocationStmt (statement ));
157
157
}
158
158
159
- public Name parseName (String qualifiedName ) {
159
+ public Name parseName (String qualifiedName ) {
160
160
return handleResult (getParser ().parseName (qualifiedName ));
161
161
}
162
162
163
- public SimpleName parseSimpleName (String name ) {
163
+ public SimpleName parseSimpleName (String name ) {
164
164
return handleResult (getParser ().parseSimpleName (name ));
165
165
}
166
166
167
- public Parameter parseParameter (String parameter ) {
167
+ public Parameter parseParameter (String parameter ) {
168
168
return handleResult (getParser ().parseParameter (parameter ));
169
169
}
170
170
171
- public PackageDeclaration parsePackageDeclaration (String packageDeclaration ) {
171
+ public PackageDeclaration parsePackageDeclaration (String packageDeclaration ) {
172
172
return handleResult (getParser ().parsePackageDeclaration (packageDeclaration ));
173
173
}
174
174
175
- public TypeDeclaration <?> parseTypeDeclaration (String typeDeclaration ) {
175
+ public TypeDeclaration <?> parseTypeDeclaration (String typeDeclaration ) {
176
176
return handleResult (getParser ().parseTypeDeclaration (typeDeclaration ));
177
177
}
178
178
179
- public ModuleDeclaration parseModuleDeclaration (String moduleDeclaration ) {
179
+ public ModuleDeclaration parseModuleDeclaration (String moduleDeclaration ) {
180
180
return handleResult (getParser ().parseModuleDeclaration (moduleDeclaration ));
181
181
}
182
182
183
- public ModuleDirective parseModuleDirective (String moduleDirective ) {
183
+ public ModuleDirective parseModuleDirective (String moduleDirective ) {
184
184
return handleResult (getParser ().parseModuleDirective (moduleDirective ));
185
185
}
186
186
187
- public TypeParameter parseTypeParameter (String typeParameter ) {
187
+ public TypeParameter parseTypeParameter (String typeParameter ) {
188
188
return handleResult (getParser ().parseTypeParameter (typeParameter ));
189
189
}
190
190
191
- public MethodDeclaration parseMethodDeclaration (String methodDeclaration ) {
191
+ public MethodDeclaration parseMethodDeclaration (String methodDeclaration ) {
192
192
return handleResult (getParser ().parseMethodDeclaration (methodDeclaration ));
193
193
}
194
194
195
- public ArrayInitializerExpr parseArrayInitializerExpr (String arrayInitializerExpr ) {
195
+ public ArrayInitializerExpr parseArrayInitializerExpr (String arrayInitializerExpr ) {
196
196
return handleResult (getParser ().parseArrayInitializerExpr (arrayInitializerExpr ));
197
197
}
198
198
}
0 commit comments