Skip to content

Commit

Permalink
SONARJAVA-4988: Expose SonarProduct on ModuleScannerContext
Browse files Browse the repository at this point in the history
DBD custom rules need this information to turn off saving IR to the
filesystem in a SonarLint context
  • Loading branch information
anton-haubner-sonarsource committed May 27, 2024
1 parent 8430033 commit 3641961
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.io.File;
import javax.annotation.Nullable;
import org.sonar.api.SonarProduct;
import org.sonar.api.batch.fs.InputComponent;
import org.sonar.java.SonarComponents;
import org.sonar.java.caching.CacheContextImpl;
Expand Down Expand Up @@ -85,4 +86,14 @@ public File getRootProjectWorkingDirectory() {
public String getModuleKey() {
return sonarComponents.getModuleKey();
}

@Override
public SonarProduct sonarProduct() {
var context = sonarComponents.context();
if (context == null) {
return null;
}

return context.runtime().getProduct();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,4 @@ public interface InputFileScannerContext extends ModuleScannerContext {
* @since SonarJava 5.12: Dropping support of file-related methods
*/
InputFile getInputFile();

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
package org.sonar.plugins.java.api;

import java.io.File;
import javax.annotation.CheckForNull;
import org.sonar.api.SonarProduct;
import org.sonar.api.batch.fs.InputComponent;
import org.sonar.plugins.java.api.caching.CacheContext;

Expand Down Expand Up @@ -80,4 +82,7 @@ public interface ModuleScannerContext {
* @return A key that uniquely identifies the current module, provided that this project consists of multiple modules.
*/
String getModuleKey();

@CheckForNull
SonarProduct sonarProduct();
}

0 comments on commit 3641961

Please sign in to comment.