Skip to content

Commit 971d146

Browse files
authored
Merge pull request #2543 from github/koesie10/exclude-anonymous-classes
Exclude methods from anonymous classes in framework mode
2 parents a76bd46 + 6e16f82 commit 971d146

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

extensions/ql-vscode/src/data-extensions-editor/queries/csharp.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ select usage, apiName, supported.toString(), "supported", api.getFile().getBaseN
3737
*/
3838
3939
private import csharp
40+
private import cil
4041
private import dotnet
4142
private import semmle.code.csharp.dispatch.Dispatch
4243
private import semmle.code.csharp.dataflow.ExternalFlow
@@ -66,11 +67,12 @@ class TestLibrary extends RefType {
6667
/** Holds if the given callable is not worth supporting. */
6768
private predicate isUninteresting(DotNet::Callable c) {
6869
c.getDeclaringType() instanceof TestLibrary or
69-
c.(Constructor).isParameterless()
70+
c.(Constructor).isParameterless() or
71+
c.getDeclaringType() instanceof AnonymousClass
7072
}
7173
7274
class PublicMethod extends DotNet::Member {
73-
PublicMethod() { this.isPublic() and not isUninteresting(this) and exists(this.(DotNet::Member)) }
75+
PublicMethod() { this.isPublic() and not isUninteresting(this) }
7476
7577
/**
7678
* Gets the unbound type, name and parameter types of this API.

extensions/ql-vscode/src/data-extensions-editor/queries/java.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ private import semmle.code.java.dataflow.internal.ModelExclusions
5050
/** Holds if the given callable is not worth supporting. */
5151
private predicate isUninteresting(Callable c) {
5252
c.getDeclaringType() instanceof TestLibrary or
53-
c.(Constructor).isParameterless()
53+
c.(Constructor).isParameterless() or
54+
c.getDeclaringType() instanceof AnonymousClass
5455
}
5556
56-
class PublicMethod extends Callable {
57+
class PublicMethod extends Method {
5758
PublicMethod() { this.isPublic() and not isUninteresting(this) }
5859
5960
/**

0 commit comments

Comments
 (0)