Skip to content

Commit e103130

Browse files
authored
Add experimental GENERIC_SIGNATURE. (#1802)
* Add experimental GENERIC_SIGNATURE. See comment section in diff for further details. * Add generated code changes.
1 parent d4a6533 commit e103130

File tree

105 files changed

+1606
-1093
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+1606
-1093
lines changed

Diff for: domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/GraphSchema.scala

+508-490
Large diffs are not rendered by default.

Diff for: domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/Properties.scala

+38-32
Original file line numberDiff line numberDiff line change
@@ -117,152 +117,158 @@ object Properties {
117117
*/
118118
val FullName = flatgraph.SinglePropertyKey[String](kind = 22, name = "FULL_NAME", default = "<empty>")
119119

120+
/** This field is experimental. It will likely be removed in the future without any notice. It stores type information
121+
* for generic types and methods as well as type information for members and locals where the type either contains a
122+
* type parameter reference or an instantiated type reference.
123+
*/
124+
val GenericSignature = flatgraph.SinglePropertyKey[String](kind = 23, name = "GENERIC_SIGNATURE", default = "<empty>")
125+
120126
/** This property contains a hash value in the form of a string. Hashes can be used to summarize data, e.g., to
121127
* summarize the contents of source files or sub graphs. Such summaries are useful to determine whether code has
122128
* already been analyzed in incremental analysis pipelines. This property is optional to allow its calculation to be
123129
* deferred or skipped if the hash is not needed.
124130
*/
125-
val Hash = flatgraph.OptionalPropertyKey[String](kind = 23, name = "HASH")
131+
val Hash = flatgraph.OptionalPropertyKey[String](kind = 24, name = "HASH")
126132

127133
/** The identifier under which the import can be accessed in the importing context. For a Java import this is always
128134
* identical to the class name. But e.g. for a Kotlin import like "import java.nio.ByteBuffer as BBuffer" this would
129135
* be "BBuffer". This property is ignored if IS_WILDCARD is true.
130136
*/
131-
val ImportedAs = flatgraph.OptionalPropertyKey[String](kind = 24, name = "IMPORTED_AS")
137+
val ImportedAs = flatgraph.OptionalPropertyKey[String](kind = 25, name = "IMPORTED_AS")
132138

133139
/** The identifying string of the imported entity. For a Java import like "import java.nio.ByteBuffer;" this would be
134140
* "java.nio.ByteBuffer".
135141
*/
136-
val ImportedEntity = flatgraph.OptionalPropertyKey[String](kind = 25, name = "IMPORTED_ENTITY")
142+
val ImportedEntity = flatgraph.OptionalPropertyKey[String](kind = 26, name = "IMPORTED_ENTITY")
137143

138144
/** Specifies an index, e.g., for a parameter or argument. Explicit parameters are numbered from 1 to N, while index 0
139145
* is reserved for implicit self / this parameter.
140146
*/
141-
val Index = flatgraph.SinglePropertyKey[Int](kind = 26, name = "INDEX", default = -1: Int)
147+
val Index = flatgraph.SinglePropertyKey[Int](kind = 27, name = "INDEX", default = -1: Int)
142148

143149
/** The static types a TYPE_DECL inherits from. This property is matched against the FULL_NAME of TYPE nodes and thus
144150
* it is required to have at least one TYPE node for each TYPE_FULL_NAME
145151
*/
146-
val InheritsFromTypeFullName = flatgraph.MultiPropertyKey[String](kind = 27, name = "INHERITS_FROM_TYPE_FULL_NAME")
152+
val InheritsFromTypeFullName = flatgraph.MultiPropertyKey[String](kind = 28, name = "INHERITS_FROM_TYPE_FULL_NAME")
147153

148154
/** Specifies whether this is an explicit import. Most languages have implicit default imports of some standard
149155
* library elements and this flag is used to distinguish those from explicit imports found in the code base.
150156
*/
151-
val IsExplicit = flatgraph.OptionalPropertyKey[Boolean](kind = 28, name = "IS_EXPLICIT")
157+
val IsExplicit = flatgraph.OptionalPropertyKey[Boolean](kind = 29, name = "IS_EXPLICIT")
152158

153159
/** Indicates that the construct (METHOD or TYPE_DECL) is external, that is, it is referenced but not defined in the
154160
* code (applies both to insular parsing and to library functions where we have header files only)
155161
*/
156-
val IsExternal = flatgraph.SinglePropertyKey[Boolean](kind = 29, name = "IS_EXTERNAL", default = false)
162+
val IsExternal = flatgraph.SinglePropertyKey[Boolean](kind = 30, name = "IS_EXTERNAL", default = false)
157163

158164
/** Specifies whether a parameter is the variadic argument handling parameter of a variadic method. Only one parameter
159165
* of a method is allowed to have this property set to true.
160166
*/
161-
val IsVariadic = flatgraph.SinglePropertyKey[Boolean](kind = 30, name = "IS_VARIADIC", default = false)
167+
val IsVariadic = flatgraph.SinglePropertyKey[Boolean](kind = 31, name = "IS_VARIADIC", default = false)
162168

163169
/** Specifies whether this is a wildcard import. For a Java import like "import java.nio.*;" IS_WILDCARD would be
164170
* "true" and IMPORTED_ENTITY would be "java.nio". For wildcard imports the IMPORTED_AS property is ignored.
165171
*/
166-
val IsWildcard = flatgraph.OptionalPropertyKey[Boolean](kind = 31, name = "IS_WILDCARD")
172+
val IsWildcard = flatgraph.OptionalPropertyKey[Boolean](kind = 32, name = "IS_WILDCARD")
167173

168174
/** This property denotes a key of a key-value pair. */
169-
val Key = flatgraph.SinglePropertyKey[String](kind = 32, name = "KEY", default = "<empty>")
175+
val Key = flatgraph.SinglePropertyKey[String](kind = 33, name = "KEY", default = "<empty>")
170176

171177
/** This field indicates which CPG language frontend generated the CPG. Frontend developers may freely choose a value
172178
* that describes their frontend so long as it is not used by an existing frontend. Reserved values are to date: C,
173179
* LLVM, GHIDRA, PHP.
174180
*/
175-
val Language = flatgraph.SinglePropertyKey[String](kind = 33, name = "LANGUAGE", default = "<empty>")
181+
val Language = flatgraph.SinglePropertyKey[String](kind = 34, name = "LANGUAGE", default = "<empty>")
176182

177183
/** This optional field provides the line number of the program construct represented by the node.
178184
*/
179-
val LineNumber = flatgraph.OptionalPropertyKey[Int](kind = 34, name = "LINE_NUMBER")
185+
val LineNumber = flatgraph.OptionalPropertyKey[Int](kind = 35, name = "LINE_NUMBER")
180186

181187
/** This optional fields provides the line number at which the program construct represented by the node ends.
182188
*/
183-
val LineNumberEnd = flatgraph.OptionalPropertyKey[Int](kind = 35, name = "LINE_NUMBER_END")
189+
val LineNumberEnd = flatgraph.OptionalPropertyKey[Int](kind = 36, name = "LINE_NUMBER_END")
184190

185191
/** The FULL_NAME of a method. Used to link CALL and METHOD nodes. It is required to have exactly one METHOD node for
186192
* each METHOD_FULL_NAME
187193
*/
188-
val MethodFullName = flatgraph.SinglePropertyKey[String](kind = 36, name = "METHOD_FULL_NAME", default = "<empty>")
194+
val MethodFullName = flatgraph.SinglePropertyKey[String](kind = 37, name = "METHOD_FULL_NAME", default = "<empty>")
189195

190-
val MethodShortName = flatgraph.SinglePropertyKey[String](kind = 37, name = "METHOD_SHORT_NAME", default = "<empty>")
196+
val MethodShortName = flatgraph.SinglePropertyKey[String](kind = 38, name = "METHOD_SHORT_NAME", default = "<empty>")
191197

192198
/** The modifier type is a free-form string. The following are known modifier types: `STATIC`, `PUBLIC`, `PROTECTED`,
193199
* `PRIVATE`, `ABSTRACT`, `NATIVE`, `CONSTRUCTOR`, `VIRTUAL`.
194200
*/
195-
val ModifierType = flatgraph.SinglePropertyKey[String](kind = 38, name = "MODIFIER_TYPE", default = "<empty>")
201+
val ModifierType = flatgraph.SinglePropertyKey[String](kind = 39, name = "MODIFIER_TYPE", default = "<empty>")
196202

197203
/** Name of represented object, e.g., method name (e.g. "run") */
198-
val Name = flatgraph.SinglePropertyKey[String](kind = 39, name = "NAME", default = "<empty>")
204+
val Name = flatgraph.SinglePropertyKey[String](kind = 40, name = "NAME", default = "<empty>")
199205

200-
val NodeLabel = flatgraph.SinglePropertyKey[String](kind = 40, name = "NODE_LABEL", default = "<empty>")
206+
val NodeLabel = flatgraph.SinglePropertyKey[String](kind = 41, name = "NODE_LABEL", default = "<empty>")
201207

202208
/** Start offset into the CONTENT property of the corresponding FILE node. The offset is such that parts of the
203209
* content can easily be accessed via `content.substring(offset, offsetEnd)`. This means that the offset must be
204210
* measured in utf16 encoding (i.e. neither in characters/codeunits nor in byte-offsets into a utf8 encoding). E.g.
205211
* for METHOD nodes this start offset points to the start of the methods source code in the string holding the source
206212
* code of the entire file.
207213
*/
208-
val Offset = flatgraph.OptionalPropertyKey[Int](kind = 41, name = "OFFSET")
214+
val Offset = flatgraph.OptionalPropertyKey[Int](kind = 42, name = "OFFSET")
209215

210216
/** End offset (exclusive) into the CONTENT property of the corresponding FILE node. See OFFSET documentation for
211217
* finer details. E.g. for METHOD nodes this end offset points to the first code position which is not part of the
212218
* method.
213219
*/
214-
val OffsetEnd = flatgraph.OptionalPropertyKey[Int](kind = 42, name = "OFFSET_END")
220+
val OffsetEnd = flatgraph.OptionalPropertyKey[Int](kind = 43, name = "OFFSET_END")
215221

216222
/** This integer indicates the position of the node among its siblings in the AST. The left-most child has an order of
217223
* 0.
218224
*/
219-
val Order = flatgraph.SinglePropertyKey[Int](kind = 43, name = "ORDER", default = -1: Int)
225+
val Order = flatgraph.SinglePropertyKey[Int](kind = 44, name = "ORDER", default = -1: Int)
220226

221227
/** The field contains the names of the overlays applied to this CPG, in order of their application. Names are
222228
* free-form strings, that is, this specification does not dictate them but rather requires tool producers and
223229
* consumers to communicate them between each other.
224230
*/
225-
val Overlays = flatgraph.MultiPropertyKey[String](kind = 44, name = "OVERLAYS")
231+
val Overlays = flatgraph.MultiPropertyKey[String](kind = 45, name = "OVERLAYS")
226232

227-
val PackageName = flatgraph.SinglePropertyKey[String](kind = 45, name = "PACKAGE_NAME", default = "<empty>")
233+
val PackageName = flatgraph.SinglePropertyKey[String](kind = 46, name = "PACKAGE_NAME", default = "<empty>")
228234

229235
/** AST node type name emitted by parser. */
230-
val ParserTypeName = flatgraph.SinglePropertyKey[String](kind = 46, name = "PARSER_TYPE_NAME", default = "<empty>")
236+
val ParserTypeName = flatgraph.SinglePropertyKey[String](kind = 47, name = "PARSER_TYPE_NAME", default = "<empty>")
231237

232238
/** Similar to `DYNAMIC_TYPE_HINT_FULL_NAME`, but that this makes no guarantee that types within this property are
233239
* correct. This property is used to capture observations between node interactions during a 'may-analysis'.
234240
*/
235-
val PossibleTypes = flatgraph.MultiPropertyKey[String](kind = 47, name = "POSSIBLE_TYPES")
241+
val PossibleTypes = flatgraph.MultiPropertyKey[String](kind = 48, name = "POSSIBLE_TYPES")
236242

237243
/** The path to the root directory of the source/binary this CPG is generated from. */
238-
val Root = flatgraph.SinglePropertyKey[String](kind = 48, name = "ROOT", default = "<empty>")
244+
val Root = flatgraph.SinglePropertyKey[String](kind = 49, name = "ROOT", default = "<empty>")
239245

240246
/** The method signature encodes the types of parameters in a string. The string SHOULD be human readable and suitable
241247
* for differentiating methods with different parameter types sufficiently to allow for resolving of function
242248
* overloading. The present specification does not enforce a strict format for the signature, that is, it can be
243249
* chosen by the frontend implementor to fit the source language.
244250
*/
245-
val Signature = flatgraph.SinglePropertyKey[String](kind = 49, name = "SIGNATURE", default = "")
251+
val Signature = flatgraph.SinglePropertyKey[String](kind = 50, name = "SIGNATURE", default = "")
246252

247-
val Symbol = flatgraph.SinglePropertyKey[String](kind = 50, name = "SYMBOL", default = "<empty>")
253+
val Symbol = flatgraph.SinglePropertyKey[String](kind = 51, name = "SYMBOL", default = "<empty>")
248254

249255
/** The static type decl of a TYPE. This property is matched against the FULL_NAME of TYPE_DECL nodes. It is required
250256
* to have exactly one TYPE_DECL for each different TYPE_DECL_FULL_NAME
251257
*/
252258
val TypeDeclFullName =
253-
flatgraph.SinglePropertyKey[String](kind = 51, name = "TYPE_DECL_FULL_NAME", default = "<empty>")
259+
flatgraph.SinglePropertyKey[String](kind = 52, name = "TYPE_DECL_FULL_NAME", default = "<empty>")
254260

255261
/** This field contains the fully-qualified static type name of the program construct represented by a node. It is the
256262
* name of an instantiated type, e.g., `java.util.List<Integer>`, rather than `java.util.List[T]`. If the type cannot
257263
* be determined, this field should be set to the empty string.
258264
*/
259-
val TypeFullName = flatgraph.SinglePropertyKey[String](kind = 52, name = "TYPE_FULL_NAME", default = "<empty>")
265+
val TypeFullName = flatgraph.SinglePropertyKey[String](kind = 53, name = "TYPE_FULL_NAME", default = "<empty>")
260266

261267
/** This property denotes a string value as used in a key-value pair. */
262-
val Value = flatgraph.SinglePropertyKey[String](kind = 53, name = "VALUE", default = "")
268+
val Value = flatgraph.SinglePropertyKey[String](kind = 54, name = "VALUE", default = "")
263269

264270
/** A version, given as a string. Used, for example, in the META_DATA node to indicate which version of the CPG spec
265271
* this CPG conforms to
266272
*/
267-
val Version = flatgraph.SinglePropertyKey[String](kind = 54, name = "VERSION", default = "<empty>")
273+
val Version = flatgraph.SinglePropertyKey[String](kind = 55, name = "VERSION", default = "<empty>")
268274
}

Diff for: domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/PropertyNames.java

+7
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ runtime as it may depend on the type of an object (as is the case for virtual me
115115
name are language specific. This field SHOULD be human readable. */
116116
public static final String FULL_NAME = "FULL_NAME";
117117

118+
/** This field is experimental. It will likely be removed in the future without any notice.
119+
It stores type information for generic types and methods as well as type information
120+
for members and locals where the type either contains a type parameter reference or
121+
an instantiated type reference. */
122+
public static final String GENERIC_SIGNATURE = "GENERIC_SIGNATURE";
123+
118124
/** This property contains a hash value in the form of a string.
119125
Hashes can be used to summarize data, e.g., to summarize the
120126
contents of source files or sub graphs. Such summaries are useful
@@ -297,6 +303,7 @@ This means that the offset must be measured in utf16 encoding (i.e. neither in
297303
add(EXPLICIT_AS);
298304
add(FILENAME);
299305
add(FULL_NAME);
306+
add(GENERIC_SIGNATURE);
300307
add(HASH);
301308
add(IMPORTED_AS);
302309
add(IMPORTED_ENTITY);

0 commit comments

Comments
 (0)