Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new config option for java debugger instrumentation #10

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Use instrumenting agent (application wide 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