add support for the Subclass token

This commit is contained in:
Erik Krogh Kristensen
2022-04-27 11:14:50 +02:00
parent a02e812de8
commit 46acce0ad4
4 changed files with 12 additions and 1 deletions

View File

@@ -57,6 +57,9 @@ API::Node getExtraSuccessorFromNode(API::Node node, AccessPathToken token) {
or
token.getName() = "Awaited" and
result = node.getAwaited()
or
token.getName() = "Subclass" and
result = node.getASubclass*()
// Some features don't have MaD tokens yet, they would need to be added to API-graphs first.
// - decorators ("DecoratedClass", "DecoratedMember", "DecoratedParameter")
// - Array/Map elements ("ArrayElement", "Element", "MapKey", "MapValue")

View File

@@ -40,6 +40,7 @@ isSource
| test.py:25:34:25:39 | ControlFlowNode for second | test-source |
| test.py:39:11:39:20 | ControlFlowNode for Await | test-source |
| test.py:41:8:41:27 | ControlFlowNode for Attribute() | test-source |
| test.py:46:7:46:16 | ControlFlowNode for SubClass() | test-source |
syntaxErrors
| Member[foo |
| Member[foo] .Member[bar] |

View File

@@ -38,4 +38,9 @@ async def async_func():
prom = CommonTokens.makePromise(1);
val = await prom
inst = CommonTokens.Class()
inst = CommonTokens.Class()
class SubClass (CommonTokens.Super):
pass
sub = SubClass()

View File

@@ -54,6 +54,7 @@ class Sinks extends ModelInput::SinkModelCsv {
}
// TODO: Commonly used tokens
// TODO: Should `instance()` be shorthand for `subClass*().getReturn()`?
// TODO: Uniform tokens for fields
// TODO: Non-positional arguments (including Named parameters)
// TODO: Any argument
@@ -74,6 +75,7 @@ class Sources extends ModelInput::SourceModelCsv {
// Common tokens.
"testlib;;Member[CommonTokens].Member[makePromise].ReturnValue.Awaited;test-source", //
"testlib;;Member[CommonTokens].Member[Class].Instance;test-source", //
"testlib;;Member[CommonTokens].Member[Super].Subclass.Instance;test-source", //
]
}
}