File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
src/main/java/io/github/bensku/tsbind Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,11 @@ public Optional<TypeDefinition> parseType(SourceUnit source) {
81
81
return Optional .empty ();
82
82
}
83
83
CompilationUnit unit = result .getResult ().orElseThrow ();
84
- TypeDeclaration <?> type = unit .findFirst (TypeDeclaration .class ).orElseThrow ();
84
+ TypeDeclaration <?> type = unit .findFirst (TypeDeclaration .class ).orElse (null );
85
+ if (type == null ) {
86
+ System .err .println ("no type declaration found in source unit: " + source .name );
87
+ return Optional .empty ();
88
+ }
85
89
if (type .getAccessSpecifier () == AccessSpecifier .PUBLIC ) {
86
90
// SourceUnit lacks fully-qualified class name, so ask JavaParser to figure it out
87
91
String fqn = type .getFullyQualifiedName ().orElseThrow ();
You can’t perform that action at this time.
0 commit comments