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:
parent
c4a98d65de
commit
ee749ddcf1
@ -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)
|
||||
|
@ -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)-})-})-})
|
||||
|
@ -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)-})-})-})
|
||||
|
14
test/fixtures/python/import-statement.parseA.txt
vendored
14
test/fixtures/python/import-statement.parseA.txt
vendored
@ -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))))
|
||||
|
14
test/fixtures/python/import-statement.parseB.txt
vendored
14
test/fixtures/python/import-statement.parseB.txt
vendored
@ -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))))
|
||||
|
Loading…
Reference in New Issue
Block a user