diff --git a/semantic.cabal b/semantic.cabal index f896702db..3e315868d 100644 --- a/semantic.cabal +++ b/semantic.cabal @@ -160,6 +160,7 @@ library , recursion-schemes , reducers , scientific + , semigroupoids , split , stm-chans , template-haskell diff --git a/src/Analysis/Abstract/Evaluating.hs b/src/Analysis/Abstract/Evaluating.hs index 80aa4849d..59beac0db 100644 --- a/src/Analysis/Abstract/Evaluating.hs +++ b/src/Analysis/Abstract/Evaluating.hs @@ -14,6 +14,7 @@ import Control.Monad.Effect.Reader import Control.Monad.Effect.State import Data.Abstract.Configuration import Data.Abstract.Evaluatable +import Data.Abstract.Address import Data.Abstract.ModuleTable import Data.Abstract.Value import Data.Blob @@ -25,28 +26,30 @@ import Prologue import System.FilePath.Posix -- | Evaluate a term to a value. -evaluate :: forall value term - . ( Evaluatable (Base term) +evaluate :: forall value term effects + . ( effects ~ RequiredEffects term value (Evaluating term value effects) + , Evaluatable (Base term) , FreeVariables term - , MonadAddressable (LocationFor value) value (Evaluating term value (EvaluatingEffects term value)) - , MonadValue term value (Evaluating term value (EvaluatingEffects term value)) + , MonadAddressable (LocationFor value) value (Evaluating term value effects) + , MonadValue term value (Evaluating term value effects) , Recursive term ) => term - -> Final (EvaluatingEffects term value) value + -> Final effects value evaluate = runAnalysis @(Evaluating term value) . evaluateModule -- | Evaluate terms and an entry point to a value. -evaluates :: forall value term - . ( Evaluatable (Base term) +evaluates :: forall value term effects + . ( effects ~ RequiredEffects term value (Evaluating term value effects) + , Evaluatable (Base term) , FreeVariables term - , MonadAddressable (LocationFor value) value (Evaluating term value (EvaluatingEffects term value)) - , MonadValue term value (Evaluating term value (EvaluatingEffects term value)) + , MonadAddressable (LocationFor value) value (Evaluating term value effects) + , MonadValue term value (Evaluating term value effects) , Recursive term ) => [(Blob, term)] -- List of (blob, term) pairs that make up the program to be evaluated -> (Blob, term) -- Entrypoint - -> Final (EvaluatingEffects term value) value + -> Final effects value evaluates pairs (b, t) = runAnalysis @(Evaluating term value) (withModules b pairs (evaluateModule t)) -- | Run an action with the passed ('Blob', @term@) pairs available for imports. @@ -76,11 +79,18 @@ type EvaluatingEffects term value , State (StoreFor value) -- The heap , Reader (ModuleTable term) -- Cache of unevaluated modules , State (ModuleTable (EnvironmentFor value)) -- Cache of evaluated modules + + , State (Map Name (Name, Maybe (Address (LocationFor value) value))) -- Set of exports ] -instance Members '[Reader (EnvironmentFor value), State (EnvironmentFor value)] effects => MonadEnvironment value (Evaluating term value effects) where +instance Members '[State (Map Name (Name, Maybe (Address (LocationFor value) value))), Reader (EnvironmentFor value), State (EnvironmentFor value)] effects => MonadEnvironment value (Evaluating term value effects) where getGlobalEnv = raise get putGlobalEnv = raise . put + withGlobalEnv s = raise . localState s . lower + + addExport key = raise . modify . Map.insert key + getExports = raise get + withExports s = raise . localState s . lower askLocalEnv = raise ask localEnv f a = raise (local f (lower a)) diff --git a/src/Analysis/Abstract/Tracing.hs b/src/Analysis/Abstract/Tracing.hs index f38978464..d7b18ac97 100644 --- a/src/Analysis/Abstract/Tracing.hs +++ b/src/Analysis/Abstract/Tracing.hs @@ -8,7 +8,8 @@ import Control.Monad.Effect.Writer import Data.Abstract.Configuration import Data.Abstract.Value import Data.Semigroup.Reducer as Reducer -import Prologue +import Data.Union +import Prologue hiding (trace) -- | Trace analysis. -- diff --git a/src/Analysis/Declaration.hs b/src/Analysis/Declaration.hs index 2cb29ec25..826837f86 100644 --- a/src/Analysis/Declaration.hs +++ b/src/Analysis/Declaration.hs @@ -147,9 +147,10 @@ instance CustomHasDeclaration (Union fs) Declaration.WildcardImport where stripQuotes = T.dropAround (`elem` ['"', '\'']) getSource = toText . flip Source.slice blobSource . getField -instance (Expression.MemberAccess :< fs) => CustomHasDeclaration (Union fs) Expression.Call where +instance (Syntax.Identifier :< fs, Expression.MemberAccess :< fs) => CustomHasDeclaration (Union fs) Expression.Call where customToDeclaration Blob{..} _ (Expression.Call _ (Term (In fromAnn fromF), _) _ _) | Just (Expression.MemberAccess (Term (In leftAnn leftF)) (Term (In idenAnn _))) <- prj fromF = Just $ CallReference (getSource idenAnn) (memberAccess leftAnn leftF) + | Just (Syntax.Identifier name) <- prj fromF = Just $ CallReference (T.decodeUtf8 (friendlyName name)) [] | otherwise = Just $ CallReference (getSource fromAnn) [] where memberAccess modAnn termFOut diff --git a/src/Control/Abstract/Analysis.hs b/src/Control/Abstract/Analysis.hs index 555788994..8393e5a2f 100644 --- a/src/Control/Abstract/Analysis.hs +++ b/src/Control/Abstract/Analysis.hs @@ -2,6 +2,8 @@ module Control.Abstract.Analysis ( MonadAnalysis(..) , evaluateTerm +, require +, load , liftAnalyze , runAnalysis , module X @@ -17,7 +19,12 @@ import Control.Monad.Effect.Fresh as X import Control.Monad.Effect.NonDet as X import Control.Monad.Effect.Reader as X import Control.Monad.Effect.State as X +import Data.Abstract.Environment +import Data.Abstract.ModuleTable +import Data.Abstract.Value import Data.Coerce +import qualified Data.Map as Map +import Prelude hiding (fail) import Prologue -- | A 'Monad' in which one can evaluate some specific term type to some specific value type. @@ -41,6 +48,38 @@ evaluateTerm :: MonadAnalysis term value m => term -> m value evaluateTerm = foldSubterms analyzeTerm +-- | Require/import another term/file and return an Effect. +-- +-- Looks up the term's name in the cache of evaluated modules first, returns a value if found, otherwise loads/evaluates the module. +require :: ( MonadAnalysis term value m + , Ord (LocationFor value) + ) + => ModuleName + -> m (EnvironmentFor value) +require name = getModuleTable >>= maybe (load name) pure . moduleTableLookup name + +-- | Load another term/file and return an Effect. +-- +-- Always loads/evaluates. +load :: ( MonadAnalysis term value m + , Ord (LocationFor value) + ) + => ModuleName + -> m (EnvironmentFor value) +load name = askModuleTable >>= maybe notFound evalAndCache . moduleTableLookup name + where notFound = fail ("cannot load module: " <> show name) + evalAndCache e = do + void $ evaluateModule e + -- TODO: If the set of exports is empty because no exports have been + -- defined, do we export all terms, or no terms? This behavior varies across + -- languages. We need better semantics rather than doing it ad-hoc. + env <- getGlobalEnv + exports <- getExports + let env' = if Map.null exports then env else bindExports exports env + modifyModuleTable (moduleTableInsert name env') + pure env' + + -- | Lift a 'SubtermAlgebra' for an underlying analysis into a containing analysis. Use this when defining an analysis which can be composed onto other analyses to ensure that a call to 'analyzeTerm' occurs in the inner analysis and not the outer one. liftAnalyze :: ( Coercible ( m term value (effects :: [* -> *]) value) (t m term value effects value) , Coercible (t m term value effects value) ( m term value effects value) diff --git a/src/Control/Abstract/Evaluator.hs b/src/Control/Abstract/Evaluator.hs index 049a5f032..13932fadb 100644 --- a/src/Control/Abstract/Evaluator.hs +++ b/src/Control/Abstract/Evaluator.hs @@ -12,6 +12,7 @@ module Control.Abstract.Evaluator import Data.Abstract.Address import Data.Abstract.Configuration +import Data.Abstract.FreeVariables import Data.Abstract.ModuleTable import Data.Abstract.Store import Data.Abstract.Value @@ -40,6 +41,14 @@ class Monad m => MonadEnvironment value m | m -> value where getGlobalEnv :: m (EnvironmentFor value) -- | Set the global environment putGlobalEnv :: EnvironmentFor value -> m () + withGlobalEnv :: EnvironmentFor value -> m a -> m a + + -- | Add an export to the global export state. + addExport :: Name -> (Name, Maybe (Address (LocationFor value) value)) -> m () + -- | Get the global export state. + getExports :: m (Map Name (Name, Maybe (Address (LocationFor value) value))) + -- | Sets the exports state to the given map for the lifetime of the given action. + withExports :: Map Name (Name, Maybe (Address (LocationFor value) value)) -> m a -> m a -- | Retrieve the local environment. askLocalEnv :: m (EnvironmentFor value) diff --git a/src/Control/Abstract/Value.hs b/src/Control/Abstract/Value.hs index 34051e222..3ba5a1b14 100644 --- a/src/Control/Abstract/Value.hs +++ b/src/Control/Abstract/Value.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE MultiParamTypeClasses, TypeFamilies, UndecidableInstances #-} +{-# LANGUAGE MultiParamTypeClasses, Rank2Types, TypeFamilies, TypeOperators, UndecidableInstances #-} module Control.Abstract.Value where import Control.Abstract.Addressable @@ -7,10 +7,20 @@ import Data.Abstract.Environment import Data.Abstract.FreeVariables import Data.Abstract.Type as Type import Data.Abstract.Value as Value -import Data.Scientific (Scientific) +import Data.Scientific (Scientific, fromFloatDigits, toRealFloat) import Prelude hiding (fail) import Prologue +-- | This datum is passed into liftComparison to handle the fact that Ruby and PHP +-- have built-in generalized-comparison ("spaceship") operators. If you want to +-- encapsulate a traditional, boolean-returning operator, wrap it in 'Concrete'; +-- if you want the generalized comparator, pass in 'Generalized'. In MonadValue +-- instances, you can then then handle the different cases to return different +-- types, if that's what you need. +data Comparator + = Concrete (forall a . Ord a => a -> a -> Bool) + | Generalized + -- | A 'Monad' abstracting the evaluation of (and under) binding constructs (functions, methods, etc). -- -- This allows us to abstract the choice of whether to evaluate under binders for different value types. @@ -22,6 +32,21 @@ class (MonadAnalysis term value m, Show value) => MonadValue term value m where -- | Construct an abstract integral value. integer :: Prelude.Integer -> m value + -- | Lift a unary operator over a 'Num' to a function on 'value's. + liftNumeric :: (forall a . Num a => a -> a) + -> (value -> m value) + + -- | Lift a pair of binary operators to a function on 'value's. + -- You usually pass the same operator as both arguments, except in the cases where + -- Haskell provides different functions for integral and fractional operations, such + -- as division, exponentiation, and modulus. + liftNumeric2 :: (forall a . (Real a, Floating a) => a -> a -> a) + -> (forall b . Integral b => b -> b -> b) + -> (value -> value -> m value) + + -- | Lift a Comparator (usually wrapping a function like == or <=) to a function on values. + liftComparison :: Comparator -> (value -> value -> m value) + -- | Construct an abstract boolean value. boolean :: Bool -> m value @@ -34,19 +59,46 @@ class (MonadAnalysis term value m, Show value) => MonadValue term value m where -- | Construct an N-ary tuple of multiple (possibly-disjoint) values multiple :: [value] -> m value - -- | Construct an abstract interface value. - interface :: value -> m value - -- | Eliminate boolean values. TODO: s/boolean/truthy - ifthenelse :: value -> m value -> m value -> m value + ifthenelse :: value -> m a -> m a -> m a -- | Evaluate an abstraction (a binder like a lambda or method definition). abstract :: [Name] -> Subterm term (m value) -> m value -- | Evaluate an application (like a function call). apply :: value -> [Subterm term (m value)] -> m value - -- | Extract the environment from an interface value. - environment :: value -> m (EnvironmentFor value) +-- | Attempt to extract a 'Prelude.Bool' from a given value. +toBool :: MonadValue term value m => value -> m Bool +toBool v = ifthenelse v (pure True) (pure False) + +forLoop :: MonadValue term value m + => m value -- | Initial statement + -> m value -- | Condition + -> m value -- | Increment/stepper + -> m value -- | Body + -> m value +forLoop initial cond step body = do + void initial + env <- getGlobalEnv + localEnv (mappend env) (fix $ \ loop -> do + cond' <- cond + ifthenelse cond' (do + void body + void step + loop) unit) + +-- | The fundamental looping primitive, built on top of ifthenelse. +while :: MonadValue term value m => m value -> m value -> m value +while cond body = do + this <- cond + ifthenelse this (body *> while cond body) unit + +-- | Do-while loop, built on top of while. +doWhile :: MonadValue term value m => m value -> m value -> m value +doWhile body cond = do + void body + this <- cond + ifthenelse this (doWhile body cond) unit -- | Construct a 'Value' wrapping the value arguments (if any). instance ( MonadAddressable location (Value location term) m @@ -64,12 +116,53 @@ instance ( MonadAddressable location (Value location term) m multiple vals = pure . injValue $ Value.Tuple vals - interface v = injValue . Value.Interface v <$> getGlobalEnv - ifthenelse cond if' else' | Just (Boolean b) <- prjValue cond = if b then if' else else' | otherwise = fail ("not defined for non-boolean conditions: " <> show cond) + liftNumeric f arg + | Just (Integer i) <- prjValue arg = pure . injValue . Integer $ f i + | Just (Value.Float i) <- prjValue arg = pure . injValue . Value.Float $ f i + | otherwise = fail ("Invalid operand to liftNumeric: " <> show arg) + + liftNumeric2 f g left right + | Just (Integer i, Integer j) <- prjPair pair = pure . injValue . Integer $ g i j + | Just (Integer i, Value.Float j) <- prjPair pair = pure . injValue . float $ f (fromIntegral i) (munge j) + | Just (Value.Float i, Value.Float j) <- prjPair pair = pure . injValue . float $ f (munge i) (munge j) + | Just (Value.Float i, Integer j) <- prjPair pair = pure . injValue . float $ f (munge i) (fromIntegral j) + | otherwise = fail ("Invalid operands to liftNumeric2: " <> show pair) + where + -- Yucky hack to work around the lack of a Floating instance for Scientific. + -- This may possibly lose precision, but there's little we can do about that. + munge :: Scientific -> Double + munge = toRealFloat + float :: Double -> Value.Float a + float = Value.Float . fromFloatDigits + pair = (left, right) + + liftComparison comparator left right + | Just (Integer i, Integer j) <- prjPair pair = go i j + | Just (Integer i, Value.Float j) <- prjPair pair = go (fromIntegral i) j + | Just (Value.Float i, Integer j) <- prjPair pair = go i (fromIntegral j) + | Just (Value.Float i, Value.Float j) <- prjPair pair = go i j + | Just (Value.String i, Value.String j) <- prjPair pair = go i j + | Just (Boolean i, Boolean j) <- prjPair pair = go i j + | Just (Value.Unit, Value.Unit) <- prjPair pair = boolean True + | otherwise = fail ("Type error: invalid arguments to liftComparison: " <> show pair) + where + -- Explicit type signature is necessary here because we're passing all sorts of things + -- to these comparison functions. + go :: (Ord a, MonadValue term value m) => a -> a -> m value + go l r = case comparator of + Concrete f -> boolean (f l r) + Generalized -> integer (orderingToInt (compare l r)) + + -- Map from [LT, EQ, GT] to [-1, 0, 1] + orderingToInt :: Ordering -> Prelude.Integer + orderingToInt = toInteger . pred . fromEnum + + pair = (left, right) + abstract names (Subterm body _) = injValue . Closure names body <$> askLocalEnv apply op params = do @@ -81,10 +174,6 @@ instance ( MonadAddressable location (Value location term) m envInsert name a <$> rest) (pure env) (zip names params) localEnv (mappend bindings) (evaluateTerm body) - environment v - | Just (Interface _ env) <- prjValue v = pure env - | otherwise = pure mempty - -- | Discard the value arguments (if any), constructing a 'Type.Type' instead. instance (Alternative m, MonadAnalysis term Type m, MonadFresh m) => MonadValue term Type m where abstract names (Subterm _ body) = do @@ -103,16 +192,22 @@ instance (Alternative m, MonadAnalysis term Type m, MonadFresh m) => MonadValue string _ = pure Type.String float _ = pure Type.Float multiple = pure . Type.Product - -- TODO - interface = undefined ifthenelse cond if' else' = unify cond Bool *> (if' <|> else') + liftNumeric _ Type.Float = pure Type.Float + liftNumeric _ Int = pure Int + liftNumeric _ _ = fail "Invalid type in unary numeric operation" + + liftNumeric2 _ _ left right = case (left, right) of + (Type.Float, Int) -> pure Type.Float + (Int, Type.Float) -> pure Type.Float + _ -> unify left right + + liftComparison _ left right = pure left <|> pure right + apply op params = do tvar <- fresh paramTypes <- traverse subtermValue params _ :-> ret <- op `unify` (Product paramTypes :-> Var tvar) pure ret - - -- TODO - environment = undefined diff --git a/src/Data/Abstract/Environment.hs b/src/Data/Abstract/Environment.hs index 483f9fae6..2d0c6ef3e 100644 --- a/src/Data/Abstract/Environment.hs +++ b/src/Data/Abstract/Environment.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE GeneralizedNewtypeDeriving, MultiParamTypeClasses, StandaloneDeriving #-} module Data.Abstract.Environment where import Prologue @@ -6,12 +6,15 @@ import Data.Abstract.Address import Data.Abstract.FreeVariables import Data.Abstract.Live import qualified Data.Map as Map +import Data.Semigroup.Reducer import qualified Data.Set as Set -- | A map of names to addresses that represents the evaluation environment. newtype Environment l a = Environment { unEnvironment :: Map.Map Name (Address l a) } deriving (Eq, Foldable, Functor, Generic1, Monoid, Ord, Semigroup, Show, Traversable) +deriving instance Reducer (Name, Address l a) (Environment l a) + -- | Lookup a 'Name' in the environment. envLookup :: Name -> Environment l a -> Maybe (Address l a) envLookup k = Map.lookup k . unEnvironment @@ -20,12 +23,15 @@ envLookup k = Map.lookup k . unEnvironment envInsert :: Name -> Address l a -> Environment l a -> Environment l a envInsert name value (Environment m) = Environment (Map.insert name value m) -envUnion :: Environment l a -> Environment l a -> Environment l a -envUnion (Environment e1) (Environment e2) = Environment $ Map.union e1 e2 - bindEnv :: (Ord l, Foldable t) => t Name -> Environment l a -> Environment l a -bindEnv names env = Environment (Map.fromList pairs) - where pairs = foldr (\name b -> maybe b (\v -> (name, v) : b) (envLookup name env)) mempty names +bindEnv names env = foldMap envForName names + where envForName name = maybe mempty (curry unit name) (envLookup name env) + +bindExports :: (Ord l) => Map Name (Name, Maybe (Address l a)) -> Environment l a -> Environment l a +bindExports aliases env = Environment pairs + where + pairs = Map.foldrWithKey (\name (alias, address) accum -> + maybe accum (\v -> Map.insert alias v accum) (address <|> envLookup name env)) mempty aliases -- | Retrieve the 'Live' set of addresses to which the given free variable names are bound. -- diff --git a/src/Data/Abstract/Evaluatable.hs b/src/Data/Abstract/Evaluatable.hs index d9820e8ef..740c49f32 100644 --- a/src/Data/Abstract/Evaluatable.hs +++ b/src/Data/Abstract/Evaluatable.hs @@ -6,20 +6,16 @@ module Data.Abstract.Evaluatable , module FreeVariables , module Value , MonadEvaluator(..) -, require -, load ) where import Control.Abstract.Addressable as Addressable import Control.Abstract.Analysis as Analysis import Control.Abstract.Value as Value -import Data.Abstract.Environment import Data.Abstract.FreeVariables as FreeVariables -import Data.Abstract.ModuleTable import Data.Abstract.Value import Data.Functor.Classes import Data.Proxy -import Data.Semigroup +import Data.Semigroup.Foldable import Data.Term import Prelude hiding (fail) import Prologue @@ -42,7 +38,7 @@ instance Apply Evaluatable fs => Evaluatable (Union fs) where -- | Evaluating a 'TermF' ignores its annotation, evaluating the underlying syntax. instance Evaluatable s => Evaluatable (TermF s a) where - eval In{..} = eval termFOut + eval = eval . termFOut -- Instances @@ -53,42 +49,17 @@ instance Evaluatable s => Evaluatable (TermF s a) where -- 2. Each statement can affect the environment of later statements (e.g. by 'modify'-ing the environment); and -- 3. Only the last statement’s return value is returned. instance Evaluatable [] where - eval [] = unit -- Return unit value if this is an empty list of terms - eval [x] = subtermValue x -- Return the value for the last term - eval (x:xs) = do - _ <- subtermValue x -- Evaluate the head term - env <- getGlobalEnv -- Get the global environment after evaluation - -- since it might have been modified by the - -- evaluation above ^. + -- 'nonEmpty' and 'foldMap1' enable us to return the last statement’s result instead of 'unit' for non-empty lists. + eval = maybe unit (runImperative . foldMap1 (Imperative . subtermValue)) . nonEmpty - -- Finally, evaluate the rest of the terms, but do so by calculating a new - -- environment each time where the free variables in those terms are bound - -- to the global environment. - localEnv (const (bindEnv (liftFreeVariables (freeVariables . subterm) xs) env)) (eval xs) +-- | A 'Semigroup' providing an imperative context which extends the local environment with new bindings. +newtype Imperative m a = Imperative { runImperative :: m a } +instance MonadEnvironment value m => Semigroup (Imperative m a) where + Imperative a <> Imperative b = Imperative $ a *> do + env <- getGlobalEnv + localEnv (<> env) b --- | Require/import another term/file and return an Effect. --- --- Looks up the term's name in the cache of evaluated modules first, returns a value if found, otherwise loads/evaluates the module. -require :: ( MonadAnalysis term value m - , MonadValue term value m - ) - => ModuleName - -> m (EnvironmentFor value) -require name = getModuleTable >>= maybe (load name) pure . moduleTableLookup name - --- | Load another term/file and return an Effect. --- --- Always loads/evaluates. -load :: ( MonadAnalysis term value m - , MonadValue term value m - ) - => ModuleName - -> m (EnvironmentFor value) -load name = askModuleTable >>= maybe notFound evalAndCache . moduleTableLookup name - where notFound = fail ("cannot load module: " <> show name) - evalAndCache e = do - v <- evaluateModule e - env <- environment v - modifyModuleTable (moduleTableInsert name env) - pure env +instance MonadValue term value m => Monoid (Imperative m value) where + mempty = Imperative unit + mappend = (<>) diff --git a/src/Data/Abstract/FreeVariables.hs b/src/Data/Abstract/FreeVariables.hs index 4e974d576..2e73218c2 100644 --- a/src/Data/Abstract/FreeVariables.hs +++ b/src/Data/Abstract/FreeVariables.hs @@ -39,7 +39,9 @@ freeVariables1 :: (FreeVariables1 t, FreeVariables a) => t a -> Set Name freeVariables1 = liftFreeVariables freeVariables freeVariable :: FreeVariables term => term -> Name -freeVariable term = let [n] = toList (freeVariables term) in n +freeVariable term = case toList (freeVariables term) of + [n] -> n + xs -> Prelude.fail ("expected single free variable, but got: " <> show xs) -- TODO: Need a dedicated concept of qualified names outside of freevariables (a -- Set) b/c you can have something like `a.a.b.a` diff --git a/src/Data/Abstract/Type.hs b/src/Data/Abstract/Type.hs index 9709d087a..423f23ebe 100644 --- a/src/Data/Abstract/Type.hs +++ b/src/Data/Abstract/Type.hs @@ -24,11 +24,11 @@ data Type -- | Unify two 'Type's. unify :: MonadFail m => Type -> Type -> m Type -unify Int Int = pure Int -unify Bool Bool = pure Bool unify (a1 :-> b1) (a2 :-> b2) = (:->) <$> unify a1 a2 <*> unify b1 b2 -- FIXME: this should be constructing a substitution. unify (Var _) b = pure b unify a (Var _) = pure a unify (Product as) (Product bs) = Product <$> sequenceA (alignWith (these pure pure unify) as bs) -unify t1 t2 = fail ("cannot unify " ++ show t1 ++ " with " ++ show t2) +unify t1 t2 + | t1 == t2 = pure t2 + | otherwise = fail ("cannot unify " ++ show t1 ++ " with " ++ show t2) diff --git a/src/Data/Abstract/Value.hs b/src/Data/Abstract/Value.hs index c2eaa552c..e2acc9e3f 100644 --- a/src/Data/Abstract/Value.hs +++ b/src/Data/Abstract/Value.hs @@ -10,12 +10,11 @@ import qualified Data.Abstract.Type as Type import qualified Data.Set as Set import Data.Scientific (Scientific) import Prologue -import Prelude hiding (Float, Integer, String, fail) +import Prelude hiding (Float, Integer, String) import qualified Prelude type ValueConstructors location term = '[Closure location term - , Interface location , Unit , Boolean , Float @@ -37,6 +36,13 @@ injValue = Value . inj prjValue :: (f :< ValueConstructors location term) => Value location term -> Maybe (f (Value location term)) prjValue = prj . deValue +-- | Convenience function for projecting two values. +prjPair :: ( f :< ValueConstructors loc term1 , g :< ValueConstructors loc term2) + => (Value loc term1, Value loc term2) + -> Maybe (f (Value loc term1), g (Value loc term2)) +prjPair = bitraverse prjValue prjValue + + -- TODO: Parameterize Value by the set of constructors s.t. each language can have a distinct value union. -- | A function value consisting of a list of parameters, the body of the function, and an environment of bindings captured by the body. @@ -47,14 +53,6 @@ instance (Eq location, Eq term) => Eq1 (Closure location term) where liftEq = ge instance (Ord location, Ord term) => Ord1 (Closure location term) where liftCompare = genericLiftCompare instance (Show location, Show term) => Show1 (Closure location term) where liftShowsPrec = genericLiftShowsPrec --- | A program value consisting of the value of the program and it's enviornment of bindings. -data Interface location value = Interface value (Environment location value) - deriving (Eq, Generic1, Ord, Show) - -instance (Eq location) => Eq1 (Interface location) where liftEq = genericLiftEq -instance (Ord location) => Ord1 (Interface location) where liftCompare = genericLiftCompare -instance (Show location) => Show1 (Interface location) where liftShowsPrec = genericLiftShowsPrec - -- | The unit value. Typically used to represent the result of imperative statements. data Unit value = Unit deriving (Eq, Generic1, Ord, Show) diff --git a/src/Data/Syntax.hs b/src/Data/Syntax.hs index 541253d8e..7b000aa68 100644 --- a/src/Data/Syntax.hs +++ b/src/Data/Syntax.hs @@ -124,14 +124,8 @@ instance Ord1 Program where liftCompare = genericLiftCompare instance Show1 Program where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Program where - eval (Program xs) = eval' xs - where - eval' [] = unit >>= interface - eval' [x] = subtermValue x >>= interface - eval' (x:xs) = do - _ <- subtermValue x - env <- getGlobalEnv - localEnv (envUnion env) (eval' xs) + eval (Program xs) = do + withExports mempty (eval xs) -- | An accessibility modifier, e.g. private, public, protected, etc. newtype AccessibilityModifier a = AccessibilityModifier ByteString diff --git a/src/Data/Syntax/Declaration.hs b/src/Data/Syntax/Declaration.hs index eb0a38798..d57323cab 100644 --- a/src/Data/Syntax/Declaration.hs +++ b/src/Data/Syntax/Declaration.hs @@ -161,14 +161,7 @@ instance Show1 Module where liftShowsPrec = genericLiftShowsPrec -- We need to ensure that all input files have aggregated their content into -- a coherent module before we begin evaluating a module. instance Evaluatable Module where - eval (Module _ xs) = eval' xs - where - eval' [] = unit >>= interface - eval' [x] = subtermValue x >>= interface - eval' (x:xs) = do - _ <- subtermValue x - env <- getGlobalEnv - localEnv (envUnion env) (eval' xs) + eval (Module _ xs) = eval xs -- | A decorator in Python data Decorator a = Decorator { decoratorIdentifier :: !a, decoratorParamaters :: ![a], decoratorBody :: !a } @@ -219,6 +212,39 @@ instance Show1 Comprehension where liftShowsPrec = genericLiftShowsPrec -- TODO: Implement Eval instance for Comprehension instance Evaluatable Comprehension +-- | Qualified Export declarations +newtype QualifiedExport a = QualifiedExport { qualifiedExportSymbols :: [(Name, Name)] } + deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable, FreeVariables1) + +instance Eq1 QualifiedExport where liftEq = genericLiftEq +instance Ord1 QualifiedExport where liftCompare = genericLiftCompare +instance Show1 QualifiedExport where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable QualifiedExport where + eval (QualifiedExport exportSymbols) = do + -- Insert the aliases with no addresses. + for_ exportSymbols $ \(name, alias) -> + addExport name (alias, Nothing) + unit + +-- | Qualified Export declarations that export from another module. +data QualifiedExportFrom a = QualifiedExportFrom { qualifiedExportFrom :: !a, qualifiedExportFromSymbols :: ![(Name, Name)]} + deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable, FreeVariables1) + +instance Eq1 QualifiedExportFrom where liftEq = genericLiftEq +instance Ord1 QualifiedExportFrom where liftCompare = genericLiftCompare +instance Show1 QualifiedExportFrom where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable QualifiedExportFrom where + eval (QualifiedExportFrom from exportSymbols) = do + let moduleName = freeVariable (subterm from) + importedEnv <- withGlobalEnv mempty (require moduleName) + -- Look up addresses in importedEnv and insert the aliases with addresses into the exports. + for_ exportSymbols $ \(name, alias) -> do + let address = Map.lookup name (unEnvironment importedEnv) + addExport name (alias, address) + unit + -- | Qualified Import declarations (symbols are qualified in calling environment). data QualifiedImport a = QualifiedImport { qualifiedImportFrom :: !a, qualifiedImportAlias :: !a, qualifiedImportSymbols :: ![(Name, Name)]} @@ -230,23 +256,29 @@ instance Show1 QualifiedImport where liftShowsPrec = genericLiftShowsPrec instance Evaluatable QualifiedImport where eval (QualifiedImport from alias xs) = do - env <- getGlobalEnv - putGlobalEnv mempty - importedEnv <- require (freeVariable (subterm from)) - env' <- Map.foldrWithKey copy (pure env) (unEnvironment importedEnv) - modifyGlobalEnv (const env') + importedEnv <- withGlobalEnv mempty (require (freeVariable (subterm from))) + modifyGlobalEnv (flip (Map.foldrWithKey copy) (unEnvironment importedEnv)) unit where prefix = freeVariable (subterm alias) symbols = Map.fromList xs copy = if Map.null symbols then qualifyInsert else directInsert - qualifyInsert k v rest = envInsert (prefix <> k) v <$> rest - directInsert k v rest = maybe rest (\symAlias -> envInsert symAlias v <$> rest) (Map.lookup k symbols) + qualifyInsert k v rest = envInsert (prefix <> k) v rest + directInsert k v rest = maybe rest (\symAlias -> envInsert symAlias v rest) (Map.lookup k symbols) + +newtype DefaultExport a = DefaultExport { defaultExport :: a } + deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable, FreeVariables1) + +instance Eq1 DefaultExport where liftEq = genericLiftEq +instance Ord1 DefaultExport where liftCompare = genericLiftCompare +instance Show1 DefaultExport where liftShowsPrec = genericLiftShowsPrec + +instance Evaluatable DefaultExport where -- | Import declarations (symbols are added directly to the calling env). -- --- If symbols is empty, just evaluate the module for it's side effects. +-- If symbols is empty, just import the module for its side effects. data Import a = Import { importFrom :: !a, importSymbols :: ![(Name, Name)] } deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable, FreeVariables1) @@ -256,15 +288,12 @@ instance Show1 Import where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Import where eval (Import from xs) = do - env <- getGlobalEnv - putGlobalEnv mempty - importedEnv <- require (freeVariable (subterm from)) - env' <- Map.foldrWithKey directInsert (pure env) (unEnvironment importedEnv) - modifyGlobalEnv (const env') + importedEnv <- withGlobalEnv mempty (require (freeVariable (subterm from))) + modifyGlobalEnv (flip (Map.foldrWithKey directInsert) (unEnvironment importedEnv)) unit where symbols = Map.fromList xs - directInsert k v rest = maybe rest (\symAlias -> envInsert symAlias v <$> rest) (Map.lookup k symbols) + directInsert k v rest = maybe rest (\symAlias -> envInsert symAlias v rest) (Map.lookup k symbols) -- | A wildcard import (all symbols are added directly to the calling env) @@ -278,7 +307,10 @@ instance Ord1 WildcardImport where liftCompare = genericLiftCompare instance Show1 WildcardImport where liftShowsPrec = genericLiftShowsPrec instance Evaluatable WildcardImport where - eval (WildcardImport from _) = putGlobalEnv mempty *> require (freeVariable (subterm from)) *> unit + eval (WildcardImport from _) = do -- require (freeVariable (subterm from)) *> putGlobalEnv mempty *> unit + importedEnv <- withGlobalEnv mempty (require (freeVariable (subterm from))) + modifyGlobalEnv (flip (Map.foldrWithKey envInsert) (unEnvironment importedEnv)) + unit -- | A declared type (e.g. `a []int` in Go). data Type a = Type { typeName :: !a, typeKind :: !a } diff --git a/src/Data/Syntax/Expression.hs b/src/Data/Syntax/Expression.hs index aa283e24a..6779bed53 100644 --- a/src/Data/Syntax/Expression.hs +++ b/src/Data/Syntax/Expression.hs @@ -2,7 +2,9 @@ module Data.Syntax.Expression where import Data.Abstract.Evaluatable +import Data.Fixed import Diffing.Algorithm +import Prelude hiding (fail) import Prologue hiding (apply) -- | Typical prefix function application, like `f(x)` in many languages, or `f x` in Haskell. @@ -31,9 +33,15 @@ instance Eq1 Comparison where liftEq = genericLiftEq instance Ord1 Comparison where liftCompare = genericLiftCompare instance Show1 Comparison where liftShowsPrec = genericLiftShowsPrec --- TODO: Implement Eval instance for Comparison -instance Evaluatable Comparison - +instance Evaluatable Comparison where + eval = traverse subtermValue >=> go where + go x = case x of + (LessThan a b) -> liftComparison (Concrete (<)) a b + (LessThanEqual a b) -> liftComparison (Concrete (<=)) a b + (GreaterThan a b) -> liftComparison (Concrete (>)) a b + (GreaterThanEqual a b) -> liftComparison (Concrete (>=)) a b + (Equal a b) -> liftComparison (Concrete (==)) a b + (Comparison a b) -> liftComparison Generalized a b -- | Binary arithmetic operators. data Arithmetic a @@ -51,8 +59,15 @@ instance Ord1 Arithmetic where liftCompare = genericLiftCompare instance Show1 Arithmetic where liftShowsPrec = genericLiftShowsPrec -- TODO: Implement Eval instance for Arithmetic -instance Evaluatable Arithmetic - +instance Evaluatable Arithmetic where + eval = traverse subtermValue >=> go where + go (Plus a b) = liftNumeric2 (+) (+) a b + go (Minus a b) = liftNumeric2 (-) (-) a b + go (Times a b) = liftNumeric2 (*) (*) a b + go (DividedBy a b) = liftNumeric2 (/) div a b + go (Modulo a b) = liftNumeric2 mod' mod a b + go (Power a b) = liftNumeric2 (**) (^) a b + go (Negate a) = liftNumeric negate a -- | Boolean operators. data Boolean a @@ -66,9 +81,17 @@ instance Eq1 Boolean where liftEq = genericLiftEq instance Ord1 Boolean where liftCompare = genericLiftCompare instance Show1 Boolean where liftShowsPrec = genericLiftShowsPrec --- TODO: Implement Eval instance for Boolean -instance Evaluatable Boolean - +instance Evaluatable Boolean where + -- N.B. we have to use Monad rather than Applicative/Traversable on 'And' and 'Or' so that we don't evaluate both operands + eval = go . fmap subtermValue where + go (And a b) = do + cond <- a + ifthenelse cond b (pure cond) + go (Or a b) = do + cond <- a + ifthenelse cond (pure cond) b + go (Not a) = a >>= toBool >>= boolean . not + go (XOr a b) = liftA2 (/=) (a >>= toBool) (b >>= toBool) >>= boolean -- | Javascript delete operator newtype Delete a = Delete a diff --git a/src/Data/Syntax/Statement.hs b/src/Data/Syntax/Statement.hs index 0b94d909d..bf4d05077 100644 --- a/src/Data/Syntax/Statement.hs +++ b/src/Data/Syntax/Statement.hs @@ -1,9 +1,10 @@ -{-# LANGUAGE DeriveAnyClass, MultiParamTypeClasses, ScopedTypeVariables, UndecidableInstances #-} +{-# LANGUAGE DeriveAnyClass, MultiParamTypeClasses, ScopedTypeVariables, UndecidableInstances, ViewPatterns #-} module Data.Syntax.Statement where import Data.Abstract.Environment import Data.Abstract.Evaluatable import Diffing.Algorithm +import Prelude hiding (fail) import Prologue -- | Conditional. This must have an else block, which can be filled with some default value when omitted in the source, e.g. 'pure ()' for C-style if-without-else or 'pure Nothing' for Ruby-style, in both cases assuming some appropriate Applicative context into which the If will be lifted. @@ -185,7 +186,6 @@ instance Eq1 NoOp where liftEq = genericLiftEq instance Ord1 NoOp where liftCompare = genericLiftCompare instance Show1 NoOp where liftShowsPrec = genericLiftShowsPrec --- TODO: Implement Eval instance for NoOp instance Evaluatable NoOp where eval _ = unit @@ -198,8 +198,8 @@ instance Eq1 For where liftEq = genericLiftEq instance Ord1 For where liftCompare = genericLiftCompare instance Show1 For where liftShowsPrec = genericLiftShowsPrec --- TODO: Implement Eval instance for For -instance Evaluatable For +instance Evaluatable For where + eval (fmap subtermValue -> For before cond step body) = forLoop before cond step body data ForEach a = ForEach { forEachBinding :: !a, forEachSubject :: !a, forEachBody :: !a } @@ -220,9 +220,8 @@ instance Eq1 While where liftEq = genericLiftEq instance Ord1 While where liftCompare = genericLiftCompare instance Show1 While where liftShowsPrec = genericLiftShowsPrec --- TODO: Implement Eval instance for While -instance Evaluatable While - +instance Evaluatable While where + eval While{..} = while (subtermValue whileCondition) (subtermValue whileBody) data DoWhile a = DoWhile { doWhileCondition :: !a, doWhileBody :: !a } deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable, FreeVariables1) @@ -231,9 +230,8 @@ instance Eq1 DoWhile where liftEq = genericLiftEq instance Ord1 DoWhile where liftCompare = genericLiftCompare instance Show1 DoWhile where liftShowsPrec = genericLiftShowsPrec --- TODO: Implement Eval instance for DoWhile -instance Evaluatable DoWhile - +instance Evaluatable DoWhile where + eval DoWhile{..} = doWhile (subtermValue doWhileBody) (subtermValue doWhileCondition) -- Exception handling diff --git a/src/Language/Go/Assignment.hs b/src/Language/Go/Assignment.hs index 044e07130..3a9e6595d 100644 --- a/src/Language/Go/Assignment.hs +++ b/src/Language/Go/Assignment.hs @@ -390,7 +390,8 @@ importDeclaration = makeTerm'' <$> symbol ImportDeclaration <*> children (manyTe <|> makeTerm <$> symbol ImportSpec <*> children namedImport <|> makeTerm <$> symbol ImportSpec <*> children plainImport - dotImport = symbol Dot *> source *> (Declaration.WildcardImport <$> expression <*> emptyTerm) + dotImport = symbol Dot *> source >>= \s -> + Declaration.WildcardImport <$> expression <*> (makeTerm <$> location <*> pure (Syntax.Identifier (name s))) sideEffectImport = symbol BlankIdentifier *> source *> (Declaration.Import <$> expression <*> pure []) namedImport = symbol PackageIdentifier >>= \loc -> do s <- source diff --git a/src/Language/TypeScript/Assignment.hs b/src/Language/TypeScript/Assignment.hs index 3fb9b9c03..17365caa5 100644 --- a/src/Language/TypeScript/Assignment.hs +++ b/src/Language/TypeScript/Assignment.hs @@ -7,12 +7,13 @@ module Language.TypeScript.Assignment ) where import Assigning.Assignment hiding (Assignment, Error) +import qualified Assigning.Assignment as Assignment import Data.Abstract.FreeVariables +import qualified Data.ByteString as B (filter) +import qualified Data.ByteString.Char8 as BC +import Data.Char (ord) import Data.Record import Data.Syntax (emptyTerm, handleError, parseError, infixContext, makeTerm, makeTerm', makeTerm'', makeTerm1, contextualize, postContextualize) -import Language.TypeScript.Grammar as Grammar -import Prologue -import qualified Assigning.Assignment as Assignment import qualified Data.Syntax as Syntax import qualified Data.Syntax.Comment as Comment import qualified Data.Syntax.Declaration as Declaration @@ -21,7 +22,9 @@ import qualified Data.Syntax.Literal as Literal import qualified Data.Syntax.Statement as Statement import qualified Data.Syntax.Type as Type import qualified Data.Term as Term +import Language.TypeScript.Grammar as Grammar import qualified Language.TypeScript.Syntax as TypeScript.Syntax +import Prologue -- | The type of TypeScript syntax. type Syntax = '[ @@ -36,6 +39,9 @@ type Syntax = '[ , Declaration.TypeAlias , Declaration.Import , Declaration.QualifiedImport + , Declaration.DefaultExport + , Declaration.QualifiedExport + , Declaration.QualifiedExportFrom , Declaration.Module , Expression.Arithmetic , Expression.Bitwise @@ -156,8 +162,6 @@ type Syntax = '[ , TypeScript.Syntax.ImportRequireClause , TypeScript.Syntax.ImportClause , TypeScript.Syntax.LabeledStatement - , TypeScript.Syntax.NamedImports - , TypeScript.Syntax.NamespaceImport , TypeScript.Syntax.Annotation , TypeScript.Syntax.With , TypeScript.Syntax.ForOf @@ -262,7 +266,12 @@ ternaryExpression :: Assignment ternaryExpression = makeTerm <$> symbol Grammar.TernaryExpression <*> children (Statement.If <$> term expression <*> term expression <*> term expression) memberExpression :: Assignment -memberExpression = makeTerm <$> (symbol Grammar.MemberExpression <|> symbol Grammar.MemberExpression') <*> children (Expression.MemberAccess <$> term expression <*> term propertyIdentifier) +memberExpression = (symbol Grammar.MemberExpression <|> symbol Grammar.MemberExpression') *> children (qualifiedIdentifier <|> memberAccess) + where + memberAccess = makeTerm <$> location <*> (Expression.MemberAccess <$> term expression <*> term propertyIdentifier) + qualifiedIdentifier = makeTerm <$> location <*> ((\a b -> Syntax.Identifier (qualifiedName [a, b])) <$> identifier' <*> propertyIdentifier') + identifier' = (symbol Identifier <|> symbol Identifier') *> source + propertyIdentifier' = symbol PropertyIdentifier *> source newExpression :: Assignment newExpression = makeTerm <$> symbol Grammar.NewExpression <*> children (Expression.New . pure <$> term expression) @@ -632,18 +641,21 @@ statementIdentifier :: Assignment statementIdentifier = makeTerm <$> symbol StatementIdentifier <*> (Syntax.Identifier <$> (name <$> source)) importStatement :: Assignment -importStatement = makeImportTerm <$> symbol Grammar.ImportStatement <*> children ((,) <$> importClause <*> term string) +importStatement = makeImportTerm <$> symbol Grammar.ImportStatement <*> children ((,) <$> importClause <*> term path) <|> makeImport <$> symbol Grammar.ImportStatement <*> children requireImport <|> makeImport <$> symbol Grammar.ImportStatement <*> children bareRequireImport - where -- Straightforward imports makeImport loc (Just alias, symbols, from) = makeTerm loc (Declaration.QualifiedImport from alias symbols) makeImport loc (Nothing, symbols, from) = makeTerm loc (Declaration.Import from symbols) -- Import a file giving it an alias (e.g. import foo = require "./foo") - requireImport = symbol Grammar.ImportRequireClause *> children ((,,) <$> (Just <$> (term identifier)) <*> pure [] <*> term string) + requireImport = symbol Grammar.ImportRequireClause *> children ((,,) <$> (Just <$> (term identifier)) <*> pure [] <*> term path) -- Import a file just for it's side effects (e.g. import "./foo") - bareRequireImport = (,,) <$> (pure Nothing) <*> pure [] <*> term string + bareRequireImport = (,,) <$> (pure Nothing) <*> pure [] <*> term path + + path = makeTerm <$> symbol Grammar.String <*> (Syntax.Identifier <$> (qualifiedName' <$> source)) + qualifiedName' = qualifiedName . BC.split '/' . (BC.dropWhile (== '/')) . (BC.dropWhile (== '.')) . stripQuotes + stripQuotes = B.filter (/= (fromIntegral (ord '\"'))) -- Imports with import clauses makeImportTerm1 loc from (Prelude.True, Just alias, symbols) = makeTerm loc (Declaration.QualifiedImport from alias symbols) @@ -666,6 +678,10 @@ importStatement = makeImportTerm <$> symbol Grammar.ImportStatement <*> children makeNameAliasPair from (Just alias) = (from, alias) makeNameAliasPair from Nothing = (from, from) + +stripQuotes :: ByteString -> ByteString +stripQuotes = B.filter (/= (fromIntegral (ord '\"'))) + debuggerStatement :: Assignment debuggerStatement = makeTerm <$> symbol Grammar.DebuggerStatement <*> (TypeScript.Syntax.Debugger <$ source) @@ -709,16 +725,21 @@ ambientDeclaration :: Assignment ambientDeclaration = makeTerm <$> symbol Grammar.AmbientDeclaration <*> children (TypeScript.Syntax.AmbientDeclaration <$> term (choice [declaration, statementBlock])) exportStatement :: Assignment -exportStatement = makeTerm <$> symbol Grammar.ExportStatement <*> children (TypeScript.Syntax.Export <$> (((\a b -> [a, b]) <$> term exportClause <*> term fromClause) <|> ((++) <$> manyTerm decorator <*> (pure <$> term (fromClause <|> exportClause <|> declaration <|> expression <|> identifier <|> importAlias'))))) +exportStatement = makeTerm <$> symbol Grammar.ExportStatement <*> (children (flip Declaration.QualifiedExportFrom <$> exportClause <*> term fromClause)) + <|> makeTerm <$> symbol Grammar.ExportStatement <*> children (Declaration.QualifiedExport <$> exportClause) + <|> makeTerm <$> symbol Grammar.ExportStatement <*> children (Declaration.DefaultExport <$> contextualize decorator (term (declaration <|> expression <|> identifier <|> importAlias'))) + where + exportClause = symbol Grammar.ExportClause *> children (many exportSymbol) + exportSymbol = symbol Grammar.ExportSpecifier *> children (makeNameAliasPair <$> rawIdentifier <*> (Just <$> rawIdentifier)) + <|> symbol Grammar.ExportSpecifier *> children (makeNameAliasPair <$> rawIdentifier <*> (pure Nothing)) + makeNameAliasPair from (Just alias) = (from, alias) + makeNameAliasPair from Nothing = (from, from) + rawIdentifier = (symbol Identifier <|> symbol Identifier') *> (name <$> source) + -- <|> (makeExport2 <$> manyTerm decorator <*> emptyTerm <*> (pure <$> term (fromClause <|> exportClause <|> declaration <|> expression <|> identifier <|> importAlias'))))) + -- makeExport2 decorators fromClause exportClause = Declaration.QualifiedExport fromClause exportClause fromClause :: Assignment -fromClause = string - -exportClause :: Assignment -exportClause = makeTerm <$> symbol Grammar.ExportClause <*> children (TypeScript.Syntax.ExportClause <$> manyTerm importExportSpecifier) - -importExportSpecifier :: Assignment -importExportSpecifier = makeTerm <$> (symbol Grammar.ExportSpecifier <|> symbol Grammar.ImportSpecifier) <*> children (TypeScript.Syntax.ImportExportSpecifier <$> term identifier <*> (term identifier <|> emptyTerm)) +fromClause = makeTerm <$> symbol Grammar.String <*> (Syntax.Identifier . name . stripQuotes <$> source) propertySignature :: Assignment propertySignature = makePropertySignature <$> symbol Grammar.PropertySignature <*> children ((,,,) <$> (term accessibilityModifier' <|> emptyTerm) <*> (term readonly' <|> emptyTerm) <*> term propertyName <*> (term typeAnnotation' <|> emptyTerm)) diff --git a/src/Language/TypeScript/Syntax.hs b/src/Language/TypeScript/Syntax.hs index 13b920796..6637e8ed0 100644 --- a/src/Language/TypeScript/Syntax.hs +++ b/src/Language/TypeScript/Syntax.hs @@ -71,14 +71,6 @@ instance Ord1 ImportClause where liftCompare = genericLiftCompare instance Show1 ImportClause where liftShowsPrec = genericLiftShowsPrec instance Evaluatable ImportClause -newtype NamespaceImport a = NamespaceImport { _namespaceImportSubject :: a } - deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable, FreeVariables1) - -instance Eq1 NamespaceImport where liftEq = genericLiftEq -instance Ord1 NamespaceImport where liftCompare = genericLiftCompare -instance Show1 NamespaceImport where liftShowsPrec = genericLiftShowsPrec -instance Evaluatable NamespaceImport - newtype Tuple a = Tuple { _tupleElements :: [a] } deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable, FreeVariables1) @@ -241,14 +233,6 @@ instance Ord1 ImportExportSpecifier where liftCompare = genericLiftCompare instance Show1 ImportExportSpecifier where liftShowsPrec = genericLiftShowsPrec instance Evaluatable ImportExportSpecifier -newtype NamedImports a = NamedImports { _namedImportElements :: [a] } - deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable, FreeVariables1) - -instance Eq1 NamedImports where liftEq = genericLiftEq -instance Ord1 NamedImports where liftCompare = genericLiftCompare -instance Show1 NamedImports where liftShowsPrec = genericLiftShowsPrec -instance Evaluatable NamedImports - data With a = With { _withExpression :: !a, _withBody :: !a } deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable, FreeVariables1) diff --git a/src/Prologue.hs b/src/Prologue.hs index c818baecb..cff645a5b 100644 --- a/src/Prologue.hs +++ b/src/Prologue.hs @@ -23,6 +23,8 @@ import Data.List.NonEmpty as X ( , some1 ) +import Debug.Trace as X + import Control.Exception as X hiding ( evaluate , throw diff --git a/src/Semantic/Util.hs b/src/Semantic/Util.hs index c732be9ee..46bdd1350 100644 --- a/src/Semantic/Util.hs +++ b/src/Semantic/Util.hs @@ -1,5 +1,6 @@ -- MonoLocalBinds is to silence a warning about a simplifiable constraint. {-# LANGUAGE DataKinds, MonoLocalBinds, TypeApplications, TypeOperators #-} +{-# OPTIONS_GHC -Wno-missing-signatures #-} module Semantic.Util where import Analysis.Abstract.Caching diff --git a/test/fixtures/go/grouped-import-declarations.diffA-B.txt b/test/fixtures/go/grouped-import-declarations.diffA-B.txt index 86e70c783..1bc556c75 100644 --- a/test/fixtures/go/grouped-import-declarations.diffA-B.txt +++ b/test/fixtures/go/grouped-import-declarations.diffA-B.txt @@ -9,13 +9,13 @@ ->(Identifier) }) {+(WildcardImport {+(TextElement)+} - {+(Empty)+})+} + {+(Identifier)+})+} {+(QualifiedImport {+(TextElement)+} {+(Identifier)+})+} {-(WildcardImport {-(TextElement)-} - {-(Empty)-})-} + {-(Identifier)-})-} {-(QualifiedImport {-(TextElement)-} {-(Identifier)-})-}) diff --git a/test/fixtures/go/grouped-import-declarations.diffB-A.txt b/test/fixtures/go/grouped-import-declarations.diffB-A.txt index 86e70c783..1bc556c75 100644 --- a/test/fixtures/go/grouped-import-declarations.diffB-A.txt +++ b/test/fixtures/go/grouped-import-declarations.diffB-A.txt @@ -9,13 +9,13 @@ ->(Identifier) }) {+(WildcardImport {+(TextElement)+} - {+(Empty)+})+} + {+(Identifier)+})+} {+(QualifiedImport {+(TextElement)+} {+(Identifier)+})+} {-(WildcardImport {-(TextElement)-} - {-(Empty)-})-} + {-(Identifier)-})-} {-(QualifiedImport {-(TextElement)-} {-(Identifier)-})-}) diff --git a/test/fixtures/go/grouped-import-declarations.parseA.txt b/test/fixtures/go/grouped-import-declarations.parseA.txt index 146b10afe..f158e32d1 100644 --- a/test/fixtures/go/grouped-import-declarations.parseA.txt +++ b/test/fixtures/go/grouped-import-declarations.parseA.txt @@ -7,7 +7,7 @@ (Identifier)) (WildcardImport (TextElement) - (Empty)) + (Identifier)) (QualifiedImport (TextElement) (Identifier))) diff --git a/test/fixtures/go/grouped-import-declarations.parseB.txt b/test/fixtures/go/grouped-import-declarations.parseB.txt index 146b10afe..f158e32d1 100644 --- a/test/fixtures/go/grouped-import-declarations.parseB.txt +++ b/test/fixtures/go/grouped-import-declarations.parseB.txt @@ -7,7 +7,7 @@ (Identifier)) (WildcardImport (TextElement) - (Empty)) + (Identifier)) (QualifiedImport (TextElement) (Identifier))) diff --git a/test/fixtures/go/single-import-declarations.diffA-B.txt b/test/fixtures/go/single-import-declarations.diffA-B.txt index 6263c4f88..60f02ea9d 100644 --- a/test/fixtures/go/single-import-declarations.diffA-B.txt +++ b/test/fixtures/go/single-import-declarations.diffA-B.txt @@ -9,7 +9,7 @@ (WildcardImport { (TextElement) ->(TextElement) } - (Empty)) + (Identifier)) (QualifiedImport { (TextElement) ->(TextElement) } diff --git a/test/fixtures/go/single-import-declarations.diffB-A.txt b/test/fixtures/go/single-import-declarations.diffB-A.txt index 6263c4f88..60f02ea9d 100644 --- a/test/fixtures/go/single-import-declarations.diffB-A.txt +++ b/test/fixtures/go/single-import-declarations.diffB-A.txt @@ -9,7 +9,7 @@ (WildcardImport { (TextElement) ->(TextElement) } - (Empty)) + (Identifier)) (QualifiedImport { (TextElement) ->(TextElement) } diff --git a/test/fixtures/go/single-import-declarations.parseA.txt b/test/fixtures/go/single-import-declarations.parseA.txt index f4eafc4c0..48ddf1c82 100644 --- a/test/fixtures/go/single-import-declarations.parseA.txt +++ b/test/fixtures/go/single-import-declarations.parseA.txt @@ -6,7 +6,7 @@ (Identifier)) (WildcardImport (TextElement) - (Empty)) + (Identifier)) (QualifiedImport (TextElement) (Identifier)) diff --git a/test/fixtures/go/single-import-declarations.parseB.txt b/test/fixtures/go/single-import-declarations.parseB.txt index f4eafc4c0..48ddf1c82 100644 --- a/test/fixtures/go/single-import-declarations.parseB.txt +++ b/test/fixtures/go/single-import-declarations.parseB.txt @@ -6,7 +6,7 @@ (Identifier)) (WildcardImport (TextElement) - (Empty)) + (Identifier)) (QualifiedImport (TextElement) (Identifier)) diff --git a/test/fixtures/javascript/chained-callbacks.diffA-B.txt b/test/fixtures/javascript/chained-callbacks.diffA-B.txt index f88bc58c9..d44152989 100644 --- a/test/fixtures/javascript/chained-callbacks.diffA-B.txt +++ b/test/fixtures/javascript/chained-callbacks.diffA-B.txt @@ -17,9 +17,6 @@ (Empty))) ( (Return - (MemberAccess - { (Identifier) - ->(Identifier) } - { (Identifier) - ->(Identifier) })))) + { (Identifier) + ->(Identifier) }))) (Empty))) diff --git a/test/fixtures/javascript/chained-callbacks.diffB-A.txt b/test/fixtures/javascript/chained-callbacks.diffB-A.txt index f88bc58c9..d44152989 100644 --- a/test/fixtures/javascript/chained-callbacks.diffB-A.txt +++ b/test/fixtures/javascript/chained-callbacks.diffB-A.txt @@ -17,9 +17,6 @@ (Empty))) ( (Return - (MemberAccess - { (Identifier) - ->(Identifier) } - { (Identifier) - ->(Identifier) })))) + { (Identifier) + ->(Identifier) }))) (Empty))) diff --git a/test/fixtures/javascript/chained-callbacks.parseA.txt b/test/fixtures/javascript/chained-callbacks.parseA.txt index f54ff9ba2..d3e54c776 100644 --- a/test/fixtures/javascript/chained-callbacks.parseA.txt +++ b/test/fixtures/javascript/chained-callbacks.parseA.txt @@ -16,7 +16,5 @@ (Empty))) ( (Return - (MemberAccess - (Identifier) - (Identifier))))) + (Identifier)))) (Empty))) diff --git a/test/fixtures/javascript/chained-callbacks.parseB.txt b/test/fixtures/javascript/chained-callbacks.parseB.txt index f54ff9ba2..d3e54c776 100644 --- a/test/fixtures/javascript/chained-callbacks.parseB.txt +++ b/test/fixtures/javascript/chained-callbacks.parseB.txt @@ -16,7 +16,5 @@ (Empty))) ( (Return - (MemberAccess - (Identifier) - (Identifier))))) + (Identifier)))) (Empty))) diff --git a/test/fixtures/javascript/chained-property-access.diffA-B.txt b/test/fixtures/javascript/chained-property-access.diffA-B.txt index 1c4c5c60f..73e2fd97a 100644 --- a/test/fixtures/javascript/chained-property-access.diffA-B.txt +++ b/test/fixtures/javascript/chained-property-access.diffA-B.txt @@ -5,19 +5,13 @@ (Call (MemberAccess (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)) (Identifier)) - (MemberAccess - { (Identifier) - ->(Identifier) } - (Identifier)) + { (Identifier) + ->(Identifier) } (Empty)) (Identifier)) - (MemberAccess - { (Identifier) - ->(Identifier) } - (Identifier)) + { (Identifier) + ->(Identifier) } (Empty)))) diff --git a/test/fixtures/javascript/chained-property-access.diffB-A.txt b/test/fixtures/javascript/chained-property-access.diffB-A.txt index 1c4c5c60f..73e2fd97a 100644 --- a/test/fixtures/javascript/chained-property-access.diffB-A.txt +++ b/test/fixtures/javascript/chained-property-access.diffB-A.txt @@ -5,19 +5,13 @@ (Call (MemberAccess (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)) (Identifier)) - (MemberAccess - { (Identifier) - ->(Identifier) } - (Identifier)) + { (Identifier) + ->(Identifier) } (Empty)) (Identifier)) - (MemberAccess - { (Identifier) - ->(Identifier) } - (Identifier)) + { (Identifier) + ->(Identifier) } (Empty)))) diff --git a/test/fixtures/javascript/chained-property-access.parseA.txt b/test/fixtures/javascript/chained-property-access.parseA.txt index c45050ddf..62aac643e 100644 --- a/test/fixtures/javascript/chained-property-access.parseA.txt +++ b/test/fixtures/javascript/chained-property-access.parseA.txt @@ -5,17 +5,11 @@ (Call (MemberAccess (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)) (Identifier)) - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)) (Identifier)) - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)))) diff --git a/test/fixtures/javascript/chained-property-access.parseB.txt b/test/fixtures/javascript/chained-property-access.parseB.txt index c45050ddf..62aac643e 100644 --- a/test/fixtures/javascript/chained-property-access.parseB.txt +++ b/test/fixtures/javascript/chained-property-access.parseB.txt @@ -5,17 +5,11 @@ (Call (MemberAccess (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)) (Identifier)) - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)) (Identifier)) - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)))) diff --git a/test/fixtures/javascript/constructor-call.diffA-B.txt b/test/fixtures/javascript/constructor-call.diffA-B.txt index 4cd5b5e65..29053395f 100644 --- a/test/fixtures/javascript/constructor-call.diffA-B.txt +++ b/test/fixtures/javascript/constructor-call.diffA-B.txt @@ -1,9 +1,7 @@ (Program (New (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Float) { (TextElement) ->(TextElement) } diff --git a/test/fixtures/javascript/constructor-call.diffB-A.txt b/test/fixtures/javascript/constructor-call.diffB-A.txt index 4cd5b5e65..29053395f 100644 --- a/test/fixtures/javascript/constructor-call.diffB-A.txt +++ b/test/fixtures/javascript/constructor-call.diffB-A.txt @@ -1,9 +1,7 @@ (Program (New (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Float) { (TextElement) ->(TextElement) } diff --git a/test/fixtures/javascript/constructor-call.parseA.txt b/test/fixtures/javascript/constructor-call.parseA.txt index 14fd6d198..b0e97bc52 100644 --- a/test/fixtures/javascript/constructor-call.parseA.txt +++ b/test/fixtures/javascript/constructor-call.parseA.txt @@ -1,9 +1,7 @@ (Program (New (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Float) (TextElement) (Empty)))) diff --git a/test/fixtures/javascript/constructor-call.parseB.txt b/test/fixtures/javascript/constructor-call.parseB.txt index 14fd6d198..b0e97bc52 100644 --- a/test/fixtures/javascript/constructor-call.parseB.txt +++ b/test/fixtures/javascript/constructor-call.parseB.txt @@ -1,9 +1,7 @@ (Program (New (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Float) (TextElement) (Empty)))) diff --git a/test/fixtures/javascript/delete-operator.diffA-B.txt b/test/fixtures/javascript/delete-operator.diffA-B.txt index 2208aa02b..6544b53c4 100644 --- a/test/fixtures/javascript/delete-operator.diffA-B.txt +++ b/test/fixtures/javascript/delete-operator.diffA-B.txt @@ -3,6 +3,4 @@ { (Subscript {-(Identifier)-} {-(TextElement)-}) - ->(MemberAccess - {+(Identifier)+} - {+(Identifier)+}) })) + ->(Identifier) })) diff --git a/test/fixtures/javascript/delete-operator.diffB-A.txt b/test/fixtures/javascript/delete-operator.diffB-A.txt index b278868d6..6375abc1d 100644 --- a/test/fixtures/javascript/delete-operator.diffB-A.txt +++ b/test/fixtures/javascript/delete-operator.diffB-A.txt @@ -1,8 +1,6 @@ (Program (Delete - { (MemberAccess - {-(Identifier)-} - {-(Identifier)-}) + { (Identifier) ->(Subscript {+(Identifier)+} {+(TextElement)+}) })) diff --git a/test/fixtures/javascript/delete-operator.parseB.txt b/test/fixtures/javascript/delete-operator.parseB.txt index 36e4bfbaa..d90828a09 100644 --- a/test/fixtures/javascript/delete-operator.parseB.txt +++ b/test/fixtures/javascript/delete-operator.parseB.txt @@ -1,5 +1,3 @@ (Program (Delete - (MemberAccess - (Identifier) - (Identifier)))) + (Identifier))) diff --git a/test/fixtures/javascript/do-while-statement.diffA-B.txt b/test/fixtures/javascript/do-while-statement.diffA-B.txt index 30c06d609..a8fc4982d 100644 --- a/test/fixtures/javascript/do-while-statement.diffA-B.txt +++ b/test/fixtures/javascript/do-while-statement.diffA-B.txt @@ -4,9 +4,7 @@ ->(Boolean) } ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty))))) diff --git a/test/fixtures/javascript/do-while-statement.diffB-A.txt b/test/fixtures/javascript/do-while-statement.diffB-A.txt index 30c06d609..a8fc4982d 100644 --- a/test/fixtures/javascript/do-while-statement.diffB-A.txt +++ b/test/fixtures/javascript/do-while-statement.diffB-A.txt @@ -4,9 +4,7 @@ ->(Boolean) } ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty))))) diff --git a/test/fixtures/javascript/do-while-statement.parseA.txt b/test/fixtures/javascript/do-while-statement.parseA.txt index 92c41b1a1..8d8016b8f 100644 --- a/test/fixtures/javascript/do-while-statement.parseA.txt +++ b/test/fixtures/javascript/do-while-statement.parseA.txt @@ -3,8 +3,6 @@ (Boolean) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty))))) diff --git a/test/fixtures/javascript/do-while-statement.parseB.txt b/test/fixtures/javascript/do-while-statement.parseB.txt index 92c41b1a1..8d8016b8f 100644 --- a/test/fixtures/javascript/do-while-statement.parseB.txt +++ b/test/fixtures/javascript/do-while-statement.parseB.txt @@ -3,8 +3,6 @@ (Boolean) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty))))) diff --git a/test/fixtures/javascript/export.diffA-B.txt b/test/fixtures/javascript/export.diffA-B.txt index 242d15d93..7743406b0 100644 --- a/test/fixtures/javascript/export.diffA-B.txt +++ b/test/fixtures/javascript/export.diffA-B.txt @@ -1,161 +1,31 @@ (Program - (Export - (ExportClause - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - (Empty)) - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+} - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - (Empty)) - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-})) - (Export - (ExportClause - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Identifier)-})-} - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - { (Empty) - ->(Identifier) }) - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+})) - (Export + {(QualifiedExport)->(QualifiedExport)} + {(QualifiedExport)->(QualifiedExport)} + (DefaultExport (VariableDeclaration - (Assignment - (Empty) - { (Identifier) - ->(Identifier) } - (Empty)) - (Assignment - (Empty) - { (Identifier) - ->(Identifier) } - (Empty)) - (Assignment - (Empty) - { (Identifier) - ->(Identifier) } - (Empty)))) - (Export + (Assignment(Empty){(Identifier)->(Identifier)}(Empty)) + (Assignment(Empty){(Identifier)->(Identifier)}(Empty)) + (Assignment(Empty){(Identifier)->(Identifier)}(Empty)))) + (DefaultExport (VariableDeclaration - {-(Assignment - {-(Empty)-} - {-(Identifier)-} - {-(Identifier)-})-} - (Assignment - (Empty) - (Identifier) - (Identifier)) - (Assignment - (Empty) - (Identifier) - { (Empty) - ->(Identifier) }) - {+(Assignment - {+(Empty)+} - {+(Identifier)+} - {+(Empty)+})+} - (Assignment - (Empty) - { (Identifier) - ->(Identifier) } - (Empty)))) - (Export - { (Identifier) - ->(Identifier) }) -{+(Export - {+(Function - {+(Empty)+} - {+(Empty)+} - {+(Identifier)+} - {+([])+})+})+} - (Export - (Function - (Empty) - (Empty) - (Empty) - ([]))) - (Export - {+(ExportClause - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Identifier)+})+})+} - {-(Function - {-(Empty)-} - {-(Empty)-} - {-(Identifier)-} - {-([])-})-}) - (Export - {+(TextElement)+} - {-(ExportClause - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Identifier)-})-})-}) -{+(Export - {+(ExportClause - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+} - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+} - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+})+} - {+(TextElement)+})+} -{+(Export - {+(ExportClause - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Identifier)+})+} - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Identifier)+})+} - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+})+} - {+(TextElement)+})+} -{-(Export - {-(TextElement)-})-} -{-(Export - {-(ExportClause - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-})-} - {-(TextElement)-})-} -{-(Export - {-(ExportClause - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Identifier)-})-} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Identifier)-})-} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-})-} - {-(TextElement)-})-}) + {-(Assignment{-(Empty)-}{-(Identifier)-}{-(Identifier)-})-} + (Assignment(Empty)(Identifier)(Identifier)) + (Assignment(Empty)(Identifier){(Empty)->(Identifier)}) + {+(Assignment{+(Empty)+}{+(Identifier)+}{+(Empty)+})+} + (Assignment(Empty){(Identifier)->(Identifier)}(Empty)))) + (DefaultExport + {(Identifier)->(Identifier)}) + {+(DefaultExport + {+(Function{+(Empty)+}{+(Empty)+}{+(Identifier)+}{+([])+})+})+} + (DefaultExport + (Function(Empty)(Empty)(Empty)([]))) + {+(QualifiedExport)+} + {+(DefaultExport {+(TextElement)+})+} + {+(QualifiedExportFrom {+(Identifier)+})+} + {+(QualifiedExportFrom {+(Identifier)+})+} + {-(DefaultExport + {-(Function{-(Empty)-}{-(Empty)-}{-(Identifier)-}{-([])-})-})-} + {-(QualifiedExport)-} + {-(DefaultExport {-(TextElement)-})-} + {-(QualifiedExportFrom {-(Identifier)-})-} + {-(QualifiedExportFrom {-(Identifier)-})-}) \ No newline at end of file diff --git a/test/fixtures/javascript/export.diffB-A.txt b/test/fixtures/javascript/export.diffB-A.txt index 7823a72b0..5bb3c4307 100644 --- a/test/fixtures/javascript/export.diffB-A.txt +++ b/test/fixtures/javascript/export.diffB-A.txt @@ -1,153 +1,24 @@ (Program - (Export - (ExportClause - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - (Empty)) - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+} - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - (Empty)) - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-})) - (Export - (ExportClause - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Identifier)+})+} - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - { (Identifier) - ->(Empty) }) - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-})) - (Export + {(QualifiedExport)->(QualifiedExport)} + {(QualifiedExport)->(QualifiedExport)} + (DefaultExport (VariableDeclaration - (Assignment - (Empty) - { (Identifier) - ->(Identifier) } - (Empty)) - (Assignment - (Empty) - { (Identifier) - ->(Identifier) } - (Empty)) - (Assignment - (Empty) - { (Identifier) - ->(Identifier) } - (Empty)))) - (Export + (Assignment(Empty){(Identifier)->(Identifier)}(Empty)) + (Assignment(Empty){(Identifier)->(Identifier)}(Empty)) + (Assignment(Empty){(Identifier)->(Identifier)}(Empty)))) + (DefaultExport (VariableDeclaration - {+(Assignment - {+(Empty)+} - {+(Identifier)+} - {+(Identifier)+})+} - (Assignment - (Empty) - (Identifier) - (Identifier)) - (Assignment - (Empty) - (Identifier) - { (Identifier) - ->(Empty) }) - {+(Assignment - {+(Empty)+} - {+(Identifier)+} - {+(Empty)+})+} - {-(Assignment - {-(Empty)-} - {-(Identifier)-} - {-(Empty)-})-} - {-(Assignment - {-(Empty)-} - {-(Identifier)-} - {-(Empty)-})-})) - (Export - { (Identifier) - ->(Identifier) }) -{-(Export - {-(Function - {-(Empty)-} - {-(Empty)-} - {-(Identifier)-} - {-([])-})-})-} - (Export - (Function - (Empty) - (Empty) - (Empty) - ([]))) - (Export - {+(Function - {+(Empty)+} - {+(Empty)+} - {+(Identifier)+} - {+([])+})+} - {-(ExportClause - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Identifier)-})-})-}) - (Export - {+(ExportClause - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Identifier)+})+})+} - {-(TextElement)-}) -{+(Export - {+(TextElement)+})+} - (Export - (ExportClause - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - (Empty)) - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - (Empty)) - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - (Empty))) - { (TextElement) - ->(TextElement) }) - (Export - (ExportClause - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - { (Identifier) - ->(Identifier) }) - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Identifier)+})+} - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Identifier)-})-} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-}) - { (TextElement) - ->(TextElement) })) + {+(Assignment{+(Empty)+}{+(Identifier)+}{+(Identifier)+})+} + (Assignment(Empty)(Identifier)(Identifier)) + (Assignment(Empty)(Identifier){(Identifier)->(Empty)}) + {+(Assignment{+(Empty)+}{+(Identifier)+}{+(Empty)+})+} + {-(Assignment{-(Empty)-}{-(Identifier)-}{-(Empty)-})-} + {-(Assignment{-(Empty)-}{-(Identifier)-}{-(Empty)-})-})) + (DefaultExport {(Identifier)->(Identifier)}) + {-(DefaultExport {-(Function{-(Empty)-}{-(Empty)-}{-(Identifier)-}{-([])-})-})-} + (DefaultExport (Function(Empty)(Empty)(Empty)([]))) + {+(DefaultExport {+(Function{+(Empty)+}{+(Empty)+}{+(Identifier)+}{+([])+})+})+} + {(QualifiedExport)->(QualifiedExport)} + (DefaultExport {(TextElement)->(TextElement)}) + {(QualifiedExportFrom {-(Identifier)-})->(QualifiedExportFrom {+(Identifier)+})} + {(QualifiedExportFrom {-(Identifier)-})->(QualifiedExportFrom {+(Identifier)+})}) \ No newline at end of file diff --git a/test/fixtures/javascript/export.parseA.txt b/test/fixtures/javascript/export.parseA.txt index 39a62d10b..a96f447eb 100644 --- a/test/fixtures/javascript/export.parseA.txt +++ b/test/fixtures/javascript/export.parseA.txt @@ -1,103 +1,20 @@ (Program - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)))) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Empty)))) - (Export - (VariableDeclaration - (Assignment - (Empty) - (Identifier) - (Empty)) - (Assignment - (Empty) - (Identifier) - (Empty)) - (Assignment - (Empty) - (Identifier) - (Empty)))) - (Export - (VariableDeclaration - (Assignment - (Empty) - (Identifier) - (Identifier)) - (Assignment - (Empty) - (Identifier) - (Identifier)) - (Assignment - (Empty) - (Identifier) - (Empty)) - (Assignment - (Empty) - (Identifier) - (Empty)))) - (Export + (QualifiedExport) + (QualifiedExport) + (DefaultExport + (VariableDeclaration(Assignment(Empty)(Identifier)(Empty))(Assignment(Empty)(Identifier)(Empty))(Assignment(Empty)(Identifier)(Empty)))) + (DefaultExport + (VariableDeclaration(Assignment(Empty)(Identifier)(Identifier))(Assignment(Empty)(Identifier)(Identifier))(Assignment(Empty)(Identifier)(Empty))(Assignment(Empty)(Identifier)(Empty)))) + (DefaultExport (Identifier)) - (Export - (Function - (Empty) - (Empty) - (Empty) - ([]))) - (Export - (Function - (Empty) - (Empty) - (Identifier) - ([]))) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Identifier)))) - (Export + (DefaultExport + (Function(Empty)(Empty)(Empty)([]))) + (DefaultExport + (Function(Empty)(Empty)(Identifier)([]))) + (QualifiedExport) + (DefaultExport (TextElement)) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty))) - (TextElement)) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Empty))) - (TextElement))) + (QualifiedExportFrom + (Identifier)) + (QualifiedExportFrom + (Identifier))) \ No newline at end of file diff --git a/test/fixtures/javascript/export.parseB.txt b/test/fixtures/javascript/export.parseB.txt index 0b08b21f6..e87ee5d80 100644 --- a/test/fixtures/javascript/export.parseB.txt +++ b/test/fixtures/javascript/export.parseB.txt @@ -1,103 +1,14 @@ (Program - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)))) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Empty)))) - (Export - (VariableDeclaration - (Assignment - (Empty) - (Identifier) - (Empty)) - (Assignment - (Empty) - (Identifier) - (Empty)) - (Assignment - (Empty) - (Identifier) - (Empty)))) - (Export - (VariableDeclaration - (Assignment - (Empty) - (Identifier) - (Identifier)) - (Assignment - (Empty) - (Identifier) - (Identifier)) - (Assignment - (Empty) - (Identifier) - (Empty)) - (Assignment - (Empty) - (Identifier) - (Empty)))) - (Export - (Identifier)) - (Export - (Function - (Empty) - (Empty) - (Identifier) - ([]))) - (Export - (Function - (Empty) - (Empty) - (Empty) - ([]))) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Identifier)))) - (Export - (TextElement)) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty))) - (TextElement)) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Empty))) - (TextElement))) + (QualifiedExport) + (QualifiedExport) + (DefaultExport + (VariableDeclaration(Assignment(Empty)(Identifier)(Empty))(Assignment(Empty)(Identifier)(Empty))(Assignment(Empty)(Identifier)(Empty)))) + (DefaultExport + (VariableDeclaration(Assignment(Empty)(Identifier)(Identifier))(Assignment(Empty)(Identifier)(Identifier))(Assignment(Empty)(Identifier)(Empty))(Assignment(Empty)(Identifier)(Empty)))) + (DefaultExport (Identifier)) + (DefaultExport (Function(Empty)(Empty)(Identifier)([]))) + (DefaultExport (Function(Empty)(Empty)(Empty)([]))) + (QualifiedExport) + (DefaultExport (TextElement)) + (QualifiedExportFrom (Identifier)) + (QualifiedExportFrom (Identifier))) \ No newline at end of file diff --git a/test/fixtures/javascript/function-call-args.diffA-B.txt b/test/fixtures/javascript/function-call-args.diffA-B.txt index cb4b6e2d9..aee47bc1c 100644 --- a/test/fixtures/javascript/function-call-args.diffA-B.txt +++ b/test/fixtures/javascript/function-call-args.diffA-B.txt @@ -31,9 +31,7 @@ {+(Empty)+})+})+} ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty)) diff --git a/test/fixtures/javascript/function-call-args.diffB-A.txt b/test/fixtures/javascript/function-call-args.diffB-A.txt index 194e964af..55c1ebf80 100644 --- a/test/fixtures/javascript/function-call-args.diffB-A.txt +++ b/test/fixtures/javascript/function-call-args.diffB-A.txt @@ -31,9 +31,7 @@ {-(Empty)-})-})-} ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty)) diff --git a/test/fixtures/javascript/function-call-args.parseA.txt b/test/fixtures/javascript/function-call-args.parseA.txt index 3f9ef783e..091f07ff5 100644 --- a/test/fixtures/javascript/function-call-args.parseA.txt +++ b/test/fixtures/javascript/function-call-args.parseA.txt @@ -23,9 +23,7 @@ (Empty))) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty)) (Return diff --git a/test/fixtures/javascript/function-call-args.parseB.txt b/test/fixtures/javascript/function-call-args.parseB.txt index 3f9ef783e..091f07ff5 100644 --- a/test/fixtures/javascript/function-call-args.parseB.txt +++ b/test/fixtures/javascript/function-call-args.parseB.txt @@ -23,9 +23,7 @@ (Empty))) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty)) (Return diff --git a/test/fixtures/javascript/if.diffA-B.txt b/test/fixtures/javascript/if.diffA-B.txt index 2a90eee30..44a616a36 100644 --- a/test/fixtures/javascript/if.diffA-B.txt +++ b/test/fixtures/javascript/if.diffA-B.txt @@ -1,9 +1,7 @@ (Program (If { (Identifier) - ->(MemberAccess - {+(Identifier)+} - {+(Identifier)+}) } + ->(Identifier) } ( (Call (Identifier) diff --git a/test/fixtures/javascript/if.diffB-A.txt b/test/fixtures/javascript/if.diffB-A.txt index a6742d0e3..d055feb2d 100644 --- a/test/fixtures/javascript/if.diffB-A.txt +++ b/test/fixtures/javascript/if.diffB-A.txt @@ -1,8 +1,6 @@ (Program (If - { (MemberAccess - {-(Identifier)-} - {-(Identifier)-}) + { (Identifier) ->(Identifier) } ( (Call diff --git a/test/fixtures/javascript/if.parseB.txt b/test/fixtures/javascript/if.parseB.txt index 82a81394a..287c84a5b 100644 --- a/test/fixtures/javascript/if.parseB.txt +++ b/test/fixtures/javascript/if.parseB.txt @@ -1,8 +1,6 @@ (Program (If - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) ( (Call (Identifier) diff --git a/test/fixtures/javascript/import.diffA-B.txt b/test/fixtures/javascript/import.diffA-B.txt index f7216f4b8..48e18361f 100644 --- a/test/fixtures/javascript/import.diffA-B.txt +++ b/test/fixtures/javascript/import.diffA-B.txt @@ -1,49 +1,41 @@ (Program -{+(Import - {+(TextElement)+})+} -{+(QualifiedImport - {+(TextElement)+} - {+(Identifier)+})+} -{+(Import - {+(TextElement)+})+} -{+(Import - {+(TextElement)+})+} + (Import + { (Identifier) + ->(Identifier) }) + (QualifiedImport + { (Identifier) + ->(Identifier) } + { (Identifier) + ->(Identifier) }) { (Import - {-(TextElement)-}) + {-(Identifier)-}) ->(Import - {+(TextElement)+}) } -{+( - {+(Import - {+(TextElement)+})+} - {+(Import - {+(TextElement)+})+})+} -{+( - {+(Import - {+(TextElement)+})+} - {+(QualifiedImport - {+(TextElement)+} - {+(Identifier)+})+})+} -{+(Import - {+(TextElement)+})+} -{-(QualifiedImport - {-(TextElement)-} - {-(Identifier)-})-} -{-(Import - {-(TextElement)-})-} -{-(Import - {-(TextElement)-})-} -{-(Import - {-(TextElement)-})-} -{-( - {-(Import - {-(TextElement)-})-} - {-(Import - {-(TextElement)-})-})-} -{-( - {-(Import - {-(TextElement)-})-} - {-(QualifiedImport - {-(TextElement)-} - {-(Identifier)-})-})-} -{-(Import - {-(TextElement)-})-}) + {+(Identifier)+}) } +{ (Import + {-(Identifier)-}) +->(Import + {+(Identifier)+}) } +{ (Import + {-(Identifier)-}) +->(Import + {+(Identifier)+}) } + ( + (Import + { (Identifier) + ->(Identifier) }) + { (Import + {-(Identifier)-}) + ->(Import + {+(Identifier)+}) }) + ( + (Import + { (Identifier) + ->(Identifier) }) + (QualifiedImport + { (Identifier) + ->(Identifier) } + { (Identifier) + ->(Identifier) })) + (Import + { (Identifier) + ->(Identifier) })) diff --git a/test/fixtures/javascript/import.diffB-A.txt b/test/fixtures/javascript/import.diffB-A.txt index 7f9f29e9c..48e18361f 100644 --- a/test/fixtures/javascript/import.diffB-A.txt +++ b/test/fixtures/javascript/import.diffB-A.txt @@ -1,49 +1,41 @@ (Program -{+(Import - {+(TextElement)+})+} -{+(QualifiedImport - {+(TextElement)+} - {+(Identifier)+})+} -{+(Import - {+(TextElement)+})+} -{+(Import - {+(TextElement)+})+} -{+(Import - {+(TextElement)+})+} -{+( - {+(Import - {+(TextElement)+})+} - {+(Import - {+(TextElement)+})+})+} -{+( - {+(Import - {+(TextElement)+})+} - {+(QualifiedImport - {+(TextElement)+} - {+(Identifier)+})+})+} -{+(Import - {+(TextElement)+})+} -{-(Import - {-(TextElement)-})-} -{-(QualifiedImport - {-(TextElement)-} - {-(Identifier)-})-} -{-(Import - {-(TextElement)-})-} -{-(Import - {-(TextElement)-})-} -{-(Import - {-(TextElement)-})-} -{-( - {-(Import - {-(TextElement)-})-} - {-(Import - {-(TextElement)-})-})-} -{-( - {-(Import - {-(TextElement)-})-} - {-(QualifiedImport - {-(TextElement)-} - {-(Identifier)-})-})-} -{-(Import - {-(TextElement)-})-}) + (Import + { (Identifier) + ->(Identifier) }) + (QualifiedImport + { (Identifier) + ->(Identifier) } + { (Identifier) + ->(Identifier) }) +{ (Import + {-(Identifier)-}) +->(Import + {+(Identifier)+}) } +{ (Import + {-(Identifier)-}) +->(Import + {+(Identifier)+}) } +{ (Import + {-(Identifier)-}) +->(Import + {+(Identifier)+}) } + ( + (Import + { (Identifier) + ->(Identifier) }) + { (Import + {-(Identifier)-}) + ->(Import + {+(Identifier)+}) }) + ( + (Import + { (Identifier) + ->(Identifier) }) + (QualifiedImport + { (Identifier) + ->(Identifier) } + { (Identifier) + ->(Identifier) })) + (Import + { (Identifier) + ->(Identifier) })) diff --git a/test/fixtures/javascript/import.parseA.txt b/test/fixtures/javascript/import.parseA.txt index 5a3bdf832..6bd6755f3 100644 --- a/test/fixtures/javascript/import.parseA.txt +++ b/test/fixtures/javascript/import.parseA.txt @@ -1,25 +1,25 @@ (Program (Import - (TextElement)) + (Identifier)) (QualifiedImport - (TextElement) + (Identifier) (Identifier)) (Import - (TextElement)) + (Identifier)) (Import - (TextElement)) + (Identifier)) (Import - (TextElement)) + (Identifier)) ( (Import - (TextElement)) + (Identifier)) (Import - (TextElement))) + (Identifier))) ( (Import - (TextElement)) + (Identifier)) (QualifiedImport - (TextElement) + (Identifier) (Identifier))) (Import - (TextElement))) + (Identifier))) diff --git a/test/fixtures/javascript/import.parseB.txt b/test/fixtures/javascript/import.parseB.txt index 5a3bdf832..6bd6755f3 100644 --- a/test/fixtures/javascript/import.parseB.txt +++ b/test/fixtures/javascript/import.parseB.txt @@ -1,25 +1,25 @@ (Program (Import - (TextElement)) + (Identifier)) (QualifiedImport - (TextElement) + (Identifier) (Identifier)) (Import - (TextElement)) + (Identifier)) (Import - (TextElement)) + (Identifier)) (Import - (TextElement)) + (Identifier)) ( (Import - (TextElement)) + (Identifier)) (Import - (TextElement))) + (Identifier))) ( (Import - (TextElement)) + (Identifier)) (QualifiedImport - (TextElement) + (Identifier) (Identifier))) (Import - (TextElement))) + (Identifier))) diff --git a/test/fixtures/javascript/member-access-assignment.diffA-B.txt b/test/fixtures/javascript/member-access-assignment.diffA-B.txt index 971eac6e7..9572881a4 100644 --- a/test/fixtures/javascript/member-access-assignment.diffA-B.txt +++ b/test/fixtures/javascript/member-access-assignment.diffA-B.txt @@ -1,7 +1,5 @@ (Program (Assignment - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Float) ->(Float) })) diff --git a/test/fixtures/javascript/member-access-assignment.diffB-A.txt b/test/fixtures/javascript/member-access-assignment.diffB-A.txt index 971eac6e7..9572881a4 100644 --- a/test/fixtures/javascript/member-access-assignment.diffB-A.txt +++ b/test/fixtures/javascript/member-access-assignment.diffB-A.txt @@ -1,7 +1,5 @@ (Program (Assignment - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Float) ->(Float) })) diff --git a/test/fixtures/javascript/member-access-assignment.parseA.txt b/test/fixtures/javascript/member-access-assignment.parseA.txt index 7d15e4ab4..7631b5f93 100644 --- a/test/fixtures/javascript/member-access-assignment.parseA.txt +++ b/test/fixtures/javascript/member-access-assignment.parseA.txt @@ -1,6 +1,4 @@ (Program (Assignment - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Float))) diff --git a/test/fixtures/javascript/member-access-assignment.parseB.txt b/test/fixtures/javascript/member-access-assignment.parseB.txt index 7d15e4ab4..7631b5f93 100644 --- a/test/fixtures/javascript/member-access-assignment.parseB.txt +++ b/test/fixtures/javascript/member-access-assignment.parseB.txt @@ -1,6 +1,4 @@ (Program (Assignment - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Float))) diff --git a/test/fixtures/javascript/member-access.diffA-B.txt b/test/fixtures/javascript/member-access.diffA-B.txt index 032d939dd..6ac9cd896 100644 --- a/test/fixtures/javascript/member-access.diffA-B.txt +++ b/test/fixtures/javascript/member-access.diffA-B.txt @@ -1,5 +1,3 @@ (Program - (MemberAccess - (Identifier) - { (Identifier) - ->(Identifier) })) +{ (Identifier) +->(Identifier) }) diff --git a/test/fixtures/javascript/member-access.diffB-A.txt b/test/fixtures/javascript/member-access.diffB-A.txt index 032d939dd..6ac9cd896 100644 --- a/test/fixtures/javascript/member-access.diffB-A.txt +++ b/test/fixtures/javascript/member-access.diffB-A.txt @@ -1,5 +1,3 @@ (Program - (MemberAccess - (Identifier) - { (Identifier) - ->(Identifier) })) +{ (Identifier) +->(Identifier) }) diff --git a/test/fixtures/javascript/member-access.parseA.txt b/test/fixtures/javascript/member-access.parseA.txt index 3a5c9e565..67b75f388 100644 --- a/test/fixtures/javascript/member-access.parseA.txt +++ b/test/fixtures/javascript/member-access.parseA.txt @@ -1,4 +1,2 @@ (Program - (MemberAccess - (Identifier) - (Identifier))) + (Identifier)) diff --git a/test/fixtures/javascript/member-access.parseB.txt b/test/fixtures/javascript/member-access.parseB.txt index 3a5c9e565..67b75f388 100644 --- a/test/fixtures/javascript/member-access.parseB.txt +++ b/test/fixtures/javascript/member-access.parseB.txt @@ -1,4 +1,2 @@ (Program - (MemberAccess - (Identifier) - (Identifier))) + (Identifier)) diff --git a/test/fixtures/javascript/method-call.diffA-B.txt b/test/fixtures/javascript/method-call.diffA-B.txt index 04b6484e5..9ff4cf165 100644 --- a/test/fixtures/javascript/method-call.diffA-B.txt +++ b/test/fixtures/javascript/method-call.diffA-B.txt @@ -1,8 +1,6 @@ (Program (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) { (TextElement) ->(TextElement) } diff --git a/test/fixtures/javascript/method-call.diffB-A.txt b/test/fixtures/javascript/method-call.diffB-A.txt index 04b6484e5..9ff4cf165 100644 --- a/test/fixtures/javascript/method-call.diffB-A.txt +++ b/test/fixtures/javascript/method-call.diffB-A.txt @@ -1,8 +1,6 @@ (Program (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) { (TextElement) ->(TextElement) } diff --git a/test/fixtures/javascript/method-call.parseA.txt b/test/fixtures/javascript/method-call.parseA.txt index 1bc561706..992897b06 100644 --- a/test/fixtures/javascript/method-call.parseA.txt +++ b/test/fixtures/javascript/method-call.parseA.txt @@ -1,8 +1,6 @@ (Program (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (TextElement) (Empty))) diff --git a/test/fixtures/javascript/method-call.parseB.txt b/test/fixtures/javascript/method-call.parseB.txt index 1bc561706..992897b06 100644 --- a/test/fixtures/javascript/method-call.parseB.txt +++ b/test/fixtures/javascript/method-call.parseB.txt @@ -1,8 +1,6 @@ (Program (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (TextElement) (Empty))) diff --git a/test/fixtures/javascript/nested-functions.diffA-B.txt b/test/fixtures/javascript/nested-functions.diffA-B.txt index 0b3c286a9..5f2bf7912 100644 --- a/test/fixtures/javascript/nested-functions.diffA-B.txt +++ b/test/fixtures/javascript/nested-functions.diffA-B.txt @@ -38,16 +38,12 @@ (Empty))) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty)) (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty))))))) diff --git a/test/fixtures/javascript/nested-functions.diffB-A.txt b/test/fixtures/javascript/nested-functions.diffB-A.txt index 0b3c286a9..5f2bf7912 100644 --- a/test/fixtures/javascript/nested-functions.diffB-A.txt +++ b/test/fixtures/javascript/nested-functions.diffB-A.txt @@ -38,16 +38,12 @@ (Empty))) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty)) (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty))))))) diff --git a/test/fixtures/javascript/nested-functions.parseA.txt b/test/fixtures/javascript/nested-functions.parseA.txt index 0955c8914..a2989cfab 100644 --- a/test/fixtures/javascript/nested-functions.parseA.txt +++ b/test/fixtures/javascript/nested-functions.parseA.txt @@ -38,14 +38,10 @@ (Empty))) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty)) (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty))))))) diff --git a/test/fixtures/javascript/nested-functions.parseB.txt b/test/fixtures/javascript/nested-functions.parseB.txt index 0955c8914..a2989cfab 100644 --- a/test/fixtures/javascript/nested-functions.parseB.txt +++ b/test/fixtures/javascript/nested-functions.parseB.txt @@ -38,14 +38,10 @@ (Empty))) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty)) (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty))))))) diff --git a/test/fixtures/javascript/ternary.diffA-B.txt b/test/fixtures/javascript/ternary.diffA-B.txt index 500a7b34a..992caebe2 100644 --- a/test/fixtures/javascript/ternary.diffA-B.txt +++ b/test/fixtures/javascript/ternary.diffA-B.txt @@ -1,19 +1,11 @@ (Program {+(Assignment - {+(MemberAccess - {+(Identifier)+} - {+(Identifier)+})+} + {+(Identifier)+} {+(If + {+(Identifier)+} + {+(Identifier)+} {+(MemberAccess {+(Identifier)+} - {+(Identifier)+})+} - {+(MemberAccess - {+(Identifier)+} - {+(Identifier)+})+} - {+(MemberAccess - {+(MemberAccess - {+(Identifier)+} - {+(Identifier)+})+} {+(Identifier)+})+})+})+} {-(If {-(Identifier)-} diff --git a/test/fixtures/javascript/ternary.diffB-A.txt b/test/fixtures/javascript/ternary.diffB-A.txt index 4696a13d8..3305baa61 100644 --- a/test/fixtures/javascript/ternary.diffB-A.txt +++ b/test/fixtures/javascript/ternary.diffB-A.txt @@ -4,18 +4,10 @@ {+(Identifier)+} {+(Identifier)+})+} {-(Assignment - {-(MemberAccess - {-(Identifier)-} - {-(Identifier)-})-} + {-(Identifier)-} {-(If + {-(Identifier)-} + {-(Identifier)-} {-(MemberAccess {-(Identifier)-} - {-(Identifier)-})-} - {-(MemberAccess - {-(Identifier)-} - {-(Identifier)-})-} - {-(MemberAccess - {-(MemberAccess - {-(Identifier)-} - {-(Identifier)-})-} {-(Identifier)-})-})-})-}) diff --git a/test/fixtures/javascript/ternary.parseB.txt b/test/fixtures/javascript/ternary.parseB.txt index 988c986b7..e072403cd 100644 --- a/test/fixtures/javascript/ternary.parseB.txt +++ b/test/fixtures/javascript/ternary.parseB.txt @@ -1,17 +1,9 @@ (Program (Assignment - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (If + (Identifier) + (Identifier) (MemberAccess (Identifier) - (Identifier)) - (MemberAccess - (Identifier) - (Identifier)) - (MemberAccess - (MemberAccess - (Identifier) - (Identifier)) (Identifier))))) diff --git a/test/fixtures/javascript/yield.parseA.txt b/test/fixtures/javascript/yield.parseA.txt index 14462c643..0a4c7dcc9 100644 --- a/test/fixtures/javascript/yield.parseA.txt +++ b/test/fixtures/javascript/yield.parseA.txt @@ -1 +1,13 @@ -(Program(Function(Empty)(Empty)(Identifier)((VariableDeclaration(Assignment(Empty)(Identifier)(Float)))(Yield(Identifier))))) \ No newline at end of file +(Program + (Function + (Empty) + (Empty) + (Identifier) + ( + (VariableDeclaration + (Assignment + (Empty) + (Identifier) + (Float))) + (Yield + (Identifier))))) diff --git a/test/fixtures/typescript/ambient-exports.diffA-B.txt b/test/fixtures/typescript/ambient-exports.diffA-B.txt index 5435de134..a7c5bad9f 100644 --- a/test/fixtures/typescript/ambient-exports.diffA-B.txt +++ b/test/fixtures/typescript/ambient-exports.diffA-B.txt @@ -1,30 +1,24 @@ (Program - (Export - {+(Function - {+(Empty)+} - {+(Empty)+} - {+(Identifier)+} - {+(RequiredParameter + (DefaultExport + {(Class + {-(Identifier)-} + {-([])-}) + -> + (Function {+(Empty)+} {+(Empty)+} - {+(Annotation - {+(PredefinedType)+})+} - {+(Assignment - {+(Identifier)+} - {+(Empty)+})+})+} - {+(RequiredParameter - {+(Empty)+} - {+(Empty)+} - {+(Annotation - {+(PredefinedType)+})+} - {+(Assignment - {+(Identifier)+} - {+(Empty)+})+})+} - {+( - {+(Return + {+(Identifier)+} + {+(RequiredParameter + {+(Empty)+} + {+(Empty)+} + {+(Annotation{+(PredefinedType)+})+} + {+(Assignment{+(Identifier)+}{+(Empty)+})+})+} + {+(RequiredParameter + {+(Empty)+} + {+(Empty)+} + {+(Annotation{+(PredefinedType)+})+} + {+(Assignment{+(Identifier)+}{+(Empty)+})+})+} + {+({+(Return {+(Hash {+(ShorthandPropertyIdentifier)+} - {+(ShorthandPropertyIdentifier)+})+})+})+})+} - {-(Class - {-(Identifier)-} - {-([])-})-})) + {+(ShorthandPropertyIdentifier)+})+})+})+})})) \ No newline at end of file diff --git a/test/fixtures/typescript/ambient-exports.diffB-A.txt b/test/fixtures/typescript/ambient-exports.diffB-A.txt index 9a1c015b0..22561ea57 100644 --- a/test/fixtures/typescript/ambient-exports.diffB-A.txt +++ b/test/fixtures/typescript/ambient-exports.diffB-A.txt @@ -1,30 +1,10 @@ (Program - (Export - {+(Class - {+(Identifier)+} - {+([])+})+} - {-(Function - {-(Empty)-} - {-(Empty)-} - {-(Identifier)-} - {-(RequiredParameter + (DefaultExport + {(Function {-(Empty)-} {-(Empty)-} - {-(Annotation - {-(PredefinedType)-})-} - {-(Assignment - {-(Identifier)-} - {-(Empty)-})-})-} - {-(RequiredParameter - {-(Empty)-} - {-(Empty)-} - {-(Annotation - {-(PredefinedType)-})-} - {-(Assignment - {-(Identifier)-} - {-(Empty)-})-})-} - {-( - {-(Return - {-(Hash - {-(ShorthandPropertyIdentifier)-} - {-(ShorthandPropertyIdentifier)-})-})-})-})-})) + {-(Identifier)-} + {-(RequiredParameter{-(Empty)-}{-(Empty)-}{-(Annotation{-(PredefinedType)-})-}{-(Assignment{-(Identifier)-}{-(Empty)-})-})-} + {-(RequiredParameter{-(Empty)-}{-(Empty)-}{-(Annotation{-(PredefinedType)-})-}{-(Assignment{-(Identifier)-}{-(Empty)-})-})-} + {-({-(Return{-(Hash{-(ShorthandPropertyIdentifier)-}{-(ShorthandPropertyIdentifier)-})-})-})-}) + ->(Class{+(Identifier)+}{+([])+})})) \ No newline at end of file diff --git a/test/fixtures/typescript/ambient-exports.parseA.txt b/test/fixtures/typescript/ambient-exports.parseA.txt index a88d95b7b..3f6f3d427 100644 --- a/test/fixtures/typescript/ambient-exports.parseA.txt +++ b/test/fixtures/typescript/ambient-exports.parseA.txt @@ -1,5 +1,5 @@ (Program - (Export + (DefaultExport (Class (Identifier) ([])))) diff --git a/test/fixtures/typescript/ambient-exports.parseB.txt b/test/fixtures/typescript/ambient-exports.parseB.txt index 7c54acd4c..c95a6be19 100644 --- a/test/fixtures/typescript/ambient-exports.parseB.txt +++ b/test/fixtures/typescript/ambient-exports.parseB.txt @@ -1,5 +1,5 @@ (Program - (Export + (DefaultExport (Function (Empty) (Empty) diff --git a/test/fixtures/typescript/analysis/.gitignore b/test/fixtures/typescript/analysis/.gitignore new file mode 100644 index 000000000..a6c7c2852 --- /dev/null +++ b/test/fixtures/typescript/analysis/.gitignore @@ -0,0 +1 @@ +*.js diff --git a/test/fixtures/typescript/analysis/a.ts b/test/fixtures/typescript/analysis/a.ts new file mode 100644 index 000000000..b856909a7 --- /dev/null +++ b/test/fixtures/typescript/analysis/a.ts @@ -0,0 +1,5 @@ +export { baz } + +function baz() { + return "this is the baz function" +} diff --git a/test/fixtures/typescript/analysis/foo.ts b/test/fixtures/typescript/analysis/foo.ts index adfcb8e26..b4728e55a 100644 --- a/test/fixtures/typescript/analysis/foo.ts +++ b/test/fixtures/typescript/analysis/foo.ts @@ -1,7 +1,5 @@ -export function bar() { - return "this is the bar function" -} +export { baz } from "a" -export default function () { - return "this is the defaultExport function" +function bar() { + return "this is the bar function"; } diff --git a/test/fixtures/typescript/analysis/main.ts b/test/fixtures/typescript/analysis/main.ts index 9e3f0fc14..dde33cffe 100644 --- a/test/fixtures/typescript/analysis/main.ts +++ b/test/fixtures/typescript/analysis/main.ts @@ -1,5 +1,5 @@ -// Use `tsc test.ts foo.ts && node test.js` to test evaluation +// Use `tsc main.ts foo.ts && node main.js` to test evaluation -import * as name from "./foo"; +import { baz as bar } from "foo"; -console.log(name.bar()) +bar() diff --git a/test/fixtures/typescript/chained-callbacks.diffA-B.txt b/test/fixtures/typescript/chained-callbacks.diffA-B.txt index f88bc58c9..d44152989 100644 --- a/test/fixtures/typescript/chained-callbacks.diffA-B.txt +++ b/test/fixtures/typescript/chained-callbacks.diffA-B.txt @@ -17,9 +17,6 @@ (Empty))) ( (Return - (MemberAccess - { (Identifier) - ->(Identifier) } - { (Identifier) - ->(Identifier) })))) + { (Identifier) + ->(Identifier) }))) (Empty))) diff --git a/test/fixtures/typescript/chained-callbacks.diffB-A.txt b/test/fixtures/typescript/chained-callbacks.diffB-A.txt index f88bc58c9..d44152989 100644 --- a/test/fixtures/typescript/chained-callbacks.diffB-A.txt +++ b/test/fixtures/typescript/chained-callbacks.diffB-A.txt @@ -17,9 +17,6 @@ (Empty))) ( (Return - (MemberAccess - { (Identifier) - ->(Identifier) } - { (Identifier) - ->(Identifier) })))) + { (Identifier) + ->(Identifier) }))) (Empty))) diff --git a/test/fixtures/typescript/chained-callbacks.parseA.txt b/test/fixtures/typescript/chained-callbacks.parseA.txt index f54ff9ba2..d3e54c776 100644 --- a/test/fixtures/typescript/chained-callbacks.parseA.txt +++ b/test/fixtures/typescript/chained-callbacks.parseA.txt @@ -16,7 +16,5 @@ (Empty))) ( (Return - (MemberAccess - (Identifier) - (Identifier))))) + (Identifier)))) (Empty))) diff --git a/test/fixtures/typescript/chained-callbacks.parseB.txt b/test/fixtures/typescript/chained-callbacks.parseB.txt index f54ff9ba2..d3e54c776 100644 --- a/test/fixtures/typescript/chained-callbacks.parseB.txt +++ b/test/fixtures/typescript/chained-callbacks.parseB.txt @@ -16,7 +16,5 @@ (Empty))) ( (Return - (MemberAccess - (Identifier) - (Identifier))))) + (Identifier)))) (Empty))) diff --git a/test/fixtures/typescript/chained-property-access.diffA-B.txt b/test/fixtures/typescript/chained-property-access.diffA-B.txt index 1c4c5c60f..73e2fd97a 100644 --- a/test/fixtures/typescript/chained-property-access.diffA-B.txt +++ b/test/fixtures/typescript/chained-property-access.diffA-B.txt @@ -5,19 +5,13 @@ (Call (MemberAccess (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)) (Identifier)) - (MemberAccess - { (Identifier) - ->(Identifier) } - (Identifier)) + { (Identifier) + ->(Identifier) } (Empty)) (Identifier)) - (MemberAccess - { (Identifier) - ->(Identifier) } - (Identifier)) + { (Identifier) + ->(Identifier) } (Empty)))) diff --git a/test/fixtures/typescript/chained-property-access.diffB-A.txt b/test/fixtures/typescript/chained-property-access.diffB-A.txt index 1c4c5c60f..73e2fd97a 100644 --- a/test/fixtures/typescript/chained-property-access.diffB-A.txt +++ b/test/fixtures/typescript/chained-property-access.diffB-A.txt @@ -5,19 +5,13 @@ (Call (MemberAccess (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)) (Identifier)) - (MemberAccess - { (Identifier) - ->(Identifier) } - (Identifier)) + { (Identifier) + ->(Identifier) } (Empty)) (Identifier)) - (MemberAccess - { (Identifier) - ->(Identifier) } - (Identifier)) + { (Identifier) + ->(Identifier) } (Empty)))) diff --git a/test/fixtures/typescript/chained-property-access.parseA.txt b/test/fixtures/typescript/chained-property-access.parseA.txt index c45050ddf..62aac643e 100644 --- a/test/fixtures/typescript/chained-property-access.parseA.txt +++ b/test/fixtures/typescript/chained-property-access.parseA.txt @@ -5,17 +5,11 @@ (Call (MemberAccess (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)) (Identifier)) - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)) (Identifier)) - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)))) diff --git a/test/fixtures/typescript/chained-property-access.parseB.txt b/test/fixtures/typescript/chained-property-access.parseB.txt index c45050ddf..62aac643e 100644 --- a/test/fixtures/typescript/chained-property-access.parseB.txt +++ b/test/fixtures/typescript/chained-property-access.parseB.txt @@ -5,17 +5,11 @@ (Call (MemberAccess (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)) (Identifier)) - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)) (Identifier)) - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)))) diff --git a/test/fixtures/typescript/constructor-call.diffA-B.txt b/test/fixtures/typescript/constructor-call.diffA-B.txt index 4cd5b5e65..29053395f 100644 --- a/test/fixtures/typescript/constructor-call.diffA-B.txt +++ b/test/fixtures/typescript/constructor-call.diffA-B.txt @@ -1,9 +1,7 @@ (Program (New (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Float) { (TextElement) ->(TextElement) } diff --git a/test/fixtures/typescript/constructor-call.diffB-A.txt b/test/fixtures/typescript/constructor-call.diffB-A.txt index 4cd5b5e65..29053395f 100644 --- a/test/fixtures/typescript/constructor-call.diffB-A.txt +++ b/test/fixtures/typescript/constructor-call.diffB-A.txt @@ -1,9 +1,7 @@ (Program (New (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Float) { (TextElement) ->(TextElement) } diff --git a/test/fixtures/typescript/constructor-call.parseA.txt b/test/fixtures/typescript/constructor-call.parseA.txt index 14fd6d198..b0e97bc52 100644 --- a/test/fixtures/typescript/constructor-call.parseA.txt +++ b/test/fixtures/typescript/constructor-call.parseA.txt @@ -1,9 +1,7 @@ (Program (New (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Float) (TextElement) (Empty)))) diff --git a/test/fixtures/typescript/constructor-call.parseB.txt b/test/fixtures/typescript/constructor-call.parseB.txt index 14fd6d198..b0e97bc52 100644 --- a/test/fixtures/typescript/constructor-call.parseB.txt +++ b/test/fixtures/typescript/constructor-call.parseB.txt @@ -1,9 +1,7 @@ (Program (New (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Float) (TextElement) (Empty)))) diff --git a/test/fixtures/typescript/delete-operator.diffA-B.txt b/test/fixtures/typescript/delete-operator.diffA-B.txt index 2208aa02b..6544b53c4 100644 --- a/test/fixtures/typescript/delete-operator.diffA-B.txt +++ b/test/fixtures/typescript/delete-operator.diffA-B.txt @@ -3,6 +3,4 @@ { (Subscript {-(Identifier)-} {-(TextElement)-}) - ->(MemberAccess - {+(Identifier)+} - {+(Identifier)+}) })) + ->(Identifier) })) diff --git a/test/fixtures/typescript/delete-operator.diffB-A.txt b/test/fixtures/typescript/delete-operator.diffB-A.txt index b278868d6..6375abc1d 100644 --- a/test/fixtures/typescript/delete-operator.diffB-A.txt +++ b/test/fixtures/typescript/delete-operator.diffB-A.txt @@ -1,8 +1,6 @@ (Program (Delete - { (MemberAccess - {-(Identifier)-} - {-(Identifier)-}) + { (Identifier) ->(Subscript {+(Identifier)+} {+(TextElement)+}) })) diff --git a/test/fixtures/typescript/delete-operator.parseB.txt b/test/fixtures/typescript/delete-operator.parseB.txt index 36e4bfbaa..d90828a09 100644 --- a/test/fixtures/typescript/delete-operator.parseB.txt +++ b/test/fixtures/typescript/delete-operator.parseB.txt @@ -1,5 +1,3 @@ (Program (Delete - (MemberAccess - (Identifier) - (Identifier)))) + (Identifier))) diff --git a/test/fixtures/typescript/do-while-statement.diffA-B.txt b/test/fixtures/typescript/do-while-statement.diffA-B.txt index 30c06d609..a8fc4982d 100644 --- a/test/fixtures/typescript/do-while-statement.diffA-B.txt +++ b/test/fixtures/typescript/do-while-statement.diffA-B.txt @@ -4,9 +4,7 @@ ->(Boolean) } ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty))))) diff --git a/test/fixtures/typescript/do-while-statement.diffB-A.txt b/test/fixtures/typescript/do-while-statement.diffB-A.txt index 30c06d609..a8fc4982d 100644 --- a/test/fixtures/typescript/do-while-statement.diffB-A.txt +++ b/test/fixtures/typescript/do-while-statement.diffB-A.txt @@ -4,9 +4,7 @@ ->(Boolean) } ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty))))) diff --git a/test/fixtures/typescript/do-while-statement.parseA.txt b/test/fixtures/typescript/do-while-statement.parseA.txt index 92c41b1a1..8d8016b8f 100644 --- a/test/fixtures/typescript/do-while-statement.parseA.txt +++ b/test/fixtures/typescript/do-while-statement.parseA.txt @@ -3,8 +3,6 @@ (Boolean) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty))))) diff --git a/test/fixtures/typescript/do-while-statement.parseB.txt b/test/fixtures/typescript/do-while-statement.parseB.txt index 92c41b1a1..8d8016b8f 100644 --- a/test/fixtures/typescript/do-while-statement.parseB.txt +++ b/test/fixtures/typescript/do-while-statement.parseB.txt @@ -3,8 +3,6 @@ (Boolean) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty))))) diff --git a/test/fixtures/typescript/export-assignments.diffA-B.txt b/test/fixtures/typescript/export-assignments.diffA-B.txt index ce7766158..280990a32 100644 --- a/test/fixtures/typescript/export-assignments.diffA-B.txt +++ b/test/fixtures/typescript/export-assignments.diffA-B.txt @@ -1,5 +1,5 @@ (Program {+(Return {+(Identifier)+})+} -{-(Export +{-(DefaultExport {-(Identifier)-})-}) diff --git a/test/fixtures/typescript/export-assignments.diffB-A.txt b/test/fixtures/typescript/export-assignments.diffB-A.txt index d72ebfb9a..f27880133 100644 --- a/test/fixtures/typescript/export-assignments.diffB-A.txt +++ b/test/fixtures/typescript/export-assignments.diffB-A.txt @@ -1,5 +1,5 @@ (Program -{+(Export +{+(DefaultExport {+(Identifier)+})+} {-(Return {-(Identifier)-})-}) diff --git a/test/fixtures/typescript/export-assignments.parseA.txt b/test/fixtures/typescript/export-assignments.parseA.txt index a974a7d6f..98edc26e4 100644 --- a/test/fixtures/typescript/export-assignments.parseA.txt +++ b/test/fixtures/typescript/export-assignments.parseA.txt @@ -1,3 +1,3 @@ (Program - (Export + (DefaultExport (Identifier))) diff --git a/test/fixtures/typescript/export.diffA-B.txt b/test/fixtures/typescript/export.diffA-B.txt index 242d15d93..eb927dac7 100644 --- a/test/fixtures/typescript/export.diffA-B.txt +++ b/test/fixtures/typescript/export.diffA-B.txt @@ -1,161 +1,37 @@ (Program - (Export - (ExportClause - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - (Empty)) - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+} - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - (Empty)) - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-})) - (Export - (ExportClause - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Identifier)-})-} - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - { (Empty) - ->(Identifier) }) - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+})) - (Export + {(QualifiedExport)->(QualifiedExport)} + {(QualifiedExport)->(QualifiedExport)} + (DefaultExport (VariableDeclaration - (Assignment - (Empty) - { (Identifier) - ->(Identifier) } - (Empty)) - (Assignment - (Empty) - { (Identifier) - ->(Identifier) } - (Empty)) - (Assignment - (Empty) - { (Identifier) - ->(Identifier) } - (Empty)))) - (Export + (Assignment(Empty){(Identifier)->(Identifier)}(Empty)) + (Assignment(Empty){(Identifier)->(Identifier)}(Empty)) + (Assignment(Empty){(Identifier)->(Identifier)}(Empty)))) + (DefaultExport (VariableDeclaration - {-(Assignment - {-(Empty)-} - {-(Identifier)-} - {-(Identifier)-})-} - (Assignment - (Empty) - (Identifier) - (Identifier)) - (Assignment - (Empty) - (Identifier) - { (Empty) - ->(Identifier) }) - {+(Assignment - {+(Empty)+} - {+(Identifier)+} - {+(Empty)+})+} - (Assignment - (Empty) - { (Identifier) - ->(Identifier) } - (Empty)))) - (Export - { (Identifier) - ->(Identifier) }) -{+(Export - {+(Function - {+(Empty)+} - {+(Empty)+} - {+(Identifier)+} - {+([])+})+})+} - (Export - (Function - (Empty) - (Empty) - (Empty) - ([]))) - (Export - {+(ExportClause - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Identifier)+})+})+} - {-(Function - {-(Empty)-} - {-(Empty)-} - {-(Identifier)-} - {-([])-})-}) - (Export - {+(TextElement)+} - {-(ExportClause - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Identifier)-})-})-}) -{+(Export - {+(ExportClause - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+} - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+} - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+})+} - {+(TextElement)+})+} -{+(Export - {+(ExportClause - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Identifier)+})+} - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Identifier)+})+} - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+})+} - {+(TextElement)+})+} -{-(Export - {-(TextElement)-})-} -{-(Export - {-(ExportClause - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-})-} - {-(TextElement)-})-} -{-(Export - {-(ExportClause - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Identifier)-})-} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Identifier)-})-} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-})-} - {-(TextElement)-})-}) + {-(Assignment{-(Empty)-}{-(Identifier)-}{-(Identifier)-})-} + (Assignment(Empty)(Identifier)(Identifier)) + (Assignment(Empty)(Identifier){(Empty)->(Identifier)}) + {+(Assignment{+(Empty)+}{+(Identifier)+}{+(Empty)+})+} + (Assignment(Empty){(Identifier)->(Identifier)}(Empty)))) + (DefaultExport + {(Identifier)->(Identifier)}) + {+(DefaultExport + {+(Function{+(Empty)+}{+(Empty)+}{+(Identifier)+}{+([])+})+})+} + (DefaultExport + (Function(Empty)(Empty)(Empty)([]))) + {+(QualifiedExport)+} + {+(DefaultExport + {+(TextElement)+})+} + {+(QualifiedExportFrom + {+(Identifier)+})+} + {+(QualifiedExportFrom + {+(Identifier)+})+} + {-(DefaultExport + {-(Function{-(Empty)-}{-(Empty)-}{-(Identifier)-}{-([])-})-})-} + {-(QualifiedExport)-} + {-(DefaultExport + {-(TextElement)-})-} + {-(QualifiedExportFrom + {-(Identifier)-})-} + {-(QualifiedExportFrom + {-(Identifier)-})-}) \ No newline at end of file diff --git a/test/fixtures/typescript/export.diffB-A.txt b/test/fixtures/typescript/export.diffB-A.txt index 7823a72b0..03d231796 100644 --- a/test/fixtures/typescript/export.diffB-A.txt +++ b/test/fixtures/typescript/export.diffB-A.txt @@ -1,153 +1,29 @@ (Program - (Export - (ExportClause - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - (Empty)) - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+} - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - (Empty)) - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-})) - (Export - (ExportClause - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Identifier)+})+} - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - { (Identifier) - ->(Empty) }) - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-})) - (Export + {(QualifiedExport)->(QualifiedExport)} + {(QualifiedExport)->(QualifiedExport)} + (DefaultExport (VariableDeclaration - (Assignment - (Empty) - { (Identifier) - ->(Identifier) } - (Empty)) - (Assignment - (Empty) - { (Identifier) - ->(Identifier) } - (Empty)) - (Assignment - (Empty) - { (Identifier) - ->(Identifier) } - (Empty)))) - (Export + (Assignment(Empty){(Identifier)->(Identifier)}(Empty)) + (Assignment(Empty){(Identifier)->(Identifier)}(Empty)) + (Assignment(Empty){(Identifier)->(Identifier)}(Empty)))) + (DefaultExport (VariableDeclaration - {+(Assignment - {+(Empty)+} - {+(Identifier)+} - {+(Identifier)+})+} - (Assignment - (Empty) - (Identifier) - (Identifier)) - (Assignment - (Empty) - (Identifier) - { (Identifier) - ->(Empty) }) - {+(Assignment - {+(Empty)+} - {+(Identifier)+} - {+(Empty)+})+} - {-(Assignment - {-(Empty)-} - {-(Identifier)-} - {-(Empty)-})-} - {-(Assignment - {-(Empty)-} - {-(Identifier)-} - {-(Empty)-})-})) - (Export - { (Identifier) - ->(Identifier) }) -{-(Export - {-(Function - {-(Empty)-} - {-(Empty)-} - {-(Identifier)-} - {-([])-})-})-} - (Export - (Function - (Empty) - (Empty) - (Empty) - ([]))) - (Export - {+(Function - {+(Empty)+} - {+(Empty)+} - {+(Identifier)+} - {+([])+})+} - {-(ExportClause - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Identifier)-})-})-}) - (Export - {+(ExportClause - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Identifier)+})+})+} - {-(TextElement)-}) -{+(Export - {+(TextElement)+})+} - (Export - (ExportClause - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - (Empty)) - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - (Empty)) - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - (Empty))) - { (TextElement) - ->(TextElement) }) - (Export - (ExportClause - (ImportExportSpecifier - { (Identifier) - ->(Identifier) } - { (Identifier) - ->(Identifier) }) - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Identifier)+})+} - {+(ImportExportSpecifier - {+(Identifier)+} - {+(Empty)+})+} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Identifier)-})-} - {-(ImportExportSpecifier - {-(Identifier)-} - {-(Empty)-})-}) - { (TextElement) - ->(TextElement) })) + {+(Assignment{+(Empty)+}{+(Identifier)+}{+(Identifier)+})+} + (Assignment(Empty)(Identifier)(Identifier)) + (Assignment(Empty)(Identifier){(Identifier)->(Empty)}) + {+(Assignment{+(Empty)+}{+(Identifier)+}{+(Empty)+})+} + {-(Assignment{-(Empty)-}{-(Identifier)-}{-(Empty)-})-} + {-(Assignment{-(Empty)-}{-(Identifier)-}{-(Empty)-})-})) + (DefaultExport + {(Identifier)->(Identifier)}) + {-(DefaultExport + {-(Function{-(Empty)-}{-(Empty)-}{-(Identifier)-}{-([])-})-})-} + (DefaultExport + (Function(Empty)(Empty)(Empty)([]))) + {+(DefaultExport + {+(Function{+(Empty)+}{+(Empty)+}{+(Identifier)+}{+([])+})+})+} + {(QualifiedExport)->(QualifiedExport)} + (DefaultExport + {(TextElement)->(TextElement)}) + {(QualifiedExportFrom {-(Identifier)-})->(QualifiedExportFrom {+(Identifier)+})} + {(QualifiedExportFrom {-(Identifier)-})->(QualifiedExportFrom {+(Identifier)+})}) \ No newline at end of file diff --git a/test/fixtures/typescript/export.parseA.txt b/test/fixtures/typescript/export.parseA.txt index 39a62d10b..2c57afc28 100644 --- a/test/fixtures/typescript/export.parseA.txt +++ b/test/fixtures/typescript/export.parseA.txt @@ -1,103 +1,21 @@ (Program - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)))) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Empty)))) - (Export + (QualifiedExport) + (QualifiedExport) + (DefaultExport (VariableDeclaration - (Assignment - (Empty) - (Identifier) - (Empty)) - (Assignment - (Empty) - (Identifier) - (Empty)) - (Assignment - (Empty) - (Identifier) - (Empty)))) - (Export + (Assignment(Empty)(Identifier)(Empty)) + (Assignment(Empty)(Identifier)(Empty)) + (Assignment(Empty)(Identifier)(Empty)))) + (DefaultExport (VariableDeclaration - (Assignment - (Empty) - (Identifier) - (Identifier)) - (Assignment - (Empty) - (Identifier) - (Identifier)) - (Assignment - (Empty) - (Identifier) - (Empty)) - (Assignment - (Empty) - (Identifier) - (Empty)))) - (Export - (Identifier)) - (Export - (Function - (Empty) - (Empty) - (Empty) - ([]))) - (Export - (Function - (Empty) - (Empty) - (Identifier) - ([]))) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Identifier)))) - (Export - (TextElement)) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty))) - (TextElement)) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Empty))) - (TextElement))) + (Assignment(Empty)(Identifier)(Identifier)) + (Assignment(Empty)(Identifier)(Identifier)) + (Assignment(Empty)(Identifier)(Empty)) + (Assignment(Empty)(Identifier)(Empty)))) + (DefaultExport (Identifier)) + (DefaultExport (Function(Empty)(Empty)(Empty)([]))) + (DefaultExport (Function(Empty)(Empty)(Identifier)([]))) + (QualifiedExport) + (DefaultExport (TextElement)) + (QualifiedExportFrom (Identifier)) + (QualifiedExportFrom (Identifier))) \ No newline at end of file diff --git a/test/fixtures/typescript/export.parseB.txt b/test/fixtures/typescript/export.parseB.txt index 0b08b21f6..217fc2584 100644 --- a/test/fixtures/typescript/export.parseB.txt +++ b/test/fixtures/typescript/export.parseB.txt @@ -1,103 +1,21 @@ (Program - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)))) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Empty)))) - (Export + (QualifiedExport) + (QualifiedExport) + (DefaultExport (VariableDeclaration - (Assignment - (Empty) - (Identifier) - (Empty)) - (Assignment - (Empty) - (Identifier) - (Empty)) - (Assignment - (Empty) - (Identifier) - (Empty)))) - (Export + (Assignment(Empty)(Identifier)(Empty)) + (Assignment(Empty)(Identifier)(Empty)) + (Assignment(Empty)(Identifier)(Empty)))) + (DefaultExport (VariableDeclaration - (Assignment - (Empty) - (Identifier) - (Identifier)) - (Assignment - (Empty) - (Identifier) - (Identifier)) - (Assignment - (Empty) - (Identifier) - (Empty)) - (Assignment - (Empty) - (Identifier) - (Empty)))) - (Export - (Identifier)) - (Export - (Function - (Empty) - (Empty) - (Identifier) - ([]))) - (Export - (Function - (Empty) - (Empty) - (Empty) - ([]))) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Identifier)))) - (Export - (TextElement)) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty)) - (ImportExportSpecifier - (Identifier) - (Empty))) - (TextElement)) - (Export - (ExportClause - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Identifier)) - (ImportExportSpecifier - (Identifier) - (Empty))) - (TextElement))) + (Assignment(Empty)(Identifier)(Identifier)) + (Assignment(Empty)(Identifier)(Identifier)) + (Assignment(Empty)(Identifier)(Empty)) + (Assignment(Empty)(Identifier)(Empty)))) + (DefaultExport(Identifier)) + (DefaultExport(Function(Empty)(Empty)(Identifier)([]))) + (DefaultExport(Function(Empty)(Empty)(Empty)([]))) + (QualifiedExport) + (DefaultExport (TextElement)) + (QualifiedExportFrom (Identifier)) + (QualifiedExportFrom (Identifier))) \ No newline at end of file diff --git a/test/fixtures/typescript/function-call-args.diffA-B.txt b/test/fixtures/typescript/function-call-args.diffA-B.txt index cb4b6e2d9..aee47bc1c 100644 --- a/test/fixtures/typescript/function-call-args.diffA-B.txt +++ b/test/fixtures/typescript/function-call-args.diffA-B.txt @@ -31,9 +31,7 @@ {+(Empty)+})+})+} ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty)) diff --git a/test/fixtures/typescript/function-call-args.diffB-A.txt b/test/fixtures/typescript/function-call-args.diffB-A.txt index 194e964af..55c1ebf80 100644 --- a/test/fixtures/typescript/function-call-args.diffB-A.txt +++ b/test/fixtures/typescript/function-call-args.diffB-A.txt @@ -31,9 +31,7 @@ {-(Empty)-})-})-} ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty)) diff --git a/test/fixtures/typescript/function-call-args.parseA.txt b/test/fixtures/typescript/function-call-args.parseA.txt index 3f9ef783e..091f07ff5 100644 --- a/test/fixtures/typescript/function-call-args.parseA.txt +++ b/test/fixtures/typescript/function-call-args.parseA.txt @@ -23,9 +23,7 @@ (Empty))) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty)) (Return diff --git a/test/fixtures/typescript/function-call-args.parseB.txt b/test/fixtures/typescript/function-call-args.parseB.txt index 3f9ef783e..091f07ff5 100644 --- a/test/fixtures/typescript/function-call-args.parseB.txt +++ b/test/fixtures/typescript/function-call-args.parseB.txt @@ -23,9 +23,7 @@ (Empty))) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty)) (Return diff --git a/test/fixtures/typescript/if.diffA-B.txt b/test/fixtures/typescript/if.diffA-B.txt index 2a90eee30..44a616a36 100644 --- a/test/fixtures/typescript/if.diffA-B.txt +++ b/test/fixtures/typescript/if.diffA-B.txt @@ -1,9 +1,7 @@ (Program (If { (Identifier) - ->(MemberAccess - {+(Identifier)+} - {+(Identifier)+}) } + ->(Identifier) } ( (Call (Identifier) diff --git a/test/fixtures/typescript/if.diffB-A.txt b/test/fixtures/typescript/if.diffB-A.txt index a6742d0e3..d055feb2d 100644 --- a/test/fixtures/typescript/if.diffB-A.txt +++ b/test/fixtures/typescript/if.diffB-A.txt @@ -1,8 +1,6 @@ (Program (If - { (MemberAccess - {-(Identifier)-} - {-(Identifier)-}) + { (Identifier) ->(Identifier) } ( (Call diff --git a/test/fixtures/typescript/if.parseB.txt b/test/fixtures/typescript/if.parseB.txt index 82a81394a..287c84a5b 100644 --- a/test/fixtures/typescript/if.parseB.txt +++ b/test/fixtures/typescript/if.parseB.txt @@ -1,8 +1,6 @@ (Program (If - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) ( (Call (Identifier) diff --git a/test/fixtures/typescript/import-graph/app.json b/test/fixtures/typescript/import-graph/app.json index 4dcdeb344..babf0ffc4 100644 --- a/test/fixtures/typescript/import-graph/app.json +++ b/test/fixtures/typescript/import-graph/app.json @@ -277,10 +277,8 @@ 11 ] }, - "symbol": "foo", - "targets": [ - "name" - ] + "symbol": "name.foo", + "targets": [] } ] } diff --git a/test/fixtures/typescript/import.diffA-B.txt b/test/fixtures/typescript/import.diffA-B.txt index e1728da63..987fcaecf 100644 --- a/test/fixtures/typescript/import.diffA-B.txt +++ b/test/fixtures/typescript/import.diffA-B.txt @@ -1,52 +1,45 @@ (Program -{+(Import - {+(TextElement)+})+} -{+(QualifiedImport - {+(TextElement)+} - {+(Identifier)+})+} -{+(Import - {+(TextElement)+})+} -{+(Import - {+(TextElement)+})+} + (Import + { (Identifier) + ->(Identifier) }) + (QualifiedImport + { (Identifier) + ->(Identifier) } + { (Identifier) + ->(Identifier) }) { (Import - {-(TextElement)-}) + {-(Identifier)-}) ->(Import - {+(TextElement)+}) } -{+( - {+(Import - {+(TextElement)+})+} - {+(Import - {+(TextElement)+})+})+} -{+( - {+(Import - {+(TextElement)+})+} - {+(QualifiedImport - {+(TextElement)+} - {+(Identifier)+})+})+} + {+(Identifier)+}) } +{ (Import + {-(Identifier)-}) +->(Import + {+(Identifier)+}) } +{ (Import + {-(Identifier)-}) +->(Import + {+(Identifier)+}) } + ( + (Import + { (Identifier) + ->(Identifier) }) + { (Import + {-(Identifier)-}) + ->(Import + {+(Identifier)+}) }) + ( + (Import + { (Identifier) + ->(Identifier) }) + (QualifiedImport + { (Identifier) + ->(Identifier) } + { (Identifier) + ->(Identifier) })) {+(Import - {+(TextElement)+})+} -{-(QualifiedImport - {-(TextElement)-} + {+(Identifier)+})+} +{-(Import {-(Identifier)-})-} -{-(Import - {-(TextElement)-})-} -{-(Import - {-(TextElement)-})-} -{-(Import - {-(TextElement)-})-} -{-( - {-(Import - {-(TextElement)-})-} - {-(Import - {-(TextElement)-})-})-} -{-( - {-(Import - {-(TextElement)-})-} - {-(QualifiedImport - {-(TextElement)-} - {-(Identifier)-})-})-} -{-(Import - {-(TextElement)-})-} {-(QualifiedImport - {-(TextElement)-} + {-(Identifier)-} {-(Identifier)-})-}) diff --git a/test/fixtures/typescript/import.diffB-A.txt b/test/fixtures/typescript/import.diffB-A.txt index 2512ff6f1..79a3b8e36 100644 --- a/test/fixtures/typescript/import.diffB-A.txt +++ b/test/fixtures/typescript/import.diffB-A.txt @@ -1,52 +1,45 @@ (Program + (Import + { (Identifier) + ->(Identifier) }) + (QualifiedImport + { (Identifier) + ->(Identifier) } + { (Identifier) + ->(Identifier) }) +{ (Import + {-(Identifier)-}) +->(Import + {+(Identifier)+}) } +{ (Import + {-(Identifier)-}) +->(Import + {+(Identifier)+}) } +{ (Import + {-(Identifier)-}) +->(Import + {+(Identifier)+}) } + ( + (Import + { (Identifier) + ->(Identifier) }) + { (Import + {-(Identifier)-}) + ->(Import + {+(Identifier)+}) }) + ( + (Import + { (Identifier) + ->(Identifier) }) + (QualifiedImport + { (Identifier) + ->(Identifier) } + { (Identifier) + ->(Identifier) })) {+(Import - {+(TextElement)+})+} -{+(QualifiedImport - {+(TextElement)+} {+(Identifier)+})+} -{+(Import - {+(TextElement)+})+} -{+(Import - {+(TextElement)+})+} -{+(Import - {+(TextElement)+})+} -{+( - {+(Import - {+(TextElement)+})+} - {+(Import - {+(TextElement)+})+})+} -{+( - {+(Import - {+(TextElement)+})+} - {+(QualifiedImport - {+(TextElement)+} - {+(Identifier)+})+})+} -{+(Import - {+(TextElement)+})+} {+(QualifiedImport - {+(TextElement)+} + {+(Identifier)+} {+(Identifier)+})+} {-(Import - {-(TextElement)-})-} -{-(QualifiedImport - {-(TextElement)-} - {-(Identifier)-})-} -{-(Import - {-(TextElement)-})-} -{-(Import - {-(TextElement)-})-} -{-(Import - {-(TextElement)-})-} -{-( - {-(Import - {-(TextElement)-})-} - {-(Import - {-(TextElement)-})-})-} -{-( - {-(Import - {-(TextElement)-})-} - {-(QualifiedImport - {-(TextElement)-} - {-(Identifier)-})-})-} -{-(Import - {-(TextElement)-})-}) + {-(Identifier)-})-}) diff --git a/test/fixtures/typescript/import.parseA.txt b/test/fixtures/typescript/import.parseA.txt index 2d54d67c9..23ec906e5 100644 --- a/test/fixtures/typescript/import.parseA.txt +++ b/test/fixtures/typescript/import.parseA.txt @@ -1,28 +1,28 @@ (Program (Import - (TextElement)) + (Identifier)) (QualifiedImport - (TextElement) + (Identifier) (Identifier)) (Import - (TextElement)) + (Identifier)) (Import - (TextElement)) + (Identifier)) (Import - (TextElement)) + (Identifier)) ( (Import - (TextElement)) + (Identifier)) (Import - (TextElement))) + (Identifier))) ( (Import - (TextElement)) + (Identifier)) (QualifiedImport - (TextElement) + (Identifier) (Identifier))) (Import - (TextElement)) + (Identifier)) (QualifiedImport - (TextElement) + (Identifier) (Identifier))) diff --git a/test/fixtures/typescript/import.parseB.txt b/test/fixtures/typescript/import.parseB.txt index 5a3bdf832..6bd6755f3 100644 --- a/test/fixtures/typescript/import.parseB.txt +++ b/test/fixtures/typescript/import.parseB.txt @@ -1,25 +1,25 @@ (Program (Import - (TextElement)) + (Identifier)) (QualifiedImport - (TextElement) + (Identifier) (Identifier)) (Import - (TextElement)) + (Identifier)) (Import - (TextElement)) + (Identifier)) (Import - (TextElement)) + (Identifier)) ( (Import - (TextElement)) + (Identifier)) (Import - (TextElement))) + (Identifier))) ( (Import - (TextElement)) + (Identifier)) (QualifiedImport - (TextElement) + (Identifier) (Identifier))) (Import - (TextElement))) + (Identifier))) diff --git a/test/fixtures/typescript/jsx-elements.diffA-B.txt b/test/fixtures/typescript/jsx-elements.diffA-B.txt index cdee6e494..dbbabb641 100644 --- a/test/fixtures/typescript/jsx-elements.diffA-B.txt +++ b/test/fixtures/typescript/jsx-elements.diffA-B.txt @@ -9,29 +9,40 @@ {+(JsxAttribute {+(Identifier)+} {+(JsxExpression - {+(MemberAccess - {+(Identifier)+} - {+(Identifier)+})+})+})+} + {+(Identifier)+})+})+} {-(JsxExpression {-(Call {-(Identifier)-} - {-(MemberAccess - {-(Identifier)-} - {-(Identifier)-})-} + {-(Identifier)-} {-(Empty)-})-})-}) (JsxExpression (Identifier)) (JsxClosingElement (Identifier))))) - {-(VariableDeclaration - {-(Assignment - {-(Empty)-} - {-(Identifier)-} - {-(JsxElement{-(JsxOpeningElement{-(NestedIdentifier{-(Identifier)-}{-(Identifier)-})-})-}{-(JsxClosingElement{-(NestedIdentifier{-(Identifier)-}{-(Identifier)-})-})-})-}) - -})-} - {-(VariableDeclaration - {-(Assignment - {-(Empty)-} - {-(Identifier)-} - {-(JsxSelfClosingElement{-(NestedIdentifier{-(Identifier)-}{-(Identifier)-})-}{-(JsxAttribute{-(Identifier)-}{-(Empty)-})-}{-(JsxAttribute{-(Identifier)-}{-(TextElement)-})-})-} - )-})-}) +{-(VariableDeclaration + {-(Assignment + {-(Empty)-} + {-(Identifier)-} + {-(JsxElement + {-(JsxOpeningElement + {-(NestedIdentifier + {-(Identifier)-} + {-(Identifier)-})-})-} + {-(JsxClosingElement + {-(NestedIdentifier + {-(Identifier)-} + {-(Identifier)-})-})-})-})-})-} +{-(VariableDeclaration + {-(Assignment + {-(Empty)-} + {-(Identifier)-} + {-(JsxSelfClosingElement + {-(NestedIdentifier + {-(Identifier)-} + {-(Identifier)-})-} + {-(JsxAttribute + {-(Identifier)-} + {-(Empty)-})-} + {-(JsxAttribute + {-(Identifier)-} + {-(TextElement)-})-})-})-})-}) diff --git a/test/fixtures/typescript/jsx-elements.diffB-A.txt b/test/fixtures/typescript/jsx-elements.diffB-A.txt index b41facd71..24a9c75ac 100644 --- a/test/fixtures/typescript/jsx-elements.diffB-A.txt +++ b/test/fixtures/typescript/jsx-elements.diffB-A.txt @@ -9,27 +9,40 @@ {+(JsxExpression {+(Call {+(Identifier)+} - {+(MemberAccess - {+(Identifier)+} - {+(Identifier)+})+} + {+(Identifier)+} {+(Empty)+})+})+} {-(JsxAttribute {-(Identifier)-} {-(JsxExpression - {-(MemberAccess - {-(Identifier)-} - {-(Identifier)-})-})-})-}) + {-(Identifier)-})-})-}) (JsxExpression (Identifier)) (JsxClosingElement (Identifier))))) - {+(VariableDeclaration - {+(Assignment - {+(Empty)+} - {+(Identifier)+} - {+(JsxElement{+(JsxOpeningElement{+(NestedIdentifier{+(Identifier)+}{+(Identifier)+})+})+}{+(JsxClosingElement{+(NestedIdentifier{+(Identifier)+}{+(Identifier)+})+})+})+})+})+} - {+(VariableDeclaration - {+(Assignment - {+(Empty)+} - {+(Identifier)+} - {+(JsxSelfClosingElement{+(NestedIdentifier{+(Identifier)+}{+(Identifier)+})+}{+(JsxAttribute{+(Identifier)+}{+(Empty)+})+}{+(JsxAttribute{+(Identifier)+}{+(TextElement)+})+})+})+})+}) +{+(VariableDeclaration + {+(Assignment + {+(Empty)+} + {+(Identifier)+} + {+(JsxElement + {+(JsxOpeningElement + {+(NestedIdentifier + {+(Identifier)+} + {+(Identifier)+})+})+} + {+(JsxClosingElement + {+(NestedIdentifier + {+(Identifier)+} + {+(Identifier)+})+})+})+})+})+} +{+(VariableDeclaration + {+(Assignment + {+(Empty)+} + {+(Identifier)+} + {+(JsxSelfClosingElement + {+(NestedIdentifier + {+(Identifier)+} + {+(Identifier)+})+} + {+(JsxAttribute + {+(Identifier)+} + {+(Empty)+})+} + {+(JsxAttribute + {+(Identifier)+} + {+(TextElement)+})+})+})+})+}) diff --git a/test/fixtures/typescript/jsx-elements.parseA.txt b/test/fixtures/typescript/jsx-elements.parseA.txt index 42d46254f..686cd6d4b 100644 --- a/test/fixtures/typescript/jsx-elements.parseA.txt +++ b/test/fixtures/typescript/jsx-elements.parseA.txt @@ -9,9 +9,7 @@ (JsxExpression (Call (Identifier) - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Empty)))) (JsxExpression (Identifier)) @@ -24,7 +22,8 @@ (JsxElement (JsxOpeningElement (NestedIdentifier - (Identifier) (Identifier))) + (Identifier) + (Identifier))) (JsxClosingElement (NestedIdentifier (Identifier) @@ -37,9 +36,9 @@ (NestedIdentifier (Identifier) (Identifier)) - (JsxAttribute - (Identifier) - (Empty)) - (JsxAttribute - (Identifier) - (TextElement)))))) + (JsxAttribute + (Identifier) + (Empty)) + (JsxAttribute + (Identifier) + (TextElement)))))) diff --git a/test/fixtures/typescript/jsx-elements.parseB.txt b/test/fixtures/typescript/jsx-elements.parseB.txt index e774bc0c4..8a9e7e2bb 100644 --- a/test/fixtures/typescript/jsx-elements.parseB.txt +++ b/test/fixtures/typescript/jsx-elements.parseB.txt @@ -9,9 +9,7 @@ (JsxAttribute (Identifier) (JsxExpression - (MemberAccess - (Identifier) - (Identifier))))) + (Identifier)))) (JsxExpression (Identifier)) (JsxClosingElement diff --git a/test/fixtures/typescript/member-access-assignment.diffA-B.txt b/test/fixtures/typescript/member-access-assignment.diffA-B.txt index 971eac6e7..9572881a4 100644 --- a/test/fixtures/typescript/member-access-assignment.diffA-B.txt +++ b/test/fixtures/typescript/member-access-assignment.diffA-B.txt @@ -1,7 +1,5 @@ (Program (Assignment - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Float) ->(Float) })) diff --git a/test/fixtures/typescript/member-access-assignment.diffB-A.txt b/test/fixtures/typescript/member-access-assignment.diffB-A.txt index 971eac6e7..9572881a4 100644 --- a/test/fixtures/typescript/member-access-assignment.diffB-A.txt +++ b/test/fixtures/typescript/member-access-assignment.diffB-A.txt @@ -1,7 +1,5 @@ (Program (Assignment - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Float) ->(Float) })) diff --git a/test/fixtures/typescript/member-access-assignment.parseA.txt b/test/fixtures/typescript/member-access-assignment.parseA.txt index 7d15e4ab4..7631b5f93 100644 --- a/test/fixtures/typescript/member-access-assignment.parseA.txt +++ b/test/fixtures/typescript/member-access-assignment.parseA.txt @@ -1,6 +1,4 @@ (Program (Assignment - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Float))) diff --git a/test/fixtures/typescript/member-access-assignment.parseB.txt b/test/fixtures/typescript/member-access-assignment.parseB.txt index 7d15e4ab4..7631b5f93 100644 --- a/test/fixtures/typescript/member-access-assignment.parseB.txt +++ b/test/fixtures/typescript/member-access-assignment.parseB.txt @@ -1,6 +1,4 @@ (Program (Assignment - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Float))) diff --git a/test/fixtures/typescript/member-access.diffA-B.txt b/test/fixtures/typescript/member-access.diffA-B.txt index 032d939dd..6ac9cd896 100644 --- a/test/fixtures/typescript/member-access.diffA-B.txt +++ b/test/fixtures/typescript/member-access.diffA-B.txt @@ -1,5 +1,3 @@ (Program - (MemberAccess - (Identifier) - { (Identifier) - ->(Identifier) })) +{ (Identifier) +->(Identifier) }) diff --git a/test/fixtures/typescript/member-access.diffB-A.txt b/test/fixtures/typescript/member-access.diffB-A.txt index 032d939dd..6ac9cd896 100644 --- a/test/fixtures/typescript/member-access.diffB-A.txt +++ b/test/fixtures/typescript/member-access.diffB-A.txt @@ -1,5 +1,3 @@ (Program - (MemberAccess - (Identifier) - { (Identifier) - ->(Identifier) })) +{ (Identifier) +->(Identifier) }) diff --git a/test/fixtures/typescript/member-access.parseA.txt b/test/fixtures/typescript/member-access.parseA.txt index 3a5c9e565..67b75f388 100644 --- a/test/fixtures/typescript/member-access.parseA.txt +++ b/test/fixtures/typescript/member-access.parseA.txt @@ -1,4 +1,2 @@ (Program - (MemberAccess - (Identifier) - (Identifier))) + (Identifier)) diff --git a/test/fixtures/typescript/member-access.parseB.txt b/test/fixtures/typescript/member-access.parseB.txt index 3a5c9e565..67b75f388 100644 --- a/test/fixtures/typescript/member-access.parseB.txt +++ b/test/fixtures/typescript/member-access.parseB.txt @@ -1,4 +1,2 @@ (Program - (MemberAccess - (Identifier) - (Identifier))) + (Identifier)) diff --git a/test/fixtures/typescript/method-call.diffA-B.txt b/test/fixtures/typescript/method-call.diffA-B.txt index 04b6484e5..9ff4cf165 100644 --- a/test/fixtures/typescript/method-call.diffA-B.txt +++ b/test/fixtures/typescript/method-call.diffA-B.txt @@ -1,8 +1,6 @@ (Program (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) { (TextElement) ->(TextElement) } diff --git a/test/fixtures/typescript/method-call.diffB-A.txt b/test/fixtures/typescript/method-call.diffB-A.txt index 04b6484e5..9ff4cf165 100644 --- a/test/fixtures/typescript/method-call.diffB-A.txt +++ b/test/fixtures/typescript/method-call.diffB-A.txt @@ -1,8 +1,6 @@ (Program (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) { (TextElement) ->(TextElement) } diff --git a/test/fixtures/typescript/method-call.parseA.txt b/test/fixtures/typescript/method-call.parseA.txt index 1bc561706..992897b06 100644 --- a/test/fixtures/typescript/method-call.parseA.txt +++ b/test/fixtures/typescript/method-call.parseA.txt @@ -1,8 +1,6 @@ (Program (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (TextElement) (Empty))) diff --git a/test/fixtures/typescript/method-call.parseB.txt b/test/fixtures/typescript/method-call.parseB.txt index 1bc561706..992897b06 100644 --- a/test/fixtures/typescript/method-call.parseB.txt +++ b/test/fixtures/typescript/method-call.parseB.txt @@ -1,8 +1,6 @@ (Program (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (TextElement) (Empty))) diff --git a/test/fixtures/typescript/nested-functions.diffA-B.txt b/test/fixtures/typescript/nested-functions.diffA-B.txt index 0b3c286a9..5f2bf7912 100644 --- a/test/fixtures/typescript/nested-functions.diffA-B.txt +++ b/test/fixtures/typescript/nested-functions.diffA-B.txt @@ -38,16 +38,12 @@ (Empty))) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty)) (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty))))))) diff --git a/test/fixtures/typescript/nested-functions.diffB-A.txt b/test/fixtures/typescript/nested-functions.diffB-A.txt index 0b3c286a9..5f2bf7912 100644 --- a/test/fixtures/typescript/nested-functions.diffB-A.txt +++ b/test/fixtures/typescript/nested-functions.diffB-A.txt @@ -38,16 +38,12 @@ (Empty))) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty)) (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) { (Identifier) ->(Identifier) } (Empty))))))) diff --git a/test/fixtures/typescript/nested-functions.parseA.txt b/test/fixtures/typescript/nested-functions.parseA.txt index 0955c8914..a2989cfab 100644 --- a/test/fixtures/typescript/nested-functions.parseA.txt +++ b/test/fixtures/typescript/nested-functions.parseA.txt @@ -38,14 +38,10 @@ (Empty))) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty)) (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty))))))) diff --git a/test/fixtures/typescript/nested-functions.parseB.txt b/test/fixtures/typescript/nested-functions.parseB.txt index 0955c8914..a2989cfab 100644 --- a/test/fixtures/typescript/nested-functions.parseB.txt +++ b/test/fixtures/typescript/nested-functions.parseB.txt @@ -38,14 +38,10 @@ (Empty))) ( (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty)) (Call - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (Identifier) (Empty))))))) diff --git a/test/fixtures/typescript/ternary.diffA-B.txt b/test/fixtures/typescript/ternary.diffA-B.txt index 500a7b34a..992caebe2 100644 --- a/test/fixtures/typescript/ternary.diffA-B.txt +++ b/test/fixtures/typescript/ternary.diffA-B.txt @@ -1,19 +1,11 @@ (Program {+(Assignment - {+(MemberAccess - {+(Identifier)+} - {+(Identifier)+})+} + {+(Identifier)+} {+(If + {+(Identifier)+} + {+(Identifier)+} {+(MemberAccess {+(Identifier)+} - {+(Identifier)+})+} - {+(MemberAccess - {+(Identifier)+} - {+(Identifier)+})+} - {+(MemberAccess - {+(MemberAccess - {+(Identifier)+} - {+(Identifier)+})+} {+(Identifier)+})+})+})+} {-(If {-(Identifier)-} diff --git a/test/fixtures/typescript/ternary.diffB-A.txt b/test/fixtures/typescript/ternary.diffB-A.txt index 4696a13d8..3305baa61 100644 --- a/test/fixtures/typescript/ternary.diffB-A.txt +++ b/test/fixtures/typescript/ternary.diffB-A.txt @@ -4,18 +4,10 @@ {+(Identifier)+} {+(Identifier)+})+} {-(Assignment - {-(MemberAccess - {-(Identifier)-} - {-(Identifier)-})-} + {-(Identifier)-} {-(If + {-(Identifier)-} + {-(Identifier)-} {-(MemberAccess {-(Identifier)-} - {-(Identifier)-})-} - {-(MemberAccess - {-(Identifier)-} - {-(Identifier)-})-} - {-(MemberAccess - {-(MemberAccess - {-(Identifier)-} - {-(Identifier)-})-} {-(Identifier)-})-})-})-}) diff --git a/test/fixtures/typescript/ternary.parseB.txt b/test/fixtures/typescript/ternary.parseB.txt index 988c986b7..e072403cd 100644 --- a/test/fixtures/typescript/ternary.parseB.txt +++ b/test/fixtures/typescript/ternary.parseB.txt @@ -1,17 +1,9 @@ (Program (Assignment - (MemberAccess - (Identifier) - (Identifier)) + (Identifier) (If + (Identifier) + (Identifier) (MemberAccess (Identifier) - (Identifier)) - (MemberAccess - (Identifier) - (Identifier)) - (MemberAccess - (MemberAccess - (Identifier) - (Identifier)) (Identifier)))))