Note that parameterizations of local classes are themselves local

Previously `LocalClass` itself would match `.isLocal()` whereas `LocalClass<Param>` would not. Rather than require each individual user to check for `.getSourceDeclaration().isLocal()`, let's note that the specializations themselves are local.
This commit is contained in:
Chris Smowton
2022-01-10 18:19:31 +00:00
parent d912a98b02
commit e352a4b994
4 changed files with 21 additions and 1 deletions

View File

@@ -905,7 +905,7 @@ class Interface extends ClassOrInterface, @interface {
/** A class or interface. */
class ClassOrInterface extends RefType, @classorinterface {
/** Holds if this class or interface is local. */
predicate isLocal() { isLocalClassOrInterface(this, _) }
predicate isLocal() { isLocalClassOrInterface(this.getSourceDeclaration(), _) }
/** Holds if this class or interface is package protected, that is, neither public nor private nor protected. */
predicate isPackageProtected() {

View File

@@ -0,0 +1,11 @@
public class Test {
public static void method() {
class GenericLocal<T> { }
GenericLocal<Integer> instantiated = new GenericLocal<>();
}
}

View File

@@ -0,0 +1,2 @@
| Test$1GenericLocal.class:0:0:0:0 | GenericLocal<Integer> |
| Test.java:5:11:5:22 | GenericLocal |

View File

@@ -0,0 +1,7 @@
import java
from ClassOrInterface ci
where
ci.getSourceDeclaration().fromSource() and
ci.isLocal()
select ci