Skip to content

Commit

Permalink
Fix for #808: parameter names from <pre>...</pre> in javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Feb 14, 2019
1 parent faa4482 commit 3ca90a9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,16 @@ public void run() {
}
if (methodDoc != null) {
// GROOVY add
int indexOfDefsList = methodDoc.indexOf("<dl>");
if (indexOfDefsList != -1) { List<String> names = new ArrayList<>();
String defsList = methodDoc.substring(indexOfDefsList, methodDoc.indexOf("</dl>", indexOfDefsList) + 5);
Matcher matcher = Pattern.compile("<dd><code>(\\p{javaJavaIdentifierPart}+)</code>.*?</dd>").matcher(defsList);
int indexOfPre = methodDoc.indexOf("<pre>");
if (indexOfPre != -1) { List<String> names = new ArrayList<>();
String methodSig = methodDoc.substring(indexOfPre, methodDoc.indexOf("</pre>", indexOfPre) + 6);
Matcher matcher = Pattern.compile("&nbsp;(\\p{javaJavaIdentifierPart}+)[,)]").matcher(methodSig);
while (matcher.find()) {
names.add(matcher.group(1));
}
return this.parameterNames = names.toArray(new String[names.size()]);
if (this.parameterTypes.length == names.size()) {
return this.parameterNames = names.toArray(new String[names.size()]);
}
}
// GROOVY end
int indexOfOpenParen = methodDoc.indexOf('(');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,16 @@ public void run() {
}
if (methodDoc != null) {
// GROOVY add
int indexOfDefsList = methodDoc.indexOf("<dl>");
if (indexOfDefsList != -1) { List<String> names = new ArrayList<>();
String defsList = methodDoc.substring(indexOfDefsList, methodDoc.indexOf("</dl>", indexOfDefsList) + 5);
Matcher matcher = Pattern.compile("<dd><code>(\\p{javaJavaIdentifierPart}+)</code>.*?</dd>").matcher(defsList);
int indexOfPre = methodDoc.indexOf("<pre>");
if (indexOfPre != -1) { List<String> names = new ArrayList<>();
String methodSig = methodDoc.substring(indexOfPre, methodDoc.indexOf("</pre>", indexOfPre) + 6);
Matcher matcher = Pattern.compile("&nbsp;(\\p{javaJavaIdentifierPart}+)[,)]").matcher(methodSig);
while (matcher.find()) {
names.add(matcher.group(1));
}
return this.parameterNames = names.toArray(new String[names.size()]);
if (this.parameterTypes.length == names.size()) {
return this.parameterNames = names.toArray(new String[names.size()]);
}
}
// GROOVY end
int indexOfOpenParen = methodDoc.indexOf('(');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,16 @@ public void run() {
}
if (methodDoc != null) {
// GROOVY add
int indexOfDefsList = methodDoc.indexOf("<dl>");
if (indexOfDefsList != -1) { List<String> names = new ArrayList<String>();
String defsList = methodDoc.substring(indexOfDefsList, methodDoc.indexOf("</dl>", indexOfDefsList) + 5);
Matcher matcher = Pattern.compile("<dd><code>(\\p{javaJavaIdentifierPart}+)</code>.*?</dd>").matcher(defsList);
int indexOfPre = methodDoc.indexOf("<pre>");
if (indexOfPre != -1) { List<String> names = new ArrayList<>();
String methodSig = methodDoc.substring(indexOfPre, methodDoc.indexOf("</pre>", indexOfPre) + 6);
Matcher matcher = Pattern.compile("&nbsp;(\\p{javaJavaIdentifierPart}+)[,)]").matcher(methodSig);
while (matcher.find()) {
names.add(matcher.group(1));
}
return this.parameterNames = names.toArray(new String[names.size()]);
if (this.parameterTypes.length == names.size()) {
return this.parameterNames = names.toArray(new String[names.size()]);
}
}
// GROOVY end
int indexOfOpenParen = methodDoc.indexOf('(');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,16 @@ public void run() {
}
if (methodDoc != null) {
// GROOVY add
int indexOfDefsList = methodDoc.indexOf("<dl>");
if (indexOfDefsList != -1) { List<String> names = new ArrayList<>();
String defsList = methodDoc.substring(indexOfDefsList, methodDoc.indexOf("</dl>", indexOfDefsList) + 5);
Matcher matcher = Pattern.compile("<dd><code>(\\p{javaJavaIdentifierPart}+)</code>.*?</dd>").matcher(defsList);
int indexOfPre = methodDoc.indexOf("<pre>");
if (indexOfPre != -1) { List<String> names = new ArrayList<>();
String methodSig = methodDoc.substring(indexOfPre, methodDoc.indexOf("</pre>", indexOfPre) + 6);
Matcher matcher = Pattern.compile("&nbsp;(\\p{javaJavaIdentifierPart}+)[,)]").matcher(methodSig);
while (matcher.find()) {
names.add(matcher.group(1));
}
return this.parameterNames = names.toArray(new String[names.size()]);
if (this.parameterTypes.length == names.size()) {
return this.parameterNames = names.toArray(new String[names.size()]);
}
}
// GROOVY end
int indexOfOpenParen = methodDoc.indexOf('(');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,16 @@ public void run() {
}
if (methodDoc != null) {
// GROOVY add
int indexOfDefsList = methodDoc.indexOf("<dl>");
if (indexOfDefsList != -1) { List<String> names = new ArrayList<>();
String defsList = methodDoc.substring(indexOfDefsList, methodDoc.indexOf("</dl>", indexOfDefsList) + 5);
Matcher matcher = Pattern.compile("<dd><code>(\\p{javaJavaIdentifierPart}+)</code>.*?</dd>").matcher(defsList);
int indexOfPre = methodDoc.indexOf("<pre>");
if (indexOfPre != -1) { List<String> names = new ArrayList<>();
String methodSig = methodDoc.substring(indexOfPre, methodDoc.indexOf("</pre>", indexOfPre) + 6);
Matcher matcher = Pattern.compile("&nbsp;(\\p{javaJavaIdentifierPart}+)[,)]").matcher(methodSig);
while (matcher.find()) {
names.add(matcher.group(1));
}
return this.parameterNames = names.toArray(new String[names.size()]);
if (this.parameterTypes.length == names.size()) {
return this.parameterNames = names.toArray(new String[names.size()]);
}
}
// GROOVY end
int indexOfOpenParen = methodDoc.indexOf('(');
Expand Down

0 comments on commit 3ca90a9

Please sign in to comment.