Skip to content
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

Declaring variables in a class and applying multiple variables results in variables not being converted to corresponding values in the output result #177

Open
zhenghongxun123 opened this issue Sep 28, 2023 · 1 comment

Comments

@zhenghongxun123
Copy link

public class StaticURI {
public final static String version3 = "/service/license/version3";

private final static String SERVICE_OPERATION = "service";
private final static String SERVICE = "/" + SERVICE_OPERATION;
public final static String version4 = SERVICE + "/pmts/convert/update";

}

// QDox构建器
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
javaProjectBuilder.setEncoding(StandardCharsets.UTF_8.name());

	// 通过addSource等相关方法, 将源码添加进QDox中 (注:可以多次添加)
	javaProjectBuilder.addSourceTree(new File(
			"D:\\sourcecodePath\\test\\smart-doc-master\\smart-doc-master\\src\\main\\java\\com\\test\\controller\\"));

	// 获取解析出来的JavaClass对象
	javaProjectBuilder.getClasses().forEach(javaClass -> {

if ("com.test.controller.StaticURI".equals(javaClass.getFullyQualifiedName())) {
System.err.println("字段\t" + javaClass.getFields());
List f = javaClass.getFields();
f.forEach(fieldRef->{
System.out.println(fieldRef.getName());
String h = fieldRef.getInitializationExpression();
System.out.println("--" + h);
});
}
}

result::::
字段 [public static final String com.test.controller.StaticURI.version3, private static final String com.test.controller.StaticURI.SERVICE_OPERATION, private static final String com.test.controller.StaticURI.SERVICE, public static final String com.test.controller.StaticURI.version4]
version3
--"/service/license/version3"
SERVICE_OPERATION
--"service"
SERVICE
--"/" + SERVICE_OPERATION
version4
--SERVICE + "/pmts/convert/update"

@paul-hammant
Copy link
Owner

Can you make an integration test -> https://github.com/paul-hammant/qdox/tree/master/src/it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants