Skip to content

Instantly share code, notes, and snippets.

@simonbrandhof
Created July 2, 2014 21:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonbrandhof/cb1006435ae086d4e264 to your computer and use it in GitHub Desktop.
Save simonbrandhof/cb1006435ae086d4e264 to your computer and use it in GitHub Desktop.
Issuable on directories
import org.sonar.api.component.ResourcePerspectives;
public class MySensor implements Sensor {
private final ResourcePerspectives perspectives;
public MySensor(ResourcePerspectives perspectives) {
this.perspectives = perspectives;
}
@Override
public void analyse(Project project, SensorContext context) {
Directory dir = Directory.create("src/main/java/foo");
Issuable issuable = perspectives.as(Issuable.class, dir);
if (issuable != null) {
// ...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment