if(sourceunit.getPackageDeclaration().isPresent()){
sourcePackage = sourceunit.getPackageDeclaration().get().getNameAsString();
}
private void method(){
...
Map<SimpleName, com.github.javaparser.ast.CompilationUnit> units = new HashMap<>();
for(...){
units.put(...);
}
CompilationUnit sourceunit = units.get(clazzName);
....
String sourcePackage = null;
if(sourceunit.getPackageDeclaration().isPresent()){
sourcePackage = sourceunit.getPackageDeclaration().get().getNameAsString();
}
....
}Optional<PackageDeclaration> packageDeclaration = sourceunit.getPackageDeclaration();
if(packageDeclaration .isPresent()){
sourcePackage = packageDeclaration.get().getNameAsString();
}
--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/bfa47dba-b268-49ca-a591-6c750459fbc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Senior Developer
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/6f0dc200-effb-49d8-b9cb-1c4154d5311d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.