I am developing a custom sonar plugin. My usecase requires me to create a file and add it to the context of the Sensor dynamically. Below is the code snippet from my class which implements Sensor interface.
String filePath="path to my temp file";
DefaultFileSystem fs = new DefaultFileSystem(context.fileSystem().baseDir());
fs.add(createAndGetNewIndexedFile(filePath));
inputFile = (DefaultInputFile)fs.inputFile(fs.predicates().hasRelativePath(filePath));
in the above section I get desired inputFile object, but the fs is not part of the context.
but for below code snippet inputFile is null but fs is part of the context. Which esssentially mean that newly added file has not been added to the context or index.
String filePath="path to my temp file";
DefaultFileSystem fs = (DefaultFileSystem) context.fileSystem();
fs.add(createAndGetNewIndexedFile(filePath));
inputFile = (DefaultInputFile)
fs.inputFile(fs.predicates().hasRelativePath(filePath));
Could someone enlighten me on how to add a file to index inside a Sensor ?
Kind Regards Ram