... with regression test.
This commit is contained in:
Kris De Volder
2020-03-17 09:16:53 -07:00
parent 57e5922f22
commit 02d2da126c
20 changed files with 955 additions and 18 deletions

View File

@@ -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");
}
}
}

View File

@@ -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));
}
}

View File

@@ -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();
}

View File

@@ -333,6 +333,11 @@ public class Wrappers {
return data.isConstructor();
}
@Override
public List<String> getParameterNames() {
return data.getParameterNames();
}
};
}