Must-share information (formatted with Markdown):
- which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
- what are you trying to achieve
- what have you tried so far to achieve this
My company is currently using SonarQube 6.7.4. and SonarJava version 5.5.0
I am trying to write a custom rule that needs to read which package a given java file is in.
package com.foo.bar.mypackage; // ^ I need to read this line.
Currently I explored the
PackageDeclarationTree interface but there doesn’t seem a way to extract the
string out of the
packageName() ExpressionTree. I initially thought that
packageDeclaration.packageName().symbolType().fullyQualifiedName() would give me the package name but it instead returns
!unknownSymbol!, which seems strange.
I also tried casting
packageName() to a
MemberSelectionExpressionTree, which exposes
expression() methods. The
identifier() gives me the very last part of my package
mypackage but again the expression part is an