You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "Achal1607 (via GitHub)" <gi...@apache.org> on 2024/07/05 09:00:35 UTC
[PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Achal1607 opened a new pull request, #7548:
URL: https://github.com/apache/netbeans/pull/7548
Unused suppress warning was not showing up in netbeans IDE, so fixed that.
Netbeans already had option for providing suppress warnings hint in the sub-menu. So, leveraged that piece of code to extend this capability in the VS Code CodeActions as well.
Introduced suppress warnings hint in vscode.
<img width="456" alt="image" src="https://github.com/apache/netbeans/assets/55803675/57a6a4a8-d14a-408d-94da-550fa3b14263">
In the above image. "- >" represents subfixes.
For more info refer: https://github.com/oracle/javavscode/issues/96
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "Achal1607 (via GitHub)" <gi...@apache.org>.
Achal1607 commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1684208183
##########
java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java:
##########
@@ -200,25 +202,55 @@ private static List<CodeAction> convertFixes(ErrorDescription err, Consumer<Exce
}
}
- List<Fix> fixes = sortFixes(lfl.getFixes());
+ List<Fix> baseFixes = lfl.getFixes();
+
+ baseFixes = sortFixes(baseFixes);
+
+ List<Pair<Fix, Boolean>> fixesAndSubfixes = new ArrayList<>(); // true if main fix
+
+ for (Fix f : baseFixes){
+ fixesAndSubfixes.add(Pair.of(f, true));
+
+ try {
+ Class<?> controller = Class.forName("org.netbeans.modules.editor.hints.HintsControllerImpl",
+ false,
+ ErrorDescription.class.getClassLoader());
+ Method getSubfixes = controller.getDeclaredMethod("getSubfixes", Fix.class);
Review Comment:
I tried out this approach what @lahodaj suggested it seems to work fine, important point is it doesn't use reflection code. Updated the code accrodingly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Implement suppress warnings on for Unused hint and codeAction for suppress warnings annotations [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1688736613
##########
java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unused.java:
##########
@@ -52,7 +52,12 @@ public class Unused {
@BooleanOption(displayName="#LBL_UnusedPackagePrivate", tooltip="#TP_UnusedPackagePrivate", defaultValue=DETECT_UNUSED_PACKAGE_PRIVATE_DEFAULT)
public static final String DETECT_UNUSED_PACKAGE_PRIVATE = "detect.unused.package.private";
- @TriggerTreeKind(Kind.COMPILATION_UNIT)
+ @TriggerTreeKind({
+ //class-like kinds:
+ Kind.ANNOTATION_TYPE, Kind.CLASS, Kind.ENUM, Kind.INTERFACE, Kind.RECORD,
+ Kind.VARIABLE,
+ Kind.METHOD
+ })
public static List<ErrorDescription> unused(HintContext ctx) {
Review Comment:
the method is going to be called a few k times on large files, compared to one time before the change. But it seems we are lucky here and a simple fast-path is able to get us closer to the old state:
I added this after `findUnused(...)` which is already caching results internally
```java
if (unused.isEmpty()) {
return null;
}
```
`null` will lead to the fast path in `CodeHintProviderImpl#createErrors`.
and we get:
```
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: {time=0.83ms, invocations=6003, cancelled=false}: org.netbeans.modules.java.hints.bugs.Unused
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: hint processing complete
```
At some point we should take a look at this method and check what is causing the slowdown there.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "lahodaj (via GitHub)" <gi...@apache.org>.
lahodaj commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1678064320
##########
java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java:
##########
@@ -200,25 +202,55 @@ private static List<CodeAction> convertFixes(ErrorDescription err, Consumer<Exce
}
}
- List<Fix> fixes = sortFixes(lfl.getFixes());
+ List<Fix> baseFixes = lfl.getFixes();
+
+ baseFixes = sortFixes(baseFixes);
+
+ List<Pair<Fix, Boolean>> fixesAndSubfixes = new ArrayList<>(); // true if main fix
+
+ for (Fix f : baseFixes){
+ fixesAndSubfixes.add(Pair.of(f, true));
+
+ try {
+ Class<?> controller = Class.forName("org.netbeans.modules.editor.hints.HintsControllerImpl",
+ false,
+ ErrorDescription.class.getClassLoader());
+ Method getSubfixes = controller.getDeclaredMethod("getSubfixes", Fix.class);
Review Comment:
I am afraid there are only bad solutions:
- either the reflection (where the problem is obvious),
- implementation dependency between `java.hints` and `spi.editor.hints`, which is problematic as a) it goes across cluster boundary; b) `java.hints` is a purely hint implementation module, it should not "normally" need to hack into any implementation,
- putting `getSubfixes` to the API, which is problematic, as `spi.editor.hints` does not have any API currently, and there's so far only a single use of this, and that is here,
- maybe some tricks with moving `JavaErrorProvider` into a bridge module which would have impl dependency on both `java.hints` and `spi.editor.hints`, which also seem pretty ugly.
So, the reflection seemed least bad out of the options. It does not open any new avenues to get additional access, and it is a clear hack that will be obvious (as opposed to e.g. implementation dependency). But I admit my opinion here may not be the only one, or even the best.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "lahodaj (via GitHub)" <gi...@apache.org>.
lahodaj commented on PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#issuecomment-2220074007
I think @dbalek or @sdedic would be better reviewers than me, as I've been too involved in the discussion on this patch development.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1686915070
##########
java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unused.java:
##########
@@ -52,7 +52,12 @@ public class Unused {
@BooleanOption(displayName="#LBL_UnusedPackagePrivate", tooltip="#TP_UnusedPackagePrivate", defaultValue=DETECT_UNUSED_PACKAGE_PRIVATE_DEFAULT)
public static final String DETECT_UNUSED_PACKAGE_PRIVATE = "detect.unused.package.private";
- @TriggerTreeKind(Kind.COMPILATION_UNIT)
+ @TriggerTreeKind({
+ //class-like kinds:
+ Kind.ANNOTATION_TYPE, Kind.CLASS, Kind.ENUM, Kind.INTERFACE, Kind.RECORD,
+ Kind.VARIABLE,
+ Kind.METHOD
+ })
public static List<ErrorDescription> unused(HintContext ctx) {
Review Comment:
@Achal1607 question: why was this change made?
I ran some benchmarks which were based on generated files I used for https://github.com/apache/netbeans/pull/4142 + https://github.com/apache/netbeans/pull/4501
very large files (10K fields and getters) with many positive unused hits performed slightly worse:
PR:
```
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: {time=69114.52ms, invocations=20003, cancelled=false}: org.netbeans.modules.java.hints.bugs.Unused
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: hint processing complete
```
master:
```
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: {time=62578.07ms, invocations=1, cancelled=false}: org.netbeans.modules.java.hints.bugs.Unused
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: hint processing complete
```
the more concerning bit is this though. a 3k fields file which are _not_ unused:
PR:
```
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: {time=565.49ms, invocations=6003, cancelled=false}: org.netbeans.modules.java.hints.bugs.Unused
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: hint processing complete
```
master:
```
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: {time=0.11ms, invocations=1, cancelled=false}: org.netbeans.modules.java.hints.bugs.Unused
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: hint processing complete
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "Achal1607 (via GitHub)" <gi...@apache.org>.
Achal1607 commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1687451295
##########
java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unused.java:
##########
@@ -52,7 +52,12 @@ public class Unused {
@BooleanOption(displayName="#LBL_UnusedPackagePrivate", tooltip="#TP_UnusedPackagePrivate", defaultValue=DETECT_UNUSED_PACKAGE_PRIVATE_DEFAULT)
public static final String DETECT_UNUSED_PACKAGE_PRIVATE = "detect.unused.package.private";
- @TriggerTreeKind(Kind.COMPILATION_UNIT)
+ @TriggerTreeKind({
+ //class-like kinds:
+ Kind.ANNOTATION_TYPE, Kind.CLASS, Kind.ENUM, Kind.INTERFACE, Kind.RECORD,
+ Kind.VARIABLE,
+ Kind.METHOD
+ })
public static List<ErrorDescription> unused(HintContext ctx) {
Review Comment:
I am also a bit of surprised by the performance degradation in the not-unused case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#issuecomment-2244263867
can we change the PR title to "Implement suppress warnings on the Unused hint" or something similar? I think this makes more sense for the NetBeans release notes which are generated from PR titles, I suppose javavscode has their own release notes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#issuecomment-2220091947
@lahodaj sure, but you're also marked as the author on `HintsController` and `HintsControllerImpl` so you seemed a good person to suggest an alternative to reflection with regard to @mbien comment (which I happen to agree is something of a red flag)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1686915070
##########
java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unused.java:
##########
@@ -52,7 +52,12 @@ public class Unused {
@BooleanOption(displayName="#LBL_UnusedPackagePrivate", tooltip="#TP_UnusedPackagePrivate", defaultValue=DETECT_UNUSED_PACKAGE_PRIVATE_DEFAULT)
public static final String DETECT_UNUSED_PACKAGE_PRIVATE = "detect.unused.package.private";
- @TriggerTreeKind(Kind.COMPILATION_UNIT)
+ @TriggerTreeKind({
+ //class-like kinds:
+ Kind.ANNOTATION_TYPE, Kind.CLASS, Kind.ENUM, Kind.INTERFACE, Kind.RECORD,
+ Kind.VARIABLE,
+ Kind.METHOD
+ })
public static List<ErrorDescription> unused(HintContext ctx) {
Review Comment:
@Achal1607 question: why was this change made?
I ran some benchmarks which were based on generated files I used for https://github.com/apache/netbeans/pull/4142
very large files (10K fields and getters) with many positive unused hits performed slightly worse:
PR:
```
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: {time=69114.52ms, invocations=20003, cancelled=false}: org.netbeans.modules.java.hints.bugs.Unused
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: hint processing complete
```
master:
```
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: {time=62578.07ms, invocations=1, cancelled=false}: org.netbeans.modules.java.hints.bugs.Unused
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: hint processing complete
```
the more concerning bit is this though. a 3k fields file which are _not_ unused:
PR:
```
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: {time=565.49ms, invocations=6003, cancelled=false}: org.netbeans.modules.java.hints.bugs.Unused
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: hint processing complete
```
master:
```
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: {time=0.11ms, invocations=1, cancelled=false}: org.netbeans.modules.java.hints.bugs.Unused
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: hint processing complete
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Implement suppress warnings on for Unused hint and codeAction for suppress warnings annotations [netbeans]
Posted by "Achal1607 (via GitHub)" <gi...@apache.org>.
Achal1607 commented on PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#issuecomment-2245370530
@mbien updated PR title
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Implement suppress warnings on for Unused hint and codeAction for suppress warnings annotations [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#issuecomment-2248773841
@neilcsmith-net does the https://github.com/apache/netbeans/labels/do%20not%20merge tag still apply?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1678241136
##########
java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java:
##########
@@ -200,25 +202,55 @@ private static List<CodeAction> convertFixes(ErrorDescription err, Consumer<Exce
}
}
- List<Fix> fixes = sortFixes(lfl.getFixes());
+ List<Fix> baseFixes = lfl.getFixes();
+
+ baseFixes = sortFixes(baseFixes);
+
+ List<Pair<Fix, Boolean>> fixesAndSubfixes = new ArrayList<>(); // true if main fix
+
+ for (Fix f : baseFixes){
+ fixesAndSubfixes.add(Pair.of(f, true));
+
+ try {
+ Class<?> controller = Class.forName("org.netbeans.modules.editor.hints.HintsControllerImpl",
+ false,
+ ErrorDescription.class.getClassLoader());
+ Method getSubfixes = controller.getDeclaredMethod("getSubfixes", Fix.class);
Review Comment:
> putting getSubfixes to the API, which is problematic, as spi.editor.hints does not have any API currently,
To clarify, because it doesn't have any API packages as opposed to public packages?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Implement suppress warnings on for Unused hint and codeAction for suppress warnings annotations [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1688816208
##########
java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unused.java:
##########
@@ -52,7 +52,12 @@ public class Unused {
@BooleanOption(displayName="#LBL_UnusedPackagePrivate", tooltip="#TP_UnusedPackagePrivate", defaultValue=DETECT_UNUSED_PACKAGE_PRIVATE_DEFAULT)
public static final String DETECT_UNUSED_PACKAGE_PRIVATE = "detect.unused.package.private";
- @TriggerTreeKind(Kind.COMPILATION_UNIT)
+ @TriggerTreeKind({
+ //class-like kinds:
+ Kind.ANNOTATION_TYPE, Kind.CLASS, Kind.ENUM, Kind.INTERFACE, Kind.RECORD,
+ Kind.VARIABLE,
+ Kind.METHOD
+ })
public static List<ErrorDescription> unused(HintContext ctx) {
Review Comment:
it turns out that reading values from Preferences in hot code causes performance problems due to the need of a read lock. This is the reason why the fast path made things so much faster in the not-unused case.
here a commit with more changes: https://github.com/mbien/netbeans/commit/eb1dc47da1f17adcf88fc03af4bf4369c83ed5f1
feel free to squash with your PR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Implement suppress warnings on for Unused hint and codeAction for suppress warnings annotations [netbeans]
Posted by "Achal1607 (via GitHub)" <gi...@apache.org>.
Achal1607 commented on PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#issuecomment-2249829149
Thank you so much @mbien for helping out on this PR. I have resolved the merge conflicts. Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Implement suppress warnings on for Unused hint and codeAction for suppress warnings annotations [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#issuecomment-2249611506
@Achal1607 small small conflict due to https://github.com/apache/netbeans/pull/7579 unfortunately. I saw that whitespace change and thought gh would be able to merge, but apparently not.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1678152730
##########
java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java:
##########
@@ -200,25 +202,55 @@ private static List<CodeAction> convertFixes(ErrorDescription err, Consumer<Exce
}
}
- List<Fix> fixes = sortFixes(lfl.getFixes());
+ List<Fix> baseFixes = lfl.getFixes();
+
+ baseFixes = sortFixes(baseFixes);
+
+ List<Pair<Fix, Boolean>> fixesAndSubfixes = new ArrayList<>(); // true if main fix
+
+ for (Fix f : baseFixes){
+ fixesAndSubfixes.add(Pair.of(f, true));
+
+ try {
+ Class<?> controller = Class.forName("org.netbeans.modules.editor.hints.HintsControllerImpl",
+ false,
+ ErrorDescription.class.getClassLoader());
+ Method getSubfixes = controller.getDeclaredMethod("getSubfixes", Fix.class);
Review Comment:
if it is decided that the reflection bits stay I would recommend the following:
- move all relfective setup code into static initializer, log exception + descriptive msg, e.g "implementation changed, update needed"
- also add a short comment that that this is the most convenient way to access the method without having to change module dependencies or complicate things further
- inside the loop I would call a utility method, which simply returns `getSubfixes.invoke(null, f))` and deals with the reflective invocation exception there (maybe log an return empty iterable)
this would move the `Class.forName` out of inner loops and help future maintainers to fix it it again once things start failing
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Implement suppress warnings on for Unused hint and codeAction for suppress warnings annotations [netbeans]
Posted by "Achal1607 (via GitHub)" <gi...@apache.org>.
Achal1607 commented on PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#issuecomment-2246924202
Thank you so much @mbien for helping in fixing the performance issue with this PR, I have incorporated your patch as well in this PR and squashed the PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1687308363
##########
java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java:
##########
@@ -200,25 +201,45 @@ private static List<CodeAction> convertFixes(ErrorDescription err, Consumer<Exce
}
}
- List<Fix> fixes = sortFixes(lfl.getFixes());
+ List<Fix> baseFixes = lfl.getFixes();
+
+ baseFixes = sortFixes(baseFixes);
Review Comment:
nitpick: this can be reverted back to one line?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Implement suppress warnings on for Unused hint and codeAction for suppress warnings annotations [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#issuecomment-2249801008
```
[PR branch]
git pull --rebase https://github.com/apache/netbeans.git master
[fix merge conflict]
git add java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java
git rebase --continue
```
should work I think. It would put the commit on top of latest master.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "Achal1607 (via GitHub)" <gi...@apache.org>.
Achal1607 commented on PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#issuecomment-2238227877
@mbien updated code of reflection according to the comments provided by you. Can you please have a look at it once again?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "lahodaj (via GitHub)" <gi...@apache.org>.
lahodaj commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1679543180
##########
java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java:
##########
@@ -200,25 +202,55 @@ private static List<CodeAction> convertFixes(ErrorDescription err, Consumer<Exce
}
}
- List<Fix> fixes = sortFixes(lfl.getFixes());
+ List<Fix> baseFixes = lfl.getFixes();
+
+ baseFixes = sortFixes(baseFixes);
+
+ List<Pair<Fix, Boolean>> fixesAndSubfixes = new ArrayList<>(); // true if main fix
+
+ for (Fix f : baseFixes){
+ fixesAndSubfixes.add(Pair.of(f, true));
+
+ try {
+ Class<?> controller = Class.forName("org.netbeans.modules.editor.hints.HintsControllerImpl",
+ false,
+ ErrorDescription.class.getClassLoader());
+ Method getSubfixes = controller.getDeclaredMethod("getSubfixes", Fix.class);
Review Comment:
`spi.editor.hints` only has SPI, which means something providers (that produce information) plug into, but that is not used to retrieve information. We could add an API package, with an API class, it just feels weird that the only method would be to get sub-fixes.
But maybe we could add a default method to `org.netbeans.spi.editor.hints.Fix`, e.g. `getSubfixes()`. `org.netbeans.modules.editor.hints.borrowed.ListCompletionView` would then use `Fix.getSubfixes()` to get sub-fixes instead of the current code, so that `Fix` subclasses could provided sub-fixes using the new method as well. And `java.hints` could also call that method. That's not completely clear, but would seem acceptable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "Achal1607 (via GitHub)" <gi...@apache.org>.
Achal1607 commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1687403920
##########
java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unused.java:
##########
@@ -52,7 +52,12 @@ public class Unused {
@BooleanOption(displayName="#LBL_UnusedPackagePrivate", tooltip="#TP_UnusedPackagePrivate", defaultValue=DETECT_UNUSED_PACKAGE_PRIVATE_DEFAULT)
public static final String DETECT_UNUSED_PACKAGE_PRIVATE = "detect.unused.package.private";
- @TriggerTreeKind(Kind.COMPILATION_UNIT)
+ @TriggerTreeKind({
+ //class-like kinds:
+ Kind.ANNOTATION_TYPE, Kind.CLASS, Kind.ENUM, Kind.INTERFACE, Kind.RECORD,
+ Kind.VARIABLE,
+ Kind.METHOD
+ })
public static List<ErrorDescription> unused(HintContext ctx) {
Review Comment:
Thanks so much @mbien for running performance tests, this change is made so that it can honour `@SuppressWarnings("unused")` otherwise currently suppress warning annotation for unused variables is not working. For more info please refer to https://github.com/oracle/javavscode/issues/96
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Implement suppress warnings on for Unused hint and codeAction for suppress warnings annotations [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1688736613
##########
java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unused.java:
##########
@@ -52,7 +52,12 @@ public class Unused {
@BooleanOption(displayName="#LBL_UnusedPackagePrivate", tooltip="#TP_UnusedPackagePrivate", defaultValue=DETECT_UNUSED_PACKAGE_PRIVATE_DEFAULT)
public static final String DETECT_UNUSED_PACKAGE_PRIVATE = "detect.unused.package.private";
- @TriggerTreeKind(Kind.COMPILATION_UNIT)
+ @TriggerTreeKind({
+ //class-like kinds:
+ Kind.ANNOTATION_TYPE, Kind.CLASS, Kind.ENUM, Kind.INTERFACE, Kind.RECORD,
+ Kind.VARIABLE,
+ Kind.METHOD
+ })
public static List<ErrorDescription> unused(HintContext ctx) {
Review Comment:
the method is going to be called a few k times on large files, compared to one time before the change. But it seems we are lucky here and a simple fast-path is able to get close to the old state:
I added this after `findUnused(...)` which is already caching results internally
```java
if (unused.isEmpty()) {
return null;
}
```
`null` will lead to the fast path in `CodeHintProviderImpl#createErrors`.
and we get:
```
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: {time=0.83ms, invocations=6003, cancelled=false}: org.netbeans.modules.java.hints.bugs.Unused
FINE [org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker]: hint processing complete
```
At some point we should take a look at this method and check what is causing the slowdown there.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Implement suppress warnings on for Unused hint and codeAction for suppress warnings annotations [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien merged PR #7548:
URL: https://github.com/apache/netbeans/pull/7548
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "Achal1607 (via GitHub)" <gi...@apache.org>.
Achal1607 commented on PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#issuecomment-2228140325
Can @dbalek or @sdedic review this PR and provide some suggestions to avoid use of reflection or any more changes that has to be done?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1687422296
##########
java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unused.java:
##########
@@ -52,7 +52,12 @@ public class Unused {
@BooleanOption(displayName="#LBL_UnusedPackagePrivate", tooltip="#TP_UnusedPackagePrivate", defaultValue=DETECT_UNUSED_PACKAGE_PRIVATE_DEFAULT)
public static final String DETECT_UNUSED_PACKAGE_PRIVATE = "detect.unused.package.private";
- @TriggerTreeKind(Kind.COMPILATION_UNIT)
+ @TriggerTreeKind({
+ //class-like kinds:
+ Kind.ANNOTATION_TYPE, Kind.CLASS, Kind.ENUM, Kind.INTERFACE, Kind.RECORD,
+ Kind.VARIABLE,
+ Kind.METHOD
+ })
public static List<ErrorDescription> unused(HintContext ctx) {
Review Comment:
ah got it, the annotation has to anchor on the trigger. I didn't expect that this would matter - makes sense though.
A bit of a shame that this makes the not-unused case so much slower.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1671858009
##########
java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java:
##########
@@ -200,25 +202,55 @@ private static List<CodeAction> convertFixes(ErrorDescription err, Consumer<Exce
}
}
- List<Fix> fixes = sortFixes(lfl.getFixes());
+ List<Fix> baseFixes = lfl.getFixes();
+
+ baseFixes = sortFixes(baseFixes);
+
+ List<Pair<Fix, Boolean>> fixesAndSubfixes = new ArrayList<>(); // true if main fix
+
+ for (Fix f : baseFixes){
+ fixesAndSubfixes.add(Pair.of(f, true));
+
+ try {
+ Class<?> controller = Class.forName("org.netbeans.modules.editor.hints.HintsControllerImpl",
+ false,
+ ErrorDescription.class.getClassLoader());
+ Method getSubfixes = controller.getDeclaredMethod("getSubfixes", Fix.class);
Review Comment:
That's not an option either. That code isn't public. The functionality needs to be exposed somewhere. I presume `HintsController` might be the place to look. cc/ @jlahoda
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "Achal1607 (via GitHub)" <gi...@apache.org>.
Achal1607 commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1671767833
##########
java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java:
##########
@@ -200,25 +202,55 @@ private static List<CodeAction> convertFixes(ErrorDescription err, Consumer<Exce
}
}
- List<Fix> fixes = sortFixes(lfl.getFixes());
+ List<Fix> baseFixes = lfl.getFixes();
+
+ baseFixes = sortFixes(baseFixes);
+
+ List<Pair<Fix, Boolean>> fixesAndSubfixes = new ArrayList<>(); // true if main fix
+
+ for (Fix f : baseFixes){
+ fixesAndSubfixes.add(Pair.of(f, true));
+
+ try {
+ Class<?> controller = Class.forName("org.netbeans.modules.editor.hints.HintsControllerImpl",
+ false,
+ ErrorDescription.class.getClassLoader());
+ Method getSubfixes = controller.getDeclaredMethod("getSubfixes", Fix.class);
Review Comment:
If reflection is something that we don't want to use here, then other option is importing`spi.editor.hints` and then using method `HintsControllerImpl`. If that is fine then code can be updated accordingly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1668839058
##########
java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java:
##########
@@ -200,25 +202,55 @@ private static List<CodeAction> convertFixes(ErrorDescription err, Consumer<Exce
}
}
- List<Fix> fixes = sortFixes(lfl.getFixes());
+ List<Fix> baseFixes = lfl.getFixes();
+
+ baseFixes = sortFixes(baseFixes);
+
+ List<Pair<Fix, Boolean>> fixesAndSubfixes = new ArrayList<>(); // true if main fix
+
+ for (Fix f : baseFixes){
+ fixesAndSubfixes.add(Pair.of(f, true));
+
+ try {
+ Class<?> controller = Class.forName("org.netbeans.modules.editor.hints.HintsControllerImpl",
+ false,
+ ErrorDescription.class.getClassLoader());
+ Method getSubfixes = controller.getDeclaredMethod("getSubfixes", Fix.class);
Review Comment:
calling `Class.forName` in a loop is not ideal. The method field could be set in a static initializer, and the loop would run when it isn't null.
I haven't looked at this in more detail but the fact that this needs reflection is a bit of a red flag already.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "Achal1607 (via GitHub)" <gi...@apache.org>.
Achal1607 commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1684208183
##########
java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java:
##########
@@ -200,25 +202,55 @@ private static List<CodeAction> convertFixes(ErrorDescription err, Consumer<Exce
}
}
- List<Fix> fixes = sortFixes(lfl.getFixes());
+ List<Fix> baseFixes = lfl.getFixes();
+
+ baseFixes = sortFixes(baseFixes);
+
+ List<Pair<Fix, Boolean>> fixesAndSubfixes = new ArrayList<>(); // true if main fix
+
+ for (Fix f : baseFixes){
+ fixesAndSubfixes.add(Pair.of(f, true));
+
+ try {
+ Class<?> controller = Class.forName("org.netbeans.modules.editor.hints.HintsControllerImpl",
+ false,
+ ErrorDescription.class.getClassLoader());
+ Method getSubfixes = controller.getDeclaredMethod("getSubfixes", Fix.class);
Review Comment:
Thanks so much @lahodaj , I tried out this approach it seems to work fine, important point is it doesn't use reflection code. Updated the code accrodingly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Introduced suppress warnings CodeAction in VS Code [netbeans]
Posted by "Achal1607 (via GitHub)" <gi...@apache.org>.
Achal1607 commented on code in PR #7548:
URL: https://github.com/apache/netbeans/pull/7548#discussion_r1687403920
##########
java/java.hints/src/org/netbeans/modules/java/hints/bugs/Unused.java:
##########
@@ -52,7 +52,12 @@ public class Unused {
@BooleanOption(displayName="#LBL_UnusedPackagePrivate", tooltip="#TP_UnusedPackagePrivate", defaultValue=DETECT_UNUSED_PACKAGE_PRIVATE_DEFAULT)
public static final String DETECT_UNUSED_PACKAGE_PRIVATE = "detect.unused.package.private";
- @TriggerTreeKind(Kind.COMPILATION_UNIT)
+ @TriggerTreeKind({
+ //class-like kinds:
+ Kind.ANNOTATION_TYPE, Kind.CLASS, Kind.ENUM, Kind.INTERFACE, Kind.RECORD,
+ Kind.VARIABLE,
+ Kind.METHOD
+ })
public static List<ErrorDescription> unused(HintContext ctx) {
Review Comment:
This change is made so that it can honour `@SuppressWarnings("unused")` otherwise currently suppress warning annotation for unused variables is not working. For more info please refer to https://github.com/oracle/javavscode/issues/96
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists