Skip to content

Commit

Permalink
Add doc string to typeOf method
Browse files Browse the repository at this point in the history
  • Loading branch information
lshala committed Sep 20, 2024
1 parent 7f3b199 commit 3c56c01
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ class PythonLanguageFrontend(language: Language<PythonLanguageFrontend>, ctx: Tr
// No type information -> we return an autoType to infer things magically
autoType()
}

is Python.AST.Name -> {
// We have some kind of name here; let's quickly check, if this is a primitive type
val id = type.id
this.typeOf(id)
this.typeOf(type.id)
}

else -> {
// The AST supplied us with some kind of type information, but we could not parse
// it, so we need to return the unknown type.
Expand All @@ -156,15 +156,17 @@ class PythonLanguageFrontend(language: Language<PythonLanguageFrontend>, ctx: Tr
}
}

/**
* Resolves a [Type] based on its string identifier.
*/
fun typeOf(typeId: String): Type {
// Otherwise, this could already be a fully qualified type
// Check if the typeId contains a namespace delimiter for qualified types
val name =
if (language.namespaceDelimiter in typeId) {
// TODO: This might create problem with nested classes
parseName(typeId)
} else {
// otherwise, we can just simply take the unqualified name and the type
// resolver will take care of the rest
// Unqualified name, resolved by the type resolver
typeId
}

Expand Down

0 comments on commit 3c56c01

Please sign in to comment.