From 3ca90a9d49500ab5a22724db14fd8723c84d419b Mon Sep 17 00:00:00 2001 From: Eric Milles Date: Thu, 14 Feb 2019 10:24:42 -0600 Subject: [PATCH] Fix for #808: parameter names from
...
in javadoc --- .../org/eclipse/jdt/internal/core/BinaryMethod.java | 12 +++++++----- .../org/eclipse/jdt/internal/core/BinaryMethod.java | 12 +++++++----- .../org/eclipse/jdt/internal/core/BinaryMethod.java | 12 +++++++----- .../org/eclipse/jdt/internal/core/BinaryMethod.java | 12 +++++++----- .../org/eclipse/jdt/internal/core/BinaryMethod.java | 12 +++++++----- 5 files changed, 35 insertions(+), 25 deletions(-) diff --git a/jdt-patch/e410/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java b/jdt-patch/e410/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java index 2204da738b..a9b4767f10 100644 --- a/jdt-patch/e410/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java +++ b/jdt-patch/e410/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java @@ -381,14 +381,16 @@ public void run() { } if (methodDoc != null) { // GROOVY add - int indexOfDefsList = methodDoc.indexOf("
"); - if (indexOfDefsList != -1) { List names = new ArrayList<>(); - String defsList = methodDoc.substring(indexOfDefsList, methodDoc.indexOf("
", indexOfDefsList) + 5); - Matcher matcher = Pattern.compile("
(\\p{javaJavaIdentifierPart}+).*?
").matcher(defsList); + int indexOfPre = methodDoc.indexOf("
");
+			if (indexOfPre != -1) { List names = new ArrayList<>();
+				String methodSig = methodDoc.substring(indexOfPre, methodDoc.indexOf("
", indexOfPre) + 6); + Matcher matcher = Pattern.compile(" (\\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('('); diff --git a/jdt-patch/e411/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java b/jdt-patch/e411/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java index 2204da738b..a9b4767f10 100644 --- a/jdt-patch/e411/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java +++ b/jdt-patch/e411/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java @@ -381,14 +381,16 @@ public void run() { } if (methodDoc != null) { // GROOVY add - int indexOfDefsList = methodDoc.indexOf("
"); - if (indexOfDefsList != -1) { List names = new ArrayList<>(); - String defsList = methodDoc.substring(indexOfDefsList, methodDoc.indexOf("
", indexOfDefsList) + 5); - Matcher matcher = Pattern.compile("
(\\p{javaJavaIdentifierPart}+).*?
").matcher(defsList); + int indexOfPre = methodDoc.indexOf("
");
+			if (indexOfPre != -1) { List names = new ArrayList<>();
+				String methodSig = methodDoc.substring(indexOfPre, methodDoc.indexOf("
", indexOfPre) + 6); + Matcher matcher = Pattern.compile(" (\\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('('); diff --git a/jdt-patch/e47/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java b/jdt-patch/e47/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java index 7121febd7d..6232473fd4 100644 --- a/jdt-patch/e47/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java +++ b/jdt-patch/e47/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java @@ -365,14 +365,16 @@ public void run() { } if (methodDoc != null) { // GROOVY add - int indexOfDefsList = methodDoc.indexOf("
"); - if (indexOfDefsList != -1) { List names = new ArrayList(); - String defsList = methodDoc.substring(indexOfDefsList, methodDoc.indexOf("
", indexOfDefsList) + 5); - Matcher matcher = Pattern.compile("
(\\p{javaJavaIdentifierPart}+).*?
").matcher(defsList); + int indexOfPre = methodDoc.indexOf("
");
+			if (indexOfPre != -1) { List names = new ArrayList<>();
+				String methodSig = methodDoc.substring(indexOfPre, methodDoc.indexOf("
", indexOfPre) + 6); + Matcher matcher = Pattern.compile(" (\\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('('); diff --git a/jdt-patch/e48/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java b/jdt-patch/e48/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java index ce040b6a3e..451107b061 100644 --- a/jdt-patch/e48/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java +++ b/jdt-patch/e48/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java @@ -378,14 +378,16 @@ public void run() { } if (methodDoc != null) { // GROOVY add - int indexOfDefsList = methodDoc.indexOf("
"); - if (indexOfDefsList != -1) { List names = new ArrayList<>(); - String defsList = methodDoc.substring(indexOfDefsList, methodDoc.indexOf("
", indexOfDefsList) + 5); - Matcher matcher = Pattern.compile("
(\\p{javaJavaIdentifierPart}+).*?
").matcher(defsList); + int indexOfPre = methodDoc.indexOf("
");
+			if (indexOfPre != -1) { List names = new ArrayList<>();
+				String methodSig = methodDoc.substring(indexOfPre, methodDoc.indexOf("
", indexOfPre) + 6); + Matcher matcher = Pattern.compile(" (\\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('('); diff --git a/jdt-patch/e49/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java b/jdt-patch/e49/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java index 2204da738b..a9b4767f10 100644 --- a/jdt-patch/e49/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java +++ b/jdt-patch/e49/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java @@ -381,14 +381,16 @@ public void run() { } if (methodDoc != null) { // GROOVY add - int indexOfDefsList = methodDoc.indexOf("
"); - if (indexOfDefsList != -1) { List names = new ArrayList<>(); - String defsList = methodDoc.substring(indexOfDefsList, methodDoc.indexOf("
", indexOfDefsList) + 5); - Matcher matcher = Pattern.compile("
(\\p{javaJavaIdentifierPart}+).*?
").matcher(defsList); + int indexOfPre = methodDoc.indexOf("
");
+			if (indexOfPre != -1) { List names = new ArrayList<>();
+				String methodSig = methodDoc.substring(indexOfPre, methodDoc.indexOf("
", indexOfPre) + 6); + Matcher matcher = Pattern.compile(" (\\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('(');