Skip to content

Commit

Permalink
Added new config option for java debugger instrumentation (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
swesteme authored Aug 16, 2024
1 parent 84d02bc commit 4796a66
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
import com.intellij.compiler.CompilerConfiguration;
import com.intellij.compiler.CompilerConfigurationImpl;
import com.intellij.compiler.impl.javaCompiler.BackendCompiler;
import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.openapi.project.Project;
import de.gebit.plugins.autoconfig.UpdateHandler;
import de.gebit.plugins.autoconfig.handlers.AbstractHandler;
import de.gebit.plugins.autoconfig.model.AnnotationProcessor;
import de.gebit.plugins.autoconfig.model.AsyncStackTraces;
import de.gebit.plugins.autoconfig.model.Compiler;
import de.gebit.plugins.autoconfig.model.Debugger;
import de.gebit.plugins.autoconfig.model.JavaConfiguration;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile;
Expand Down Expand Up @@ -55,30 +58,49 @@ public Class<JavaConfiguration> getConfigurationClass() {
public List<String> updateConfiguration(JavaConfiguration configuration, Project project) {
List<String> changedConfigs = new ArrayList<>();
Compiler compiler = configuration.getCompiler();
if (compiler != null && CompilerConfiguration.getInstance(project) instanceof CompilerConfigurationImpl compilerConfiguration) {
if (compiler != null && CompilerConfiguration.getInstance(
project) instanceof CompilerConfigurationImpl compilerConfiguration) {
Compiler.JavaCompiler javaCompiler = compiler.getJavaCompiler();
if (javaCompiler != null && !compilerConfiguration.getDefaultCompiler().getId().equals(javaCompiler.value())) {
if (javaCompiler != null && !compilerConfiguration.getDefaultCompiler()
.getId()
.equals(javaCompiler.value())) {
for (BackendCompiler registeredCompiler : compilerConfiguration.getRegisteredJavaCompilers()) {
if (registeredCompiler.getId().equals(javaCompiler.value())) {
applySetting(registeredCompiler, compilerConfiguration.getDefaultCompiler(), compilerConfiguration::setDefaultCompiler, changedConfigs, "Java compiler");
applySetting(registeredCompiler, compilerConfiguration.getDefaultCompiler(),
compilerConfiguration::setDefaultCompiler, changedConfigs, "Java compiler");
break;
}
}
}
AnnotationProcessor annotationProcessor = compiler.getAnnotationProcessor();
if (annotationProcessor != null) {
ProcessorConfigProfile defaultProcessorProfile = compilerConfiguration.getDefaultProcessorProfile();
applySetting(annotationProcessor.getEnable(), defaultProcessorProfile.isEnabled(), defaultProcessorProfile::setEnabled, changedConfigs, "Enable annotation processor");
applySetting(annotationProcessor.getEnable(), defaultProcessorProfile.isEnabled(),
defaultProcessorProfile::setEnabled, changedConfigs, "Enable annotation processor");
}

Boolean parallelCompilation = compiler.getParallelCompilation();
if (parallelCompilation != null) {
applySetting(parallelCompilation, compilerConfiguration.isParallelCompilationEnabled(), compilerConfiguration::setParallelCompilationEnabled, changedConfigs, "Enable parallel compilation");
applySetting(parallelCompilation, compilerConfiguration.isParallelCompilationEnabled(),
compilerConfiguration::setParallelCompilationEnabled, changedConfigs,
"Enable parallel compilation");
}

Integer buildProcessHeapSize = compiler.getBuildProcessHeapSize();
if (buildProcessHeapSize != null) {
applySetting(buildProcessHeapSize, compilerConfiguration.getBuildProcessHeapSize(0), compilerConfiguration::setBuildProcessHeapSize, changedConfigs, "Build process heap size");
applySetting(buildProcessHeapSize, compilerConfiguration.getBuildProcessHeapSize(0),
compilerConfiguration::setBuildProcessHeapSize, changedConfigs, "Build process heap size");
}
}

Debugger debugger = configuration.getDebugger();
if (debugger != null) {
AsyncStackTraces asyncStackTraces = debugger.getAsyncStackTraces();
if (asyncStackTraces != null) {
applySetting(asyncStackTraces.getUseInstrumentingAgent(),
DebuggerSettings.getInstance().INSTRUMENTING_AGENT,
v -> DebuggerSettings.getInstance().INSTRUMENTING_AGENT = v, changedConfigs,
"Use instrumenting agent (application setting)");
}
}
return changedConfigs;
Expand Down
16 changes: 16 additions & 0 deletions src/main/resources/schema/java.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@
"title": "Java configuration",
"type": "object",
"properties": {
"debugger": {
"type": "object",
"description": "Debugger settings",
"properties": {
"asyncStackTraces": {
"description": "Settings for async stack traces",
"type": "object",
"properties": {
"useInstrumentingAgent": {
"type": "boolean",
"description": "Whether instrumenting agent should be used (application wide setting!)"
}
}
}
}
},
"compiler": {
"type": "object",
"description": "Compiler settings",
Expand Down

0 comments on commit 4796a66

Please sign in to comment.