Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Nov 4, 2024
1 parent 9db5751 commit cc59bcc
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,13 @@ void collect(current: (FunctionDeclaration) `<FunctionDeclaration decl>`, Collec
if("test" in modifiers){
c.report(warning(decl.signature, "Modifier `test` cannot be used for Java functions"));
}
} else {
c.report(warning(decl, "Empty function body"));
}
else if ("java" in modifiers && "javaClass" notin tagsMap) {
c.report(warning(decl.signature, "Missing @javaClass tag with Java function"), fixes=javaClassProposals(decl));
}
else {
c.report(warning(decl, "Empty function body, without a `java` modifier or @javaClass tag."),
fixes=[addJavaModifier(decl), *javaClassProposals(decl)]);
}
} else {
if("javaClass" in tagsMap){
Expand Down Expand Up @@ -733,15 +738,20 @@ void collect (current: (Declaration) `<Tags tags> <Visibility visibility> alias
CodeAction addJavaModifier(FunctionDeclaration decl) = action(
title="add `java` modifier",
edits=[changed(decl.top, [replace(decl.signature.modifiers@\loc, "java <decl.signature.modifiers>")])]
edits=[changed(decl@\loc.top, [replace(decl.signature.modifiers@\loc, "java <decl.signature.modifiers>")])]
);
CodeAction removeJavaModifier(FunctionDeclaration decl) = action(
title="remove `java` modifier",
edits=[changed(decl.top, [replace(l@\loc, "") | /l:(FunctionModifier) `java` := decl])]
edits=[changed(decl@\loc.top, [replace(l@\loc, "") | /l:(FunctionModifier) `java` := decl])]
);
CodeAction removeJavaClass(FunctionDeclaration decl) = action(
title="remove @javaClass tag",
edits=[changed(decl.top, [replace(l@\loc, "") | /l:(Tag) `@javaClass<TagString _>` := decl])]
);
edits=[changed(decl@\loc.top, [replace(l@\loc, "") | /l:(Tag) `@javaClass<TagString _>` := decl])]
);
list[CodeAction] javaClassProposals(FunctionDeclaration decl) = [
action(title="add missing <t>", edits=[replace(decl.tags@\loc.top(decl.tags@\loc.offset, 0), "<t>\n")])
| /t:(Tag) `@javaClass<TagString _>` := parseModule(decl@\loc.top)
];

0 comments on commit cc59bcc

Please sign in to comment.