Skip to content

Commit 07499f5

Browse files
committed
Rework comments for some CPG properties.
Added/adjuted comments for METHOD_FULL_NAME, TYPE_FULL_NAME, DYNAMIC_TYPE_HINT_FULL_NAME.
1 parent afa541f commit 07499f5

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

schema/src/main/scala/io/shiftleft/codepropertygraph/schema/CallGraph.scala

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,18 @@ object CallGraph extends SchemaBase {
5555
.addProperty(
5656
name = "METHOD_FULL_NAME",
5757
valueType = ValueType.String,
58-
comment = """The FULL_NAME of a method. Used to link CALL and METHOD nodes. It is required
59-
|to have exactly one METHOD node for each METHOD_FULL_NAME""".stripMargin
58+
comment = """The FULL_NAME of a method. Used to link CALL and METHOD nodes.
59+
|For METHOD nodes this property must be a unique fully-qualified name.
60+
|For CALL nodes this property has different semantics depending on the
61+
|CALL nodes DISPATCH_TYPE property.
62+
|For DISPATCH_TYPE STATIC_DISPATCH this property contains the
63+
|fully-qualified name of the called method.
64+
|For DISPATCH_TYPE DYNAMIC_DISPATCH this property contains the
65+
|fully-qualified name of the assured interface method which is
66+
|straight forward for statically typed languages like Java and CSharp.
67+
|For dynamically typed languages no interface assurance exists so
68+
|frontends should indicate by some name like "<unknown>".
69+
|""".stripMargin
6070
)
6171
.mandatory(PropertyDefaults.String)
6272
.protoId(54)

schema/src/main/scala/io/shiftleft/codepropertygraph/schema/Hidden.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,14 @@ object Hidden extends SchemaBase {
155155
.addProperty(
156156
name = "DYNAMIC_TYPE_HINT_FULL_NAME",
157157
valueType = ValueType.String,
158-
comment = "Type hint for the dynamic type"
158+
comment = """This is a multi valued property which gives information about all observable
159+
|runtime types for the node carrying this property. This means if e.g. an
160+
|expression has the static TYPE_FULL_NAME `SomeInterface` which is implemented
161+
|by `ImplA`, `ImplB` and `ImplC` and DYNAMIC_TYPE_HINT_FULL_NAME is given as
162+
|`List(ImplA, ImplB)`, that only `ImplA` and `ImplB` can ever be observed
163+
|as runtime times and never `ImplC`. This property is used to enable shortcuts
164+
|in data flow tracker implementations.
165+
|""".stripMargin
159166
)
160167
.asList()
161168
.protoId(1591)

schema/src/main/scala/io/shiftleft/codepropertygraph/schema/Type.scala

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,23 @@ object Type extends SchemaBase {
3131
name = "TYPE_FULL_NAME",
3232
valueType = ValueType.String,
3333
comment = """This field contains the fully-qualified static type name of the program
34-
|construct represented by a node. It is the name of an instantiated type, e.g.,
35-
|`java.util.List<Integer>`, rather than `java.util.List[T]`. If the type
36-
|cannot be determined, this field should be set to the empty string.
34+
|construct represented by a node. For static languages like Java and CSharp
35+
|this property is supposed to be filled with type names guaranteed to be
36+
|correct. E.g. type names coming from a compiler library or byte code.
37+
|Dynamic languages have no static type information and are supposed
38+
|to fill this property with always the same type name which indicates "any".
39+
|This is why for example for Javascript the type name "ANY" is used.
40+
|Type full names for higher kinded types like `java.util.List<T>` can
41+
|appear with or without a concrete types for `T`. Two examples for Java
42+
|illustrate this:
43+
| 1. `List<Integer> l = null`
44+
| Here the IDENTIFIER and LOCAL nodes for `l` have `java.lang.List<T>`
45+
| as type full name.
46+
| 2. `class SomeGenericClass<A> { void doStuff(List<A> par1) { ... } }`
47+
| Here the METHOD_PARAMETER_IN node for `par` has `java.lang.List<A>`
48+
| as type full name.
49+
|If the type cannot be determined, use some indicative name reflecting this
50+
|fact like "<unresolved>".
3751
|""".stripMargin
3852
)
3953
.mandatory(PropertyDefaults.String)

0 commit comments

Comments
 (0)