1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 23:42:31 +03:00

Restructure Python import alias assignment

This commit is contained in:
Timothy Clem 2018-03-01 11:45:43 -08:00
parent c4a98d65de
commit ee749ddcf1
5 changed files with 102 additions and 44 deletions

View File

@ -380,8 +380,11 @@ import' = makeTerm'' <$> symbol ImportStatement <*> children (manyTerm (aliased
aliasedSymbol = makeTerm <$> symbol AliasedImport <*> children (Declaration.ImportSymbol <$> expression <*> expression)
wildCard = makeTerm <$> symbol WildcardImport <*> (Syntax.Identifier <$> source)
aliasedImport = makeTerm <$> symbol AliasedImport <*> children (Declaration.Import <$> expression <*> expression <*> pure [])
plainImport = makeTerm <$> symbol DottedName <*> children (Declaration.Import <$> expressions <*> emptyTerm <*> pure [])
aliasedImport = makeImport <$> symbol AliasedImport <*> children ((,) <$> expression <*> (Just <$> expression))
plainImport = makeImport <$> symbol DottedName <*> children ((,) <$> expressions <*> pure Nothing)
makeImport loc (from, Just alias) = makeTerm loc (Declaration.Import from alias [])
makeImport loc (from, Nothing) = makeTerm loc (Declaration.Import from from [])
assertStatement :: Assignment
assertStatement = makeTerm <$> symbol AssertStatement <*> children (Expression.Call <$> pure [] <*> (makeTerm <$> symbol AnonAssert <*> (Syntax.Identifier <$> source)) <*> manyTerm expression <*> emptyTerm)

View File

@ -1,16 +1,44 @@
(Program
({+(Import
(
{+(Import
{+(Identifier)+}
{+(Empty)+})+}(Import(Identifier)(Empty))
{-(Import{-(ScopeResolution{-(Identifier)-})-}{-(Identifier)-})-})
{+(Import
{+(ScopeResolution
{+(Identifier)+}
{+(Identifier)+})+}
{+(Identifier)+})+}
(Import
(Identifier)
(Identifier))
{-(Import
{-(ScopeResolution
{-(Identifier)-})-}
{-(Identifier)-})-})
{+(Import
{+({+(Identifier)+}{+(Identifier)+}{+(Identifier)+})+}
{+(Empty)+})+}
{-({-(Import{-(ScopeResolution{-(Identifier)-}{-(Identifier)-})-}{-(Identifier)-})-}
{-(Import{-(Identifier)-}{-(Empty)-})-})-}
{-(Import{-({-(Identifier)-}{-(Identifier)-}{-(Identifier)-})-}{-(Empty)-})-})
{+(ScopeResolution
{+(Identifier)+}
{+(Identifier)+})+}
{+(Identifier)+})+}
{+(Import
{+(
{+(Identifier)+}
{+(Identifier)+}
{+(Identifier)+})+}
{+(
{+(Identifier)+}
{+(Identifier)+}
{+(Identifier)+})+})+}
{-(
{-(Import
{-(ScopeResolution
{-(Identifier)-}
{-(Identifier)-})-}
{-(Identifier)-})-}
{-(Import
{-(Identifier)-}
{-(Identifier)-})-})-}
{-(Import
{-(
{-(Identifier)-}
{-(Identifier)-}
{-(Identifier)-})-}
{-(
{-(Identifier)-}
{-(Identifier)-}
{-(Identifier)-})-})-})

View File

@ -1,31 +1,44 @@
(Program
(
(
{-(Import
{-(Identifier)-}
{-(Empty)-})-}
(Import
(Identifier)
(Empty))
{-(Identifier)-})-}
(Import
(Identifier)
(Identifier))
{+(Import
{+(ScopeResolution{+(Identifier)+})+}
{+(ScopeResolution
{+(Identifier)+})+}
{+(Identifier)+})+})
{+(
{+(Import
{+(ScopeResolution
{+(Identifier)+}
{+(Identifier)+})+}
{+(Identifier)+})+}
)
{+({+
(Import
{+(ScopeResolution
{+(Import
{+(Identifier)+}
{+(Identifier)+})+})+}
{+(Import
{+(
{+(Identifier)+}
{+(Identifier)+}
{+(Identifier)+})+}
{+(Identifier)+})+}
{+(Import
{+(Identifier)+}
{+(Empty)+})+})+}
(Import
{(ScopeResolution
{-(Identifier)-}
{-(Identifier)-})->({+(Identifier)+}{+(Identifier)+}{+(Identifier)+})}
{(Identifier)->(Empty)})
{+(
{+(Identifier)+}
{+(Identifier)+}
{+(Identifier)+})+})+}
{-(Import
{-({-(Identifier)-}{-(Identifier)-}{-(Identifier)-})-}
{-(Empty)-})-})
{-(ScopeResolution
{-(Identifier)-}
{-(Identifier)-})-}
{-(Identifier)-})-}
{-(Import
{-(
{-(Identifier)-}
{-(Identifier)-}
{-(Identifier)-})-}
{-(
{-(Identifier)-}
{-(Identifier)-}
{-(Identifier)-})-})-})

View File

@ -2,7 +2,7 @@
(
(Import
(Identifier)
(Empty))
(Identifier))
(Import
(ScopeResolution
(Identifier))
@ -15,5 +15,13 @@
(Identifier))
(Import
(Identifier)
(Empty)))
(Import((Identifier)(Identifier)(Identifier))(Empty)))
(Identifier)))
(Import
(
(Identifier)
(Identifier)
(Identifier))
(
(Identifier)
(Identifier)
(Identifier))))

View File

@ -2,15 +2,21 @@
(
(Import
(Identifier)
(Empty))
(Identifier))
(Import
(Identifier)
(Empty)))
(Identifier)))
(Import
(ScopeResolution
(Identifier)
(Identifier))
(Identifier))
(Import
((Identifier) (Identifier) (Identifier))
(Empty)))
(
(Identifier)
(Identifier)
(Identifier))
(
(Identifier)
(Identifier)
(Identifier))))