... with regression test.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
package org.springframework.ide.vscode.commons.jandex;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.jboss.jandex.MethodInfo;
|
||||
@@ -23,6 +24,12 @@ import org.springframework.ide.vscode.commons.javadoc.IJavadoc;
|
||||
|
||||
public class MethodImpl implements IMethod {
|
||||
|
||||
/**
|
||||
* Test code may set this to manually inject test data to make up for some missing
|
||||
* capabilities of Jandex (e.g. discovering the names of method parameters).
|
||||
*/
|
||||
public static TestDataProvider testDataProvider = null;
|
||||
|
||||
private static final String JANDEX_CONTRUCTOR_NAME = "<init>";
|
||||
|
||||
private IType declaringType;
|
||||
@@ -109,4 +116,13 @@ public class MethodImpl implements IMethod {
|
||||
return method.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getParameterNames() {
|
||||
if (testDataProvider!=null) {
|
||||
return testDataProvider.getParameterNames(this);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Not supported with jandex");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.jandex;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.ide.vscode.commons.java.IMethod;
|
||||
import org.springframework.ide.vscode.commons.util.Assert;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class TestDataProvider {
|
||||
|
||||
private Map<String, List<String>> methodParameters = new HashMap<>();
|
||||
|
||||
public List<String> getParameterNames(IMethod method) {
|
||||
String key = method.getBindingKey();
|
||||
List<String> l = methodParameters.get(method.getBindingKey());
|
||||
Assert.isLegal(l!=null, "Test code should provide method parameter names for '"+key+"'");;
|
||||
return l;
|
||||
}
|
||||
|
||||
public void methodParams(String bindingKey, String... names) {
|
||||
methodParameters.put(bindingKey, ImmutableList.copyOf(names));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.java;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public interface IMethod extends IMember {
|
||||
@@ -71,4 +72,6 @@ public interface IMethod extends IMember {
|
||||
return getDeclaringType().classpathContainer();
|
||||
}
|
||||
|
||||
List<String> getParameterNames();
|
||||
|
||||
}
|
||||
|
||||
@@ -333,6 +333,11 @@ public class Wrappers {
|
||||
return data.isConstructor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getParameterNames() {
|
||||
return data.getParameterNames();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -313,6 +313,7 @@ public class TypeData extends TypeDescriptorData {
|
||||
private boolean constructor;
|
||||
private JavaTypeData returnType;
|
||||
private List<JavaTypeData> parameters;
|
||||
private List<String> parameterNames;
|
||||
private List<AnnotationData> annotations;
|
||||
|
||||
public String getBindingKey() {
|
||||
@@ -346,7 +347,7 @@ public class TypeData extends TypeDescriptorData {
|
||||
public void setReturnType(JavaTypeData returnType) {
|
||||
this.returnType = returnType;
|
||||
}
|
||||
|
||||
|
||||
public List<JavaTypeData> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
@@ -355,6 +356,14 @@ public class TypeData extends TypeDescriptorData {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public List<String> getParameterNames() {
|
||||
return parameterNames;
|
||||
}
|
||||
|
||||
public void setParameterNames(List<String> parameterNames) {
|
||||
this.parameterNames = parameterNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
@@ -362,6 +371,7 @@ public class TypeData extends TypeDescriptorData {
|
||||
result = prime * result + ((annotations == null) ? 0 : annotations.hashCode());
|
||||
result = prime * result + ((bindingKey == null) ? 0 : bindingKey.hashCode());
|
||||
result = prime * result + (constructor ? 1231 : 1237);
|
||||
result = prime * result + ((parameterNames == null) ? 0 : parameterNames.hashCode());
|
||||
result = prime * result + ((parameters == null) ? 0 : parameters.hashCode());
|
||||
result = prime * result + ((returnType == null) ? 0 : returnType.hashCode());
|
||||
return result;
|
||||
@@ -388,6 +398,11 @@ public class TypeData extends TypeDescriptorData {
|
||||
return false;
|
||||
if (constructor != other.constructor)
|
||||
return false;
|
||||
if (parameterNames == null) {
|
||||
if (other.parameterNames != null)
|
||||
return false;
|
||||
} else if (!parameterNames.equals(other.parameterNames))
|
||||
return false;
|
||||
if (parameters == null) {
|
||||
if (other.parameters != null)
|
||||
return false;
|
||||
@@ -400,6 +415,5 @@ public class TypeData extends TypeDescriptorData {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user