mirror of
https://github.com/github/semantic.git
synced 2025-01-03 21:16:12 +03:00
Merge pull request #1500 from github/python-fixes
Fix definition of plainImport
This commit is contained in:
commit
13d311f544
@ -372,14 +372,14 @@ comment = makeTerm <$> symbol Comment <*> (Comment.Comment <$> source)
|
||||
|
||||
import' :: Assignment
|
||||
import' = makeTerm'' <$> symbol ImportStatement <*> children (manyTerm (aliasedImport <|> plainImport))
|
||||
<|> makeTerm <$> symbol ImportFromStatement <*> children (Declaration.Import <$> expression <*> emptyTerm <*> someTerm (wildCard <|> dottedName <|> aliasedSymbol <|> importSymbol))
|
||||
<|> makeTerm <$> symbol ImportFromStatement <*> children (Declaration.Import <$> (dottedName <|> emptyTerm) <*> emptyTerm <*> someTerm (wildCard <|> dottedName <|> aliasedSymbol <|> importSymbol))
|
||||
where
|
||||
importSymbol = makeTerm <$> location <*> (Declaration.ImportSymbol <$> expression <*> emptyTerm)
|
||||
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 <$> expression <*> emptyTerm <*> pure [])
|
||||
plainImport = makeTerm <$> symbol DottedName <*> children (Declaration.Import <$> expressions <*> emptyTerm <*> pure [])
|
||||
|
||||
assertStatement :: Assignment
|
||||
assertStatement = makeTerm <$> symbol AssertStatement <*> children (Expression.Call <$> pure [] <*> (makeTerm <$> symbol AnonAssert <*> (Syntax.Identifier <$> source)) <*> manyTerm expression <*> emptyTerm)
|
||||
|
@ -1,3 +1,5 @@
|
||||
from a import b
|
||||
from a import (b, c)
|
||||
from a import *
|
||||
from a.b import c
|
||||
from . import b
|
||||
|
@ -2,3 +2,5 @@ from b import a
|
||||
from b import (c, a)
|
||||
from b import *
|
||||
from b import a as x, b as y
|
||||
from b.c import d
|
||||
from . import d
|
||||
|
@ -35,4 +35,15 @@
|
||||
{+(ImportSymbol
|
||||
{+(ScopeResolution
|
||||
{+(Identifier)+})+}
|
||||
{+(Identifier)+})+})+})
|
||||
{+(Identifier)+})+})+}
|
||||
(Import
|
||||
(ScopeResolution
|
||||
{-(Identifier)-}
|
||||
(Identifier)
|
||||
{+(Identifier)+})
|
||||
(Empty)
|
||||
(ScopeResolution{(Identifier)->(Identifier)}))
|
||||
(Import
|
||||
(Empty)
|
||||
(Empty)
|
||||
(ScopeResolution{(Identifier)->(Identifier)})))
|
||||
|
@ -24,6 +24,16 @@
|
||||
->(Identifier) })
|
||||
(Empty)
|
||||
(Identifier))
|
||||
{+(Import
|
||||
{+(ScopeResolution
|
||||
{+(Identifier)+}
|
||||
{+(Identifier)+})+}
|
||||
{+(Empty)+}
|
||||
{+(ScopeResolution{+(Identifier)+})+})+}
|
||||
{+(Import
|
||||
{+(Empty)+}
|
||||
{+(Empty)+}
|
||||
{+(ScopeResolution{+(Identifier)+})+})+}
|
||||
{-(Import
|
||||
{-(ScopeResolution
|
||||
{-(Identifier)-})-}
|
||||
@ -35,4 +45,14 @@
|
||||
{-(ImportSymbol
|
||||
{-(ScopeResolution
|
||||
{-(Identifier)-})-}
|
||||
{-(Identifier)-})-})-})
|
||||
{-(Identifier)-})-})-}
|
||||
{-(Import
|
||||
{-(ScopeResolution
|
||||
{-(Identifier)-}
|
||||
{-(Identifier)-})-}
|
||||
{-(Empty)-}
|
||||
{-(ScopeResolution{-(Identifier)-})-})-}
|
||||
{-(Import
|
||||
{-(Empty)-}
|
||||
{-(Empty)-}
|
||||
{-(ScopeResolution{-(Identifier)-})-})-})
|
||||
|
@ -17,4 +17,14 @@
|
||||
(ScopeResolution
|
||||
(Identifier))
|
||||
(Empty)
|
||||
(Identifier)))
|
||||
(Identifier))
|
||||
(Import
|
||||
(ScopeResolution
|
||||
(Identifier)
|
||||
(Identifier))
|
||||
(Empty)
|
||||
(ScopeResolution(Identifier)))
|
||||
(Import
|
||||
(Empty)
|
||||
(Empty)
|
||||
(ScopeResolution(Identifier))))
|
||||
|
@ -29,4 +29,14 @@
|
||||
(ImportSymbol
|
||||
(ScopeResolution
|
||||
(Identifier))
|
||||
(Identifier))))
|
||||
(Identifier)))
|
||||
(Import
|
||||
(ScopeResolution
|
||||
(Identifier)
|
||||
(Identifier))
|
||||
(Empty)
|
||||
(ScopeResolution(Identifier)))
|
||||
(Import
|
||||
(Empty)
|
||||
(Empty)
|
||||
(ScopeResolution(Identifier))))
|
||||
|
1
test/fixtures/python/import-statement.A.py
vendored
1
test/fixtures/python/import-statement.A.py
vendored
@ -1,2 +1,3 @@
|
||||
import a, b as c
|
||||
import b.c as d, e
|
||||
import a.b.c
|
||||
|
1
test/fixtures/python/import-statement.B.py
vendored
1
test/fixtures/python/import-statement.B.py
vendored
@ -1,2 +1,3 @@
|
||||
import b, a
|
||||
import a.c as e
|
||||
import b.c.d
|
||||
|
@ -1,26 +1,16 @@
|
||||
(Program
|
||||
(
|
||||
{+(Import
|
||||
({+(Import
|
||||
{+(Identifier)+}
|
||||
{+(Empty)+})+}
|
||||
(Import
|
||||
(Identifier)
|
||||
(Empty))
|
||||
{-(Import
|
||||
{-(ScopeResolution
|
||||
{-(Identifier)-})-}
|
||||
{-(Identifier)-})-})
|
||||
{+(Empty)+})+}(Import(Identifier)(Empty))
|
||||
{-(Import{-(ScopeResolution{-(Identifier)-})-}{-(Identifier)-})-})
|
||||
{+(Import
|
||||
{+(ScopeResolution
|
||||
{+(Identifier)+}
|
||||
{+(ScopeResolution
|
||||
{+(Identifier)+}
|
||||
{+(Identifier)+})+}
|
||||
{+(Identifier)+})+}
|
||||
{+(Identifier)+})+}
|
||||
{-(
|
||||
{-(Import
|
||||
{-(ScopeResolution
|
||||
{-(Identifier)-}
|
||||
{-(Identifier)-})-}
|
||||
{-(Identifier)-})-}
|
||||
{-(Import
|
||||
{-(Identifier)-}
|
||||
{-(Empty)-})-})-})
|
||||
{+(Import
|
||||
{+({+(Identifier)+}{+(Identifier)+}{+(Identifier)+})+}
|
||||
{+(Empty)+})+}
|
||||
{-({-(Import{-(ScopeResolution{-(Identifier)-}{-(Identifier)-})-}{-(Identifier)-})-}
|
||||
{-(Import{-(Identifier)-}{-(Empty)-})-})-}
|
||||
{-(Import{-({-(Identifier)-}{-(Identifier)-}{-(Identifier)-})-}{-(Empty)-})-})
|
@ -1,26 +1,31 @@
|
||||
(Program
|
||||
(
|
||||
|
||||
(
|
||||
{-(Import
|
||||
{-(Identifier)-}
|
||||
{-(Empty)-})-}
|
||||
(Import
|
||||
(Identifier)
|
||||
(Empty))
|
||||
(Import
|
||||
(Identifier)
|
||||
(Empty))
|
||||
{+(Import
|
||||
{+(ScopeResolution
|
||||
{+(Identifier)+})+}
|
||||
{+(Identifier)+})+})
|
||||
{+(
|
||||
{+(Import
|
||||
{+(ScopeResolution
|
||||
{+(Identifier)+}
|
||||
{+(Identifier)+})+}
|
||||
{+(ScopeResolution{+(Identifier)+})+}
|
||||
{+(Identifier)+})+}
|
||||
{+(Import
|
||||
)
|
||||
{+({+
|
||||
(Import
|
||||
{+(ScopeResolution
|
||||
{+(Identifier)+}
|
||||
{+(Empty)+})+})+}
|
||||
{-(Import
|
||||
{-(ScopeResolution
|
||||
{+(Identifier)+})+}
|
||||
{+(Identifier)+})+}
|
||||
{+(Import
|
||||
{+(Identifier)+}
|
||||
{+(Empty)+})+})+}
|
||||
|
||||
(Import
|
||||
{(ScopeResolution
|
||||
{-(Identifier)-}
|
||||
{-(Identifier)-})-}
|
||||
{-(Identifier)-})-})
|
||||
{-(Identifier)-})->({+(Identifier)+}{+(Identifier)+}{+(Identifier)+})}
|
||||
{(Identifier)->(Empty)})
|
||||
{-(Import
|
||||
{-({-(Identifier)-}{-(Identifier)-}{-(Identifier)-})-}
|
||||
{-(Empty)-})-})
|
||||
|
@ -15,4 +15,5 @@
|
||||
(Identifier))
|
||||
(Import
|
||||
(Identifier)
|
||||
(Empty))))
|
||||
(Empty)))
|
||||
(Import((Identifier)(Identifier)(Identifier))(Empty)))
|
||||
|
@ -10,4 +10,7 @@
|
||||
(ScopeResolution
|
||||
(Identifier)
|
||||
(Identifier))
|
||||
(Identifier)))
|
||||
(Identifier))
|
||||
(Import
|
||||
((Identifier) (Identifier) (Identifier))
|
||||
(Empty)))
|
||||
|
Loading…
Reference in New Issue
Block a user