Skip to content

Set appropriate default instance names for the 'syntax' section #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions ReferenceGenerator/src/writers/BaseWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,24 @@ protected static String getUsage(Element element) {
}

protected static String getInstanceName(Element element) {
List<String> tags = Shared
.i()
.getTags(element.getEnclosingElement())
.get("instanceName");
if (tags != null && tags.size() > 0) {
return tags.get(0).split("\\s")[0];
if (element.getModifiers().contains(Modifier.STATIC)) {
// always use original class name for static methods
return element.getEnclosingElement().getSimpleName().toString();
} else {
// TODO add some coloration and/or italics around the instance name to
// signify "this can/needs to be changed"
List<String> tags = Shared
.i()
.getTags(element.getEnclosingElement())
.get("instanceName");
if (tags != null && tags.size() > 0) {
// use the javadoc @instanceName if there is one
return tags.get(0).split("\\s")[0];
} else {
// if none, default to "myClassName"
return "my" + element.getEnclosingElement().getSimpleName().toString();
}
}
return "";
}

protected static String getInstanceDescription(Element element) {
Expand All @@ -387,6 +397,9 @@ protected static String getInstanceDescription(Element element) {
String s = tags.get(0);
return s.substring(s.indexOf(" "));
}
if (!element.getModifiers().contains(Modifier.STATIC)) {
return "your " + element.getEnclosingElement().getSimpleName().toString() + " object";
}
return "";
}

Expand Down