You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
selam! is there a way to highlight when a modifier is not used within it's scope? For example
Main.java
keys
Key.java <- public class and constructor but only used by KeyManager, this should be marked
KeyManager.java <- public class and constructor but used by Main so this won't be marked
Hi, i think he means to show if an access modifier is being really used. I was looking to ask for this feature aswell as IntelliJ IDEA has it and it was really useful.
Mark "doTest()" because it's protected but it's only being used in a private matter. (Only by the constructor) so the auto-correction would be to make it private. (Unused access modifier)
The Eclipse compiler has no option that flags a package-private method that could be private.
Unused private member: org.eclipse.jdt.core.compiler.problem.unusedPrivateMember only checks members that are already private. A non-private method, even one nothing outside the class calls, is never reported, because the compiler can't see other classes in the package or reflection users.
Closest built-ins: there's no "declaration access can be weaker" check in the JDT compiler or in jdt.ls code actions. At best, if you make it private by hand and nothing uses it, it'll then warn as unused.
Other tools do have this check:
IntelliJ: has "Declaration access can be weaker".
PMD: can approximate it with rules like CouldBeStatic or unused-code rules, depending on the rule set.
SonarLint: likewise, with the relevant rules enabled.
Checkstyle: has DesignForExtension and VisibilityModifier, but those are about extension and fields, not this case.
It's also worth noting this check would generally be expensive, as you'd need to make sure nobody else in the package is actually calling it. That's why it's usually better suited to linters.
Closing as wont-fix, unless someone implements it upstream in eclipse
wont a simple rg solve it tho? I've seen intellij do this.
or maybe just detect from the already scanned scopes which ones to touch or work on.
(I no longer use both btw)
Activity
testforstephen commentedon Jun 20, 2020
Please provide a complete Java snippet to describe what's your expectation.
linsaftw commentedon Jun 28, 2020
Hi, i think he means to show if an access modifier is being really used. I was looking to ask for this feature aswell as IntelliJ IDEA has it and it was really useful.
linsaftw commentedon Jul 5, 2020
An example would be:
class Test {
public Test() {
doTest();
}
doTest() {
System.out.println("test");
}
}
Mark "doTest()" because it's protected but it's only being used in a private matter. (Only by the constructor) so the auto-correction would be to make it private. (Unused access modifier)
robstryker commentedon Oct 29, 2026
The Eclipse compiler has no option that flags a package-private method that could be private.
Other tools do have this check:
robstryker commentedon Oct 29, 2026
It's also worth noting this check would generally be expensive, as you'd need to make sure nobody else in the package is actually calling it. That's why it's usually better suited to linters.
Closing as wont-fix, unless someone implements it upstream in eclipse
linsaftw commentedon Oct 29, 2026
wont a simple rg solve it tho? I've seen intellij do this.
or maybe just detect from the already scanned scopes which ones to touch or work on.
(I no longer use both btw)