mirror of https://github.com/mtshiba/pylyzer
fix: type decl generator
This commit is contained in:
parent
fa4cefd327
commit
4c57e6ead7
|
|
@ -63,6 +63,7 @@ impl DeclFileGenerator {
|
||||||
fn escape_type(&self, typ: String) -> String {
|
fn escape_type(&self, typ: String) -> String {
|
||||||
typ.replace('%', "Type_")
|
typ.replace('%', "Type_")
|
||||||
.replace("<module>", "")
|
.replace("<module>", "")
|
||||||
|
.replace('/', ".")
|
||||||
.trim_start_matches(self.filename.trim_end_matches(".d.er"))
|
.trim_start_matches(self.filename.trim_end_matches(".d.er"))
|
||||||
.trim_start_matches(&self.namespace)
|
.trim_start_matches(&self.namespace)
|
||||||
.to_string()
|
.to_string()
|
||||||
|
|
@ -70,7 +71,15 @@ impl DeclFileGenerator {
|
||||||
|
|
||||||
// e.g. `x: foo.Bar` => `foo = pyimport "foo"; x: foo.Bar`
|
// e.g. `x: foo.Bar` => `foo = pyimport "foo"; x: foo.Bar`
|
||||||
fn prepare_using_type(&mut self, typ: &Type) {
|
fn prepare_using_type(&mut self, typ: &Type) {
|
||||||
let namespace = Str::rc(typ.namespace().split('.').next().unwrap());
|
let namespace = Str::rc(
|
||||||
|
typ.namespace()
|
||||||
|
.split('/')
|
||||||
|
.next()
|
||||||
|
.unwrap()
|
||||||
|
.split('.')
|
||||||
|
.next()
|
||||||
|
.unwrap(),
|
||||||
|
);
|
||||||
if namespace != self.namespace
|
if namespace != self.namespace
|
||||||
&& !namespace.is_empty()
|
&& !namespace.is_empty()
|
||||||
&& self.imported.insert(namespace.clone())
|
&& self.imported.insert(namespace.clone())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue