-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathmethod.ts
More file actions
79 lines (71 loc) · 2.15 KB
/
method.ts
File metadata and controls
79 lines (71 loc) · 2.15 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { ResolvableLocationValue } from "../common/bqrs-cli-types";
import { ModeledMethod, ModeledMethodType } from "./modeled-method";
export type Call = {
label: string;
url: ResolvableLocationValue;
};
export enum CallClassification {
Unknown = "unknown",
Source = "source",
Test = "test",
Generated = "generated",
}
export type Usage = Call & {
classification: CallClassification;
};
export interface MethodSignature {
/**
* Contains the version of the library if it can be determined by CodeQL, e.g. `4.2.2.2`
*/
libraryVersion?: string;
/**
* A unique signature that can be used to identify this external API usage.
*
* The signature contains the package name, type name, method name, and method parameters
* in the form "packageName.typeName#methodName(methodParameters)".
* e.g. `org.sql2o.Connection#createQuery(String)`
*/
signature: string;
/**
* The package name in Java, or the namespace in C#, e.g. `org.sql2o` or `System.Net.Http.Headers`.
*
* If the class is not in a package, the value should be an empty string.
*/
packageName: string;
typeName: string;
methodName: string;
/**
* The method parameters, including enclosing parentheses, e.g. `(String, String)`
*/
methodParameters: string;
}
export interface Method extends MethodSignature {
/**
* Contains the name of the library containing the method declaration, e.g. `sql2o-1.6.0.jar` or `System.Runtime.dll`
*/
library: string;
/**
* Is this method already supported by CodeQL standard libraries.
* If so, there is no need for the user to model it themselves.
*/
supported: boolean;
supportedType: ModeledMethodType;
usages: Usage[];
}
export function getArgumentsList(methodParameters: string): string[] {
if (methodParameters === "()") {
return [];
}
return methodParameters.substring(1, methodParameters.length - 1).split(",");
}
export function canMethodBeModeled(
method: Method,
modeledMethods: ModeledMethod[],
methodIsUnsaved: boolean,
): boolean {
return (
!method.supported ||
modeledMethods.some((modeledMethod) => modeledMethod.type !== "none") ||
methodIsUnsaved
);
}