GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — codeql/java/ql/src/Metrics/Internal/Extents.qll at codeql-cli/v2.25.1 · github/codeql

Expand file tree

/

Extents.qll

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
61 lines (56 loc) · 2.09 KB
/

Extents.qll

Copy path

File metadata and controls

61 lines (56 loc) · 2.09 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* Provides classes that modify the default location information
* of `RefType`s and `Callable`s to cover their full extent.
*
* When this library is imported, the `hasLocationInfo` predicate of
* `Callable` and `RefTypes` is overridden to specify their entire range
* instead of just the range of their name. The latter can still be
* obtained by invoking the `getLocation()` predicate.
*
* The full ranges may be used to determine whether a given location
* (for example, the location of an alert) is contained within the extent
* of a `Callable` or `RefType`.
*/
import java
/**
* A Callable whose `hasLocationInfo` is overridden to specify its entire range
* including the body (if any), as opposed to the location of its name only.
*/
class RangeCallable extends Callable {
override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
exists(int elSuper, int ecSuper | super.hasLocationInfo(path, sl, sc, elSuper, ecSuper) |
this.getBody().hasLocationInfo(path, _, _, el, ec)
or
not exists(this.getBody()) and
(
this.lastParameter().hasLocationInfo(path, _, _, el, ec)
or
not exists(this.getAParameter()) and el = elSuper and ec = ecSuper
)
)
}
private Parameter lastParameter() {
result = this.getAParameter() and
not this.getAParameter().getPosition() > result.getPosition()
}
}
/**
* A `RefType` whose `hasLocationInfo` is overridden to specify its entire range
* including the range of its members (if any), as opposed to the location of its name only.
*/
class RangeRefType extends RefType {
override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
exists(int elSuper, int ecSuper | super.hasLocationInfo(path, sl, sc, elSuper, ecSuper) |
this.lastMember().hasLocationInfo(path, _, _, el, ec)
or
not exists(this.getAMember()) and el = elSuper and ec = ecSuper
)
}
private Member lastMember() {
result =
max(this.getAMember() as m
order by
m.getLocation().getStartLine(), m.getLocation().getStartColumn()
)
}
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.