Description
Describe the bug
I didn't open this up as a PR as I was hoping to ask about it first in case there was a use-case for it beyond what I've figured.
Currently, the extension is set to activate whenever an XML-like file is opened. (Among other conditions.)
I'm looking through the activation events of all my extensions since lately, I've noticed some of them activate eagerly even when they don't apply to my workspace, which can use a lot more resources on my system. This adds up when you have many extensions, i.e. I have 92.
When sorted by
MEM%
my top 3 processes.
Does it make sense to activate the extension, which then also activates Language Support for Java(TM) by Red Hat, just because an XML file was opened?
I can see you already check for pom.xml
in workspaceContains
, so I'd think the purpose of onLanguage:xml
is in case the user opens an XML Spring config file?
Maybe this would be better:
{
"activationEvents": [
"onLanguage:spring-boot-properties",
"onLanguage:spring-boot-properties-yaml",
"onLanguage:java",
- "onLanguage:xml",
"onLanguage:spring-factories",
"onDebugResolve:java",
"onCommand:vscode-spring-boot.rewrite.list.refactorings",
"onCommand:vscode-spring-boot.rewrite.list.boot-upgrades",
"onCommand:vscode-spring-boot.ls.start",
"workspaceContains:pom.xml",
"workspaceContains:*/pom.xml",
"workspaceContains:build.gradle",
"workspaceContains:*/build.gradle",
"workspaceContains:settings.gradle",
"workspaceContains:*/settings.gradle",
"workspaceContains:build.gradle.kts",
"workspaceContains:*/build.gradle.kts",
"workspaceContains:settings.gradle.kts",
"workspaceContains:*/settings.gradle.kts",
"workspaceContains:.classpath",
"workspaceContains:*/.classpath"
],
}
Fun fact, as of VSC 1.74.0 (November 2022), you don't have to specify languages/commands/etc that the extension itself provides. [source]
I think it'd be fair to say if the extension was needed, any of the many other conditions would be met first before onLanguage:xml
. Perhaps it'd be better to reduce false-positive activations, especially as this extension causes a fair bit of memory usage?
If you really wanted to activate on all XML files, then maybe we could at least target XML files specifically instead of anything that uses an XML-like file? Though this might actually increase false activations, so might be a dumb idea.
{
"activationEvents": [
"onLanguage:spring-boot-properties",
"onLanguage:spring-boot-properties-yaml",
"onLanguage:java",
- "onLanguage:xml",
"onLanguage:spring-factories",
"onDebugResolve:java",
"onCommand:vscode-spring-boot.rewrite.list.refactorings",
"onCommand:vscode-spring-boot.rewrite.list.boot-upgrades",
"onCommand:vscode-spring-boot.ls.start",
- "workspaceContains:pom.xml",
- "workspaceContains:*/pom.xml",
+ "workspaceContains:**/*.xml",
"workspaceContains:build.gradle",
"workspaceContains:*/build.gradle",
"workspaceContains:settings.gradle",
"workspaceContains:*/settings.gradle",
"workspaceContains:build.gradle.kts",
"workspaceContains:*/build.gradle.kts",
"workspaceContains:settings.gradle.kts",
"workspaceContains:*/settings.gradle.kts",
"workspaceContains:.classpath",
"workspaceContains:*/.classpath"
],
}
To Reproduce
Open any non-Java/Spring project with XML files. Given how widely XML is used, this can activate for pretty much any workspace. In my case, it mostly comes from opening SVGs.
Sample
N/A (I think in this case it's fair not to include a sample.)
Just a heads-up even setting the onLanguage:xml
aside, I believe you can compress the activation events a bit by using the **
wildcard and omitting contributions from the extension itself.
{
"activationEvents": [
- "onLanguage:spring-boot-properties",
- "onLanguage:spring-boot-properties-yaml",
"onLanguage:java",
"onLanguage:xml",
- "onLanguage:spring-factories",
"onDebugResolve:java",
- "onCommand:vscode-spring-boot.rewrite.list.refactorings",
- "onCommand:vscode-spring-boot.rewrite.list.boot-upgrades",
- "onCommand:vscode-spring-boot.ls.start",
- "workspaceContains:pom.xml",
- "workspaceContains:*/pom.xml",
+ "workspaceContains:**/pom.xml",
- "workspaceContains:build.gradle",
- "workspaceContains:*/build.gradle",
+ "workspaceContains:**/build.gradle",
- "workspaceContains:settings.gradle",
- "workspaceContains:*/settings.gradle",
+ "workspaceContains:**/settings.gradle",
- "workspaceContains:build.gradle.kts",
- "workspaceContains:*/build.gradle.kts",
+ "workspaceContains:**/build.gradle.kts",
- "workspaceContains:settings.gradle.kts",
- "workspaceContains:*/settings.gradle.kts",
+ "workspaceContains:**/settings.gradle.kts",
- "workspaceContains:.classpath",
- "workspaceContains:*/.classpath"
+ "workspaceContains:**/.classpath"
],
}